]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/build/build.py
BaseTools: Various typo
[mirror_edk2.git] / BaseTools / Source / Python / build / build.py
index b5b969e876d2d4f526c0517e8025e7e3b1cc304a..99e79d4dca768e0850abbe6e76108eb4108bf337 100644 (file)
@@ -20,7 +20,6 @@
 from __future__ import print_function\r
 import Common.LongFilePathOs as os\r
 import re\r
-from io import BytesIO\r
 import sys\r
 import glob\r
 import time\r
@@ -182,8 +181,8 @@ def ReadMessage(From, To, ExitFlag):
         # read one line a time\r
         Line = From.readline()\r
         # empty string means "end"\r
-        if Line is not None and Line != "":\r
-            To(Line.rstrip())\r
+        if Line is not None and Line != b"":\r
+            To(Line.rstrip().decode(encoding='utf-8', errors='ignore'))\r
         else:\r
             break\r
         if ExitFlag.isSet():\r
@@ -443,7 +442,7 @@ class BuildTask:
 \r
                 # get all pending tasks\r
                 BuildTask._PendingQueueLock.acquire()\r
-                BuildObjectList = BuildTask._PendingQueue.keys()\r
+                BuildObjectList = list(BuildTask._PendingQueue.keys())\r
                 #\r
                 # check if their dependency is resolved, and if true, move them\r
                 # into ready queue\r
@@ -489,7 +488,7 @@ class BuildTask:
                 time.sleep(0.1)\r
         except BaseException as X:\r
             #\r
-            # TRICK: hide the output of threads left runing, so that the user can\r
+            # TRICK: hide the output of threads left running, so that the user can\r
             #        catch the error message easily\r
             #\r
             EdkLogger.SetLevel(EdkLogger.ERROR)\r
@@ -614,7 +613,7 @@ class BuildTask:
             self.CompleteFlag = True\r
         except:\r
             #\r
-            # TRICK: hide the output of threads left runing, so that the user can\r
+            # TRICK: hide the output of threads left running, so that the user can\r
             #        catch the error message easily\r
             #\r
             if not BuildTask._ErrorFlag.isSet():\r
@@ -796,7 +795,8 @@ class Build():
             if PYTHON3_ENABLE != "TRUE":\r
                 PYTHON3_ENABLE = "FALSE"\r
             EdkLogger.quiet("%-16s = %s" % ("PYTHON3_ENABLE", PYTHON3_ENABLE))\r
-        EdkLogger.quiet("%-16s = %s" % ("PYTHON", os.environ["PYTHON"]))\r
+        if "PYTHON_COMMAND" in os.environ:\r
+            EdkLogger.quiet("%-16s = %s" % ("PYTHON_COMMAND", os.environ["PYTHON_COMMAND"]))\r
         self.InitPreBuild()\r
         self.InitPostBuild()\r
         if self.Prebuild:\r
@@ -1380,7 +1380,7 @@ class Build():
                 LaunchCommand(["GenFw", "--address", str(BaseAddress), "-r", ModuleOutputImage], ModuleInfo.OutputDir)\r
                 LaunchCommand(["GenFw", "--address", str(BaseAddress), "-r", ModuleDebugImage], ModuleInfo.DebugDir)\r
             #\r
-            # Collect funtion address from Map file\r
+            # Collect function address from Map file\r
             #\r
             ImageMapTable = ModuleOutputImage.replace('.efi', '.map')\r
             FunctionList = []\r
@@ -1409,11 +1409,11 @@ class Build():
             # Add general information.\r
             #\r
             if ModeIsSmm:\r
-                MapBuffer.write('\n\n%s (Fixed SMRAM Offset,   BaseAddress=0x%010X,  EntryPoint=0x%010X)\n' % (ModuleName, BaseAddress, BaseAddress + ModuleInfo.Image.EntryPoint))\r
+                MapBuffer.append('\n\n%s (Fixed SMRAM Offset,   BaseAddress=0x%010X,  EntryPoint=0x%010X)\n' % (ModuleName, BaseAddress, BaseAddress + ModuleInfo.Image.EntryPoint))\r
             elif AddrIsOffset:\r
