forked from qt-creator/qt-creator
sync host & target mode determination with qmake
they are dynamically determined from the qmakespec now. Task-number: QTCREATORBUG-3512
This commit is contained in:
@@ -96,7 +96,9 @@ ProFileOption::ProFileOption()
|
|||||||
#endif
|
#endif
|
||||||
qmakespec = QString::fromLocal8Bit(qgetenv("QMAKESPEC").data());
|
qmakespec = QString::fromLocal8Bit(qgetenv("QMAKESPEC").data());
|
||||||
|
|
||||||
setHostTargetMode();
|
host_mode = HOST_UNKNOWN_MODE;
|
||||||
|
target_mode = TARG_UNKNOWN_MODE;
|
||||||
|
|
||||||
#ifdef PROEVALUATOR_THREAD_SAFE
|
#ifdef PROEVALUATOR_THREAD_SAFE
|
||||||
base_inProgress = false;
|
base_inProgress = false;
|
||||||
#endif
|
#endif
|
||||||
@@ -111,8 +113,6 @@ void ProFileOption::setCommandLineArguments(const QStringList &args)
|
|||||||
QStringList _precmds, _preconfigs, _postcmds, _postconfigs;
|
QStringList _precmds, _preconfigs, _postcmds, _postconfigs;
|
||||||
bool after = false;
|
bool after = false;
|
||||||
|
|
||||||
setHostTargetMode();
|
|
||||||
|
|
||||||
bool isConf = false;
|
bool isConf = false;
|
||||||
foreach (const QString &arg, args) {
|
foreach (const QString &arg, args) {
|
||||||
if (isConf) {
|
if (isConf) {
|
||||||
@@ -127,10 +127,13 @@ void ProFileOption::setCommandLineArguments(const QStringList &args)
|
|||||||
} else if (arg == QLatin1String("-config")) {
|
} else if (arg == QLatin1String("-config")) {
|
||||||
isConf = true;
|
isConf = true;
|
||||||
} else if (arg == QLatin1String("-win32")) {
|
} else if (arg == QLatin1String("-win32")) {
|
||||||
|
host_mode = HOST_WIN_MODE;
|
||||||
target_mode = TARG_WIN_MODE;
|
target_mode = TARG_WIN_MODE;
|
||||||
} else if (arg == QLatin1String("-unix")) {
|
} else if (arg == QLatin1String("-unix")) {
|
||||||
|
host_mode = HOST_UNIX_MODE;
|
||||||
target_mode = TARG_UNIX_MODE;
|
target_mode = TARG_UNIX_MODE;
|
||||||
} else if (arg == QLatin1String("-macx")) {
|
} else if (arg == QLatin1String("-macx")) {
|
||||||
|
host_mode = HOST_MACX_MODE;
|
||||||
target_mode = TARG_MACX_MODE;
|
target_mode = TARG_MACX_MODE;
|
||||||
}
|
}
|
||||||
} else if (arg.contains(QLatin1Char('='))) {
|
} else if (arg.contains(QLatin1Char('='))) {
|
||||||
@@ -147,19 +150,18 @@ void ProFileOption::setCommandLineArguments(const QStringList &args)
|
|||||||
if (!_postconfigs.isEmpty())
|
if (!_postconfigs.isEmpty())
|
||||||
_postcmds << (fL1S("CONFIG += ") + _postconfigs.join(fL1S(" ")));
|
_postcmds << (fL1S("CONFIG += ") + _postconfigs.join(fL1S(" ")));
|
||||||
postcmds = _postcmds.join(fL1S("\n"));
|
postcmds = _postcmds.join(fL1S("\n"));
|
||||||
|
|
||||||
|
if (host_mode != HOST_UNKNOWN_MODE)
|
||||||
|
applyHostMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProFileOption::setHostTargetMode()
|
void ProFileOption::applyHostMode()
|
||||||
{
|
{
|
||||||
#if defined(Q_OS_WIN32)
|
if (host_mode == HOST_WIN_MODE) {
|
||||||
target_mode = TARG_WIN_MODE;
|
dir_sep = fL1S("\\");
|
||||||
#elif defined(Q_OS_MAC)
|
} else {
|
||||||
target_mode = TARG_MACX_MODE;
|
dir_sep = fL1S("/");
|
||||||
#elif defined(Q_OS_QNX6)
|
}
|
||||||
target_mode = TARG_QNX6_MODE;
|
|
||||||
#else
|
|
||||||
target_mode = TARG_UNIX_MODE;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
@@ -249,6 +251,9 @@ public:
|
|||||||
VisitReturn evaluateBoolFunction(const FunctionDef &func, const QList<ProStringList> &argumentsList,
|
VisitReturn evaluateBoolFunction(const FunctionDef &func, const QList<ProStringList> &argumentsList,
|
||||||
const ProString &function);
|
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 qmakeMkspecPaths() const;
|
||||||
QStringList qmakeFeaturePaths() const;
|
QStringList qmakeFeaturePaths() const;
|
||||||
|
|
||||||
@@ -314,10 +319,9 @@ static struct {
|
|||||||
QString strfalse;
|
QString strfalse;
|
||||||
QString strunix;
|
QString strunix;
|
||||||
QString strmacx;
|
QString strmacx;
|
||||||
QString strqnx6;
|
|
||||||
QString strmac9;
|
|
||||||
QString strmac;
|
QString strmac;
|
||||||
QString strwin32;
|
QString strwin32;
|
||||||
|
QString strsymbian;
|
||||||
ProString strCONFIG;
|
ProString strCONFIG;
|
||||||
ProString strARGS;
|
ProString strARGS;
|
||||||
QString strDot;
|
QString strDot;
|
||||||
@@ -344,10 +348,9 @@ void ProFileEvaluator::Private::initStatics()
|
|||||||
statics.strfalse = QLatin1String("false");
|
statics.strfalse = QLatin1String("false");
|
||||||
statics.strunix = QLatin1String("unix");
|
statics.strunix = QLatin1String("unix");
|
||||||
statics.strmacx = QLatin1String("macx");
|
statics.strmacx = QLatin1String("macx");
|
||||||
statics.strqnx6 = QLatin1String("qnx6");
|
|
||||||
statics.strmac9 = QLatin1String("mac9");
|
|
||||||
statics.strmac = QLatin1String("mac");
|
statics.strmac = QLatin1String("mac");
|
||||||
statics.strwin32 = QLatin1String("win32");
|
statics.strwin32 = QLatin1String("win32");
|
||||||
|
statics.strsymbian = QLatin1String("symbian");
|
||||||
statics.strCONFIG = ProString("CONFIG");
|
statics.strCONFIG = ProString("CONFIG");
|
||||||
statics.strARGS = ProString("ARGS");
|
statics.strARGS = ProString("ARGS");
|
||||||
statics.strDot = QLatin1String(".");
|
statics.strDot = QLatin1String(".");
|
||||||
@@ -1398,25 +1401,23 @@ QStringList ProFileEvaluator::Private::qmakeFeaturePaths() const
|
|||||||
QString mkspecs_concat = QLatin1String("/mkspecs");
|
QString mkspecs_concat = QLatin1String("/mkspecs");
|
||||||
QString features_concat = QLatin1String("/features");
|
QString features_concat = QLatin1String("/features");
|
||||||
QStringList concat;
|
QStringList concat;
|
||||||
|
|
||||||
|
validateModes();
|
||||||
switch (m_option->target_mode) {
|
switch (m_option->target_mode) {
|
||||||
case ProFileOption::TARG_MACX_MODE:
|
case ProFileOption::TARG_MACX_MODE:
|
||||||
concat << QLatin1String("/features/mac");
|
concat << QLatin1String("/features/mac");
|
||||||
concat << QLatin1String("/features/macx");
|
concat << QLatin1String("/features/macx");
|
||||||
concat << QLatin1String("/features/unix");
|
concat << QLatin1String("/features/unix");
|
||||||
break;
|
break;
|
||||||
|
default: // Can't happen, just make the compiler shut up
|
||||||
case ProFileOption::TARG_UNIX_MODE:
|
case ProFileOption::TARG_UNIX_MODE:
|
||||||
concat << QLatin1String("/features/unix");
|
concat << QLatin1String("/features/unix");
|
||||||
break;
|
break;
|
||||||
case ProFileOption::TARG_WIN_MODE:
|
case ProFileOption::TARG_WIN_MODE:
|
||||||
concat << QLatin1String("/features/win32");
|
concat << QLatin1String("/features/win32");
|
||||||
break;
|
break;
|
||||||
case ProFileOption::TARG_MAC9_MODE:
|
case ProFileOption::TARG_SYMBIAN_MODE:
|
||||||
concat << QLatin1String("/features/mac");
|
concat << QLatin1String("/features/symbian");
|
||||||
concat << QLatin1String("/features/mac9");
|
|
||||||
break;
|
|
||||||
case ProFileOption::TARG_QNX6_MODE:
|
|
||||||
concat << QLatin1String("/features/qnx6");
|
|
||||||
concat << QLatin1String("/features/unix");
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
concat << features_concat;
|
concat << features_concat;
|
||||||
@@ -1793,6 +1794,88 @@ ProStringList ProFileEvaluator::Private::expandVariableReferences(
|
|||||||
return ret;
|
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)
|
bool ProFileEvaluator::Private::isActiveConfig(const QString &config, bool regex)
|
||||||
{
|
{
|
||||||
// magic types for easy flipping
|
// magic types for easy flipping
|
||||||
@@ -1801,30 +1884,28 @@ bool ProFileEvaluator::Private::isActiveConfig(const QString &config, bool regex
|
|||||||
if (config == statics.strfalse)
|
if (config == statics.strfalse)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// mkspecs
|
if (config == statics.strunix) {
|
||||||
if ((m_option->target_mode == m_option->TARG_MACX_MODE
|
validateModes();
|
||||||
|| m_option->target_mode == m_option->TARG_QNX6_MODE
|
return m_option->target_mode == ProFileOption::TARG_UNIX_MODE
|
||||||
|| m_option->target_mode == m_option->TARG_UNIX_MODE)
|
|| m_option->target_mode == ProFileOption::TARG_MACX_MODE
|
||||||
&& config == statics.strunix)
|
|| m_option->target_mode == ProFileOption::TARG_SYMBIAN_MODE;
|
||||||
return true;
|
} else if (config == statics.strmacx || config == statics.strmac) {
|
||||||
if (m_option->target_mode == m_option->TARG_MACX_MODE && config == statics.strmacx)
|
validateModes();
|
||||||
return true;
|
return m_option->target_mode == ProFileOption::TARG_MACX_MODE;
|
||||||
if (m_option->target_mode == m_option->TARG_QNX6_MODE && config == statics.strqnx6)
|
} else if (config == statics.strsymbian) {
|
||||||
return true;
|
validateModes();
|
||||||
if (m_option->target_mode == m_option->TARG_MAC9_MODE && config == statics.strmac9)
|
return m_option->target_mode == ProFileOption::TARG_SYMBIAN_MODE;
|
||||||
return true;
|
} else if (config == statics.strwin32) {
|
||||||
if ((m_option->target_mode == m_option->TARG_MAC9_MODE
|
validateModes();
|
||||||
|| m_option->target_mode == m_option->TARG_MACX_MODE)
|
return m_option->target_mode == ProFileOption::TARG_WIN_MODE;
|
||||||
&& config == statics.strmac)
|
}
|
||||||
return true;
|
|
||||||
if (m_option->target_mode == m_option->TARG_WIN_MODE && config == statics.strwin32)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (regex && (config.contains(QLatin1Char('*')) || config.contains(QLatin1Char('?')))) {
|
if (regex && (config.contains(QLatin1Char('*')) || config.contains(QLatin1Char('?')))) {
|
||||||
QString cfg = config;
|
QString cfg = config;
|
||||||
cfg.detach(); // Keep m_tmp out of QRegExp's cache
|
cfg.detach(); // Keep m_tmp out of QRegExp's cache
|
||||||
QRegExp re(cfg, Qt::CaseSensitive, QRegExp::Wildcard);
|
QRegExp re(cfg, Qt::CaseSensitive, QRegExp::Wildcard);
|
||||||
|
|
||||||
|
// mkspecs
|
||||||
if (re.exactMatch(m_option->qmakespec_name))
|
if (re.exactMatch(m_option->qmakespec_name))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -2926,6 +3007,7 @@ ProStringList ProFileEvaluator::Private::values(const ProString &variableName) c
|
|||||||
ret = currentDirectory();
|
ret = currentDirectory();
|
||||||
break;
|
break;
|
||||||
case V_DIR_SEPARATOR:
|
case V_DIR_SEPARATOR:
|
||||||
|
validateModes();
|
||||||
ret = m_option->dir_sep;
|
ret = m_option->dir_sep;
|
||||||
break;
|
break;
|
||||||
case V_DIRLIST_SEPARATOR:
|
case V_DIRLIST_SEPARATOR:
|
||||||
|
|||||||
@@ -171,8 +171,6 @@ struct ProFileOption
|
|||||||
QHash<QString, QString> properties;
|
QHash<QString, QString> properties;
|
||||||
QString sysroot;
|
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 pro_ext;
|
||||||
//QString res_ext;
|
//QString res_ext;
|
||||||
|
|
||||||
@@ -181,15 +179,21 @@ struct ProFileOption
|
|||||||
void setCommandLineArguments(const QStringList &args);
|
void setCommandLineArguments(const QStringList &args);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setHostTargetMode();
|
|
||||||
|
|
||||||
friend class ProFileEvaluator;
|
friend class ProFileEvaluator;
|
||||||
friend class ProFileEvaluator::Private;
|
friend class ProFileEvaluator::Private;
|
||||||
|
|
||||||
|
void applyHostMode();
|
||||||
|
|
||||||
QHash<ProString, ProStringList> base_valuemap; // Cached results of qmake.conf, .qmake.cache & default_pre.prf
|
QHash<ProString, ProStringList> base_valuemap; // Cached results of qmake.conf, .qmake.cache & default_pre.prf
|
||||||
ProFileEvaluator::FunctionDefs base_functions;
|
ProFileEvaluator::FunctionDefs base_functions;
|
||||||
QStringList feature_roots;
|
QStringList feature_roots;
|
||||||
QString qmakespec_name;
|
QString qmakespec_name;
|
||||||
QString precmds, postcmds;
|
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
|
#ifdef PROEVALUATOR_THREAD_SAFE
|
||||||
QMutex mutex;
|
QMutex mutex;
|
||||||
QWaitCondition cond;
|
QWaitCondition cond;
|
||||||
|
|||||||
Reference in New Issue
Block a user