summaryrefslogtreecommitdiff
path: root/BaseTools/Source/Python/Workspace/MetaFileParser.py
diff options
context:
space:
mode:
authorBob Chen (UST Global Singapore Pte Limited) <v-kuanlchen@microsoft.com>2026-08-25 17:08:31 +0300
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2026-09-01 17:42:26 +0300
commit7b01c71a83e0bf6a89f5e803a4f60adc29c1f70f (patch)
tree2dbffaea5f80b10f866218d14be9e33d2b348971 /BaseTools/Source/Python/Workspace/MetaFileParser.py
parent3d36a819ae67f4871ca07df1a2df01ce4758100b (diff)
downloadedk2-7b01c71a83e0bf6a89f5e803a4f60adc29c1f70f.tar.xz
BaseTools: Make DSC arch macro expansion owner-aware
PR #12628 expanded architecture macros for every DSC record so component-private records match their component. A positive raw owner can also represent include provenance, so broad expansion changes records outside component scope. Expand architecture macros only for Component records and records whose owner maps to a final Component. Reset the owner mapping whenever the post-processed table is rebuilt to prevent stale ownership across DoPostProcess calls. Add regression coverage for component-private LibraryClasses and PCDs, nested and private includes, multiple architectures, unresolved macros, repeated sections, and repeated post-processing. Signed-off-by: Bob Chen (UST Global Singapore Pte Limited) <v-kuanlchen@microsoft.com>
Diffstat (limited to 'BaseTools/Source/Python/Workspace/MetaFileParser.py')
-rw-r--r--BaseTools/Source/Python/Workspace/MetaFileParser.py24
1 files changed, 13 insertions, 11 deletions
diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py
index 862f4fc436..e3f0e6334c 100644
--- a/BaseTools/Source/Python/Workspace/MetaFileParser.py
+++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py
@@ -1377,6 +1377,7 @@ class DscParser(MetaFileParser):
}
self._Table = MetaFileStorage(self._RawTable.DB, self.MetaFile, MODEL_FILE_DSC, True)
+ self._IdMapping = {-1:-1}
self._DirectiveStack = []
self._DirectiveEvalStack = []
self._FileWithError = self.MetaFile
@@ -1400,17 +1401,6 @@ 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
#
@@ -1469,6 +1459,8 @@ class DscParser(MetaFileParser):
continue
NewOwner = self._IdMapping.get(Owner, -1)
+ if NewOwner > 0:
+ self.__ExpandArchitectureScope()
self._Enabled = int((not self._DirectiveEvalStack) or (False not in self._DirectiveEvalStack))
self._LastItem = self._Store(
self._ItemType,
@@ -1723,6 +1715,16 @@ class DscParser(MetaFileParser):
def __ProcessComponent(self):
self._ValueList[0] = ReplaceMacro(self._ValueList[0], self._Macros)
+ self.__ExpandArchitectureScope()
+
+ def __ExpandArchitectureScope(self):
+ OriginalArch = self._Scope[0][0]
+ self._Scope[0][0] = ReplaceMacro(OriginalArch, self._Macros)
+ if '$(' in self._Scope[0][0] and OriginalArch != TAB_ARCH_COMMON:
+ EdkLogger.warn("Parser",
+ "Macro in arch field was not resolved. "
+ "'%s' used in section header is not defined." % OriginalArch,
+ File=self._FileWithError, Line=self._LineIndex + 1)
def __ProcessBuildOption(self):
self._ValueList = [ReplaceMacro(Value, self._Macros, RaiseError=False)