From f86f3613a52568e216c98d8f19ecc5204e76c3fb Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 10 May 2012 10:41:54 +0200 Subject: find .qmake.cache for subprojects independently this allows the creation of aggregator projects, like, say, qt5. this is not expected to have a negative impact, as no project could reasonably expect a nested .qmake.cache to *not* take effect - in fact, if the project was processed stand-alone, it would already use it. Change-Id: I33f2935d309baba7e95465f2fefb8231c4f03eda Reviewed-by: Joerg Bornemann --- qmake/project.cpp | 85 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 47 insertions(+), 38 deletions(-) (limited to 'qmake/project.cpp') diff --git a/qmake/project.cpp b/qmake/project.cpp index b141860556..88535bd0e8 100644 --- a/qmake/project.cpp +++ b/qmake/project.cpp @@ -186,9 +186,8 @@ struct parser_info { bool from_file; } parser; -static QString project_root; -static QString project_build_root; - +static QString cached_source_root; +static QString cached_build_root; static QStringList cached_qmakepath; static QStringList cached_qmakefeatures; @@ -593,10 +592,10 @@ QStringList qmake_feature_paths(QMakeProperty *prop, bool host_build) feature_roots += cached_qmakefeatures; if(prop) feature_roots += splitPathList(prop->value("QMAKEFEATURES")); - if (!project_build_root.isEmpty()) + if (!cached_build_root.isEmpty()) for(QStringList::Iterator concat_it = concat.begin(); concat_it != concat.end(); ++concat_it) - feature_roots << (project_build_root + (*concat_it)); + feature_roots << (cached_build_root + (*concat_it)); QStringList qmakepath = splitPathList(QString::fromLocal8Bit(qgetenv("QMAKEPATH"))); qmakepath += cached_qmakepath; foreach (const QString &path, qmakepath) @@ -640,10 +639,10 @@ QStringList qmake_mkspec_paths() qmakepath += cached_qmakepath; foreach (const QString &path, qmakepath) ret << (path + concat); - if (!project_build_root.isEmpty()) - ret << project_build_root + concat; - if (!project_root.isEmpty()) - ret << project_root + concat; + if (!cached_build_root.isEmpty()) + ret << cached_build_root + concat; + if (!cached_source_root.isEmpty()) + ret << cached_source_root + concat; ret << QLibraryInfo::rawLocation(QLibraryInfo::HostDataPath, QLibraryInfo::EffectivePaths) + concat; ret.removeDuplicates(); @@ -1334,27 +1333,34 @@ QMakeProject::read(uchar cmd) if(!Option::user_template_prefix.isEmpty()) base_vars["TEMPLATE_PREFIX"] = QStringList(Option::user_template_prefix); - project_build_root.clear(); - + QString project_root; + QString project_build_root; QStringList qmakepath; QStringList qmakefeatures; if (Option::mkfile::do_cache) { // parse the cache if (Option::mkfile::cachefile.isEmpty()) { //find it as it has not been specified - QDir dir(Option::output_dir); - while (!dir.exists(QLatin1String(".qmake.cache"))) - if (dir.isRoot() || !dir.cdUp()) + QString dir = Option::output_dir; + forever { + QFileInfo qfi(dir, QLatin1String(".qmake.cache")); + if (qfi.exists()) { + cachefile = qfi.filePath(); + project_build_root = dir; + break; + } + QFileInfo qdfi(dir); + if (qdfi.isRoot()) goto no_cache; - Option::mkfile::cachefile = dir.filePath(QLatin1String(".qmake.cache")); - project_build_root = dir.path(); + dir = qdfi.path(); + } } else { QFileInfo fi(Option::mkfile::cachefile); - Option::mkfile::cachefile = QDir::cleanPath(fi.absoluteFilePath()); + cachefile = QDir::cleanPath(fi.absoluteFilePath()); project_build_root = QDir::cleanPath(fi.absolutePath()); } QHash cache; - if (!read(Option::mkfile::cachefile, cache)) { - Option::mkfile::cachefile.clear(); + if (!read(cachefile, cache)) { + cachefile.clear(); goto no_cache; } if (Option::mkfile::xqmakespec.isEmpty() && !cache["XQMAKESPEC"].isEmpty()) @@ -1366,11 +1372,6 @@ QMakeProject::read(uchar cmd) } qmakepath = cache.value(QLatin1String("QMAKEPATH")); qmakefeatures = cache.value(QLatin1String("QMAKEFEATURES")); - if (qmakepath != cached_qmakepath || qmakefeatures != cached_qmakefeatures) { - cached_qmakepath = qmakepath; - cached_qmakefeatures = qmakefeatures; - invalidateFeatureRoots(); - } if (Option::output_dir.startsWith(project_build_root)) Option::mkfile::cachefile_depth = @@ -1403,6 +1404,15 @@ QMakeProject::read(uchar cmd) project_root.clear(); } + if (qmakepath != cached_qmakepath || qmakefeatures != cached_qmakefeatures + || project_build_root != cached_build_root) { // No need to check source dir, as it goes in sync + cached_source_root = project_root; + cached_build_root = project_build_root; + cached_qmakepath = qmakepath; + cached_qmakefeatures = qmakefeatures; + invalidateFeatureRoots(); + } + { // parse mkspec QString *specp = host_build ? &Option::mkfile::qmakespec : &Option::mkfile::xqmakespec; QString qmakespec = *specp; @@ -1439,9 +1449,9 @@ QMakeProject::read(uchar cmd) } validateModes(); - if(Option::mkfile::do_cache && !Option::mkfile::cachefile.isEmpty()) { - debug_msg(1, "QMAKECACHE file: reading %s", Option::mkfile::cachefile.toLatin1().constData()); - read(Option::mkfile::cachefile, base_vars); + if (!cachefile.isEmpty()) { + debug_msg(1, "QMAKECACHE file: reading %s", cachefile.toLatin1().constData()); + read(cachefile, base_vars); } } } @@ -3259,14 +3269,13 @@ QMakeProject::doProjectTest(QString func, QList args_list, QHash args_list, QHash