diff options
author | Sergii Dmytruk <sergii.dmytruk@3mdeb.com> | 2025-08-09 16:47:12 +0300 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2025-08-25 14:54:17 +0300 |
commit | 433bbe6e493adeb75d8799e01a84968aa97db1a0 (patch) | |
tree | 30c33e08c5d9148c450affb7bb1136e08d681907 /BaseTools/Source/Python/Workspace/MetaFileParser.py | |
parent | 829e42d3a345a641c8359e25e357d7acb1dee292 (diff) | |
download | edk2-433bbe6e493adeb75d8799e01a84968aa97db1a0.tar.xz |
BaseTools: DSC: fix processing !include in multiarch subsections
Commit f0a2015373 ("UefiPayloadPkg: Add AARCH64 support") changed
`[Components.X64]` to `[Components.X64, Components.AARCH64]` which
resulted in the following code within that section to not work as
expected (the code wasn't there, just providing a real world example
that uncovered the issue):
[Components.X64, Components.AARCH64]
FmpDevicePkg/FmpDxe/FmpDxe.inf {
...
<PcdsFixedAtBuild>
!include .../...PcdFmpDevicePkcs7CertBufferXdr.inc
...
}
At the same time `[Components.X64]` or even `[Components.AARCH64,
Components.X64]` (notice the swapped order) worked fine for X64 target.
The cause of the issue turned out to be skipping includes inside
`_PostProcess()` method of `DscParser` class. This method processes
list of items stored in a database filled on the first pass through a
DSC file in `Start()` method. One of the fields stored in each row
of a table is link to a parent object (owner). A section like
`[Components.X64, Components.AARCH64]` creates two objects and all of
its subelements are duplicated for both X64 and AARCH64. This was not
happening for !include statement in the example above.
Because `_PostProcess()` contracted a sequence of !include objects
disregarding their owner, it did not create instance for each of the
requested targets. Codewise, `self._ContentIndex` was incremented more
than once, while `__ProcessDirective()` method (invoked indirectly as
`Processer[self._ItemType]()`) queried owner of the current directive
as:
if self._InSubsection:
Owner = self._Content[self._ContentIndex - 1][8]
else: # not taken in this case
This is why order of targets made a difference, only the last was fully
initialized in this case.
An alternative fix is completely dropping merging of !include
directives, but hard to say whether it still has some utility (the code
is complex, hard to follow and barely documented). Safer to keep it, in
the worst case it doesn't do anything now.
Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
Diffstat (limited to 'BaseTools/Source/Python/Workspace/MetaFileParser.py')
-rw-r--r-- | BaseTools/Source/Python/Workspace/MetaFileParser.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py index ed1ccb1cf1..5d2a44481d 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py @@ -1407,7 +1407,11 @@ class DscParser(MetaFileParser): if self._ContentIndex >= len(self._Content):
break
Record = self._Content[self._ContentIndex]
- if LineStart == Record[10] and LineEnd == Record[12]:
+ #
+ # Avoid merging includes with different owners to make sure an
+ # include is correctly processed per arch.
+ #
+ if Owner == Record[8] and LineStart == Record[10] and LineEnd == Record[12]:
if [Record[5], Record[6], Record[7]] not in self._Scope:
self._Scope.append([Record[5], Record[6], Record[7]])
self._ContentIndex += 1
|