forked from qt-creator/qt-creator
QmakePriFile::update: Don't call buildDir() all the time.
Instead call it once per .pro file and pass that to all .pri file parses and other functions. This cuts down the number of calls for opening qtproject.pro from ~3000 to ~700 and speeds up opening qtproject.pro by roughly 3%. Change-Id: Iffd46d4bbedc9c380f70e916dae7151495990b39 Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
@@ -587,7 +587,9 @@ QSet<Utils::FileName> QmakePriFileNode::recursiveEnumerate(const QString &folder
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmakePriFileNode::update(ProFile *includeFileExact, QtSupport::ProFileReader *readerExact, ProFile *includeFileCumlative, QtSupport::ProFileReader *readerCumulative)
|
void QmakePriFileNode::update(ProFile *includeFileExact, QtSupport::ProFileReader *readerExact,
|
||||||
|
ProFile *includeFileCumlative, QtSupport::ProFileReader *readerCumulative,
|
||||||
|
const QString &buildDir)
|
||||||
{
|
{
|
||||||
// add project file node
|
// add project file node
|
||||||
if (m_fileNodes.isEmpty())
|
if (m_fileNodes.isEmpty())
|
||||||
@@ -651,10 +653,10 @@ void QmakePriFileNode::update(ProFile *includeFileExact, QtSupport::ProFileReade
|
|||||||
|
|
||||||
QStringList baseVPathsExact;
|
QStringList baseVPathsExact;
|
||||||
if (includeFileExact)
|
if (includeFileExact)
|
||||||
baseVPathsExact = baseVPaths(readerExact, projectDir, m_qmakeProFileNode->buildDir());
|
baseVPathsExact = baseVPaths(readerExact, projectDir, buildDir);
|
||||||
QStringList baseVPathsCumulative;
|
QStringList baseVPathsCumulative;
|
||||||
if (includeFileCumlative)
|
if (includeFileCumlative)
|
||||||
baseVPathsCumulative = baseVPaths(readerCumulative, projectDir, m_qmakeProFileNode->buildDir());
|
baseVPathsCumulative = baseVPaths(readerCumulative, projectDir, buildDir);
|
||||||
|
|
||||||
const QVector<QmakeNodeStaticData::FileTypeData> &fileTypes = qmakeNodeStaticData()->fileTypeData;
|
const QVector<QmakeNodeStaticData::FileTypeData> &fileTypes = qmakeNodeStaticData()->fileTypeData;
|
||||||
|
|
||||||
@@ -1848,6 +1850,8 @@ void QmakeProFileNode::applyEvaluate(EvalResult evalResult, bool async)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString buildDirectory = buildDir();
|
||||||
|
|
||||||
SortByPath sortByPath;
|
SortByPath sortByPath;
|
||||||
Utils::sort(existingProjectNodes, sortByPath);
|
Utils::sort(existingProjectNodes, sortByPath);
|
||||||
Utils::sort(newProjectFilesExact, sortByPath);
|
Utils::sort(newProjectFilesExact, sortByPath);
|
||||||
@@ -1921,7 +1925,7 @@ 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);
|
priFileNode->update(fileExact, m_readerExact, fileCumlative, m_readerCumulative, buildDirectory);
|
||||||
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
|
||||||
@@ -1959,7 +1963,7 @@ 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);
|
qmakePriFileNode->update(fileExact, m_readerExact, fileCumlative, m_readerCumulative, buildDirectory);
|
||||||
toAdd << qmakePriFileNode;
|
toAdd << qmakePriFileNode;
|
||||||
} else {
|
} else {
|
||||||
QmakeProFileNode *qmakeProFileNode = new QmakeProFileNode(m_project, nodeToAdd);
|
QmakeProFileNode *qmakeProFileNode = new QmakeProFileNode(m_project, nodeToAdd);
|
||||||
@@ -1986,7 +1990,7 @@ 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);
|
QmakePriFileNode::update(fileForCurrentProjectExact, m_readerExact, fileForCurrentProjectCumlative, m_readerCumulative, buildDirectory);
|
||||||
|
|
||||||
m_validParse = (evalResult == EvalOk);
|
m_validParse = (evalResult == EvalOk);
|
||||||
if (m_validParse) {
|
if (m_validParse) {
|
||||||
@@ -2025,18 +2029,17 @@ void QmakeProFileNode::applyEvaluate(EvalResult evalResult, bool async)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// update TargetInformation
|
// update TargetInformation
|
||||||
m_qmakeTargetInformation = targetInformation(m_readerExact, readerBuildPass);
|
m_qmakeTargetInformation = targetInformation(m_readerExact, readerBuildPass, buildDirectory);
|
||||||
m_resolvedMkspecPath = m_readerExact->resolvedMkSpec();
|
m_resolvedMkspecPath = m_readerExact->resolvedMkSpec();
|
||||||
|
|
||||||
m_subProjectsNotToDeploy = subProjectsNotToDeploy;
|
m_subProjectsNotToDeploy = subProjectsNotToDeploy;
|
||||||
setupInstallsList(readerBuildPass);
|
setupInstallsList(readerBuildPass);
|
||||||
|
|
||||||
QString buildDirectory = buildDir();
|
|
||||||
// update other variables
|
// update other variables
|
||||||
QHash<QmakeVariable, QStringList> newVarValues;
|
QHash<QmakeVariable, QStringList> newVarValues;
|
||||||
|
|
||||||
newVarValues[DefinesVar] = m_readerExact->values(QLatin1String("DEFINES"));
|
newVarValues[DefinesVar] = m_readerExact->values(QLatin1String("DEFINES"));
|
||||||
newVarValues[IncludePathVar] = includePaths(m_readerExact);
|
newVarValues[IncludePathVar] = includePaths(m_readerExact, buildDirectory);
|
||||||
newVarValues[CppFlagsVar] = m_readerExact->values(QLatin1String("QMAKE_CXXFLAGS"));
|
newVarValues[CppFlagsVar] = m_readerExact->values(QLatin1String("QMAKE_CXXFLAGS"));
|
||||||
newVarValues[CppHeaderVar] = fileListForVar(m_readerExact, m_readerCumulative,
|
newVarValues[CppHeaderVar] = fileListForVar(m_readerExact, m_readerCumulative,
|
||||||
QLatin1String("HEADERS"), m_projectDir, buildDirectory);
|
QLatin1String("HEADERS"), m_projectDir, buildDirectory);
|
||||||
@@ -2046,8 +2049,8 @@ void QmakeProFileNode::applyEvaluate(EvalResult evalResult, bool async)
|
|||||||
QLatin1String("OBJECTIVE_SOURCES"), m_projectDir, buildDirectory);
|
QLatin1String("OBJECTIVE_SOURCES"), m_projectDir, buildDirectory);
|
||||||
newVarValues[ObjCHeaderVar] = fileListForVar(m_readerExact, m_readerCumulative,
|
newVarValues[ObjCHeaderVar] = fileListForVar(m_readerExact, m_readerCumulative,
|
||||||
QLatin1String("OBJECTIVE_HEADERS"), m_projectDir, buildDirectory);
|
QLatin1String("OBJECTIVE_HEADERS"), m_projectDir, buildDirectory);
|
||||||
newVarValues[UiDirVar] = QStringList() << uiDirPath(m_readerExact);
|
newVarValues[UiDirVar] = QStringList() << uiDirPath(m_readerExact, buildDirectory);
|
||||||
newVarValues[MocDirVar] = QStringList() << mocDirPath(m_readerExact);
|
newVarValues[MocDirVar] = QStringList() << mocDirPath(m_readerExact, buildDirectory);
|
||||||
newVarValues[ResourceVar] = fileListForVar(m_readerExact, m_readerCumulative,
|
newVarValues[ResourceVar] = fileListForVar(m_readerExact, m_readerCumulative,
|
||||||
QLatin1String("RESOURCES"), m_projectDir, buildDirectory);
|
QLatin1String("RESOURCES"), m_projectDir, buildDirectory);
|
||||||
newVarValues[ExactResourceVar] = fileListForVar(m_readerExact, 0,
|
newVarValues[ExactResourceVar] = fileListForVar(m_readerExact, 0,
|
||||||
@@ -2104,7 +2107,7 @@ void QmakeProFileNode::applyEvaluate(EvalResult evalResult, bool async)
|
|||||||
|
|
||||||
setParseInProgress(false);
|
setParseInProgress(false);
|
||||||
|
|
||||||
updateUiFiles();
|
updateUiFiles(buildDirectory);
|
||||||
|
|
||||||
m_project->destroyProFileReader(m_readerExact);
|
m_project->destroyProFileReader(m_readerExact);
|
||||||
m_project->destroyProFileReader(m_readerCumulative);
|
m_project->destroyProFileReader(m_readerCumulative);
|
||||||
@@ -2136,23 +2139,23 @@ QStringList QmakeProFileNode::fileListForVar(QtSupport::ProFileReader *readerExa
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QmakeProFileNode::uiDirPath(QtSupport::ProFileReader *reader) const
|
QString QmakeProFileNode::uiDirPath(QtSupport::ProFileReader *reader, const QString &buildDir) const
|
||||||
{
|
{
|
||||||
QString path = reader->value(QLatin1String("UI_DIR"));
|
QString path = reader->value(QLatin1String("UI_DIR"));
|
||||||
if (QFileInfo(path).isRelative())
|
if (QFileInfo(path).isRelative())
|
||||||
path = QDir::cleanPath(buildDir() + QLatin1Char('/') + path);
|
path = QDir::cleanPath(buildDir + QLatin1Char('/') + path);
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QmakeProFileNode::mocDirPath(QtSupport::ProFileReader *reader) const
|
QString QmakeProFileNode::mocDirPath(QtSupport::ProFileReader *reader, const QString &buildDir) const
|
||||||
{
|
{
|
||||||
QString path = reader->value(QLatin1String("MOC_DIR"));
|
QString path = reader->value(QLatin1String("MOC_DIR"));
|
||||||
if (QFileInfo(path).isRelative())
|
if (QFileInfo(path).isRelative())
|
||||||
path = QDir::cleanPath(buildDir() + QLatin1Char('/') + path);
|
path = QDir::cleanPath(buildDir + QLatin1Char('/') + path);
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList QmakeProFileNode::includePaths(QtSupport::ProFileReader *reader) const
|
QStringList QmakeProFileNode::includePaths(QtSupport::ProFileReader *reader, const QString &buildDir) const
|
||||||
{
|
{
|
||||||
QStringList paths;
|
QStringList paths;
|
||||||
foreach (const QString &cxxflags, m_readerExact->values(QLatin1String("QMAKE_CXXFLAGS"))) {
|
foreach (const QString &cxxflags, m_readerExact->values(QLatin1String("QMAKE_CXXFLAGS"))) {
|
||||||
@@ -2165,7 +2168,7 @@ QStringList QmakeProFileNode::includePaths(QtSupport::ProFileReader *reader) con
|
|||||||
// paths already contains moc dir and ui dir, due to corrrectly parsing uic.prf and moc.prf
|
// paths already contains moc dir and ui dir, due to corrrectly parsing uic.prf and moc.prf
|
||||||
// except if those directories don't exist at the time of parsing
|
// except if those directories don't exist at the time of parsing
|
||||||
// thus we add those directories manually (without checking for existence)
|
// thus we add those directories manually (without checking for existence)
|
||||||
paths << mocDirPath(reader) << uiDirPath(reader);
|
paths << mocDirPath(reader, buildDir) << uiDirPath(reader, buildDir);
|
||||||
// qmake always adds "."
|
// qmake always adds "."
|
||||||
paths << m_projectDir;
|
paths << m_projectDir;
|
||||||
paths.removeDuplicates();
|
paths.removeDuplicates();
|
||||||
@@ -2236,7 +2239,7 @@ QStringList QmakeProFileNode::subDirsPaths(QtSupport::ProFileReader *reader, QSt
|
|||||||
return subProjectPaths;
|
return subProjectPaths;
|
||||||
}
|
}
|
||||||
|
|
||||||
TargetInformation QmakeProFileNode::targetInformation(QtSupport::ProFileReader *reader, QtSupport::ProFileReader *readerBuildPass) const
|
TargetInformation QmakeProFileNode::targetInformation(QtSupport::ProFileReader *reader, QtSupport::ProFileReader *readerBuildPass, const QString &buildDir) const
|
||||||
{
|
{
|
||||||
TargetInformation result;
|
TargetInformation result;
|
||||||
if (!reader || !readerBuildPass)
|
if (!reader || !readerBuildPass)
|
||||||
@@ -2249,7 +2252,7 @@ TargetInformation QmakeProFileNode::targetInformation(QtSupport::ProFileReader *
|
|||||||
}
|
}
|
||||||
|
|
||||||
// BUILD DIR
|
// BUILD DIR
|
||||||
result.buildDir = buildDir();
|
result.buildDir = buildDir;
|
||||||
|
|
||||||
if (readerBuildPass->contains(QLatin1String("DESTDIR")))
|
if (readerBuildPass->contains(QLatin1String("DESTDIR")))
|
||||||
result.destDir = readerBuildPass->value(QLatin1String("DESTDIR"));
|
result.destDir = readerBuildPass->value(QLatin1String("DESTDIR"));
|
||||||
@@ -2338,12 +2341,12 @@ QString QmakeProFileNode::buildDir(QmakeBuildConfiguration *bc) const
|
|||||||
return QDir::cleanPath(QDir(bc->buildDirectory().toString()).absoluteFilePath(relativeDir));
|
return QDir::cleanPath(QDir(bc->buildDirectory().toString()).absoluteFilePath(relativeDir));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QmakeProFileNode::uiDirectory() const
|
QString QmakeProFileNode::uiDirectory(const QString &buildDir) const
|
||||||
{
|
{
|
||||||
const QmakeVariablesHash::const_iterator it = m_varValues.constFind(UiDirVar);
|
const QmakeVariablesHash::const_iterator it = m_varValues.constFind(UiDirVar);
|
||||||
if (it != m_varValues.constEnd() && !it.value().isEmpty())
|
if (it != m_varValues.constEnd() && !it.value().isEmpty())
|
||||||
return it.value().front();
|
return it.value().front();
|
||||||
return buildDir();
|
return buildDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QmakeProFileNode::uiHeaderFile(const QString &uiDir, const QString &formFile)
|
QString QmakeProFileNode::uiHeaderFile(const QString &uiDir, const QString &formFile)
|
||||||
@@ -2355,7 +2358,7 @@ QString QmakeProFileNode::uiHeaderFile(const QString &uiDir, const QString &form
|
|||||||
return QDir::cleanPath(uiHeaderFilePath);
|
return QDir::cleanPath(uiHeaderFilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmakeProFileNode::updateUiFiles()
|
void QmakeProFileNode::updateUiFiles(const QString &buildDir)
|
||||||
{
|
{
|
||||||
m_uiFiles.clear();
|
m_uiFiles.clear();
|
||||||
|
|
||||||
@@ -2367,7 +2370,7 @@ void QmakeProFileNode::updateUiFiles()
|
|||||||
const QList<ProjectExplorer::FileNode*> uiFiles = uiFilesVisitor.uiFileNodes;
|
const QList<ProjectExplorer::FileNode*> uiFiles = uiFilesVisitor.uiFileNodes;
|
||||||
|
|
||||||
// Find the UiDir, there can only ever be one
|
// Find the UiDir, there can only ever be one
|
||||||
const QString uiDir = uiDirectory();
|
const QString uiDir = uiDirectory(buildDir);
|
||||||
foreach (const ProjectExplorer::FileNode *uiFile, uiFiles)
|
foreach (const ProjectExplorer::FileNode *uiFile, uiFiles)
|
||||||
m_uiFiles.insert(uiFile->path(), uiHeaderFile(uiDir, uiFile->path()));
|
m_uiFiles.insert(uiFile->path(), uiHeaderFile(uiDir, uiFile->path()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ 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);
|
void update(ProFile *includeFileExact, QtSupport::ProFileReader *readerExact, ProFile *includeFileCumlative, QtSupport::ProFileReader *readerCumalative, const QString &buildDir);
|
||||||
|
|
||||||
|
|
||||||
// ProjectNode interface
|
// ProjectNode interface
|
||||||
@@ -385,7 +385,7 @@ public:
|
|||||||
QString sourceDir() const;
|
QString sourceDir() const;
|
||||||
QString buildDir(QmakeBuildConfiguration *bc = 0) const;
|
QString buildDir(QmakeBuildConfiguration *bc = 0) const;
|
||||||
|
|
||||||
QString uiDirectory() const;
|
QString uiDirectory(const QString &buildDir) const;
|
||||||
static QString uiHeaderFile(const QString &uiDir, const QString &formFile);
|
static QString uiHeaderFile(const QString &uiDir, const QString &formFile);
|
||||||
QHash<QString, QString> uiFiles() const;
|
QHash<QString, QString> uiFiles() const;
|
||||||
|
|
||||||
@@ -432,17 +432,17 @@ private:
|
|||||||
|
|
||||||
typedef QHash<QmakeVariable, QStringList> QmakeVariablesHash;
|
typedef QHash<QmakeVariable, QStringList> QmakeVariablesHash;
|
||||||
|
|
||||||
void updateUiFiles();
|
void updateUiFiles(const QString &buildDir);
|
||||||
|
|
||||||
QStringList fileListForVar(QtSupport::ProFileReader *readerExact, QtSupport::ProFileReader *readerCumulative,
|
QStringList fileListForVar(QtSupport::ProFileReader *readerExact, QtSupport::ProFileReader *readerCumulative,
|
||||||
const QString &varName, const QString &projectDir, const QString &buildDir) const;
|
const QString &varName, const QString &projectDir, const QString &buildDir) const;
|
||||||
QString uiDirPath(QtSupport::ProFileReader *reader) const;
|
QString uiDirPath(QtSupport::ProFileReader *reader, const QString &buildDir) const;
|
||||||
QString mocDirPath(QtSupport::ProFileReader *reader) const;
|
QString mocDirPath(QtSupport::ProFileReader *reader, const QString &buildDir) const;
|
||||||
QStringList includePaths(QtSupport::ProFileReader *reader) const;
|
QStringList includePaths(QtSupport::ProFileReader *reader, const QString &buildDir) const;
|
||||||
QStringList libDirectories(QtSupport::ProFileReader *reader) const;
|
QStringList libDirectories(QtSupport::ProFileReader *reader) const;
|
||||||
QStringList subDirsPaths(QtSupport::ProFileReader *reader, QStringList *subProjectsNotToDeploy, bool silent) const;
|
QStringList subDirsPaths(QtSupport::ProFileReader *reader, QStringList *subProjectsNotToDeploy, bool silent) const;
|
||||||
|
|
||||||
TargetInformation targetInformation(QtSupport::ProFileReader *reader, QtSupport::ProFileReader *readerBuildPass) const;
|
TargetInformation targetInformation(QtSupport::ProFileReader *reader, QtSupport::ProFileReader *readerBuildPass, const QString &buildDir) const;
|
||||||
void setupInstallsList(const QtSupport::ProFileReader *reader);
|
void setupInstallsList(const QtSupport::ProFileReader *reader);
|
||||||
|
|
||||||
bool m_isDeployable;
|
bool m_isDeployable;
|
||||||
|
|||||||
@@ -976,7 +976,7 @@ QString QmakeProject::generatedUiHeader(const QString &formFile) const
|
|||||||
// the top-level project only.
|
// the top-level project only.
|
||||||
if (m_rootProjectNode)
|
if (m_rootProjectNode)
|
||||||
if (const QmakeProFileNode *pro = proFileNodeOf(m_rootProjectNode, FormType, formFile))
|
if (const QmakeProFileNode *pro = proFileNodeOf(m_rootProjectNode, FormType, formFile))
|
||||||
return QmakeProFileNode::uiHeaderFile(pro->uiDirectory(), formFile);
|
return QmakeProFileNode::uiHeaderFile(pro->uiDirectory(pro->buildDir()), formFile);
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user