forked from qt-creator/qt-creator
Allow external tools to use build or run environment
Add mechanism for registering environment providers, since just registering the environment as a prefix variable in the macro expander doesn't really fit the use case of using more than an individual variable. Project explorer registers providers for the current build and run environments. External tools can refer to a provider by id and then use that as base environment. Task-number: QTCREATORBUG-18394 Task-number: QTCREATORBUG-19892 Change-Id: I19fc4dfa8286b2f1e4679c6406f285dcc9514ba3 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -37,6 +37,8 @@
|
||||
Q_GLOBAL_STATIC_WITH_ARGS(Utils::Environment, staticSystemEnvironment,
|
||||
(QProcessEnvironment::systemEnvironment().toStringList()))
|
||||
|
||||
Q_GLOBAL_STATIC(QVector<Utils::EnvironmentProvider>, environmentProviders)
|
||||
|
||||
static QMap<QString, QString>::iterator findKey(QMap<QString, QString> &input, Utils::OsType osType,
|
||||
const QString &key)
|
||||
{
|
||||
@@ -691,4 +693,22 @@ QStringList Environment::expandVariables(const QStringList &variables) const
|
||||
return Utils::transform(variables, [this](const QString &i) { return expandVariables(i); });
|
||||
}
|
||||
|
||||
void EnvironmentProvider::addProvider(EnvironmentProvider &&provider)
|
||||
{
|
||||
environmentProviders->append(std::move(provider));
|
||||
}
|
||||
|
||||
const QVector<EnvironmentProvider> EnvironmentProvider::providers()
|
||||
{
|
||||
return *environmentProviders;
|
||||
}
|
||||
|
||||
optional<EnvironmentProvider> EnvironmentProvider::provider(const QByteArray &id)
|
||||
{
|
||||
const int index = indexOf(*environmentProviders, equal(&EnvironmentProvider::id, id));
|
||||
if (index >= 0)
|
||||
return make_optional(environmentProviders->at(index));
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
} // namespace Utils
|
||||
|
||||
Reference in New Issue
Block a user