the project evaluator becomes oblivious of the target mode.
the mode is set up in spec_post.prf according to the spec.
$$QMAKE_TARGET contains the feature suffixes to search, and is also
contained in $$CONFIG.
the target_mode variable itself becomes private to the Makefile class.
Change-Id: I3c06d9dab536b753343cec6c5c491d3203e50bd8
Reviewed-by: Mark Brand <mabrand@mabrand.nl>
--- /dev/null
+isEmpty(MAKEFILE_GENERATOR):error("Qmake spec does not set MAKEFILE_GENERATOR.")
+isEmpty(QMAKE_PLATFORM) {
+ isEmpty(TARGET_PLATFORM) {
+ equals(MAKEFILE_GENERATOR, UNIX) {
+ equals(QMAKE_HOST.os, Darwin): \
+ TARGET_PLATFORM = macx
+ else: \
+ TARGET_PLATFORM = unix
+ } else:if(equals(MAKEFILE_GENERATOR, MSVC.NET) \
+ |equals(MAKEFILE_GENERATOR, BMAKE) \
+ |equals(MAKEFILE_GENERATOR, MSBUILD) \
+ |equals(MAKEFILE_GENERATOR, MINGW)) {
+ TARGET_PLATFORM = win32
+ } else:if(equals(MAKEFILE_GENERATOR, PROJECTBUILDER) \
+ |equals(MAKEFILE_GENERATOR, XCODE)) {
+ } else:equals(MAKEFILE_GENERATOR, GBUILD) {
+ TARGET_PLATFORM = unix
+ } else {
+ error("Qmake spec sets an invalid MAKEFILE_GENERATOR.")
+ }
+ }
+ equals(TARGET_PLATFORM, unix): \
+ QMAKE_PLATFORM = unix
+ else:equals(TARGET_PLATFORM, macx): \
+ QMAKE_PLATFORM = mac macx unix
+ else:equals(TARGET_PLATFORM, win32): \
+ QMAKE_PLATFORM = win32
+ else: \
+ error("Qmake spec sets an invalid TARGET_PLATFORM.")
+}
+CONFIG += $$QMAKE_PLATFORM
if(project)
return;
project = p;
+ if (project->isActiveConfig("win32"))
+ target_mode = TARG_WIN_MODE;
+ else if (project->isActiveConfig("macx"))
+ target_mode = TARG_MACX_MODE;
+ else
+ target_mode = TARG_UNIX_MODE;
init();
findLibraries();
if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE &&
t << "Libs: ";
QString pkgConfiglibDir;
QString pkgConfiglibName;
- if (Option::target_mode == Option::TARG_MACX_MODE && project->isActiveConfig("lib_bundle")) {
+ if (target_mode == TARG_MACX_MODE && project->isActiveConfig("lib_bundle")) {
pkgConfiglibDir = "-F${libdir}";
QString bundle;
if (!project->isEmpty("QMAKE_FRAMEWORK_BUNDLE_NAME"))
mutable QHash<ReplaceExtraCompilerCacheKey, QString> extraCompilerVariablesCache;
protected:
+ enum TARG_MODE { TARG_UNIX_MODE, TARG_MACX_MODE, TARG_WIN_MODE } target_mode;
+
QStringList createObjectList(const QStringList &sources);
//makefile style generator functions
#endif // QT_QMAKE_PARSER_ONLY
-bool
-MetaMakefileGenerator::modeForGenerator(const QString &gen, Option::TARG_MODE *target_mode)
-{
- if (gen == "UNIX") {
-#ifdef Q_OS_MAC
- *target_mode = Option::TARG_MACX_MODE;
-#else
- *target_mode = Option::TARG_UNIX_MODE;
-#endif
- } else if (gen == "MSVC.NET" || gen == "BMAKE" || gen == "MSBUILD") {
- *target_mode = Option::TARG_WIN_MODE;
- } else if (gen == "MINGW") {
- *target_mode = Option::TARG_WIN_MODE;
- } else if (gen == "PROJECTBUILDER" || gen == "XCODE") {
- *target_mode = Option::TARG_MACX_MODE;
- } else if (gen == "GBUILD") {
- *target_mode = Option::TARG_UNIX_MODE;
- } else {
- fprintf(stderr, "Unknown generator specified: %s\n", gen.toLatin1().constData());
- return false;
- }
- return true;
-}
QT_END_NAMESPACE
#ifndef METAMAKEFILE_H
#define METAMAKEFILE_H
-#include <option.h>
-
#include <qlist.h>
#include <qstring.h>
static MetaMakefileGenerator *createMetaGenerator(QMakeProject *proj, const QString &name, bool op=true, bool *success = 0);
static MakefileGenerator *createMakefileGenerator(QMakeProject *proj, bool noIO = false);
- static bool modeForGenerator(const QString &generator, Option::TARG_MODE *target_mode);
-
inline QMakeProject *projectFile() const { return project; }
virtual bool init() = 0;
} else {
stub = opt.mid(2);
}
- } else if(Option::target_mode == Option::TARG_MACX_MODE && opt.startsWith("-F")) {
+ } else if (target_mode == TARG_MACX_MODE && opt.startsWith("-F")) {
frameworkdirs.append(QMakeLocalFileName(opt.right(opt.length()-2)));
- } else if(Option::target_mode == Option::TARG_MACX_MODE && opt.startsWith("-framework")) {
+ } else if (target_mode == TARG_MACX_MODE && opt.startsWith("-framework")) {
if(opt.length() > 11) {
opt = opt.mid(11);
} else {
break;
}
}
- } else if(Option::target_mode == Option::TARG_MACX_MODE && opt.startsWith("-F")) {
+ } else if (target_mode == TARG_MACX_MODE && opt.startsWith("-F")) {
QMakeLocalFileName f(opt.right(opt.length()-2));
if(!frameworkdirs.contains(f))
frameworkdirs.append(f);
- } else if(Option::target_mode == Option::TARG_MACX_MODE && opt.startsWith("-framework")) {
+ } else if (target_mode == TARG_MACX_MODE && opt.startsWith("-framework")) {
if(opt.length() > 11)
opt = opt.mid(11);
else
QString arch("default");
QString opt = l.at(lit).trimmed();
if(opt.startsWith("-")) {
- if (Option::target_mode == Option::TARG_MACX_MODE && opt.startsWith("-Xarch")) {
+ if (target_mode == TARG_MACX_MODE && opt.startsWith("-Xarch")) {
if (opt.length() > 7) {
arch = opt.mid(7);
opt = l.at(++lit);
}
if(opt.startsWith("-L") ||
- (Option::target_mode == Option::TARG_MACX_MODE && opt.startsWith("-F"))) {
+ (target_mode == TARG_MACX_MODE && opt.startsWith("-F"))) {
if(!lflags[arch].contains(opt))
lflags[arch].append(opt);
} else if(opt.startsWith("-l") || opt == "-pthread") {
if (lflags[arch].contains(opt))
lflags[arch].removeAll(opt);
lflags[arch].append(opt);
- } else if(Option::target_mode == Option::TARG_MACX_MODE && opt.startsWith("-framework")) {
+ } else if (target_mode == TARG_MACX_MODE && opt.startsWith("-framework")) {
if(opt.length() > 11)
opt = opt.mid(11);
else {
opt = l.at(++lit);
- if (Option::target_mode == Option::TARG_MACX_MODE && opt.startsWith("-Xarch"))
+ if (target_mode == TARG_MACX_MODE && opt.startsWith("-Xarch"))
opt = l.at(++lit); // The user has done the right thing and prefixed each part
}
bool found = false;
uninst.append("-$(DEL_FILE) \"" + dst_targ + "\"");
if(!links.isEmpty()) {
for(int i = 0; i < links.size(); ++i) {
- if(Option::target_mode == Option::TARG_UNIX_MODE ||
- Option::target_mode == Option::TARG_MACX_MODE) {
+ if (target_mode == TARG_UNIX_MODE || target_mode == TARG_MACX_MODE) {
QString link = Option::fixPathToTargetOS(destdir + links[i], false);
int lslash = link.lastIndexOf(Option::dir_sep);
if(lslash != -1)
QString Option::user_template_prefix;
QStringList Option::shellPath;
Option::HOST_MODE Option::host_mode = Option::HOST_UNKNOWN_MODE;
-Option::TARG_MODE Option::target_mode = Option::TARG_UNKNOWN_MODE;
//QMAKE_*_PROPERTY stuff
QStringList Option::prop::properties;
}
#endif
}
- } else if (Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT) {
-#if defined(Q_OS_MAC)
- Option::target_mode = Option::TARG_MACX_MODE;
-#elif defined(Q_OS_UNIX)
- Option::target_mode = Option::TARG_UNIX_MODE;
-#else
- Option::target_mode = Option::TARG_WIN_MODE;
-#endif
}
//defaults for globals
static QStringList before_user_vars, after_user_vars;
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 QString user_template, user_template_prefix;
static QStringList shellPath;
1) features/(unix|win32|macx)/
2) features/
*/
-QStringList qmake_feature_paths(QMakeProperty *prop, bool host_build)
+QStringList QMakeProject::qmakeFeaturePaths()
{
const QString mkspecs_concat = QLatin1String("/mkspecs");
const QString base_concat = QLatin1String("/features");
QStringList concat;
- {
- switch(Option::target_mode) {
- case Option::TARG_MACX_MODE: //also a unix
- concat << base_concat + QLatin1String("/mac");
- concat << base_concat + QLatin1String("/macx");
- concat << base_concat + QLatin1String("/unix");
- break;
- default: // Can't happen, just make the compiler shut up
- case Option::TARG_UNIX_MODE:
- concat << base_concat + QLatin1String("/unix");
- break;
- case Option::TARG_WIN_MODE:
- concat << base_concat + QLatin1String("/win32");
- break;
- }
- concat << base_concat;
- }
+ foreach (const QString &sfx, values("QMAKE_PLATFORM"))
+ concat << base_concat + QLatin1Char('/') + sfx;
+ concat << base_concat;
QStringList feature_roots = splitPathList(QString::fromLocal8Bit(qgetenv("QMAKEFEATURES")));
feature_roots += cached_qmakefeatures;
return false;
}
doProjectInclude("spec_post", IncludeFlagFeature, vars);
- validateModes();
+ // The spec extends the feature search path, so invalidate the cache.
+ invalidateFeatureRoots();
if (!conffile.isEmpty()) {
debug_msg(1, "Project config file: reading %s", conffile.toLatin1().constData());
return true;
}
-void QMakeProject::validateModes()
-{
- if (Option::target_mode == Option::TARG_UNKNOWN_MODE) {
- Option::TARG_MODE target_mode;
- const QStringList &gen = 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::modeForGenerator(gen.first(), &target_mode)) {
- const QStringList &tgt = 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;
- }
- }
- }
-}
-
void
QMakeProject::resolveSpec(QString *spec, const QString &qmakespec)
{
else if(x == "false")
return false;
- if (x == "unix") {
- validateModes();
- return Option::target_mode == Option::TARG_UNIX_MODE
- || Option::target_mode == Option::TARG_MACX_MODE;
- } else if (x == "macx" || x == "mac") {
- validateModes();
- return Option::target_mode == Option::TARG_MACX_MODE;
- } else if (x == "win32") {
- validateModes();
- return Option::target_mode == Option::TARG_WIN_MODE;
- }
-
if (x == "host_build")
return host_build;
qmakeAddCacheClear(qmakeDeleteCacheClear<QStringList>, (void**)&feature_roots);
}
if (feature_roots->isEmpty())
- *feature_roots = qmake_feature_paths(prop, host_build);
+ *feature_roots = qmakeFeaturePaths();
debug_msg(2, "Looking for feature '%s' in (%s)", file.toLatin1().constData(),
feature_roots->join("::").toLatin1().constData());
int start_root = 0;
void init(QMakeProperty *);
void cleanup();
QStringList &values(const QString &v, QHash<QString, QStringList> &place);
- void validateModes();
void resolveSpec(QString *spec, const QString &qmakespec);
+ QStringList qmakeFeaturePaths();
public:
QMakeProject(QMakeProperty *p = 0) { init(p); }