-                MapBuffer.write('\n\n%s (Fixed Memory Offset,  BaseAddress=-0x%010X, EntryPoint=-0x%010X)\n' % (ModuleName, 0 - BaseAddress, 0 - (BaseAddress + ModuleInfo.Image.EntryPoint)))\r
+                MapBuffer.append('\n\n%s (Fixed Memory Offset,  BaseAddress=-0x%010X, EntryPoint=-0x%010X)\n' % (ModuleName, 0 - BaseAddress, 0 - (BaseAddress + ModuleInfo.Image.EntryPoint)))\r
             else:\r
-                MapBuffer.write('\n\n%s (Fixed Memory Address, BaseAddress=0x%010X,  EntryPoint=0x%010X)\n' % (ModuleName, BaseAddress, BaseAddress + ModuleInfo.Image.EntryPoint))\r
+                MapBuffer.append('\n\n%s (Fixed Memory Address, BaseAddress=0x%010X,  EntryPoint=0x%010X)\n' % (ModuleName, BaseAddress, BaseAddress + ModuleInfo.Image.EntryPoint))\r
             #\r
             # Add guid and general seciton section.\r
             #\r
@@ -1425,21 +1425,21 @@ class Build():
                 elif SectionHeader[0] in ['.data', '.sdata']:\r
                     DataSectionAddress = SectionHeader[1]\r
             if AddrIsOffset:\r
-                MapBuffer.write('(GUID=%s, .textbaseaddress=-0x%010X, .databaseaddress=-0x%010X)\n' % (ModuleInfo.Guid, 0 - (BaseAddress + TextSectionAddress), 0 - (BaseAddress + DataSectionAddress)))\r
+                MapBuffer.append('(GUID=%s, .textbaseaddress=-0x%010X, .databaseaddress=-0x%010X)\n' % (ModuleInfo.Guid, 0 - (BaseAddress + TextSectionAddress), 0 - (BaseAddress + DataSectionAddress)))\r
             else:\r
-                MapBuffer.write('(GUID=%s, .textbaseaddress=0x%010X, .databaseaddress=0x%010X)\n' % (ModuleInfo.Guid, BaseAddress + TextSectionAddress, BaseAddress + DataSectionAddress))\r
+                MapBuffer.append('(GUID=%s, .textbaseaddress=0x%010X, .databaseaddress=0x%010X)\n' % (ModuleInfo.Guid, BaseAddress + TextSectionAddress, BaseAddress + DataSectionAddress))\r
             #\r
             # Add debug image full path.\r
             #\r
-            MapBuffer.write('(IMAGE=%s)\n\n' % (ModuleDebugImage))\r
+            MapBuffer.append('(IMAGE=%s)\n\n' % (ModuleDebugImage))\r
             #\r
-            # Add funtion address\r
+            # Add function address\r
             #\r
             for Function in FunctionList:\r
                 if AddrIsOffset:\r
-                    MapBuffer.write('  -0x%010X    %s\n' % (0 - (BaseAddress + Function[1]), Function[0]))\r
+                    MapBuffer.append('  -0x%010X    %s\n' % (0 - (BaseAddress + Function[1]), Function[0]))\r
                 else:\r
-                    MapBuffer.write('  0x%010X    %s\n' % (BaseAddress + Function[1], Function[0]))\r
+                    MapBuffer.append('  0x%010X    %s\n' % (BaseAddress + Function[1], Function[0]))\r
             ImageMap.close()\r
 \r
             #\r
@@ -1474,7 +1474,7 @@ class Build():
                         GuidString = MatchGuid.group()\r
                         if GuidString.upper() in ModuleList:\r
                             Line = Line.replace(GuidString, ModuleList[GuidString.upper()].Name)\r
-                    MapBuffer.write(Line)\r
+                    MapBuffer.append(Line)\r
                     #\r
                     # Add the debug image full path.\r
                     #\r
@@ -1482,7 +1482,7 @@ class Build():
                     if MatchGuid is not None:\r
                         GuidString = MatchGuid.group().split("=")[1]\r
                         if GuidString.upper() in ModuleList:\r
