summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael D Kinney <michael.d.kinney@intel.com>2025-01-29 20:35:38 -0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2025-02-02 19:22:42 +0000
commit62b0698309cdffa1ed11eca3ebc389e0cb452c70 (patch)
tree08204261f902df81f5ddd152424400dfbcf20f9e
parent15a7d311a869737580b09a158bf86983bb766d6e (diff)
downloadedk2-62b0698309cdffa1ed11eca3ebc389e0cb452c70.tar.gz
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 <michael.d.kinney@intel.com>
-rwxr-xr-xBaseTools/Source/Python/AutoGen/GenMake.py17
1 files 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: