Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion edk2toollib/uefi/edk2/parsers/dsc_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def __init__(self) -> "HashFileParser":
def ReplacePcds(self, line: str) -> str:
"""Attempts to replace a token if it is a PCD token."""
if line.startswith("!if"):
for token in line.split():
for token in re.split(r"[^\w\.]", line):
if token in self.PcdValueDict:
line = line.replace(token, self.PcdValueDict[token])
return line
Expand Down
25 changes: 25 additions & 0 deletions tests.unit/parsers/test_dsc_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,3 +224,28 @@ def test_dsc_pcd_in_include_files(self):
parser.ParseFile(file1_path)

self.assertEqual(parser.LocalVars["INCLUDE"], "TRUE")

def test_dsc_pcd_mix_with_symbols(self):
"""This tests pcd can be parsed correctly when next to symbols"""
workspace = tempfile.mkdtemp()

file_name = "test.dsc"
file_path = os.path.join(workspace, file_name)

file_data = textwrap.dedent("""\
[PcdsFixedAtBuild]
gFakePcdTokenSpaceGuid.PcdFake1|0xAB
gFakePcdTokenSpaceGuid.PcdFake2|TRUE

[Defines]
!if (gFakePcdTokenSpaceGuid.PcdFake1>=0xA0)&&(gFakePcdTokenSpaceGuid.PcdFake2==TRUE)
INCLUDE=TRUE
!endif
""")

TestDscParserIncludes.write_to_file(file_path, file_data)

parser = DscParser().SetEdk2Path(Edk2Path(workspace, []))
parser.ParseFile(file_path)

self.assertEqual(parser.LocalVars["INCLUDE"], "TRUE")
Loading