Profile parsing: Extract VPATH information for the .pro file

And reuse that for all .pri files. This is a lot faster.

Change-Id: Iff81a50b892ad666ed6c899aa242b6e9b394f339
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
Daniel Teske
2014-09-09 15:38:48 +02:00
parent 0691bf93b0
commit fa8d52cd23
2 changed files with 50 additions and 20 deletions

View File

@@ -591,7 +591,8 @@ QSet<Utils::FileName> QmakePriFileNode::recursiveEnumerate(const QString &folder
void QmakePriFileNode::update(ProFile *includeFileExact, QtSupport::ProFileReader *readerExact, void QmakePriFileNode::update(ProFile *includeFileExact, QtSupport::ProFileReader *readerExact,
ProFile *includeFileCumlative, QtSupport::ProFileReader *readerCumulative, ProFile *includeFileCumlative, QtSupport::ProFileReader *readerCumulative,
const QString &buildDir) const QString &buildDir,
const QList<QList<VariableAndVPathInformation>> &variableAndVPathInformation)
{ {
// add project file node // add project file node
if (m_fileNodes.isEmpty()) if (m_fileNodes.isEmpty())
@@ -652,27 +653,17 @@ void QmakePriFileNode::update(ProFile *includeFileExact, QtSupport::ProFileReade
m_recursiveEnumerateFiles += recursiveEnumerate(folder); m_recursiveEnumerateFiles += recursiveEnumerate(folder);
} }
QMap<FileType, QSet<Utils::FileName> > foundFiles; QMap<FileType, QSet<Utils::FileName> > foundFiles;
QStringList baseVPathsExact;
if (includeFileExact)
baseVPathsExact = baseVPaths(readerExact, projectDir, buildDir);
QStringList baseVPathsCumulative;
if (includeFileCumlative)
baseVPathsCumulative = baseVPaths(readerCumulative, projectDir, buildDir);
const QVector<QmakeNodeStaticData::FileTypeData> &fileTypes = qmakeNodeStaticData()->fileTypeData; const QVector<QmakeNodeStaticData::FileTypeData> &fileTypes = qmakeNodeStaticData()->fileTypeData;
// update files // update files
QFileInfo tmpFi; QFileInfo tmpFi;
for (int i = 0; i < fileTypes.size(); ++i) { for (int i = 0; i < fileTypes.size(); ++i) {
FileType type = fileTypes.at(i).type; FileType type = fileTypes.at(i).type;
QStringList qmakeVariables = varNames(type, readerExact); const QList<VariableAndVPathInformation> &qmakeVariables = variableAndVPathInformation.at(i);
QSet<Utils::FileName> newFilePaths; QSet<Utils::FileName> newFilePaths;
foreach (const QString &qmakeVariable, qmakeVariables) { foreach (const VariableAndVPathInformation &qmakeVariable, qmakeVariables) {
if (includeFileExact) { if (includeFileExact) {
QStringList vPathsExact = fullVPaths(baseVPathsExact, readerExact, qmakeVariable, projectDir); QStringList tmp = readerExact->absoluteFileValues(qmakeVariable.variable, projectDir, qmakeVariable.vPathsExact, includeFileExact);
QStringList tmp = readerExact->absoluteFileValues(qmakeVariable, projectDir, vPathsExact, includeFileExact);
foreach (const QString &t, tmp) { foreach (const QString &t, tmp) {
tmpFi.setFile(t); tmpFi.setFile(t);
if (tmpFi.isFile()) if (tmpFi.isFile())
@@ -680,8 +671,7 @@ void QmakePriFileNode::update(ProFile *includeFileExact, QtSupport::ProFileReade
} }
} }
if (includeFileCumlative) { if (includeFileCumlative) {
QStringList vPathsCumulative = fullVPaths(baseVPathsCumulative, readerCumulative, qmakeVariable, projectDir); QStringList tmp = readerCumulative->absoluteFileValues(qmakeVariable.variable, projectDir, qmakeVariable.vPathsCumulative, includeFileCumlative);
QStringList tmp = readerCumulative->absoluteFileValues(qmakeVariable, projectDir, vPathsCumulative, includeFileCumlative);
foreach (const QString &t, tmp) { foreach (const QString &t, tmp) {
tmpFi.setFile(t); tmpFi.setFile(t);
if (tmpFi.isFile()) if (tmpFi.isFile())
@@ -1853,6 +1843,30 @@ void QmakeProFileNode::applyEvaluate(EvalResult evalResult, bool async)
} }
QString buildDirectory = buildDir(); QString buildDirectory = buildDir();
QList<QList<VariableAndVPathInformation>> variableAndVPathInformation;
{ // Collect information on VPATHS and qmake variables
QStringList baseVPathsExact = baseVPaths(m_readerExact, m_projectDir, buildDirectory);
QStringList baseVPathsCumulative = baseVPaths(m_readerCumulative, m_projectDir, buildDirectory);
const QVector<QmakeNodeStaticData::FileTypeData> &fileTypes = qmakeNodeStaticData()->fileTypeData;
variableAndVPathInformation.reserve(fileTypes.size());
for (int i = 0; i < fileTypes.size(); ++i) {
FileType type = fileTypes.at(i).type;
QList<VariableAndVPathInformation> list;
QStringList qmakeVariables = varNames(type, m_readerExact);
list.reserve(qmakeVariables.size());
foreach (const QString &qmakeVariable, qmakeVariables) {
VariableAndVPathInformation info;
info.variable = qmakeVariable;
info.vPathsExact = fullVPaths(baseVPathsExact, m_readerExact, qmakeVariable, m_projectDir);
info.vPathsCumulative = fullVPaths(baseVPathsCumulative, m_readerCumulative, qmakeVariable, m_projectDir);
list.append(info);
}
variableAndVPathInformation.append(list);
}
}
SortByPath sortByPath; SortByPath sortByPath;
Utils::sort(existingProjectNodes, sortByPath); Utils::sort(existingProjectNodes, sortByPath);
@@ -1927,7 +1941,8 @@ void QmakeProFileNode::applyEvaluate(EvalResult evalResult, bool async)
ProFile *fileCumlative = includeFilesCumlative.value((*existingIt)->path()); ProFile *fileCumlative = includeFilesCumlative.value((*existingIt)->path());
if (fileExact || fileCumlative) { if (fileExact || fileCumlative) {
QmakePriFileNode *priFileNode = static_cast<QmakePriFileNode *>(*existingIt); QmakePriFileNode *priFileNode = static_cast<QmakePriFileNode *>(*existingIt);
priFileNode->update(fileExact, m_readerExact, fileCumlative, m_readerCumulative, buildDirectory); priFileNode->update(fileExact, m_readerExact, fileCumlative, m_readerCumulative,
buildDirectory, variableAndVPathInformation);
priFileNode->setIncludedInExactParse(fileExact != 0 && includedInExactParse()); priFileNode->setIncludedInExactParse(fileExact != 0 && includedInExactParse());
} else { } else {
// We always parse exactly, because we later when async parsing don't know whether // We always parse exactly, because we later when async parsing don't know whether
@@ -1965,7 +1980,8 @@ void QmakeProFileNode::applyEvaluate(EvalResult evalResult, bool async)
QmakePriFileNode *qmakePriFileNode = new QmakePriFileNode(m_project, this, nodeToAdd); QmakePriFileNode *qmakePriFileNode = new QmakePriFileNode(m_project, this, nodeToAdd);
qmakePriFileNode->setParentFolderNode(this); // Needed for loop detection qmakePriFileNode->setParentFolderNode(this); // Needed for loop detection
qmakePriFileNode->setIncludedInExactParse(fileExact != 0 && includedInExactParse()); qmakePriFileNode->setIncludedInExactParse(fileExact != 0 && includedInExactParse());
qmakePriFileNode->update(fileExact, m_readerExact, fileCumlative, m_readerCumulative, buildDirectory); qmakePriFileNode->update(fileExact, m_readerExact, fileCumlative, m_readerCumulative,
buildDirectory, variableAndVPathInformation);
toAdd << qmakePriFileNode; toAdd << qmakePriFileNode;
} else { } else {
QmakeProFileNode *qmakeProFileNode = new QmakeProFileNode(m_project, nodeToAdd); QmakeProFileNode *qmakeProFileNode = new QmakeProFileNode(m_project, nodeToAdd);
@@ -1992,7 +2008,8 @@ void QmakeProFileNode::applyEvaluate(EvalResult evalResult, bool async)
if (!toAdd.isEmpty()) if (!toAdd.isEmpty())
addProjectNodes(toAdd); addProjectNodes(toAdd);
QmakePriFileNode::update(fileForCurrentProjectExact, m_readerExact, fileForCurrentProjectCumlative, m_readerCumulative, buildDirectory); QmakePriFileNode::update(fileForCurrentProjectExact, m_readerExact, fileForCurrentProjectCumlative, m_readerCumulative,
buildDirectory, variableAndVPathInformation);
m_validParse = (evalResult == EvalOk); m_validParse = (evalResult == EvalOk);
if (m_validParse) { if (m_validParse) {

View File

@@ -131,6 +131,16 @@ using ProjectExplorer::FileType;
namespace Internal { namespace Internal {
class QmakePriFile; class QmakePriFile;
struct InternalNode; struct InternalNode;
class VariableAndVPathInformation
{
public:
QString variable;
QStringList vPathsExact;
QStringList vPathsCumulative;
};
} }
// Implements ProjectNode for qmake .pri files // Implements ProjectNode for qmake .pri files
@@ -142,7 +152,10 @@ public:
QmakePriFileNode(QmakeProject *project, QmakeProFileNode *qmakeProFileNode, const QString &filePath); QmakePriFileNode(QmakeProject *project, QmakeProFileNode *qmakeProFileNode, const QString &filePath);
~QmakePriFileNode(); ~QmakePriFileNode();
void update(ProFile *includeFileExact, QtSupport::ProFileReader *readerExact, ProFile *includeFileCumlative, QtSupport::ProFileReader *readerCumalative, const QString &buildDir); void update(ProFile *includeFileExact, QtSupport::ProFileReader *readerExact,
ProFile *includeFileCumlative, QtSupport::ProFileReader *readerCumalative,
const QString &buildDir,
const QList<QList<Internal::VariableAndVPathInformation> > &variableAndVPathInformation);
// ProjectNode interface // ProjectNode interface