Commit 5eb220b5 authored by Oswald Buddenhagen's avatar Oswald Buddenhagen
Browse files

sync host & target mode determination with qmake

they are dynamically determined from the qmakespec now.

Task-number: QTCREATORBUG-3512
parent 08deb390
......@@ -96,7 +96,9 @@ ProFileOption::ProFileOption()
#endif
qmakespec = QString::fromLocal8Bit(qgetenv("QMAKESPEC").data());
setHostTargetMode();
host_mode = HOST_UNKNOWN_MODE;
target_mode = TARG_UNKNOWN_MODE;
#ifdef PROEVALUATOR_THREAD_SAFE
base_inProgress = false;
#endif
......@@ -111,8 +113,6 @@ void ProFileOption::setCommandLineArguments(const QStringList &args)
QStringList _precmds, _preconfigs, _postcmds, _postconfigs;
bool after = false;
setHostTargetMode();
bool isConf = false;
foreach (const QString &arg, args) {
if (isConf) {
......@@ -127,10 +127,13 @@ void ProFileOption::setCommandLineArguments(const QStringList &args)
} else if (arg == QLatin1String("-config")) {
isConf = true;
} else if (arg == QLatin1String("-win32")) {
host_mode = HOST_WIN_MODE;
target_mode = TARG_WIN_MODE;
} else if (arg == QLatin1String("-unix")) {
host_mode = HOST_UNIX_MODE;
target_mode = TARG_UNIX_MODE;
} else if (arg == QLatin1String("-macx")) {
host_mode = HOST_MACX_MODE;
target_mode = TARG_MACX_MODE;
}
} else if (arg.contains(QLatin1Char('='))) {
......@@ -147,19 +150,18 @@ void ProFileOption::setCommandLineArguments(const QStringList &args)
if (!_postconfigs.isEmpty())
_postcmds << (fL1S("CONFIG += ") + _postconfigs.join(fL1S(" ")));
postcmds = _postcmds.join(fL1S("\n"));
if (host_mode != HOST_UNKNOWN_MODE)
applyHostMode();
}
void ProFileOption::setHostTargetMode()
void ProFileOption::applyHostMode()
{
#if defined(Q_OS_WIN32)
target_mode = TARG_WIN_MODE;
#elif defined(Q_OS_MAC)
target_mode = TARG_MACX_MODE;
#elif defined(Q_OS_QNX6)
target_mode = TARG_QNX6_MODE;
#else
target_mode = TARG_UNIX_MODE;
#endif
if (host_mode == HOST_WIN_MODE) {
dir_sep = fL1S("\\");
} else {
dir_sep = fL1S("/");
}
}
///////////////////////////////////////////////////////////////////////
......@@ -249,6 +251,9 @@ public:
VisitReturn evaluateBoolFunction(const FunctionDef &func, const QList<ProStringList> &argumentsList,
const ProString &function);
bool modesForGenerator(const QString &gen,
ProFileOption::HOST_MODE *host_mode, ProFileOption::TARG_MODE *target_mode) const;
void validateModes() const;
QStringList qmakeMkspecPaths() const;
QStringList qmakeFeaturePaths() const;
......@@ -314,10 +319,9 @@ static struct {
QString strfalse;
QString strunix;
QString strmacx;
QString strqnx6;
QString strmac9;
QString strmac;
QString strwin32;
QString strsymbian;
ProString strCONFIG;
ProString strARGS;
QString strDot;
......@@ -344,10 +348,9 @@ void ProFileEvaluator::Private::initStatics()
statics.strfalse = QLatin1String("false");
statics.strunix = QLatin1String("unix");
statics.strmacx = QLatin1String("macx");
statics.strqnx6 = QLatin1String("qnx6");
statics.strmac9 = QLatin1String("mac9");
statics.strmac = QLatin1String("mac");
statics.strwin32 = QLatin1String("win32");
statics.strsymbian = QLatin1String("symbian");
statics.strCONFIG = ProString("CONFIG");
statics.strARGS = ProString("ARGS");
statics.strDot = QLatin1String(".");
......@@ -1398,25 +1401,23 @@ QStringList ProFileEvaluator::Private::qmakeFeaturePaths() const
QString mkspecs_concat = QLatin1String("/mkspecs");
QString features_concat = QLatin1String("/features");
QStringList concat;
validateModes();
switch (m_option->target_mode) {
case ProFileOption::TARG_MACX_MODE:
concat << QLatin1String("/features/mac");
concat << QLatin1String("/features/macx");
concat << QLatin1String("/features/unix");
break;
default: // Can't happen, just make the compiler shut up
case ProFileOption::TARG_UNIX_MODE:
concat << QLatin1String("/features/unix");
break;
case ProFileOption::TARG_WIN_MODE:
concat << QLatin1String("/features/win32");
break;
case ProFileOption::TARG_MAC9_MODE:
concat << QLatin1String("/features/mac");
concat << QLatin1String("/features/mac9");
break;
case ProFileOption::TARG_QNX6_MODE:
concat << QLatin1String("/features/qnx6");
concat << QLatin1String("/features/unix");
case ProFileOption::TARG_SYMBIAN_MODE:
concat << QLatin1String("/features/symbian");
break;
}
concat << features_concat;
......@@ -1793,6 +1794,88 @@ ProStringList ProFileEvaluator::Private::expandVariableReferences(
return ret;
}
bool ProFileEvaluator::Private::modesForGenerator(const QString &gen,
ProFileOption::HOST_MODE *host_mode, ProFileOption::TARG_MODE *target_mode) const
{
if (gen == fL1S("UNIX")) {
#ifdef Q_OS_MAC
*host_mode = ProFileOption::HOST_MACX_MODE;
*target_mode = ProFileOption::TARG_MACX_MODE;
#else
*host_mode = ProFileOption::HOST_UNIX_MODE;
*target_mode = ProFileOption::TARG_UNIX_MODE;
#endif
} else if (gen == fL1S("MSVC.NET") || gen == fL1S("BMAKE") || gen == fL1S("MSBUILD")) {
*host_mode = ProFileOption::HOST_WIN_MODE;
*target_mode = ProFileOption::TARG_WIN_MODE;
} else if (gen == fL1S("MINGW")) {
#if defined(Q_OS_MAC)
*host_mode = ProFileOption::HOST_MACX_MODE;
#elif defined(Q_OS_UNIX)
*host_mode = ProFileOption::HOST_UNIX_MODE;
#else
*host_mode = ProFileOption::HOST_WIN_MODE;
#endif
*target_mode = ProFileOption::TARG_WIN_MODE;
} else if (gen == fL1S("PROJECTBUILDER") || gen == fL1S("XCODE")) {
*host_mode = ProFileOption::HOST_MACX_MODE;
*target_mode = ProFileOption::TARG_MACX_MODE;
} else if (gen == fL1S("SYMBIAN_ABLD") || gen == fL1S("SYMBIAN_SBSV2")
|| gen == fL1S("SYMBIAN_UNIX") || gen == fL1S("SYMBIAN_MINGW")) {
#if defined(Q_OS_MAC)
*host_mode = ProFileOption::HOST_MACX_MODE;
#elif defined(Q_OS_UNIX)
*host_mode = ProFileOption::HOST_UNIX_MODE;
#else
*host_mode = ProFileOption::HOST_WIN_MODE;
#endif
*target_mode = ProFileOption::TARG_SYMBIAN_MODE;
} else {
evalError(fL1S("Unknown generator specified: %1").arg(gen));
return false;
}
return true;
}
void ProFileEvaluator::Private::validateModes() const
{
if (m_option->host_mode == ProFileOption::HOST_UNKNOWN_MODE
|| m_option->target_mode == ProFileOption::TARG_UNKNOWN_MODE) {
const QHash<ProString, ProStringList> &vals =
m_option->base_valuemap.isEmpty() ? m_valuemapStack[0] : m_option->base_valuemap;
ProFileOption::HOST_MODE host_mode;
ProFileOption::TARG_MODE target_mode;
const ProStringList &gen = vals.value(ProString("MAKEFILE_GENERATOR"));
if (gen.isEmpty()) {
evalError(fL1S("Using OS scope before setting MAKEFILE_GENERATOR"));
} else if (modesForGenerator(gen.at(0).toQString(), &host_mode, &target_mode)) {
if (m_option->host_mode == ProFileOption::HOST_UNKNOWN_MODE) {
m_option->host_mode = host_mode;
m_option->applyHostMode();
}
if (m_option->target_mode == ProFileOption::TARG_UNKNOWN_MODE) {
const ProStringList &tgt = vals.value(ProString("TARGET_PLATFORM"));
if (!tgt.isEmpty()) {
const QString &os = tgt.at(0).toQString();
if (os == statics.strunix)
m_option->target_mode = ProFileOption::TARG_UNIX_MODE;
else if (os == statics.strmacx)
m_option->target_mode = ProFileOption::TARG_MACX_MODE;
else if (os == statics.strsymbian)
m_option->target_mode = ProFileOption::TARG_SYMBIAN_MODE;
else if (os == statics.strwin32)
m_option->target_mode = ProFileOption::TARG_WIN_MODE;
else
evalError(fL1S("Unknown target platform specified: %1").arg(os));
} else {
m_option->target_mode = target_mode;
}
}
}
}
}
bool ProFileEvaluator::Private::isActiveConfig(const QString &config, bool regex)
{
// magic types for easy flipping
......@@ -1801,30 +1884,28 @@ bool ProFileEvaluator::Private::isActiveConfig(const QString &config, bool regex
if (config == statics.strfalse)
return false;
// mkspecs
if ((m_option->target_mode == m_option->TARG_MACX_MODE
|| m_option->target_mode == m_option->TARG_QNX6_MODE
|| m_option->target_mode == m_option->TARG_UNIX_MODE)
&& config == statics.strunix)
return true;
if (m_option->target_mode == m_option->TARG_MACX_MODE && config == statics.strmacx)
return true;
if (m_option->target_mode == m_option->TARG_QNX6_MODE && config == statics.strqnx6)
return true;
if (m_option->target_mode == m_option->TARG_MAC9_MODE && config == statics.strmac9)
return true;
if ((m_option->target_mode == m_option->TARG_MAC9_MODE
|| m_option->target_mode == m_option->TARG_MACX_MODE)
&& config == statics.strmac)
return true;
if (m_option->target_mode == m_option->TARG_WIN_MODE && config == statics.strwin32)
return true;
if (config == statics.strunix) {
validateModes();
return m_option->target_mode == ProFileOption::TARG_UNIX_MODE
|| m_option->target_mode == ProFileOption::TARG_MACX_MODE
|| m_option->target_mode == ProFileOption::TARG_SYMBIAN_MODE;
} else if (config == statics.strmacx || config == statics.strmac) {
validateModes();
return m_option->target_mode == ProFileOption::TARG_MACX_MODE;
} else if (config == statics.strsymbian) {
validateModes();
return m_option->target_mode == ProFileOption::TARG_SYMBIAN_MODE;
} else if (config == statics.strwin32) {
validateModes();
return m_option->target_mode == ProFileOption::TARG_WIN_MODE;
}
if (regex && (config.contains(QLatin1Char('*')) || config.contains(QLatin1Char('?')))) {
QString cfg = config;
cfg.detach(); // Keep m_tmp out of QRegExp's cache
QRegExp re(cfg, Qt::CaseSensitive, QRegExp::Wildcard);
// mkspecs
if (re.exactMatch(m_option->qmakespec_name))
return true;
......@@ -2926,6 +3007,7 @@ ProStringList ProFileEvaluator::Private::values(const ProString &variableName) c
ret = currentDirectory();
break;
case V_DIR_SEPARATOR:
validateModes();
ret = m_option->dir_sep;
break;
case V_DIRLIST_SEPARATOR:
......
......@@ -171,8 +171,6 @@ struct ProFileOption
QHash<QString, QString> properties;
QString sysroot;
enum TARG_MODE { TARG_UNIX_MODE, TARG_WIN_MODE, TARG_MACX_MODE, TARG_MAC9_MODE, TARG_QNX6_MODE };
TARG_MODE target_mode;
//QString pro_ext;
//QString res_ext;
......@@ -181,15 +179,21 @@ struct ProFileOption
void setCommandLineArguments(const QStringList &args);
private:
void setHostTargetMode();
friend class ProFileEvaluator;
friend class ProFileEvaluator::Private;
void applyHostMode();
QHash<ProString, ProStringList> base_valuemap; // Cached results of qmake.conf, .qmake.cache & default_pre.prf
ProFileEvaluator::FunctionDefs base_functions;
QStringList feature_roots;
QString qmakespec_name;
QString precmds, postcmds;
enum HOST_MODE { HOST_UNKNOWN_MODE, HOST_UNIX_MODE, HOST_WIN_MODE, HOST_MACX_MODE };
HOST_MODE host_mode;
enum TARG_MODE { TARG_UNKNOWN_MODE, TARG_UNIX_MODE, TARG_WIN_MODE, TARG_MACX_MODE,
TARG_SYMBIAN_MODE };
TARG_MODE target_mode;
#ifdef PROEVALUATOR_THREAD_SAFE
QMutex mutex;
QWaitCondition cond;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment