]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/build/build.py
BaseTools: Rationalise makefile generation
[mirror_edk2.git] / BaseTools / Source / Python / build / build.py
index 1e47e382cba94dc6fba7d8ecad2bc924b02cea1d..d841fefdc502b1ff9e494d6e64aa8b2ae7aa6751 100755 (executable)
@@ -4,6 +4,7 @@
 #  Copyright (c) 2014, Hewlett-Packard Development Company, L.P.<BR>\r
 #  Copyright (c) 2007 - 2020, Intel Corporation. All rights reserved.<BR>\r
 #  Copyright (c) 2018, Hewlett Packard Enterprise Development, L.P.<BR>\r
+#  Copyright (c) 2020, ARM Limited. All rights reserved.<BR>\r
 #\r
 #  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 #\r
@@ -736,6 +737,7 @@ class Build():
         self.AutoGenTime    = 0\r
         self.MakeTime       = 0\r
         self.GenFdsTime     = 0\r
+        self.MakeFileName   = ""\r
         TargetObj = TargetTxtDict()\r
         ToolDefObj = ToolDefDict((os.path.join(os.getenv("WORKSPACE"),"Conf")))\r
         self.TargetTxt = TargetObj.Target\r
@@ -1251,8 +1253,6 @@ class Build():
                                 (AutoGenObject.BuildTarget, AutoGenObject.ToolChain, AutoGenObject.Arch),\r
                             ExtraData=str(AutoGenObject))\r
 \r
-        makefile = GenMake.BuildFile(AutoGenObject)._FILE_NAME_[GenMake.gMakeType]\r
-\r
         # run\r
         if Target == 'run':\r
             return True\r
@@ -1278,7 +1278,7 @@ class Build():
                 if not Lib.IsBinaryModule:\r
                     DirList.append((os.path.join(AutoGenObject.BuildDir, Lib.BuildDir),Lib))\r
             for Lib, LibAutoGen in DirList:\r
-                NewBuildCommand = BuildCommand + ['-f', os.path.normpath(os.path.join(Lib, makefile)), 'pbuild']\r
+                NewBuildCommand = BuildCommand + ['-f', os.path.normpath(os.path.join(Lib, self.MakeFileName)), 'pbuild']\r
                 LaunchCommand(NewBuildCommand, AutoGenObject.MakeFileDir,LibAutoGen)\r
             return True\r
 \r
@@ -1289,7 +1289,7 @@ class Build():
                 if not Lib.IsBinaryModule:\r
                     DirList.append((os.path.join(AutoGenObject.BuildDir, Lib.BuildDir),Lib))\r
             for Lib, LibAutoGen in DirList:\r
-                NewBuildCommand = BuildCommand + ['-f', os.path.normpath(os.path.join(Lib, makefile)), 'pbuild']\r
+                NewBuildCommand = BuildCommand + ['-f', os.path.normpath(os.path.join(Lib, self.MakeFileName)), 'pbuild']\r
                 LaunchCommand(NewBuildCommand, AutoGenObject.MakeFileDir,LibAutoGen)\r
 \r
             DirList = []\r
@@ -1297,7 +1297,7 @@ class Build():
                 if not ModuleAutoGen.IsBinaryModule:\r
                     DirList.append((os.path.join(AutoGenObject.BuildDir, ModuleAutoGen.BuildDir),ModuleAutoGen))\r
             for Mod,ModAutoGen in DirList:\r
-                NewBuildCommand = BuildCommand + ['-f', os.path.normpath(os.path.join(Mod, makefile)), 'pbuild']\r
+                NewBuildCommand = BuildCommand + ['-f', os.path.normpath(os.path.join(Mod, self.MakeFileName)), 'pbuild']\r
                 LaunchCommand(NewBuildCommand, AutoGenObject.MakeFileDir,ModAutoGen)\r
             self.CreateAsBuiltInf()\r
             if GlobalData.gBinCacheDest:\r
@@ -1312,7 +1312,7 @@ class Build():
         # cleanlib\r
         if Target == 'cleanlib':\r
             for Lib in AutoGenObject.LibraryBuildDirectoryList:\r
-                LibMakefile = os.path.normpath(os.path.join(Lib, makefile))\r
+                LibMakefile = os.path.normpath(os.path.join(Lib, self.MakeFileName))\r
                 if os.path.exists(LibMakefile):\r
                     NewBuildCommand = BuildCommand + ['-f', LibMakefile, 'cleanall']\r
                     LaunchCommand(NewBuildCommand, AutoGenObject.MakeFileDir)\r
@@ -1321,12 +1321,12 @@ class Build():
         # clean\r
         if Target == 'clean':\r
             for Mod in AutoGenObject.ModuleBuildDirectoryList:\r
-                ModMakefile = os.path.normpath(os.path.join(Mod, makefile))\r
+                ModMakefile = os.path.normpath(os.path.join(Mod, self.MakeFileName))\r
                 if os.path.exists(ModMakefile):\r
                     NewBuildCommand = BuildCommand + ['-f', ModMakefile, 'cleanall']\r
                     LaunchCommand(NewBuildCommand, AutoGenObject.MakeFileDir)\r
             for Lib in AutoGenObject.LibraryBuildDirectoryList:\r
-                LibMakefile = os.path.normpath(os.path.join(Lib, makefile))\r
+                LibMakefile = os.path.normpath(os.path.join(Lib, self.MakeFileName))\r
                 if os.path.exists(LibMakefile):\r
                     NewBuildCommand = BuildCommand + ['-f', LibMakefile, 'cleanall']\r
                     LaunchCommand(NewBuildCommand, AutoGenObject.MakeFileDir)\r
@@ -2040,10 +2040,10 @@ class Build():
             ModuleBuildDirectoryList = data_pipe.Get("ModuleBuildDirectoryList")\r
 \r
             for m_build_dir in LibraryBuildDirectoryList:\r
-                if not os.path.exists(os.path.join(m_build_dir,GenMake.BuildFile._FILE_NAME_[GenMake.gMakeType])):\r
+                if not os.path.exists(os.path.join(m_build_dir,self.MakeFileName)):\r
                     return None\r
             for m_build_dir in ModuleBuildDirectoryList:\r
-                if not os.path.exists(os.path.join(m_build_dir,GenMake.BuildFile._FILE_NAME_[GenMake.gMakeType])):\r
+                if not os.path.exists(os.path.join(m_build_dir,self.MakeFileName)):\r
                     return None\r
             Wa = WorkSpaceInfo(\r
                 workspacedir,active_p,target,toolchain,archlist\r
@@ -2128,6 +2128,11 @@ class Build():
             Pa.DataPipe.DataContainer = {"Workspace_timestamp": Wa._SrcTimeStamp}\r
             Pa.DataPipe.DataContainer = {"CommandTarget": self.Target}\r
             Pa.CreateLibModuelDirs()\r
+            # Fetch the MakeFileName.\r
+            self.MakeFileName = Pa.MakeFileName\r
+            if not self.MakeFileName:\r
+                self.MakeFileName = Pa.MakeFile\r
+\r
             Pa.DataPipe.DataContainer = {"LibraryBuildDirectoryList":Pa.LibraryBuildDirectoryList}\r
             Pa.DataPipe.DataContainer = {"ModuleBuildDirectoryList":Pa.ModuleBuildDirectoryList}\r
             Pa.DataPipe.DataContainer = {"FdsCommandDict": Wa.GenFdsCommandDict}\r