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:
Eike Ziller
2018-09-25 13:56:46 +02:00
parent 217e944485
commit d69470c15c
7 changed files with 147 additions and 15 deletions

View File

@@ -27,6 +27,7 @@
#include "fileutils.h"
#include "hostosinfo.h"
#include "optional.h"
#include "utils_global.h"
#include <QMap>
@@ -148,4 +149,16 @@ private:
OsType m_osType;
};
class QTCREATOR_UTILS_EXPORT EnvironmentProvider
{
public:
QByteArray id;
QString displayName;
std::function<Environment()> environment;
static void addProvider(EnvironmentProvider &&provider);
static const QVector<EnvironmentProvider> providers();
static optional<EnvironmentProvider> provider(const QByteArray &id);
};
} // namespace Utils