]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/build/build.py
Sync EDKII BaseTools to BaseTools project r1928
[mirror_edk2.git] / BaseTools / Source / Python / build / build.py
index e3a3dd9f3fc3368f3e5d726f51fe588b3111f27a..61293080117cae0862a581ea67c43f7ec9aa438e 100644 (file)
@@ -1090,9 +1090,10 @@ class Build():
 \r
     ## Collect MAP information of all FVs\r
     #\r
-    def _CollectFvMapBuffer (self, MapBuffer, Wa):\r
+    def _CollectFvMapBuffer (self, MapBuffer, Wa, ModuleList):\r
         if self.Fdf != '':\r
             # First get the XIP base address for FV map file.\r
+            GuidPattern = re.compile("[-a-fA-F0-9]+")\r
             for FvName in Wa.FdfProfile.FvDict.keys():\r
                 FvMapBuffer = os.path.join(Wa.FvDir, FvName + '.Fv.map')\r
                 if not os.path.exists(FvMapBuffer):\r
@@ -1103,7 +1104,16 @@ class Build():
                 FvMap.readline()\r
                 FvMap.readline()\r
                 FvMap.readline()\r
-                MapBuffer.write(FvMap.read())\r
+                for Line in FvMap:\r
+                    MatchGuid = GuidPattern.match(Line)\r
+                    if MatchGuid != None:\r
+                        #\r
+                        # Replace GUID with module name\r
+                        #\r
+                        GuidString = MatchGuid.group()\r
+                        if GuidString.upper() in ModuleList:\r
+                            Line = Line.replace(GuidString, ModuleList[GuidString.upper()].Name)\r
+                    MapBuffer.write('%s' % (Line))\r
                 FvMap.close()\r
 \r
     ## Collect MAP information of all modules\r
@@ -1124,7 +1134,8 @@ class Build():
         IsIpfPlatform = False\r
         if 'IPF' in self.ArchList:\r
             IsIpfPlatform = True\r
-        for Module in ModuleList:\r
+        for ModuleGuid in ModuleList:\r
+            Module = ModuleList[ModuleGuid]\r
             GlobalData.gProcessingFile = "%s [%s, %s, %s]" % (Module.MetaFile, Module.Arch, Module.ToolChain, Module.BuildTarget)\r
             \r
             OutputImageFile = ''\r
@@ -1259,7 +1270,8 @@ class Build():
         #\r
         SaveFileOnChange(MapFilePath, MapBuffer.getvalue(), False)\r
         MapBuffer.close()\r
-        sys.stdout.write ("\nLoad Module At Fix Address Map file saved to %s\n" %(MapFilePath))
+        if self.LoadFixAddress != 0:
+            sys.stdout.write ("\nLoad Module At Fix Address Map file saved to %s\n" %(MapFilePath))
         sys.stdout.flush()
 \r
     ## Build active platform for different build targets and different tool chains\r
@@ -1286,7 +1298,7 @@ class Build():
                 self._Build(self.Target, Wa)\r
                 \r
                 # Create MAP file when Load Fix Address is enabled.\r
-                if self.Target in ["", "all", "fds"] and self.LoadFixAddress != 0:\r
+                if self.Target in ["", "all", "fds"]:\r
                     for Arch in self.ArchList:\r
                         #\r
                         # Check whether the set fix address is above 4G for 32bit image.\r
@@ -1296,19 +1308,20 @@ class Build():
                     #\r
                     # Get Module List\r
                     #\r
-                    ModuleList = []\r
+                    ModuleList = {}\r
                     for Pa in Wa.AutoGenObjectList:\r
                         for Ma in Pa.ModuleAutoGenList:\r
                             if Ma == None:\r
                                 continue\r
                             if not Ma.IsLibrary:\r
-                                ModuleList.append (Ma)\r
+                                ModuleList[Ma.Guid.upper()] = Ma\r
 \r
                     MapBuffer = StringIO('')\r
-                    #\r
-                    # Rebase module to the preferred memory address before GenFds\r
-                    #\r
-                    self._CollectModuleMapBuffer(MapBuffer, ModuleList)\r
+                    if self.LoadFixAddress != 0:\r
+                        #\r
+                        # Rebase module to the preferred memory address before GenFds\r
+                        #\r
+                        self._CollectModuleMapBuffer(MapBuffer, ModuleList)\r
                     if self.Fdf != '':\r
                         #\r
                         # create FDS again for the updated EFI image\r
@@ -1317,7 +1330,7 @@ class Build():
                         #\r
                         # Create MAP file for all platform FVs after GenFds.\r
                         #\r
