]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools/Trim: Normalize filepaths to fix comparisons on Windows
authorChris Co <Christopher.Co@microsoft.com>
Thu, 28 Jun 2018 19:31:21 +0000 (03:31 +0800)
committerLiming Gao <liming.gao@intel.com>
Wed, 4 Jul 2018 02:42:32 +0000 (10:42 +0800)
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>
BaseTools/Source/Python/Trim/Trim.py

index 76944c0e25b3284d69f1b30854162b4b785ffaf5..b46d507b4e55e503712ecf0a205cb3d940f206b4 100644 (file)
@@ -166,6 +166,8 @@ def TrimPreprocessedFile(Source, Target, ConvertHex, TrimLong):
             if len(MatchList) == 2:\r
                 LineNumber = int(MatchList[0], 0)\r
                 InjectedFile = MatchList[1]\r
+                InjectedFile = os.path.normpath(InjectedFile)\r
+                InjectedFile = os.path.normcase(InjectedFile)\r
                 # The first injetcted file must be the preprocessed file itself\r
                 if PreprocessedFile == "":\r
                     PreprocessedFile = InjectedFile\r