Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: base_parser.TargetFilePath not reverted when exiting an !include parse #394

Open
Javagedes opened this issue Aug 24, 2023 · 0 comments · May be fixed by #399
Open

[Bug]: base_parser.TargetFilePath not reverted when exiting an !include parse #394

Javagedes opened this issue Aug 24, 2023 · 0 comments · May be fixed by #399
Labels
bug Something isn't working

Comments

@Javagedes
Copy link
Contributor

Javagedes commented Aug 24, 2023

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 revert TargetFilePath 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

src
└─ Platforms
  └─ PlatformPkg
    ├─ PlatformPkg.dsc
    └─ includes
      ├─ PCDs1.dsc.inc
      └─ PCDs2.dsc.inc   

Abbreviated DSC we are parsing

[PcdsFixedAtBuild]
gPlatformPkgTokenSpaceGuid.PcdSomethig
!include includes/PCDs1.dsc.inc
!include includes/PCDs2.dsc.inc

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.

!include relative/myfile1.dsc
!include relative/myfile2.dsc
!include relative/myfile3.dsc

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

@Javagedes Javagedes added the bug Something isn't working label Aug 24, 2023
@Javagedes Javagedes linked a pull request Aug 28, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant