[Bug]: base_parser.TargetFilePath
not reverted when exiting an !include parse
#394
Labels
bug
Something isn't working
Contact Details
No response
Describe the Bug
Per section 2.2.5 of the DSC specification, when searching for an !include filepath, the first location to check is relative to the directory containing the currently parsed file.
edk2-pytool-library emulates this functionality by storing the currently parsed file in
TargetFilePath
so that if we need to find another include, we are looking in the correct relative directory. The bug, is that we do not revertTargetFilePath
to the previous file when we are done parsing an included file. This means that searches for additional includes could fail as the relative directory we look for is incorrect.Example
Folder layout we are parsing
Abbreviated DSC we are parsing
When we start parsing PlatformPkg.dsc,
TargetFilePath
is~/src/Platforms/PlatformPkg/PlatformPkg.dsc
.When we start parsing the first include, the relative import is a success because the
~src/Platforms/PlatformPkg/
+includes/PCDs1.dsc.inc
exists. We then update TargetFilePath to~/src/Platforms/PlatformPkg/includes/PCDs1.dsc.inc
.When we start parsing the second include, we fail because
TargetFilePath
was not reverted back to~/src/Platforms/PlatformPkg/PlatformPkg.dsc
. Since it remains the same, we think the file path should be~src/Platforms/PlatformPkg/includes/includes/PCDs2.dsc.inc
, which is wrong.Reproduction steps
Update your two dscs to use two relative path includes (not macro defined absolute paths or edk2 package path relative paths) and the parsing will fail.
Expected behavior
Parsing should correctly update TargetFilePath and relative includes should not fail.
What Python version are you using?
Python 3.9, Python 3.10, Python 3.11
Execution Environment
No response
Pip packages
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: