forked from qt-creator/qt-creator
use environment from build configuration in the project evaluator
Task-number: QTCREATORBUG-2866
This commit is contained in:
@@ -192,6 +192,8 @@ void Qt4BuildConfiguration::ctor()
|
|||||||
{
|
{
|
||||||
connect(this, SIGNAL(environmentChanged()),
|
connect(this, SIGNAL(environmentChanged()),
|
||||||
this, SLOT(emitBuildDirectoryChanged()));
|
this, SLOT(emitBuildDirectoryChanged()));
|
||||||
|
connect(this, SIGNAL(environmentChanged()),
|
||||||
|
this, SLOT(emitProFileEvaluteNeeded()));
|
||||||
|
|
||||||
QtVersionManager *vm = QtVersionManager::instance();
|
QtVersionManager *vm = QtVersionManager::instance();
|
||||||
connect(vm, SIGNAL(qtVersionsChanged(QList<int>)),
|
connect(vm, SIGNAL(qtVersionsChanged(QList<int>)),
|
||||||
|
|||||||
@@ -83,7 +83,6 @@ public:
|
|||||||
void setQMakeBuildConfiguration(QtVersion::QmakeBuildConfigs config);
|
void setQMakeBuildConfiguration(QtVersion::QmakeBuildConfigs config);
|
||||||
|
|
||||||
/// \internal for qmakestep
|
/// \internal for qmakestep
|
||||||
void emitProFileEvaluteNeeded();
|
|
||||||
// used by qmake step to notify that the qmake args have changed
|
// used by qmake step to notify that the qmake args have changed
|
||||||
// not really nice, the build configuration should save the arguments
|
// not really nice, the build configuration should save the arguments
|
||||||
// since they are needed for reevaluation
|
// since they are needed for reevaluation
|
||||||
@@ -127,6 +126,7 @@ public:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void importFromBuildDirectory();
|
void importFromBuildDirectory();
|
||||||
|
void emitProFileEvaluteNeeded();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
/// emitted if the qt version changes (either directly, or because the default qt version changed
|
/// emitted if the qt version changes (either directly, or because the default qt version changed
|
||||||
|
|||||||
@@ -892,6 +892,15 @@ ProFileReader *Qt4Project::createProFileReader(Qt4ProFileNode *qt4ProFileNode, Q
|
|||||||
m_proFileOption->sysroot = bc->qtVersion()->systemRoot();
|
m_proFileOption->sysroot = bc->qtVersion()->systemRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Utils::Environment env = bc->environment();
|
||||||
|
Utils::Environment::const_iterator eit = env.constBegin(), eend = env.constEnd();
|
||||||
|
for (; eit != eend; ++eit)
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
m_proFileOption->environment.insert(env.key(eit).toUpper(), env.value(eit));
|
||||||
|
#else
|
||||||
|
m_proFileOption->environment.insert(env.key(eit), env.value(eit));
|
||||||
|
#endif
|
||||||
|
|
||||||
QStringList args;
|
QStringList args;
|
||||||
if (QMakeStep *qs = bc->qmakeStep())
|
if (QMakeStep *qs = bc->qmakeStep())
|
||||||
args = qs->parserArguments();
|
args = qs->parserArguments();
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ ProFileOption::ProFileOption()
|
|||||||
dirlist_sep = QLatin1Char(':');
|
dirlist_sep = QLatin1Char(':');
|
||||||
dir_sep = QLatin1Char('/');
|
dir_sep = QLatin1Char('/');
|
||||||
#endif
|
#endif
|
||||||
qmakespec = QString::fromLocal8Bit(qgetenv("QMAKESPEC").data());
|
qmakespec = getEnv(QLatin1String("QMAKESPEC"));
|
||||||
|
|
||||||
host_mode = HOST_UNKNOWN_MODE;
|
host_mode = HOST_UNKNOWN_MODE;
|
||||||
target_mode = TARG_UNKNOWN_MODE;
|
target_mode = TARG_UNKNOWN_MODE;
|
||||||
@@ -163,6 +163,17 @@ void ProFileOption::applyHostMode()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString ProFileOption::getEnv(const QString &var) const
|
||||||
|
{
|
||||||
|
if (!environment.isEmpty())
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
return environment.value(var.toUpper());
|
||||||
|
#else
|
||||||
|
return environment.value(var);
|
||||||
|
#endif
|
||||||
|
return QString::fromLocal8Bit(qgetenv(var.toLocal8Bit().constData()));
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// ProFileEvaluator::Private
|
// ProFileEvaluator::Private
|
||||||
@@ -256,6 +267,8 @@ public:
|
|||||||
QStringList qmakeMkspecPaths() const;
|
QStringList qmakeMkspecPaths() const;
|
||||||
QStringList qmakeFeaturePaths() const;
|
QStringList qmakeFeaturePaths() const;
|
||||||
|
|
||||||
|
QString expandEnvVars(const QString &str) const;
|
||||||
|
QString fixPathToLocalOS(const QString &str) const;
|
||||||
QString sysrootify(const QString &path, const QString &baseDir) const;
|
QString sysrootify(const QString &path, const QString &baseDir) const;
|
||||||
|
|
||||||
int m_skipLevel;
|
int m_skipLevel;
|
||||||
@@ -635,19 +648,19 @@ static void replaceInList(ProStringList *varlist,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static QString expandEnvVars(const QString &str)
|
QString ProFileEvaluator::Private::expandEnvVars(const QString &str) const
|
||||||
{
|
{
|
||||||
QString string = str;
|
QString string = str;
|
||||||
int rep;
|
int rep;
|
||||||
QRegExp reg_variableName = statics.reg_variableName; // Copy for thread safety
|
QRegExp reg_variableName = statics.reg_variableName; // Copy for thread safety
|
||||||
while ((rep = reg_variableName.indexIn(string)) != -1)
|
while ((rep = reg_variableName.indexIn(string)) != -1)
|
||||||
string.replace(rep, reg_variableName.matchedLength(),
|
string.replace(rep, reg_variableName.matchedLength(),
|
||||||
QString::fromLocal8Bit(qgetenv(string.mid(rep + 2, reg_variableName.matchedLength() - 3).toLatin1().constData()).constData()));
|
m_option->getEnv(string.mid(rep + 2, reg_variableName.matchedLength() - 3)));
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is braindead, but we want qmake compat
|
// This is braindead, but we want qmake compat
|
||||||
static QString fixPathToLocalOS(const QString &str)
|
QString ProFileEvaluator::Private::fixPathToLocalOS(const QString &str) const
|
||||||
{
|
{
|
||||||
QString string = expandEnvVars(str);
|
QString string = expandEnvVars(str);
|
||||||
|
|
||||||
@@ -750,8 +763,8 @@ void ProFileEvaluator::Private::evaluateExpression(
|
|||||||
getStr(tokPtr).toQString(m_tmp1), true), NoHash), ret, pending, joined);
|
getStr(tokPtr).toQString(m_tmp1), true), NoHash), ret, pending, joined);
|
||||||
break;
|
break;
|
||||||
case TokEnvVar:
|
case TokEnvVar:
|
||||||
addStrList(split_value_list(QString::fromLocal8Bit(qgetenv(
|
addStrList(split_value_list(m_option->getEnv(getStr(tokPtr).toQString(m_tmp1))),
|
||||||
getStr(tokPtr).toQString(m_tmp1).toLatin1().constData()))), tok, ret, pending, joined);
|
tok, ret, pending, joined);
|
||||||
break;
|
break;
|
||||||
case TokFuncName: {
|
case TokFuncName: {
|
||||||
ProString func = getHashStr(tokPtr);
|
ProString func = getHashStr(tokPtr);
|
||||||
@@ -1376,9 +1389,9 @@ QStringList ProFileEvaluator::Private::qmakeMkspecPaths() const
|
|||||||
QStringList ret;
|
QStringList ret;
|
||||||
const QString concat = QLatin1String("/mkspecs");
|
const QString concat = QLatin1String("/mkspecs");
|
||||||
|
|
||||||
QByteArray qmakepath = qgetenv("QMAKEPATH");
|
QString qmakepath = m_option->getEnv(QLatin1String("QMAKEPATH"));
|
||||||
if (!qmakepath.isEmpty())
|
if (!qmakepath.isEmpty())
|
||||||
foreach (const QString &it, QString::fromLocal8Bit(qmakepath).split(m_option->dirlist_sep))
|
foreach (const QString &it, qmakepath.split(m_option->dirlist_sep))
|
||||||
ret << QDir::cleanPath(it) + concat;
|
ret << QDir::cleanPath(it) + concat;
|
||||||
|
|
||||||
QString builtIn = propertyValue(QLatin1String("QT_INSTALL_DATA"), false) + concat;
|
QString builtIn = propertyValue(QLatin1String("QT_INSTALL_DATA"), false) + concat;
|
||||||
@@ -1416,9 +1429,9 @@ QStringList ProFileEvaluator::Private::qmakeFeaturePaths() const
|
|||||||
|
|
||||||
QStringList feature_roots;
|
QStringList feature_roots;
|
||||||
|
|
||||||
QByteArray mkspec_path = qgetenv("QMAKEFEATURES");
|
QString mkspec_path = m_option->getEnv(QLatin1String("QMAKEFEATURES"));
|
||||||
if (!mkspec_path.isEmpty())
|
if (!mkspec_path.isEmpty())
|
||||||
foreach (const QString &f, QString::fromLocal8Bit(mkspec_path).split(m_option->dirlist_sep))
|
foreach (const QString &f, mkspec_path.split(m_option->dirlist_sep))
|
||||||
feature_roots += resolvePath(f);
|
feature_roots += resolvePath(f);
|
||||||
|
|
||||||
feature_roots += propertyValue(QLatin1String("QMAKEFEATURES"), false).split(
|
feature_roots += propertyValue(QLatin1String("QMAKEFEATURES"), false).split(
|
||||||
@@ -1430,9 +1443,9 @@ QStringList ProFileEvaluator::Private::qmakeFeaturePaths() const
|
|||||||
feature_roots << (path + concat_it);
|
feature_roots << (path + concat_it);
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray qmakepath = qgetenv("QMAKEPATH");
|
QString qmakepath = m_option->getEnv(QLatin1String("QMAKEPATH"));
|
||||||
if (!qmakepath.isNull()) {
|
if (!qmakepath.isNull()) {
|
||||||
const QStringList lst = QString::fromLocal8Bit(qmakepath).split(m_option->dirlist_sep);
|
const QStringList lst = qmakepath.split(m_option->dirlist_sep);
|
||||||
foreach (const QString &item, lst) {
|
foreach (const QString &item, lst) {
|
||||||
QString citem = resolvePath(item);
|
QString citem = resolvePath(item);
|
||||||
foreach (const QString &concat_it, concat)
|
foreach (const QString &concat_it, concat)
|
||||||
@@ -1700,8 +1713,7 @@ ProStringList ProFileEvaluator::Private::expandVariableReferences(
|
|||||||
|
|
||||||
ProStringList replacement;
|
ProStringList replacement;
|
||||||
if (var_type == ENVIRON) {
|
if (var_type == ENVIRON) {
|
||||||
replacement = split_value_list(QString::fromLocal8Bit(qgetenv(
|
replacement = split_value_list(m_option->getEnv(var.toQString(m_tmp1)));
|
||||||
var.toQString(m_tmp1).toLocal8Bit().constData())));
|
|
||||||
} else if (var_type == PROPERTY) {
|
} else if (var_type == PROPERTY) {
|
||||||
replacement << ProString(propertyValue(var.toQString(m_tmp1), true), NoHash);
|
replacement << ProString(propertyValue(var.toQString(m_tmp1), true), NoHash);
|
||||||
} else if (var_type == FUNCTION) {
|
} else if (var_type == FUNCTION) {
|
||||||
@@ -3242,14 +3254,6 @@ bool ProFileEvaluator::contains(const QString &variableName) const
|
|||||||
return d->m_valuemapStack.top().contains(ProString(variableName));
|
return d->m_valuemapStack.top().contains(ProString(variableName));
|
||||||
}
|
}
|
||||||
|
|
||||||
static QStringList expandEnvVars(const ProStringList &x)
|
|
||||||
{
|
|
||||||
QStringList ret;
|
|
||||||
foreach (const ProString &str, x)
|
|
||||||
ret << expandEnvVars(str.toQString());
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ProFileEvaluator::value(const QString &variable) const
|
QString ProFileEvaluator::value(const QString &variable) const
|
||||||
{
|
{
|
||||||
const QStringList &vals = values(variable);
|
const QStringList &vals = values(variable);
|
||||||
@@ -3261,7 +3265,12 @@ QString ProFileEvaluator::value(const QString &variable) const
|
|||||||
|
|
||||||
QStringList ProFileEvaluator::values(const QString &variableName) const
|
QStringList ProFileEvaluator::values(const QString &variableName) const
|
||||||
{
|
{
|
||||||
return expandEnvVars(d->values(ProString(variableName)));
|
const ProStringList &values = d->values(ProString(variableName));
|
||||||
|
QStringList ret;
|
||||||
|
ret.reserve(values.size());
|
||||||
|
foreach (const ProString &str, values)
|
||||||
|
ret << d->expandEnvVars(str.toQString());
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList ProFileEvaluator::values(const QString &variableName, const ProFile *pro) const
|
QStringList ProFileEvaluator::values(const QString &variableName, const ProFile *pro) const
|
||||||
@@ -3272,7 +3281,7 @@ QStringList ProFileEvaluator::values(const QString &variableName, const ProFile
|
|||||||
ret.reserve(values.size());
|
ret.reserve(values.size());
|
||||||
foreach (const ProString &str, values)
|
foreach (const ProString &str, values)
|
||||||
if (str.sourceFile() == pro)
|
if (str.sourceFile() == pro)
|
||||||
ret << expandEnvVars(str.toQString());
|
ret << d->expandEnvVars(str.toQString());
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -168,6 +168,7 @@ struct ProFileOption
|
|||||||
QString qmakespec;
|
QString qmakespec;
|
||||||
QString cachefile;
|
QString cachefile;
|
||||||
QHash<QString, QString> properties;
|
QHash<QString, QString> properties;
|
||||||
|
QHash<QString, QString> environment;
|
||||||
QString sysroot;
|
QString sysroot;
|
||||||
|
|
||||||
//QString pro_ext;
|
//QString pro_ext;
|
||||||
@@ -182,6 +183,7 @@ struct ProFileOption
|
|||||||
friend class ProFileEvaluator::Private;
|
friend class ProFileEvaluator::Private;
|
||||||
|
|
||||||
void applyHostMode();
|
void applyHostMode();
|
||||||
|
QString getEnv(const QString &) const;
|
||||||
|
|
||||||
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;
|
||||||
|
|||||||
Reference in New Issue
Block a user