forked from qt-creator/qt-creator
McuSupport: Only expand variables from the same target
There are multiple packages in different targets that share the same variable name (eg. QUL_BOARD_SDK_DIR). Registering all packages into the same macro expander will make these packages overwrite the variables from other packages. The macro expander should only use packages included in a specific target to expand values from (plus the global ones). Change-Id: Ia2568696a54e48e4e77f81a9bb1a844f2910bb8d Reviewed-by: Yasser Grimes <yasser.grimes@qt.io> Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -38,17 +38,20 @@ Macros *McuSdkRepository::globalMacros()
|
|||||||
|
|
||||||
void McuSdkRepository::expandVariables()
|
void McuSdkRepository::expandVariables()
|
||||||
{
|
{
|
||||||
auto macroExpander = getMacroExpander();
|
for (const auto &target : std::as_const(mcuTargets)) {
|
||||||
for (const auto &package : std::as_const(packages))
|
auto macroExpander = getMacroExpander(*target);
|
||||||
|
for (const auto &package : target->packages()) {
|
||||||
package->setPath(macroExpander->expand(package->path()));
|
package->setPath(macroExpander->expand(package->path()));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MacroExpanderPtr McuSdkRepository::getMacroExpander()
|
MacroExpanderPtr McuSdkRepository::getMacroExpander(const McuTarget &target)
|
||||||
{
|
{
|
||||||
auto macroExpander = std::make_shared<Utils::MacroExpander>();
|
auto macroExpander = std::make_shared<Utils::MacroExpander>();
|
||||||
|
|
||||||
//register the macros
|
//register the macros
|
||||||
for (const auto &package : std::as_const(packages)) {
|
for (const auto &package : target.packages()) {
|
||||||
macroExpander->registerVariable(package->cmakeVariableName().toLocal8Bit(),
|
macroExpander->registerVariable(package->cmakeVariableName().toLocal8Bit(),
|
||||||
package->label(),
|
package->label(),
|
||||||
[package] { return package->path().toString(); });
|
[package] { return package->path().toString(); });
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public:
|
|||||||
Packages packages;
|
Packages packages;
|
||||||
|
|
||||||
void expandVariables();
|
void expandVariables();
|
||||||
MacroExpanderPtr getMacroExpander();
|
MacroExpanderPtr getMacroExpander(const McuTarget &target);
|
||||||
|
|
||||||
static Macros *globalMacros();
|
static Macros *globalMacros();
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user