summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2010-02-22 17:59:00 (GMT)
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2010-02-26 13:31:02 (GMT)
commitf5b19c173109c53bf3d8167573f7276cf39262d2 (patch)
treec88224e2e4ac7afeaa00093d8a8dc0f636e1ef2f
parent7e9cf4a4b3e04e4268e6920aef263a85b5b3de70 (diff)
downloadQt-f5b19c173109c53bf3d8167573f7276cf39262d2.zip
Qt-f5b19c173109c53bf3d8167573f7276cf39262d2.tar.gz
Qt-f5b19c173109c53bf3d8167573f7276cf39262d2.tar.bz2
decouple host platform mode from target platform mode
derive the host mode from the generator - this doesn't work *too* well if the mode is different from the real host platform, so it's only for testing. get the target platform mode from the qmakespec, falling back to the host platform mode. Reviewed-by: mariusSO
-rw-r--r--qmake/generators/makefile.cpp14
-rw-r--r--qmake/generators/makefile.h2
-rw-r--r--qmake/generators/metamakefile.cpp34
-rw-r--r--qmake/generators/metamakefile.h5
-rw-r--r--qmake/option.cpp20
-rw-r--r--qmake/option.h5
-rw-r--r--qmake/project.cpp45
-rw-r--r--qmake/project.h1
8 files changed, 110 insertions, 16 deletions
diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp
index ec712a0..a8c1c3c 100644
--- a/qmake/generators/makefile.cpp
+++ b/qmake/generators/makefile.cpp
@@ -2152,12 +2152,14 @@ QString MakefileGenerator::buildArgs(const QString &outdir)
ret += " -nodependheuristics";
if(!Option::mkfile::qmakespec_commandline.isEmpty())
ret += " -spec " + specdir(outdir);
- if(Option::target_mode == Option::TARG_MACX_MODE)
- ret += " -macx";
- else if(Option::target_mode == Option::TARG_UNIX_MODE)
- ret += " -unix";
- else if(Option::target_mode == Option::TARG_WIN_MODE)
- ret += " -win32";
+ if (Option::target_mode_overridden) {
+ if (Option::target_mode == Option::TARG_MACX_MODE)
+ ret += " -macx";
+ else if (Option::target_mode == Option::TARG_UNIX_MODE)
+ ret += " -unix";
+ else if (Option::target_mode == Option::TARG_WIN_MODE)
+ ret += " -win32";
+ }
//configs
for(QStringList::Iterator it = Option::user_configs.begin();
diff --git a/qmake/generators/makefile.h b/qmake/generators/makefile.h
index d89c3b1..1f70e64 100644
--- a/qmake/generators/makefile.h
+++ b/qmake/generators/makefile.h
@@ -247,7 +247,7 @@ public:
virtual bool supportsMergedBuilds() { return false; }
virtual bool mergeBuildProject(MakefileGenerator * /*other*/) { return false; }
virtual bool openOutput(QFile &, const QString &build) const;
- virtual bool isWindowsShell() const { return Option::target_mode == Option::TARG_WIN_MODE; }
+ virtual bool isWindowsShell() const { return Option::host_mode == Option::HOST_WIN_MODE; }
};
inline void MakefileGenerator::setNoIO(bool o)
diff --git a/qmake/generators/metamakefile.cpp b/qmake/generators/metamakefile.cpp
index ec26a99..e764dd3 100644
--- a/qmake/generators/metamakefile.cpp
+++ b/qmake/generators/metamakefile.cpp
@@ -486,6 +486,40 @@ MetaMakefileGenerator::createMakefileGenerator(QMakeProject *proj, bool noIO)
return mkfile;
}
+bool
+MetaMakefileGenerator::modesForGenerator(const QString &gen,
+ Option::HOST_MODE *host_mode, Option::TARG_MODE *target_mode)
+{
+ if (gen == "UNIX") {
+#ifdef Q_OS_MAC
+ *host_mode = Option::HOST_MACX_MODE;
+ *target_mode = Option::TARG_MACX_MODE;
+#else
+ *host_mode = Option::HOST_UNIX_MODE;
+ *target_mode = Option::TARG_UNIX_MODE;
+#endif
+ } else if (gen == "MSVC.NET" || gen == "MINGW" || gen == "BMAKE") {
+ *host_mode = Option::HOST_WIN_MODE;
+ *target_mode = Option::TARG_WIN_MODE;
+ } else if (gen == "PROJECTBUILDER" || gen == "XCODE") {
+ *host_mode = Option::HOST_MACX_MODE;
+ *target_mode = Option::TARG_MACX_MODE;
+ } else if (gen == "SYMBIAN_ABLD" || gen == "SYMBIAN_SBSV2") {
+#if defined(Q_OS_MAC)
+ *host_mode = Option::HOST_MACX_MODE;
+#elif defined(Q_OS_UNIX)
+ *host_mode = Option::HOST_UNIX_MODE;
+#else
+ *host_mode = Option::HOST_WIN_MODE;
+#endif
+ *target_mode = Option::TARG_WIN_MODE; // anything, just not unknown
+ } else {
+ fprintf(stderr, "Unknown generator specified: %s\n", gen.toLatin1().constData());
+ return false;
+ }
+ return true;
+}
+
MetaMakefileGenerator *
MetaMakefileGenerator::createMetaGenerator(QMakeProject *proj, const QString &name, bool op, bool *success)
{
diff --git a/qmake/generators/metamakefile.h b/qmake/generators/metamakefile.h
index 8675115..e559c8e 100644
--- a/qmake/generators/metamakefile.h
+++ b/qmake/generators/metamakefile.h
@@ -42,6 +42,8 @@
#ifndef METAMAKEFILE_H
#define METAMAKEFILE_H
+#include <option.h>
+
#include <qlist.h>
#include <qstring.h>
@@ -65,6 +67,9 @@ public:
static MetaMakefileGenerator *createMetaGenerator(QMakeProject *proj, const QString &name, bool op=true, bool *success = 0);
static MakefileGenerator *createMakefileGenerator(QMakeProject *proj, bool noIO = false);
+ static bool modesForGenerator(const QString &generator,
+ Option::HOST_MODE *host_mode, Option::TARG_MODE *target_mode);
+
inline QMakeProject *projectFile() const { return project; }
virtual bool init() = 0;
diff --git a/qmake/option.cpp b/qmake/option.cpp
index 9e99ae4..630f882 100644
--- a/qmake/option.cpp
+++ b/qmake/option.cpp
@@ -96,13 +96,9 @@ QStringList Option::after_user_configs;
QString Option::user_template;
QString Option::user_template_prefix;
QStringList Option::shellPath;
-#if defined(Q_OS_WIN32)
-Option::TARG_MODE Option::target_mode = Option::TARG_WIN_MODE;
-#elif defined(Q_OS_MAC)
-Option::TARG_MODE Option::target_mode = Option::TARG_MACX_MODE;
-#else
-Option::TARG_MODE Option::target_mode = Option::TARG_UNIX_MODE;
-#endif
+Option::HOST_MODE Option::host_mode = Option::HOST_UNKNOWN_MODE;
+Option::TARG_MODE Option::target_mode = Option::TARG_UNKNOWN_MODE;
+bool Option::target_mode_overridden = false;
//QMAKE_*_PROPERTY stuff
QStringList Option::prop::properties;
@@ -251,11 +247,17 @@ Option::parseCommandLine(int argc, char **argv, int skip)
} else if(opt == "tp" || opt == "template_prefix") {
Option::user_template_prefix = argv[++x];
} else if(opt == "macx") {
+ Option::host_mode = HOST_MACX_MODE;
Option::target_mode = TARG_MACX_MODE;
+ Option::target_mode_overridden = true;
} else if(opt == "unix") {
+ Option::host_mode = HOST_UNIX_MODE;
Option::target_mode = TARG_UNIX_MODE;
+ Option::target_mode_overridden = true;
} else if(opt == "win32") {
+ Option::host_mode = HOST_WIN_MODE;
Option::target_mode = TARG_WIN_MODE;
+ Option::target_mode_overridden = true;
} else if(opt == "d") {
Option::debug_level++;
} else if(opt == "version" || opt == "v" || opt == "-version") {
@@ -405,6 +407,7 @@ Option::init(int argc, char **argv)
#ifdef Q_OS_WIN
Option::dirlist_sep = ";";
Option::shellPath = detectShellPath();
+ Option::res_ext = ".res";
#else
Option::dirlist_sep = ":";
#endif
@@ -525,7 +528,8 @@ Option::init(int argc, char **argv)
}
//defaults for globals
- applyHostMode();
+ if (Option::host_mode != Option::HOST_UNKNOWN_MODE)
+ applyHostMode();
return QMAKE_CMDLINE_SUCCESS;
}
diff --git a/qmake/option.h b/qmake/option.h
index d9e3c39..953d91e 100644
--- a/qmake/option.h
+++ b/qmake/option.h
@@ -152,8 +152,11 @@ struct Option
enum QMAKE_RECURSIVE { QMAKE_RECURSIVE_DEFAULT, QMAKE_RECURSIVE_YES, QMAKE_RECURSIVE_NO };
static QMAKE_RECURSIVE recursive;
static QStringList before_user_vars, after_user_vars, user_configs, after_user_configs;
- enum TARG_MODE { TARG_UNIX_MODE, TARG_WIN_MODE, TARG_MACX_MODE };
+ enum HOST_MODE { HOST_UNKNOWN_MODE, HOST_UNIX_MODE, HOST_WIN_MODE, HOST_MACX_MODE };
+ static HOST_MODE host_mode;
+ enum TARG_MODE { TARG_UNKNOWN_MODE, TARG_UNIX_MODE, TARG_WIN_MODE, TARG_MACX_MODE };
static TARG_MODE target_mode;
+ static bool target_mode_overridden;
static QString user_template, user_template_prefix;
static QStringList shellPath;
diff --git a/qmake/project.cpp b/qmake/project.cpp
index 7b681eb..d2fdf02 100644
--- a/qmake/project.cpp
+++ b/qmake/project.cpp
@@ -43,6 +43,7 @@
#include "property.h"
#include "option.h"
#include "cachekeys.h"
+#include "generators/metamakefile.h"
#include <qdatetime.h>
#include <qfile.h>
@@ -592,6 +593,7 @@ QStringList qmake_feature_paths(QMakeProperty *prop=0)
concat << base_concat + QDir::separator() + "macx";
concat << base_concat + QDir::separator() + "unix";
break;
+ default: // Can't happen, just make the compiler shut up
case Option::TARG_UNIX_MODE:
{
if (isForSymbian())
@@ -1445,6 +1447,7 @@ QMakeProject::read(uchar cmd)
fprintf(stderr, "Failure to read QMAKESPEC conf file %s.\n", spec.toLatin1().constData());
return false;
}
+ validateModes();
init_symbian(base_vars);
@@ -1570,6 +1573,44 @@ QMakeProject::read(uchar cmd)
return true;
}
+void QMakeProject::validateModes()
+{
+ if (Option::host_mode == Option::HOST_UNKNOWN_MODE
+ || Option::target_mode == Option::TARG_UNKNOWN_MODE) {
+ Option::HOST_MODE host_mode;
+ Option::TARG_MODE target_mode;
+ const QStringList &gen = base_vars.value("MAKEFILE_GENERATOR");
+ if (gen.isEmpty()) {
+ fprintf(stderr, "%s:%d: Using OS scope before setting MAKEFILE_GENERATOR\n",
+ parser.file.toLatin1().constData(), parser.line_no);
+ } else if (MetaMakefileGenerator::modesForGenerator(gen.first(),
+ &host_mode, &target_mode)) {
+ if (Option::host_mode == Option::HOST_UNKNOWN_MODE) {
+ Option::host_mode = host_mode;
+ Option::applyHostMode();
+ }
+
+ if (Option::target_mode == Option::TARG_UNKNOWN_MODE) {
+ const QStringList &tgt = base_vars.value("TARGET_PLATFORM");
+ if (!tgt.isEmpty()) {
+ const QString &os = tgt.first();
+ if (os == "unix")
+ Option::target_mode = Option::TARG_UNIX_MODE;
+ else if (os == "macx")
+ Option::target_mode = Option::TARG_MACX_MODE;
+ else if (os == "win32")
+ Option::target_mode = Option::TARG_WIN_MODE;
+ else
+ fprintf(stderr, "Unknown target platform specified: %s\n",
+ os.toLatin1().constData());
+ } else {
+ Option::target_mode = target_mode;
+ }
+ }
+ }
+ }
+}
+
bool
QMakeProject::isActiveConfig(const QString &x, bool regex, QMap<QString, QStringList> *place)
{
@@ -1588,14 +1629,17 @@ QMakeProject::isActiveConfig(const QString &x, bool regex, QMap<QString, QString
// using a mkspec starting with 'symbian*' will resolve both the 'symbian'
// and the 'unix' (because of Open C) scopes to true.
if (x == "unix") {
+ validateModes();
return Option::target_mode == Option::TARG_UNIX_MODE
|| Option::target_mode == Option::TARG_MACX_MODE
|| isForSymbian();
} else if (x == "macx" || x == "mac") {
+ validateModes();
return Option::target_mode == Option::TARG_MACX_MODE && !isForSymbian();
} else if (x == "symbian") {
return isForSymbian();
} else if (x == "win32") {
+ validateModes();
return Option::target_mode == Option::TARG_WIN_MODE && !isForSymbian();
}
@@ -1694,6 +1738,7 @@ QMakeProject::doProjectInclude(QString file, uchar flags, QMap<QString, QStringL
if(file.indexOf(Option::dir_sep) == -1 || !QFile::exists(file)) {
static QStringList *feature_roots = 0;
if(!feature_roots) {
+ validateModes();
init_symbian(base_vars);
feature_roots = new QStringList(qmake_feature_paths(prop));
qmakeAddCacheClear(qmakeDeleteCacheClear_QStringList, (void**)&feature_roots);
diff --git a/qmake/project.h b/qmake/project.h
index a8dcc28..50706cb 100644
--- a/qmake/project.h
+++ b/qmake/project.h
@@ -106,6 +106,7 @@ class QMakeProject
QStringList doVariableReplaceExpand(const QString &str, QMap<QString, QStringList> &place, bool *ok=0);
void init(QMakeProperty *, const QMap<QString, QStringList> *);
QStringList &values(const QString &v, QMap<QString, QStringList> &place);
+ void validateModes();
public:
QMakeProject() { init(0, 0); }