-                        self._CollectFvMapBuffer(MapBuffer, Wa)\r
+                        self._CollectFvMapBuffer(MapBuffer, Wa, ModuleList)\r
                     #\r
                     # Save MAP buffer into MAP file.\r
                     #\r
@@ -1367,7 +1380,7 @@ class Build():
                                 ExtraData=self.ModuleFile\r
                                 )\r
                 # Create MAP file when Load Fix Address is enabled.\r
-                if self.LoadFixAddress != 0 and self.Target == "fds" and self.Fdf != '':\r
+                if self.Target == "fds" and self.Fdf != '':\r
                     for Arch in self.ArchList:\r
                         #\r
                         # Check whether the set fix address is above 4G for 32bit image.\r
@@ -1377,27 +1390,28 @@ class Build():
                     #\r
                     # Get Module List\r
                     #\r
-                    ModuleList = []\r
+                    ModuleList = {}\r
                     for Pa in Wa.AutoGenObjectList:\r
                         for Ma in Pa.ModuleAutoGenList:\r
                             if Ma == None:\r
                                 continue\r
                             if not Ma.IsLibrary:\r
-                                ModuleList.append (Ma)\r
+                                ModuleList[Ma.Guid.upper()] = Ma\r
 \r
                     MapBuffer = StringIO('')\r
-                    #\r
-                    # Rebase module to the preferred memory address before GenFds\r
-                    #\r
-                    self._CollectModuleMapBuffer(MapBuffer, ModuleList)\r
-                    #\r
-                    # create FDS again for the updated EFI image\r
-                    #\r
-                    self._Build("fds", Wa)\r
+                    if self.LoadFixAddress != 0:\r
+                        #\r
+                        # Rebase module to the preferred memory address before GenFds\r
+                        #\r
+                        self._CollectModuleMapBuffer(MapBuffer, ModuleList)\r
+                        #\r
+                        # create FDS again for the updated EFI image\r
+                        #\r
+                        self._Build("fds", Wa)\r
                     #\r
                     # Create MAP file for all platform FVs after GenFds.\r
                     #\r
-                    self._CollectFvMapBuffer(MapBuffer, Wa)\r
+                    self._CollectFvMapBuffer(MapBuffer, Wa, ModuleList)\r
                     #\r
                     # Save MAP buffer into MAP file.\r
                     #\r
@@ -1483,7 +1497,7 @@ class Build():
                     EdkLogger.error("build", BUILD_ERROR, "Failed to build module", ExtraData=GlobalData.gBuildingModule)\r
 \r
                 # Create MAP file when Load Fix Address is enabled.\r
-                if self.Target in ["", "all", "fds"] and self.LoadFixAddress != 0:\r
+                if self.Target in ["", "all", "fds"]:\r
                     for Arch in self.ArchList:\r
                         #\r
                         # Check whether the set fix address is above 4G for 32bit image.\r
@@ -1493,30 +1507,31 @@ class Build():
                     #\r
                     # Get Module List\r
                     #\r
-                    ModuleList = []\r
+                    ModuleList = {}\r
                     for Pa in Wa.AutoGenObjectList:\r
                         for Ma in Pa.ModuleAutoGenList:\r
                             if Ma == None:\r
                                 continue\r
                             if not Ma.IsLibrary:\r
-                                ModuleList.append (Ma)\r
+                                ModuleList[Ma.Guid.upper()] = Ma\r
                     #\r
                     # Rebase module to the preferred memory address before GenFds\r
                     #\r
                     MapBuffer = StringIO('')\r
-                    self._CollectModuleMapBuffer(MapBuffer, ModuleList)\r
+                    if self.LoadFixAddress != 0:\r
+                        self._CollectModuleMapBuffer(MapBuffer, ModuleList)\r
 \r
                 # Generate FD image if there's a FDF file found\r
                 if self.Fdf != '' and self.Target in ["", "all", "fds"]:\r
                     LaunchCommand(Wa.BuildCommand + ["fds"], Wa.MakeFileDir)\r
 \r
                 # Create MAP file for all platform FV after GenFds\r
-                if self.Target in ["", "all", "fds"] and self.LoadFixAddress != 0:\r
+                if self.Target in ["", "all", "fds"]:\r
                     if self.Fdf != '':\r
                         #\r
                         # Create MAP file for all platform FVs after GenFds.\r
                         #\r
-                        self._CollectFvMapBuffer(MapBuffer, Wa)\r
+                        self._CollectFvMapBuffer(MapBuffer, Wa, ModuleList)\r
                     #\r
                     # Save MAP buffer into MAP file.\r
                     #\r