From 62b0698309cdffa1ed11eca3ebc389e0cb452c70 Mon Sep 17 00:00:00 2001 From: Michael D Kinney Date: Wed, 29 Jan 2025 20:35:38 -0800 Subject: [PATCH] BaseTools/AutoGen: GenMake response file quotes strings If command line options are moved into a response file of a GCC family build, then the file path separators are converted from '\' to '/'. However, this can corrupt command line options that are quoted strings. Update GenMake to no convert '\' to '/' in quoted strings. Signed-off-by: Michael D Kinney --- BaseTools/Source/Python/AutoGen/GenMake.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/Python/AutoGen/GenMake.py index 6d9c60b702..547c708fc7 100755 --- a/BaseTools/Source/Python/AutoGen/GenMake.py +++ b/BaseTools/Source/Python/AutoGen/GenMake.py @@ -899,9 +899,20 @@ cleanlib: break if self._AutoGenObject.ToolChainFamily == 'GCC': - RespDict[Key] = Value.replace('\\', '/') - else: - RespDict[Key] = Value + # + # Replace '\' with '/' in the response file. + # Skip content within "" or \"\" + # + ValueList = re.split(r'("|\\"|\s+)', Value) + Skip = False + for i, v in enumerate(ValueList): + if v in ('"', '\\"'): + Skip = not Skip + elif not Skip: + ValueList[i] = v.replace('\\', '/') + Value = ''.join(ValueList) + RespDict[Key] = Value + for Target in BuildTargets: for i, SingleCommand in enumerate(BuildTargets[Target].Commands): if FlagDict[Flag]['Macro'] in SingleCommand: