summaryrefslogtreecommitdiffstats
path: root/BaseTools
diff options
context:
space:
mode:
authorChris Co <Christopher.Co@microsoft.com>2018-06-29 03:31:21 +0800
committerLiming Gao <liming.gao@intel.com>2018-07-04 10:42:32 +0800
commit5895956dd955714c0e578a413d0e289153cc9eea (patch)
tree1466aef405598290939f295ffc60c165a2af44ba /BaseTools
parentcd69c8738391d9ce6c09cf5118c913cc7cd41d8b (diff)
downloadedk2-5895956dd955714c0e578a413d0e289153cc9eea.tar.gz
edk2-5895956dd955714c0e578a413d0e289153cc9eea.tar.bz2
edk2-5895956dd955714c0e578a413d0e289153cc9eea.zip
BaseTools/Trim: Normalize filepaths to fix comparisons on Windows
When using Linaro GCC5+ arm-eabi toolchain on Windows, the generated DSDT.iii contains a canonicalized ("\.\" removed and lower case) filepath for the preprocessed DSDT.i file in the first line. Trim.exe is called on DSDT.iii to generate DSDT.iiii, which does a line for line comparison of filepaths encountered to the preprocessed DSDT.i filepath found in the first line to determine what lines to place in DSDT.iiii. Since the DSDT.i filepath is canonicalized and all later filepaths in DSDT.iii are not canonicalized, all comparisons fail and the result is in an empty DSDT.iiii. Issue was first reported to Linaro here: https://bugs.linaro.org/show_bug.cgi?id=2909 where the recommendation was to address the issue in Trim.exe. This patch normalizes the case and pathname of all filepaths encountered during Trim.exe execution on preprocessed files. This fixes comparisons of filepaths that contain mismatching case on case-insensitive filesystems, redundant separators, and uplevel references. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Christopher Co <christopher.co@microsoft.com> Cc: Leif Lindholm <leif.lindholm@linaro.org> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
Diffstat (limited to 'BaseTools')
-rw-r--r--BaseTools/Source/Python/Trim/Trim.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/BaseTools/Source/Python/Trim/Trim.py b/BaseTools/Source/Python/Trim/Trim.py
index 76944c0e25..b46d507b4e 100644
--- a/BaseTools/Source/Python/Trim/Trim.py
+++ b/BaseTools/Source/Python/Trim/Trim.py
@@ -166,6 +166,8 @@ def TrimPreprocessedFile(Source, Target, ConvertHex, TrimLong):
if len(MatchList) == 2:
LineNumber = int(MatchList[0], 0)
InjectedFile = MatchList[1]
+ InjectedFile = os.path.normpath(InjectedFile)
+ InjectedFile = os.path.normcase(InjectedFile)
# The first injetcted file must be the preprocessed file itself
if PreprocessedFile == "":
PreprocessedFile = InjectedFile