diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2017-01-16 19:01:08 +0100 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@qt.io> | 2017-01-19 12:31:34 +0000 |
commit | e9ac4e7d83e8cc1ed4256c3d0b8e915637f2e6d5 (patch) | |
tree | e3e71e21a258a56634aa58cf7abc8e1fd25f2492 /src/lib/corelib/buildgraph/jscommandexecutor.cpp | |
parent | b17e94f932fd8adab4f1a123c3221bbe110c93d1 (diff) |
Make loaded extensions available in JavaScript commands
When JS commands are created in a function that's defined in a separate
JS file then loaded extensions of this file were not visible within the
JS command's source code.
Determine the current import scope name at the location of the
JavaScriptCommand's constructor and pass it to the JsCommandExecutor
where it is pushed to the current context.
Task-number: QBS-1093
Change-Id: I471e277c6821f38af6f2a06fc34005cf3c296f6c
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src/lib/corelib/buildgraph/jscommandexecutor.cpp')
-rw-r--r-- | src/lib/corelib/buildgraph/jscommandexecutor.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/lib/corelib/buildgraph/jscommandexecutor.cpp b/src/lib/corelib/buildgraph/jscommandexecutor.cpp index b382e785a..99c27631b 100644 --- a/src/lib/corelib/buildgraph/jscommandexecutor.cpp +++ b/src/lib/corelib/buildgraph/jscommandexecutor.cpp @@ -112,6 +112,11 @@ private: scope.setPrototype(scriptEngine->globalObject()); PrepareScriptObserver observer(scriptEngine); setupScriptEngineForFile(scriptEngine, transformer->rule->prepareScript->fileContext, scope); + + QScriptValue importScopeForSourceCode; + if (!cmd->scopeName().isEmpty()) + importScopeForSourceCode = scope.property(cmd->scopeName()); + setupScriptEngineForProduct(scriptEngine, transformer->product(), transformer->rule->module, scope, &observer); transformer->setupInputs(scope); @@ -123,7 +128,11 @@ private: } scriptEngine->setGlobalObject(scope); + if (importScopeForSourceCode.isObject()) + scriptEngine->currentContext()->pushScope(importScopeForSourceCode); scriptEngine->evaluate(cmd->sourceCode()); + if (importScopeForSourceCode.isObject()) + scriptEngine->currentContext()->popScope(); scriptEngine->setGlobalObject(scope.prototype()); transformer->propertiesRequestedInCommands += scriptEngine->propertiesRequestedInScript(); |