BaseTools/Source/Python/build/build.py:
authorjljusten <jljusten@7335b38e-4728-0410-8992-fb3ffe349368>
Thu, 29 Nov 2007 17:52:22 +0000 (17:52 +0000)
committerjljusten <jljusten@7335b38e-4728-0410-8992-fb3ffe349368>
Thu, 29 Nov 2007 17:52:22 +0000 (17:52 +0000)
  Generate GuidedSectionTools.txt as a sibling to the
  firmware volumes files.  This file will concisely list
  which tools can be used to decode guided sections
  within the firmware volume.

git-svn-id: https://buildtools.tianocore.org/svn/buildtools/trunk/BaseTools@888 7335b38e-4728-0410-8992-fb3ffe349368

Source/Python/build/build.py

index e987035..dbcb182 100644 (file)
@@ -942,6 +942,61 @@ class Build():
                 if self.Fdf != '' and self.Target in ["", "all", "fds"]:\r
                     LaunchCommand(Pa.GetBuildCommand() + ("fds",), Pa.GetMakeFileDir())\r
 \r
+    ## Generate GuidedSectionTools.txt in the FV directories.\r
+    #\r
+    def CreateGuidedSectionToolsFile(self):\r
+        for Dsc in self.Ewb.DscDatabase.keys():\r
+            for Arch in self.ArchList:\r
+                for BuildTarget in self.BuildTargetList:\r
+                    for ToolChain in self.ToolChainList:\r
+                        FvDir = os.path.join(\r
+                                    self.WorkspaceDir,\r
+                                    self.Ewb.Build[Arch].PlatformDatabase[Dsc].OutputDirectory,\r
+                                    '_'.join((BuildTarget, ToolChain)),\r
+                                    'FV'\r
+                                    )\r
+                        # Build up the list of supported architectures for this build\r
+                        prefix = '%s_%s_%s_' % (BuildTarget, ToolChain, Arch)\r
+\r
+                        # Look through the tool definitions for GUIDed tools\r
+                        guidAttribs = []\r
+                        for (attrib, value) in self.ToolDef.ToolsDefTxtDictionary.iteritems():\r
+                            if attrib.upper().endswith('_GUID'):\r
+                                split = attrib.split('_')\r
+                                thisPrefix = '_'.join(split[0:3]) + '_'\r
+                                if thisPrefix == prefix:\r
+                                    guid = self.ToolDef.ToolsDefTxtDictionary[attrib]\r
+                                    guid = guid.lower()\r
+                                    toolName = split[3]\r
+                                    path = '_'.join(split[0:4]) + '_PATH'\r
+                                    path = self.ToolDef.ToolsDefTxtDictionary[path]\r
+                                    path = self.GetFullPathOfTool(path)\r
+                                    guidAttribs.append((guid, toolName, path))\r
+\r
+                        # Write out GuidedSecTools.txt\r
+                        toolsFile = os.path.join(FvDir, 'GuidedSectionTools.txt')\r
+                        toolsFile = open(toolsFile, 'wt')\r
+                        for guidedSectionTool in guidAttribs:\r
+                            print >> toolsFile, ' '.join(guidedSectionTool)\r
+                        toolsFile.close()\r
+\r
+    ## Returns the full path of the tool.\r
+    #\r
+    def GetFullPathOfTool (self, tool):\r
+        if os.path.exists(tool):\r
+            return os.path.realpath(tool)\r
+        else:\r
+            # We need to search for the tool using the\r
+            # PATH environment variable.\r
+            for dirInPath in os.environ['PATH'].split(os.pathsep):\r
+                foundPath = os.path.join(dirInPath, tool)\r
+                if os.path.exists(foundPath):\r
+                    return os.path.realpath(foundPath)\r
+\r
+        # If the tool was not found in the path then we just return\r
+        # the input tool.\r
+        return tool\r
+\r
     ## Launch the module or platform build\r
     #\r
     def Launch(self):\r
@@ -951,6 +1006,7 @@ class Build():
                 self._BuildPlatform()\r
             else:\r
                 self._MultiThreadBuildPlatform()\r
+            self.CreateGuidedSectionToolsFile()\r
         else:\r
             self.SpawnMode = False\r
             self._BuildModule()\r