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()
|
||||
{
|
||||
auto macroExpander = getMacroExpander();
|
||||
for (const auto &package : std::as_const(packages))
|
||||
package->setPath(macroExpander->expand(package->path()));
|
||||
for (const auto &target : std::as_const(mcuTargets)) {
|
||||
auto macroExpander = getMacroExpander(*target);
|
||||
for (const auto &package : target->packages()) {
|
||||
package->setPath(macroExpander->expand(package->path()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MacroExpanderPtr McuSdkRepository::getMacroExpander()
|
||||
MacroExpanderPtr McuSdkRepository::getMacroExpander(const McuTarget &target)
|
||||
{
|
||||
auto macroExpander = std::make_shared<Utils::MacroExpander>();
|
||||
|
||||
//register the macros
|
||||
for (const auto &package : std::as_const(packages)) {
|
||||
for (const auto &package : target.packages()) {
|
||||
macroExpander->registerVariable(package->cmakeVariableName().toLocal8Bit(),
|
||||
package->label(),
|
||||
[package] { return package->path().toString(); });
|
||||
|
||||
Reference in New Issue
Block a user