summaryrefslogtreecommitdiffstats
path: root/qmake
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2012-02-23 17:16:03 +0100
committerQt by Nokia <qt-info@nokia.com>2012-02-29 00:05:38 +0100
commit65b42dd4c8e6aed6ad84dbd4063da3961a779433 (patch)
treeff587f071e2bc6eff8760824c58e2b66d6f17a15 /qmake
parente05d5c36beb1116657e87d0088ee6153115f320a (diff)
look for mkspecs in the project root, not next to every project
qmake would look for mkspecs/ in the directory containing the current project file. this makes completely no sense with recursive projects: a) nobody would make per-project specs and b) specs meant to be global would not be found. consequently, we look for a project root when starting qmake and use only that directory. if .qmake.cache is found/set, we assume that to be the project root. otherwise, we search for mkspecs/ the same way we search for the cache - just to up until we find one or hit the root. if we are shadow-building, search the build dir as well. Change-Id: Ie66b189a40c21203d956e681cbef44a89f98cd17 Reviewed-by: Joerg Bornemann <joerg.bornemann@nokia.com> Reviewed-by: Marius Storm-Olsen <marius.storm-olsen@nokia.com>
Diffstat (limited to 'qmake')
-rw-r--r--qmake/main.cpp2
-rw-r--r--qmake/option.cpp31
-rw-r--r--qmake/option.h3
-rw-r--r--qmake/project.cpp9
4 files changed, 36 insertions, 9 deletions
diff --git a/qmake/main.cpp b/qmake/main.cpp
index 54cf9f9bdf..985afaa8e8 100644
--- a/qmake/main.cpp
+++ b/qmake/main.cpp
@@ -163,7 +163,7 @@ int runQMake(int argc, char **argv)
fn = fn.right(fn.length() - di - 1);
}
- if (!Option::prepareProject()) {
+ if (!Option::prepareProject(fn)) {
exit_val = 3;
break;
}
diff --git a/qmake/option.cpp b/qmake/option.cpp
index 0c649fdd77..16c5390348 100644
--- a/qmake/option.cpp
+++ b/qmake/option.cpp
@@ -116,6 +116,7 @@ bool Option::mkfile::do_dep_heuristics = true;
bool Option::mkfile::do_preprocess = false;
bool Option::mkfile::do_stub_makefile = false;
bool Option::mkfile::do_cache = true;
+QString Option::mkfile::project_root;
QString Option::mkfile::project_build_root;
QString Option::mkfile::cachefile;
QStringList Option::mkfile::project_files;
@@ -576,7 +577,7 @@ void Option::applyHostMode()
}
}
-bool Option::prepareProject()
+bool Option::prepareProject(const QString &pfile)
{
mkfile::project_build_root.clear();
if (mkfile::do_cache) {
@@ -601,6 +602,34 @@ bool Option::prepareProject()
}
}
no_cache:
+
+ QString srcpath = (pfile != "-")
+ ? QDir::cleanPath(QFileInfo(pfile).absolutePath()) : qmake_getpwd();
+ if (srcpath != output_dir || mkfile::project_build_root.isEmpty()) {
+ QDir srcdir(srcpath);
+ QDir dstdir(output_dir);
+ do {
+ if (!mkfile::project_build_root.isEmpty()) {
+ // If we already know the build root, just match up the source root with it.
+ if (dstdir.path() == mkfile::project_build_root) {
+ mkfile::project_root = srcdir.path();
+ break;
+ }
+ } else {
+ // Look for mkspecs/ in source and build. First to win determines the root.
+ if (dstdir.exists("mkspecs") || srcdir.exists("mkspecs")) {
+ mkfile::project_build_root = dstdir.path();
+ mkfile::project_root = srcdir.path();
+ if (mkfile::project_root == mkfile::project_build_root)
+ mkfile::project_root.clear();
+ break;
+ }
+ }
+ } while (!srcdir.isRoot() && srcdir.cdUp() && !dstdir.isRoot() && dstdir.cdUp());
+ } else {
+ mkfile::project_root.clear();
+ }
+
return true;
}
diff --git a/qmake/option.h b/qmake/option.h
index b8a3b561fa..a4d8cccbec 100644
--- a/qmake/option.h
+++ b/qmake/option.h
@@ -108,7 +108,7 @@ struct Option
//both of these must be called..
static int init(int argc=0, char **argv=0); //parse cmdline
static void applyHostMode();
- static bool prepareProject();
+ static bool prepareProject(const QString &pfile);
static bool postProcessProject(QMakeProject *);
enum StringFixFlags {
@@ -202,6 +202,7 @@ struct Option
static bool do_dep_heuristics;
static bool do_preprocess;
static bool do_stub_makefile;
+ static QString project_root;
static QString project_build_root;
static QString cachefile;
static int cachefile_depth;
diff --git a/qmake/project.cpp b/qmake/project.cpp
index 1179812b1b..0e0ac93c5a 100644
--- a/qmake/project.cpp
+++ b/qmake/project.cpp
@@ -607,6 +607,9 @@ QStringList qmake_mkspec_paths()
for(QStringList::ConstIterator it = lst.begin(); it != lst.end(); ++it)
ret << ((*it) + concat);
}
+ ret << Option::mkfile::project_build_root + concat;
+ if (!Option::mkfile::project_root.isEmpty())
+ ret << Option::mkfile::project_root + concat;
ret << QLibraryInfo::location(QLibraryInfo::DataPath) + concat;
return ret;
@@ -1307,11 +1310,6 @@ QMakeProject::read(uchar cmd)
}
if(QDir::isRelativePath(qmakespec)) {
- if (QFile::exists(Option::output_dir+"/"+qmakespec+"/qmake.conf")) {
- qmakespec = Option::mkfile::qmakespec = QFileInfo(Option::output_dir+"/"+qmakespec).absoluteFilePath();
- } else if (QFile::exists(qmakespec+"/qmake.conf")) {
- Option::mkfile::qmakespec = QFileInfo(Option::mkfile::qmakespec).absoluteFilePath();
- } else {
bool found_mkspec = false;
for(QStringList::ConstIterator it = mkspec_roots.begin(); it != mkspec_roots.end(); ++it) {
QString mkspec = (*it) + QLatin1Char('/') + qmakespec;
@@ -1326,7 +1324,6 @@ QMakeProject::read(uchar cmd)
qmakespec.toLatin1().constData(), mkspec_roots.join("\n\t").toLatin1().constData());
return false;
}
- }
}
// parse qmake configuration