BaseTools/Build: Fix arch macro expansion scope in DSC parser

Signed-off-by: Kirk Chou <kirk.chou@hpe.com>
This commit is contained in:
Kirk Chou 2026-05-29 00:45:49 +08:00 committed by mergify[bot]
parent 12c5ded287
commit 34a3cc89de

View file

@ -1400,6 +1400,17 @@ class DscParser(MetaFileParser):
self._Scope = [[S1, S2, S3]]
#
# Expand macros in arch field for all records so that per-module
# sub-items (e.g. <LibraryClasses> under [Components.$(PEI_ARCH)])
# resolve correctly, not just the Component record itself.
#
self._Scope[0][0] = ReplaceMacro(self._Scope[0][0], self._Macros)
if '$(' in self._Scope[0][0] and S1 != TAB_ARCH_COMMON:
EdkLogger.warn("Parser",
"Macro in arch field was not resolved. "
"'%s' used in section header is not defined." % S1,
File=self._FileWithError, Line=LineStart)
#
# For !include directive, handle it specially,
# merge arch and module type in case of duplicate items
#
@ -1712,7 +1723,6 @@ class DscParser(MetaFileParser):
def __ProcessComponent(self):
self._ValueList[0] = ReplaceMacro(self._ValueList[0], self._Macros)
self._Scope[0][0] = ReplaceMacro(self._Scope[0][0], self._Macros)
def __ProcessBuildOption(self):
self._ValueList = [ReplaceMacro(Value, self._Macros, RaiseError=False)