]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/Trim/Trim.py
BaseTools/Trim: Normalize filepaths to fix comparisons on Windows
[mirror_edk2.git] / BaseTools / Source / Python / Trim / Trim.py
index 97f4e87587ee15f47a1930d563bc5a5b16daac77..b46d507b4e55e503712ecf0a205cb3d940f206b4 100644 (file)
@@ -17,7 +17,7 @@
 import Common.LongFilePathOs as os\r
 import sys\r
 import re\r
-import StringIO\r
+from io import BytesIO\r
 \r
 from optparse import OptionParser\r
 from optparse import make_option\r
@@ -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
@@ -455,8 +457,8 @@ def GenerateVfrBinSec(ModuleName, DebugDir, OutputFile):
     except:\r
         EdkLogger.error("Trim", FILE_OPEN_FAILURE, "File open failed for %s" %OutputFile, None)\r
 \r
-    # Use a instance of StringIO to cache data\r
-    fStringIO = StringIO.StringIO('')\r
+    # Use a instance of BytesIO to cache data\r
+    fStringIO = BytesIO('')\r
 \r
     for Item in VfrUniOffsetList:\r
         if (Item[0].find("Strings") != -1):\r