summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2012-02-23 19:34:10 +0100
committerQt by Nokia <qt-info@nokia.com>2012-03-02 08:43:06 +0100
commit74a6669fa7c0d6e2cb7d34d56332d620d2a07755 (patch)
tree9dccf49e81b2a212822304c50b3a7976580da816
parent123eb803ef1a7af36eefdf9a668f1f29d6597f1d (diff)
move finding the makespec to Option
this is a one-time operation which depends only on the invocation, so this new home is much more appropriate. Change-Id: I07c66d95a9ae01a664cec17564995311fb78ec9b Reviewed-by: Joerg Bornemann <joerg.bornemann@nokia.com> Reviewed-by: Marius Storm-Olsen <marius.storm-olsen@nokia.com>
-rw-r--r--qmake/option.cpp44
-rw-r--r--qmake/option.h2
-rw-r--r--qmake/project.cpp43
-rw-r--r--qmake/property.cpp4
4 files changed, 48 insertions, 45 deletions
diff --git a/qmake/option.cpp b/qmake/option.cpp
index 16c5390348..93a0ffbd9c 100644
--- a/qmake/option.cpp
+++ b/qmake/option.cpp
@@ -577,6 +577,47 @@ void Option::applyHostMode()
}
}
+QStringList Option::mkspecPaths()
+{
+ QStringList ret;
+ const QString concat = QLatin1String("/mkspecs");
+
+ QByteArray qmakepath = qgetenv("QMAKEPATH");
+ if (!qmakepath.isEmpty()) {
+ const QStringList lst = splitPathList(QString::fromLocal8Bit(qmakepath));
+ 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;
+}
+
+bool Option::resolveSpec(QString *spec)
+{
+ QString qmakespec = fixEnvVariables(*spec);
+ if (qmakespec.isEmpty())
+ qmakespec = "default";
+ if (QDir::isRelativePath(qmakespec)) {
+ QStringList mkspec_roots = mkspecPaths();
+ debug_msg(2, "Looking for mkspec %s in (%s)", qmakespec.toLatin1().constData(),
+ mkspec_roots.join("::").toLatin1().constData());
+ for (QStringList::ConstIterator it = mkspec_roots.begin(); it != mkspec_roots.end(); ++it) {
+ QString mkspec = (*it) + QLatin1Char('/') + qmakespec;
+ if (QFile::exists(mkspec)) {
+ *spec = mkspec;
+ return true;
+ }
+ }
+ fprintf(stderr, "Could not find mkspecs for your QMAKESPEC(%s) after trying:\n\t%s\n",
+ qmakespec.toLatin1().constData(), mkspec_roots.join("\n\t").toLatin1().constData());
+ return false;
+ }
+ return true;
+}
+
bool Option::prepareProject(const QString &pfile)
{
mkfile::project_build_root.clear();
@@ -630,6 +671,9 @@ bool Option::prepareProject(const QString &pfile)
mkfile::project_root.clear();
}
+ if (!resolveSpec(&Option::mkfile::qmakespec))
+ return false;
+
return true;
}
diff --git a/qmake/option.h b/qmake/option.h
index a4d8cccbec..96549bb5bc 100644
--- a/qmake/option.h
+++ b/qmake/option.h
@@ -108,6 +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 QStringList mkspecPaths();
static bool prepareProject(const QString &pfile);
static bool postProcessProject(QMakeProject *);
@@ -212,6 +213,7 @@ struct Option
private:
static int parseCommandLine(int, char **, int=0);
+ static bool resolveSpec(QString *spec);
};
inline QString fixEnvVariables(const QString &x) { return Option::fixString(x, Option::FixEnvVars); }
diff --git a/qmake/project.cpp b/qmake/project.cpp
index 2d339ccb63..0533ab30b5 100644
--- a/qmake/project.cpp
+++ b/qmake/project.cpp
@@ -596,24 +596,6 @@ QStringList qmake_feature_paths(QMakeProperty *prop=0)
return feature_roots;
}
-QStringList qmake_mkspec_paths()
-{
- QStringList ret;
- const QString concat = QLatin1String("/mkspecs");
- QByteArray qmakepath = qgetenv("QMAKEPATH");
- if (!qmakepath.isEmpty()) {
- const QStringList lst = splitPathList(QString::fromLocal8Bit(qmakepath));
- 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;
-}
-
QMakeProject::~QMakeProject()
{
if(own_prop)
@@ -1290,30 +1272,7 @@ QMakeProject::read(uchar cmd)
Option::output_dir.mid(Option::mkfile::project_build_root.length()).count('/');
}
if (cmd & ReadSetup) { // parse mkspec
- QString qmakespec = fixEnvVariables(Option::mkfile::qmakespec);
- if (qmakespec.isEmpty())
- qmakespec = "default";
- if(QDir::isRelativePath(qmakespec)) {
- QStringList mkspec_roots = qmake_mkspec_paths();
- debug_msg(2, "Looking for mkspec %s in (%s)", qmakespec.toLatin1().constData(),
- mkspec_roots.join("::").toLatin1().constData());
- bool found_mkspec = false;
- for(QStringList::ConstIterator it = mkspec_roots.begin(); it != mkspec_roots.end(); ++it) {
- QString mkspec = (*it) + QLatin1Char('/') + qmakespec;
- if(QFile::exists(mkspec)) {
- found_mkspec = true;
- Option::mkfile::qmakespec = qmakespec = mkspec;
- break;
- }
- }
- if(!found_mkspec) {
- fprintf(stderr, "Could not find mkspecs for your QMAKESPEC(%s) after trying:\n\t%s\n",
- qmakespec.toLatin1().constData(), mkspec_roots.join("\n\t").toLatin1().constData());
- return false;
- }
- }
-
- // parse qmake configuration
+ QString qmakespec = Option::mkfile::qmakespec;
while(qmakespec.endsWith(QLatin1Char('/')))
qmakespec.truncate(qmakespec.length()-1);
QString spec = qmakespec + QLatin1String("/qmake.conf");
diff --git a/qmake/property.cpp b/qmake/property.cpp
index 4221605545..064c8f6082 100644
--- a/qmake/property.cpp
+++ b/qmake/property.cpp
@@ -49,8 +49,6 @@
QT_BEGIN_NAMESPACE
-QStringList qmake_mkspec_paths(); //project.cpp
-
QMakeProperty::QMakeProperty() : settings(0)
{
}
@@ -107,7 +105,7 @@ QMakeProperty::value(QString v, bool just_check)
else if(v == "QT_INSTALL_DEMOS")
return QLibraryInfo::location(QLibraryInfo::ExamplesPath);
else if(v == "QMAKE_MKSPECS")
- return qmake_mkspec_paths().join(Option::dirlist_sep);
+ return Option::mkspecPaths().join(Option::dirlist_sep);
else if(v == "QMAKE_VERSION")
return qmake_version();
#ifdef QT_VERSION_STR