revamp handling of qmake target mode
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>
This commit is contained in:
parent
777fa561ab
commit
4753958db7
31
mkspecs/features/spec_post.prf
Normal file
31
mkspecs/features/spec_post.prf
Normal file
@ -0,0 +1,31 @@
|
||||
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
|
@ -300,6 +300,12 @@ MakefileGenerator::setProjectFile(QMakeProject *p)
|
||||
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 &&
|
||||
@ -3253,7 +3259,7 @@ MakefileGenerator::writePkgConfigFile()
|
||||
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"))
|
||||
|
@ -91,6 +91,8 @@ class MakefileGenerator : protected QMakeSourceFileInfo
|
||||
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
|
||||
|
@ -514,28 +514,5 @@ MetaMakefileGenerator::createMetaGenerator(QMakeProject *proj, const QString &na
|
||||
|
||||
#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
|
||||
|
@ -42,8 +42,6 @@
|
||||
#ifndef METAMAKEFILE_H
|
||||
#define METAMAKEFILE_H
|
||||
|
||||
#include <option.h>
|
||||
|
||||
#include <qlist.h>
|
||||
#include <qstring.h>
|
||||
|
||||
@ -67,8 +65,6 @@ 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 modeForGenerator(const QString &generator, Option::TARG_MODE *target_mode);
|
||||
|
||||
inline QMakeProject *projectFile() const { return project; }
|
||||
|
||||
virtual bool init() = 0;
|
||||
|
@ -491,9 +491,9 @@ UnixMakefileGenerator::findLibraries()
|
||||
} 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 {
|
||||
@ -612,11 +612,11 @@ UnixMakefileGenerator::processPrlFiles()
|
||||
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
|
||||
@ -655,7 +655,7 @@ UnixMakefileGenerator::processPrlFiles()
|
||||
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);
|
||||
@ -663,7 +663,7 @@ UnixMakefileGenerator::processPrlFiles()
|
||||
}
|
||||
|
||||
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") {
|
||||
@ -671,12 +671,12 @@ UnixMakefileGenerator::processPrlFiles()
|
||||
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;
|
||||
@ -838,8 +838,7 @@ UnixMakefileGenerator::defaultInstall(const QString &t)
|
||||
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)
|
||||
|
@ -93,7 +93,6 @@ QString Option::user_template;
|
||||
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;
|
||||
@ -557,14 +556,6 @@ Option::init(int argc, char **argv)
|
||||
}
|
||||
#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
|
||||
|
@ -173,8 +173,6 @@ struct Option
|
||||
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;
|
||||
|
||||
|
@ -565,28 +565,14 @@ static void qmake_error_msg(const QString &msg)
|
||||
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;
|
||||
@ -1489,7 +1475,8 @@ QMakeProject::read(uchar cmd)
|
||||
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());
|
||||
@ -1607,34 +1594,6 @@ QMakeProject::read(uchar cmd)
|
||||
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)
|
||||
{
|
||||
@ -1677,18 +1636,6 @@ QMakeProject::isActiveConfig(const QString &x, bool regex, QHash<QString, QStrin
|
||||
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;
|
||||
|
||||
@ -1758,7 +1705,7 @@ QMakeProject::doProjectInclude(QString file, uchar flags, QHash<QString, QString
|
||||
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;
|
||||
|
@ -114,8 +114,8 @@ class QMakeProject
|
||||
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); }
|
||||
|
Loading…
Reference in New Issue
Block a user