diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2017-11-09 16:10:24 +0100 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2017-11-20 09:43:06 +0000 |
commit | 2ff14a89f8bd97e7c355596db548c8556f8cbdfb (patch) | |
tree | 51d626570016c133e1867458983743064b698687 /src/lib/corelib/api/runenvironment.cpp | |
parent | 9b838c0dc6ee80f5dbd60819a22a569d89ec014c (diff) |
Make Module.setup{Build,Run}Environment first-class citizens
They did not have the project and product variables available, and they
accessed module properties in a way that made it look as if they were
normal properties rather than scripts, which was misleading.
Now everything works the same as in Rule scripts and JS commands.
Task-number: QBS-744
Change-Id: I11d70876185d528282a56747747dd8310a77fbc4
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
Diffstat (limited to 'src/lib/corelib/api/runenvironment.cpp')
-rw-r--r-- | src/lib/corelib/api/runenvironment.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/lib/corelib/api/runenvironment.cpp b/src/lib/corelib/api/runenvironment.cpp index 0a2c1f0e5..e980210cf 100644 --- a/src/lib/corelib/api/runenvironment.cpp +++ b/src/lib/corelib/api/runenvironment.cpp @@ -40,7 +40,9 @@ #include "runenvironment.h" #include <api/projectdata.h> +#include <buildgraph/environmentscriptrunner.h> #include <buildgraph/productinstaller.h> +#include <buildgraph/rulesevaluationcontext.h> #include <language/language.h> #include <language/propertymapinternal.h> #include <language/scriptengine.h> @@ -78,7 +80,7 @@ public: , environment(environment) , settings(settings) , logger(logger) - , engine(this->logger, EvalContext::PropertyEvaluation) + , evalContext(this->logger) { } @@ -88,7 +90,7 @@ public: const QProcessEnvironment environment; Settings * const settings; Logger logger; - ScriptEngine engine; + RulesEvaluationContext evalContext; }; RunEnvironment::RunEnvironment(const ResolvedProductPtr &product, @@ -150,8 +152,10 @@ const QProcessEnvironment RunEnvironment::buildEnvironment(ErrorInfo *error) con int RunEnvironment::doRunShell() { - if (d->resolvedProduct) - d->resolvedProduct->setupBuildEnvironment(&d->engine, d->project->environment); + if (d->resolvedProduct) { + EnvironmentScriptRunner(d->resolvedProduct.get(), &d->evalContext, + d->project->environment).setupForBuild(); + } const QString productId = d->resolvedProduct ? d->resolvedProduct->name : QString(); const QString configName = d->project->id(); @@ -399,7 +403,7 @@ int RunEnvironment::doRunTarget(const QString &targetBin, const QStringList &arg QProcessEnvironment env = d->environment; env.insert(QLatin1String("QBS_RUN_FILE_PATH"), targetBin); - d->resolvedProduct->setupRunEnvironment(&d->engine, env); + EnvironmentScriptRunner(d->resolvedProduct.get(), &d->evalContext, env).setupForRun(); d->logger.qbsInfo() << Tr::tr("Starting target '%1'.").arg(QDir::toNativeSeparators(targetBin)); QProcess process; @@ -434,7 +438,8 @@ const QProcessEnvironment RunEnvironment::getRunEnvironment() const { if (!d->resolvedProduct) return d->environment; - d->resolvedProduct->setupRunEnvironment(&d->engine, d->environment); + EnvironmentScriptRunner(d->resolvedProduct.get(), &d->evalContext, d->environment) + .setupForRun(); return d->resolvedProduct->runEnvironment; } @@ -442,7 +447,8 @@ const QProcessEnvironment RunEnvironment::getBuildEnvironment() const { if (!d->resolvedProduct) return d->environment; - d->resolvedProduct->setupBuildEnvironment(&d->engine, d->environment); + EnvironmentScriptRunner(d->resolvedProduct.get(), &d->evalContext, d->environment) + .setupForBuild(); return d->resolvedProduct->buildEnvironment; } |