-                            MapBuffer.write('(IMAGE=%s)\n' % (os.path.join(ModuleList[GuidString.upper()].DebugDir, ModuleList[GuidString.upper()].Name + '.efi')))\r
+                            MapBuffer.append('(IMAGE=%s)\n' % (os.path.join(ModuleList[GuidString.upper()].DebugDir, ModuleList[GuidString.upper()].Name + '.efi')))\r
 \r
                 FvMap.close()\r
 \r
@@ -1598,11 +1598,11 @@ class Build():
                 if ReturnValue != 0:\r
                     EdkLogger.error("build", PARAMETER_INVALID, "Patch PCD value failed", ExtraData=ErrorInfo)\r
 \r
-        MapBuffer.write('PEI_CODE_PAGE_NUMBER      = 0x%x\n' % (PeiSize // 0x1000))\r
-        MapBuffer.write('BOOT_CODE_PAGE_NUMBER     = 0x%x\n' % (BtSize // 0x1000))\r
-        MapBuffer.write('RUNTIME_CODE_PAGE_NUMBER  = 0x%x\n' % (RtSize // 0x1000))\r
+        MapBuffer.append('PEI_CODE_PAGE_NUMBER      = 0x%x\n' % (PeiSize // 0x1000))\r
+        MapBuffer.append('BOOT_CODE_PAGE_NUMBER     = 0x%x\n' % (BtSize // 0x1000))\r
+        MapBuffer.append('RUNTIME_CODE_PAGE_NUMBER  = 0x%x\n' % (RtSize // 0x1000))\r
         if len (SmmModuleList) > 0:\r
-            MapBuffer.write('SMM_CODE_PAGE_NUMBER      = 0x%x\n' % (SmmSize // 0x1000))\r
+            MapBuffer.append('SMM_CODE_PAGE_NUMBER      = 0x%x\n' % (SmmSize // 0x1000))\r
 \r
         PeiBaseAddr = TopMemoryAddress - RtSize - BtSize\r
         BtBaseAddr  = TopMemoryAddress - RtSize\r
@@ -1612,7 +1612,7 @@ class Build():
         self._RebaseModule (MapBuffer, BtBaseAddr, BtModuleList, TopMemoryAddress == 0)\r
         self._RebaseModule (MapBuffer, RtBaseAddr, RtModuleList, TopMemoryAddress == 0)\r
         self._RebaseModule (MapBuffer, 0x1000, SmmModuleList, AddrIsOffset=False, ModeIsSmm=True)\r
-        MapBuffer.write('\n\n')\r
+        MapBuffer.append('\n\n')\r
         sys.stdout.write ("\n")\r
         sys.stdout.flush()\r
 \r
@@ -1626,8 +1626,7 @@ class Build():
         #\r
         # Save address map into MAP file.\r
         #\r
-        SaveFileOnChange(MapFilePath, MapBuffer.getvalue(), False)\r
-        MapBuffer.close()\r
+        SaveFileOnChange(MapFilePath, ''.join(MapBuffer), False)\r
         if self.LoadFixAddress != 0:\r
             sys.stdout.write ("\nLoad Module At Fix Address Map file can be found at %s\n" % (MapFilePath))\r
         sys.stdout.flush()\r
@@ -1702,7 +1701,7 @@ class Build():
                             if not Ma.IsLibrary:\r
                                 ModuleList[Ma.Guid.upper()] = Ma\r
 \r
-                    MapBuffer = BytesIO('')\r
+                    MapBuffer = []\r
                     if self.LoadFixAddress != 0:\r
                         #\r
                         # Rebase module to the preferred memory address before GenFds\r
@@ -1860,7 +1859,7 @@ class Build():
                             if not Ma.IsLibrary:\r
                                 ModuleList[Ma.Guid.upper()] = Ma\r
 \r
-                    MapBuffer = BytesIO('')\r
+                    MapBuffer = []\r
                     if self.LoadFixAddress != 0:\r
                         #\r
                         # Rebase module to the preferred memory address before GenFds\r
@@ -2041,7 +2040,7 @@ class Build():
                     #\r
                     # Rebase module to the preferred memory address before GenFds\r
                     #\r
-                    MapBuffer = BytesIO('')\r
+                    MapBuffer = []\r
                     if self.LoadFixAddress != 0:\r
                         self._CollectModuleMapBuffer(MapBuffer, ModuleList)\r
 \r