edk2/BaseTools/Source/Python
Sergii Dmytruk 433bbe6e49 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>
2025-08-25 11:54:17 +00:00
..
AmlToC BaseTools: Resolve regex syntax warnings 2023-12-21 00:33:31 +00:00
AutoGen BaseTools: AutoGen: Remove unnecessary code 2025-07-01 09:51:38 +08:00
BPDG BaseTools: Remove unused import 2025-07-01 09:51:38 +08:00
build BaseTools: Improve report generation for Nested Fvs. 2025-07-08 10:06:36 +08:00
Capsule BaseTools: Capsule: Remove unnecessary code 2025-07-01 09:51:38 +08:00
Common BaseTools:Expression.py Adding a check for missing '}' in the parser 2025-04-14 20:53:02 +00:00
CommonDataClass BaseTools: Add support for SUBTYPE_GUID section generation 2022-10-19 06:32:07 +00:00
Ecc BaseTools: Ecc: Remove unnecessary code 2025-07-01 09:51:38 +08:00
Eot BaseTools: Eot: Remove unnecessary code 2025-07-01 09:51:38 +08:00
FirmwareStorageFormat BaseTools: FMMT support ELF UPLD parser 2023-12-11 10:12:52 +00:00
FMMT BaseTools: Fix FMMT FvHandler Padding operation issue 2025-07-30 02:44:25 +00:00
GenFds BaseTools: GenFds: Remove unnecessary code 2025-07-01 09:51:38 +08:00
GenPatchPcdTable BaseTools: Resolve regex syntax warnings 2023-12-21 00:33:31 +00:00
PatchPcdValue BaseTools: Decouple AutoGen Objects 2019-08-09 23:15:52 +08:00
Pkcs7Sign BaseTools:Updata the output encoding of the Popen function 2019-08-01 15:36:48 +08:00
Rsa2048Sha256Sign BaseTools:Updata the output encoding of the Popen function 2019-08-01 15:36:48 +08:00
Split BaseTools: use shutil.copyfile instead shutil.copy2 2021-08-02 03:52:15 +00:00
Table BaseTools: Table: Remove unnecessary code 2025-07-01 09:51:38 +08:00
TargetTool BaseTools: Remove unreachable code 2025-07-01 09:51:38 +08:00
tests/Split BaseTools: fix the split output files root dir 2021-02-07 01:46:18 +00:00
Trim BaseTools: Trim: Add header/footer for ASL include 2024-08-31 04:58:54 +00:00
UPT BaseTools: UPT/Library: Remove unnecessary code 2025-07-01 09:51:38 +08:00
Workspace BaseTools: DSC: fix processing !include in multiarch subsections 2025-08-25 11:54:17 +00:00
basetool_tiano_python_path_env.yaml BaseTools: Add YAML files with path env and tool extdeps 2019-11-11 13:01:53 -08:00
GNUmakefile BaseTools: Replace BSD License with BSD+Patent License 2019-04-09 09:10:20 -07:00
Makefile BaseTools: strip trailing whitespace 2019-10-04 11:18:22 +01:00
sitecustomize.py BaseTools: Do not call sys.setdefaultencoding with python 3 2019-10-23 14:25:23 +08:00