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 <joerg.bornemann@nokia.com>
This commit is contained in:
parent
c80697cfbe
commit
f86f3613a5
@ -198,12 +198,12 @@ MakefileGenerator::initOutPaths()
|
|||||||
QHash<QString, QStringList> &v = project->variables();
|
QHash<QString, QStringList> &v = project->variables();
|
||||||
//for shadow builds
|
//for shadow builds
|
||||||
if(!v.contains("QMAKE_ABSOLUTE_SOURCE_PATH")) {
|
if(!v.contains("QMAKE_ABSOLUTE_SOURCE_PATH")) {
|
||||||
if(Option::mkfile::do_cache && !Option::mkfile::cachefile.isEmpty() &&
|
if (Option::mkfile::do_cache && !project->cacheFile().isEmpty() &&
|
||||||
v.contains("QMAKE_ABSOLUTE_SOURCE_ROOT")) {
|
v.contains("QMAKE_ABSOLUTE_SOURCE_ROOT")) {
|
||||||
QString root = v["QMAKE_ABSOLUTE_SOURCE_ROOT"].first();
|
QString root = v["QMAKE_ABSOLUTE_SOURCE_ROOT"].first();
|
||||||
root = QDir::fromNativeSeparators(root);
|
root = QDir::fromNativeSeparators(root);
|
||||||
if(!root.isEmpty()) {
|
if(!root.isEmpty()) {
|
||||||
QFileInfo fi = fileInfo(Option::mkfile::cachefile);
|
QFileInfo fi = fileInfo(project->cacheFile());
|
||||||
if(!fi.makeAbsolute()) {
|
if(!fi.makeAbsolute()) {
|
||||||
QString cache_r = fi.path(), pwd = Option::output_dir;
|
QString cache_r = fi.path(), pwd = Option::output_dir;
|
||||||
if(pwd.startsWith(cache_r) && !pwd.startsWith(root)) {
|
if(pwd.startsWith(cache_r) && !pwd.startsWith(root)) {
|
||||||
@ -2692,7 +2692,7 @@ MakefileGenerator::writeMakeQmake(QTextStream &t)
|
|||||||
if(!ofile.isEmpty() && !project->isActiveConfig("no_autoqmake")) {
|
if(!ofile.isEmpty() && !project->isActiveConfig("no_autoqmake")) {
|
||||||
t << escapeFilePath(ofile) << ": " << escapeDependencyPath(fileFixify(pfile)) << " ";
|
t << escapeFilePath(ofile) << ": " << escapeDependencyPath(fileFixify(pfile)) << " ";
|
||||||
if(Option::mkfile::do_cache)
|
if(Option::mkfile::do_cache)
|
||||||
t << escapeDependencyPath(fileFixify(Option::mkfile::cachefile)) << " ";
|
t << escapeDependencyPath(fileFixify(project->cacheFile())) << " ";
|
||||||
if(!specdir().isEmpty()) {
|
if(!specdir().isEmpty()) {
|
||||||
if(exists(Option::fixPathToLocalOS(specdir()+QDir::separator()+"qmake.conf")))
|
if(exists(Option::fixPathToLocalOS(specdir()+QDir::separator()+"qmake.conf")))
|
||||||
t << escapeDependencyPath(specdir() + Option::dir_sep + "qmake.conf") << " ";
|
t << escapeDependencyPath(specdir() + Option::dir_sep + "qmake.conf") << " ";
|
||||||
|
@ -186,9 +186,8 @@ struct parser_info {
|
|||||||
bool from_file;
|
bool from_file;
|
||||||
} parser;
|
} parser;
|
||||||
|
|
||||||
static QString project_root;
|
static QString cached_source_root;
|
||||||
static QString project_build_root;
|
static QString cached_build_root;
|
||||||
|
|
||||||
static QStringList cached_qmakepath;
|
static QStringList cached_qmakepath;
|
||||||
static QStringList cached_qmakefeatures;
|
static QStringList cached_qmakefeatures;
|
||||||
|
|
||||||
@ -593,10 +592,10 @@ QStringList qmake_feature_paths(QMakeProperty *prop, bool host_build)
|
|||||||
feature_roots += cached_qmakefeatures;
|
feature_roots += cached_qmakefeatures;
|
||||||
if(prop)
|
if(prop)
|
||||||
feature_roots += splitPathList(prop->value("QMAKEFEATURES"));
|
feature_roots += splitPathList(prop->value("QMAKEFEATURES"));
|
||||||
if (!project_build_root.isEmpty())
|
if (!cached_build_root.isEmpty())
|
||||||
for(QStringList::Iterator concat_it = concat.begin();
|
for(QStringList::Iterator concat_it = concat.begin();
|
||||||
concat_it != concat.end(); ++concat_it)
|
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")));
|
QStringList qmakepath = splitPathList(QString::fromLocal8Bit(qgetenv("QMAKEPATH")));
|
||||||
qmakepath += cached_qmakepath;
|
qmakepath += cached_qmakepath;
|
||||||
foreach (const QString &path, qmakepath)
|
foreach (const QString &path, qmakepath)
|
||||||
@ -640,10 +639,10 @@ QStringList qmake_mkspec_paths()
|
|||||||
qmakepath += cached_qmakepath;
|
qmakepath += cached_qmakepath;
|
||||||
foreach (const QString &path, qmakepath)
|
foreach (const QString &path, qmakepath)
|
||||||
ret << (path + concat);
|
ret << (path + concat);
|
||||||
if (!project_build_root.isEmpty())
|
if (!cached_build_root.isEmpty())
|
||||||
ret << project_build_root + concat;
|
ret << cached_build_root + concat;
|
||||||
if (!project_root.isEmpty())
|
if (!cached_source_root.isEmpty())
|
||||||
ret << project_root + concat;
|
ret << cached_source_root + concat;
|
||||||
ret << QLibraryInfo::rawLocation(QLibraryInfo::HostDataPath, QLibraryInfo::EffectivePaths) + concat;
|
ret << QLibraryInfo::rawLocation(QLibraryInfo::HostDataPath, QLibraryInfo::EffectivePaths) + concat;
|
||||||
ret.removeDuplicates();
|
ret.removeDuplicates();
|
||||||
|
|
||||||
@ -1334,27 +1333,34 @@ QMakeProject::read(uchar cmd)
|
|||||||
if(!Option::user_template_prefix.isEmpty())
|
if(!Option::user_template_prefix.isEmpty())
|
||||||
base_vars["TEMPLATE_PREFIX"] = QStringList(Option::user_template_prefix);
|
base_vars["TEMPLATE_PREFIX"] = QStringList(Option::user_template_prefix);
|
||||||
|
|
||||||
project_build_root.clear();
|
QString project_root;
|
||||||
|
QString project_build_root;
|
||||||
QStringList qmakepath;
|
QStringList qmakepath;
|
||||||
QStringList qmakefeatures;
|
QStringList qmakefeatures;
|
||||||
if (Option::mkfile::do_cache) { // parse the cache
|
if (Option::mkfile::do_cache) { // parse the cache
|
||||||
if (Option::mkfile::cachefile.isEmpty()) { //find it as it has not been specified
|
if (Option::mkfile::cachefile.isEmpty()) { //find it as it has not been specified
|
||||||
QDir dir(Option::output_dir);
|
QString dir = Option::output_dir;
|
||||||
while (!dir.exists(QLatin1String(".qmake.cache")))
|
forever {
|
||||||
if (dir.isRoot() || !dir.cdUp())
|
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;
|
goto no_cache;
|
||||||
Option::mkfile::cachefile = dir.filePath(QLatin1String(".qmake.cache"));
|
dir = qdfi.path();
|
||||||
project_build_root = dir.path();
|
}
|
||||||
} else {
|
} else {
|
||||||
QFileInfo fi(Option::mkfile::cachefile);
|
QFileInfo fi(Option::mkfile::cachefile);
|
||||||
Option::mkfile::cachefile = QDir::cleanPath(fi.absoluteFilePath());
|
cachefile = QDir::cleanPath(fi.absoluteFilePath());
|
||||||
project_build_root = QDir::cleanPath(fi.absolutePath());
|
project_build_root = QDir::cleanPath(fi.absolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
QHash<QString, QStringList> cache;
|
QHash<QString, QStringList> cache;
|
||||||
if (!read(Option::mkfile::cachefile, cache)) {
|
if (!read(cachefile, cache)) {
|
||||||
Option::mkfile::cachefile.clear();
|
cachefile.clear();
|
||||||
goto no_cache;
|
goto no_cache;
|
||||||
}
|
}
|
||||||
if (Option::mkfile::xqmakespec.isEmpty() && !cache["XQMAKESPEC"].isEmpty())
|
if (Option::mkfile::xqmakespec.isEmpty() && !cache["XQMAKESPEC"].isEmpty())
|
||||||
@ -1366,11 +1372,6 @@ QMakeProject::read(uchar cmd)
|
|||||||
}
|
}
|
||||||
qmakepath = cache.value(QLatin1String("QMAKEPATH"));
|
qmakepath = cache.value(QLatin1String("QMAKEPATH"));
|
||||||
qmakefeatures = cache.value(QLatin1String("QMAKEFEATURES"));
|
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))
|
if (Option::output_dir.startsWith(project_build_root))
|
||||||
Option::mkfile::cachefile_depth =
|
Option::mkfile::cachefile_depth =
|
||||||
@ -1403,6 +1404,15 @@ QMakeProject::read(uchar cmd)
|
|||||||
project_root.clear();
|
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
|
{ // parse mkspec
|
||||||
QString *specp = host_build ? &Option::mkfile::qmakespec : &Option::mkfile::xqmakespec;
|
QString *specp = host_build ? &Option::mkfile::qmakespec : &Option::mkfile::xqmakespec;
|
||||||
QString qmakespec = *specp;
|
QString qmakespec = *specp;
|
||||||
@ -1439,9 +1449,9 @@ QMakeProject::read(uchar cmd)
|
|||||||
}
|
}
|
||||||
validateModes();
|
validateModes();
|
||||||
|
|
||||||
if(Option::mkfile::do_cache && !Option::mkfile::cachefile.isEmpty()) {
|
if (!cachefile.isEmpty()) {
|
||||||
debug_msg(1, "QMAKECACHE file: reading %s", Option::mkfile::cachefile.toLatin1().constData());
|
debug_msg(1, "QMAKECACHE file: reading %s", cachefile.toLatin1().constData());
|
||||||
read(Option::mkfile::cachefile, base_vars);
|
read(cachefile, base_vars);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3259,14 +3269,13 @@ QMakeProject::doProjectTest(QString func, QList<QStringList> args_list, QHash<QS
|
|||||||
}
|
}
|
||||||
varstr += QLatin1Char('\n');
|
varstr += QLatin1Char('\n');
|
||||||
}
|
}
|
||||||
if (Option::mkfile::cachefile.isEmpty()) {
|
if (cachefile.isEmpty()) {
|
||||||
Option::mkfile::cachefile = Option::output_dir + QLatin1String("/.qmake.cache");
|
cachefile = Option::output_dir + QLatin1String("/.qmake.cache");
|
||||||
printf("Info: creating cache file %s\n",
|
printf("Info: creating cache file %s\n", cachefile.toLatin1().constData());
|
||||||
Option::mkfile::cachefile.toLatin1().constData());
|
cached_build_root = Option::output_dir;
|
||||||
project_build_root = Option::output_dir;
|
cached_source_root = values("_PRO_FILE_PWD_", place).first();
|
||||||
project_root = values("_PRO_FILE_PWD_", place).first();
|
if (cached_source_root == cached_build_root)
|
||||||
if (project_root == project_build_root)
|
cached_source_root.clear();
|
||||||
project_root.clear();
|
|
||||||
invalidateFeatureRoots();
|
invalidateFeatureRoots();
|
||||||
}
|
}
|
||||||
QFileInfo qfi(Option::mkfile::cachefile);
|
QFileInfo qfi(Option::mkfile::cachefile);
|
||||||
@ -3277,9 +3286,9 @@ QMakeProject::doProjectTest(QString func, QList<QStringList> args_list, QHash<QS
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
QString errStr;
|
QString errStr;
|
||||||
if (!writeFile(Option::mkfile::cachefile, QIODevice::Append, varstr, &errStr)) {
|
if (!writeFile(cachefile, QIODevice::Append, varstr, &errStr)) {
|
||||||
fprintf(stderr, "ERROR writing cache file %s: %s\n",
|
fprintf(stderr, "ERROR writing cache file %s: %s\n",
|
||||||
Option::mkfile::cachefile.toLatin1().constData(), errStr.toLatin1().constData());
|
cachefile.toLatin1().constData(), errStr.toLatin1().constData());
|
||||||
#if defined(QT_BUILD_QMAKE_LIBRARY)
|
#if defined(QT_BUILD_QMAKE_LIBRARY)
|
||||||
return false;
|
return false;
|
||||||
#else
|
#else
|
||||||
@ -3695,7 +3704,7 @@ QStringList &QMakeProject::values(const QString &_var, QHash<QString, QStringLis
|
|||||||
} else if(var == QLatin1String("_QMAKE_CACHE_")) {
|
} else if(var == QLatin1String("_QMAKE_CACHE_")) {
|
||||||
var = ".BUILTIN." + var;
|
var = ".BUILTIN." + var;
|
||||||
if(Option::mkfile::do_cache)
|
if(Option::mkfile::do_cache)
|
||||||
place[var] = QStringList(Option::mkfile::cachefile);
|
place[var] = QStringList(cachefile);
|
||||||
} else if(var == QLatin1String("TEMPLATE")) {
|
} else if(var == QLatin1String("TEMPLATE")) {
|
||||||
if(!Option::user_template.isEmpty()) {
|
if(!Option::user_template.isEmpty()) {
|
||||||
var = ".BUILTIN.USER." + var;
|
var = ".BUILTIN.USER." + var;
|
||||||
|
@ -83,6 +83,7 @@ class QMakeProject
|
|||||||
bool need_restart;
|
bool need_restart;
|
||||||
bool own_prop;
|
bool own_prop;
|
||||||
bool backslashWarned;
|
bool backslashWarned;
|
||||||
|
QString cachefile;
|
||||||
QString pfile;
|
QString pfile;
|
||||||
QMakeProperty *prop;
|
QMakeProperty *prop;
|
||||||
void reset();
|
void reset();
|
||||||
@ -131,6 +132,7 @@ public:
|
|||||||
QStringList userTestFunctions() { return testFunctions.keys(); }
|
QStringList userTestFunctions() { return testFunctions.keys(); }
|
||||||
|
|
||||||
QString projectFile();
|
QString projectFile();
|
||||||
|
QString cacheFile() const { return cachefile; }
|
||||||
inline QMakeProperty *properties() { return prop; }
|
inline QMakeProperty *properties() { return prop; }
|
||||||
|
|
||||||
bool doProjectTest(QString str, QHash<QString, QStringList> &place);
|
bool doProjectTest(QString str, QHash<QString, QStringList> &place);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user