]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: Rationalise makefile generation
authorPierre Gondois <pierre.gondois@arm.com>
Mon, 10 Feb 2020 10:49:07 +0000 (18:49 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Wed, 12 Feb 2020 02:34:44 +0000 (02:34 +0000)
The GenMake.py script tests the platform environment
to determine the type of makefile that needs to be
generated. If a Windows build host is detected, the
makefile generated is of Nmake type. Otherwise a
GNUmake type is generated.

Furthermore, the <TARGET>_<TAGNAME>_<ARCH>_MAKE_PATH
option in tools_def.template defines the make tool
to use.
E.g.: for VS2017 this is configured to use Nmake, cf.
*_VS2017_*_MAKE_PATH = DEF(VS2017_BIN_HOST)\nmake.exe
while for GCC5 it is setup to use GNU make.
*_GCC5_*_MAKE_PATH = DEF(GCC_HOST_PREFIX)make

This prevents using the GCC compiler toolchain on a
Windows build host.

To address this issue this patch introduces 2 factors
to determine the generated makefile output.
  1. Platform -> to determine shell commands used
                 in makefile.
  2. MakeTool -> to determine the type of makefile
                 that needs to be generated.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
BaseTools/Source/Python/AutoGen/GenMake.py
BaseTools/Source/Python/AutoGen/IncludesAutoGen.py
BaseTools/Source/Python/AutoGen/PlatformAutoGen.py
BaseTools/Source/Python/build/build.py

index 9ae09c47caf8a674168de1ef4667f17af4f06a73..f5d15c40ad3196e5ea56f375bec12c38d313c9ee 100755 (executable)
@@ -2,6 +2,7 @@
 # Create makefile for MS nmake and GNU make\r
 #\r
 # Copyright (c) 2007 - 2020, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2020, ARM Limited. All rights reserved.<BR>\r
 # SPDX-License-Identifier: BSD-2-Clause-Patent\r
 #\r
 \r
@@ -52,13 +53,10 @@ gIncludeMacroConversion = {
   "EFI_PPI_DEPENDENCY"              :   gPpiDefinition,\r
 }\r
 \r
-## default makefile type\r
-gMakeType = ""\r
-if sys.platform == "win32":\r
-    gMakeType = "nmake"\r
-else:\r
-    gMakeType = "gmake"\r
-\r
+NMAKE_FILETYPE = "nmake"\r
+GMAKE_FILETYPE = "gmake"\r
+WIN32_PLATFORM = "win32"\r
+POSIX_PLATFORM = "posix"\r
 \r
 ## BuildFile class\r
 #\r
@@ -73,10 +71,17 @@ class BuildFile(object):
 \r
     ## default file name for each type of build file\r
     _FILE_NAME_ = {\r
-        "nmake" :   "Makefile",\r
-        "gmake" :   "GNUmakefile"\r
+        NMAKE_FILETYPE :   "Makefile",\r
+        GMAKE_FILETYPE :   "GNUmakefile"\r
     }\r
 \r
+    # Get Makefile name.\r
+    def getMakefileName(self):\r
+        if not self._FileType:\r
+            return self._DEFAULT_FILE_NAME_\r
+        else:\r
+            return self._FILE_NAME_[self._FileType]\r
+\r
     ## Fixed header string for makefile\r
     _MAKEFILE_HEADER = '''#\r
 # DO NOT EDIT\r
@@ -94,8 +99,8 @@ class BuildFile(object):
 \r
     ## Header string for each type of build file\r
     _FILE_HEADER_ = {\r
-        "nmake" :   _MAKEFILE_HEADER % _FILE_NAME_["nmake"],\r
-        "gmake" :   _MAKEFILE_HEADER % _FILE_NAME_["gmake"]\r
+        NMAKE_FILETYPE :   _MAKEFILE_HEADER % _FILE_NAME_[NMAKE_FILETYPE],\r
+        GMAKE_FILETYPE :   _MAKEFILE_HEADER % _FILE_NAME_[GMAKE_FILETYPE]\r
     }\r
 \r
     ## shell commands which can be used in build file in the form of macro\r
@@ -106,7 +111,7 @@ class BuildFile(object):
     #   $(RD)     remove dir command\r
     #\r
     _SHELL_CMD_ = {\r
-        "nmake" : {\r
+        WIN32_PLATFORM : {\r
             "CP"    :   "copy /y",\r
             "MV"    :   "move /y",\r
             "RM"    :   "del /f /q",\r
@@ -114,7 +119,7 @@ class BuildFile(object):
             "RD"    :   "rmdir /s /q",\r
         },\r
 \r
-        "gmake" : {\r
+        POSIX_PLATFORM : {\r
             "CP"    :   "cp -f",\r
             "MV"    :   "mv -f",\r
             "RM"    :   "rm -f",\r
@@ -125,40 +130,40 @@ class BuildFile(object):
 \r
     ## directory separator\r
     _SEP_ = {\r
-        "nmake" :   "\\",\r
-        "gmake" :   "/"\r
+        WIN32_PLATFORM :   "\\",\r
+        POSIX_PLATFORM :   "/"\r
     }\r
 \r
     ## directory creation template\r
     _MD_TEMPLATE_ = {\r
-        "nmake" :   'if not exist %(dir)s $(MD) %(dir)s',\r
-        "gmake" :   "$(MD) %(dir)s"\r
+        WIN32_PLATFORM :   'if not exist %(dir)s $(MD) %(dir)s',\r
+        POSIX_PLATFORM :   "$(MD) %(dir)s"\r
     }\r
 \r
     ## directory removal template\r
     _RD_TEMPLATE_ = {\r
-        "nmake" :   'if exist %(dir)s $(RD) %(dir)s',\r
-        "gmake" :   "$(RD) %(dir)s"\r
+        WIN32_PLATFORM :   'if exist %(dir)s $(RD) %(dir)s',\r
+        POSIX_PLATFORM :   "$(RD) %(dir)s"\r
     }\r
     ## cp if exist\r
     _CP_TEMPLATE_ = {\r
-        "nmake" :   'if exist %(Src)s $(CP) %(Src)s %(Dst)s',\r
-        "gmake" :   "test -f %(Src)s && $(CP) %(Src)s %(Dst)s"\r
+        WIN32_PLATFORM :   'if exist %(Src)s $(CP) %(Src)s %(Dst)s',\r
+        POSIX_PLATFORM :   "test -f %(Src)s && $(CP) %(Src)s %(Dst)s"\r
     }\r
 \r
     _CD_TEMPLATE_ = {\r
-        "nmake" :   'if exist %(dir)s cd %(dir)s',\r
-        "gmake" :   "test -e %(dir)s && cd %(dir)s"\r
+        WIN32_PLATFORM :   'if exist %(dir)s cd %(dir)s',\r
+        POSIX_PLATFORM :   "test -e %(dir)s && cd %(dir)s"\r
     }\r
 \r
     _MAKE_TEMPLATE_ = {\r
-        "nmake" :   'if exist %(file)s "$(MAKE)" $(MAKE_FLAGS) -f %(file)s',\r
-        "gmake" :   'test -e %(file)s && "$(MAKE)" $(MAKE_FLAGS) -f %(file)s'\r
+        WIN32_PLATFORM :   'if exist %(file)s "$(MAKE)" $(MAKE_FLAGS) -f %(file)s',\r
+        POSIX_PLATFORM :   'test -e %(file)s && "$(MAKE)" $(MAKE_FLAGS) -f %(file)s'\r
     }\r
 \r
     _INCLUDE_CMD_ = {\r
-        "nmake" :   '!INCLUDE',\r
-        "gmake" :   "include"\r
+        NMAKE_FILETYPE :   '!INCLUDE',\r
+        GMAKE_FILETYPE :   "include"\r
     }\r
 \r
     _INC_FLAG_ = {TAB_COMPILER_MSFT : "/I", "GCC" : "-I", "INTEL" : "-I", "RVCT" : "-I", "NASM" : "-I"}\r
@@ -169,22 +174,30 @@ class BuildFile(object):
     #\r
     def __init__(self, AutoGenObject):\r
         self._AutoGenObject = AutoGenObject\r
-        self._FileType = gMakeType\r
 \r
-    ## Create build file\r
+        MakePath = AutoGenObject.BuildOption.get('MAKE', {}).get('PATH')\r
+        if not MakePath:\r
+            self._FileType = ""\r
+        elif "nmake" in MakePath:\r
+            self._FileType = NMAKE_FILETYPE\r
+        else:\r
+            self._FileType = "gmake"\r
+\r
+        if sys.platform == "win32":\r
+            self._Platform = WIN32_PLATFORM\r
+        else:\r
+            self._Platform = POSIX_PLATFORM\r
+\r
+    ## Create build file.\r
     #\r
-    #   @param  FileType    Type of build file. Only nmake and gmake are supported now.\r
+    #  Only nmake and gmake are supported.\r
     #\r
-    #   @retval TRUE        The build file is created or re-created successfully\r
-    #   @retval FALSE       The build file exists and is the same as the one to be generated\r
+    #  @retval TRUE     The build file is created or re-created successfully.\r
+    #  @retval FALSE    The build file exists and is the same as the one to be generated.\r
     #\r
-    def Generate(self, FileType=gMakeType):\r
-        if FileType not in self._FILE_NAME_:\r
-            EdkLogger.error("build", PARAMETER_INVALID, "Invalid build type [%s]" % FileType,\r
-                            ExtraData="[%s]" % str(self._AutoGenObject))\r
-        self._FileType = FileType\r
+    def Generate(self):\r
         FileContent = self._TEMPLATE_.Replace(self._TemplateDict)\r
-        FileName = self._FILE_NAME_[FileType]\r
+        FileName = self.getMakefileName()\r
         if not os.path.exists(os.path.join(self._AutoGenObject.MakeFileDir, "deps.txt")):\r
             with open(os.path.join(self._AutoGenObject.MakeFileDir, "deps.txt"),"w+") as fd:\r
                 fd.write("")\r
@@ -203,7 +216,7 @@ class BuildFile(object):
     #   @retval     list        The directory creation command list\r
     #\r
     def GetCreateDirectoryCommand(self, DirList):\r
-        return [self._MD_TEMPLATE_[self._FileType] % {'dir':Dir} for Dir in DirList]\r
+        return [self._MD_TEMPLATE_[self._Platform] % {'dir':Dir} for Dir in DirList]\r
 \r
     ## Return a list of directory removal command string\r
     #\r
@@ -212,7 +225,7 @@ class BuildFile(object):
     #   @retval     list        The directory removal command list\r
     #\r
     def GetRemoveDirectoryCommand(self, DirList):\r
-        return [self._RD_TEMPLATE_[self._FileType] % {'dir':Dir} for Dir in DirList]\r
+        return [self._RD_TEMPLATE_[self._Platform] % {'dir':Dir} for Dir in DirList]\r
 \r
     def PlaceMacro(self, Path, MacroDefinitions=None):\r
         if Path.startswith("$("):\r
@@ -462,11 +475,8 @@ cleanlib:
     # Compose a dict object containing information used to do replacement in template\r
     @property\r
     def _TemplateDict(self):\r
-        if self._FileType not in self._SEP_:\r
-            EdkLogger.error("build", PARAMETER_INVALID, "Invalid Makefile type [%s]" % self._FileType,\r
-                            ExtraData="[%s]" % str(self._AutoGenObject))\r
         MyAgo = self._AutoGenObject\r
-        Separator = self._SEP_[self._FileType]\r
+        Separator = self._SEP_[self._Platform]\r
 \r
         # break build if no source files and binary files are found\r
         if len(MyAgo.SourceFileList) == 0 and len(MyAgo.BinaryFileList) == 0:\r
@@ -628,10 +638,10 @@ cleanlib:
 \r
         BcTargetList = []\r
 \r
-        MakefileName = self._FILE_NAME_[self._FileType]\r
+        MakefileName = self.getMakefileName()\r
         LibraryMakeCommandList = []\r
         for D in self.LibraryBuildDirectoryList:\r
-            Command = self._MAKE_TEMPLATE_[self._FileType] % {"file":os.path.join(D, MakefileName)}\r
+            Command = self._MAKE_TEMPLATE_[self._Platform] % {"file":os.path.join(D, MakefileName)}\r
             LibraryMakeCommandList.append(Command)\r
 \r
         package_rel_dir = MyAgo.SourceDir\r
@@ -683,8 +693,8 @@ cleanlib:
             "separator"                 : Separator,\r
             "module_tool_definitions"   : ToolsDef,\r
 \r
-            "shell_command_code"        : list(self._SHELL_CMD_[self._FileType].keys()),\r
-            "shell_command"             : list(self._SHELL_CMD_[self._FileType].values()),\r
+            "shell_command_code"        : list(self._SHELL_CMD_[self._Platform].keys()),\r
+            "shell_command"             : list(self._SHELL_CMD_[self._Platform].values()),\r
 \r
             "module_entry_point"        : ModuleEntryPoint,\r
             "image_entry_point"         : ImageEntryPoint,\r
@@ -721,7 +731,7 @@ cleanlib:
                         self.ResultFileList.append(Dst)\r
                     if '%s :' %(Dst) not in self.BuildTargetList:\r
                         self.BuildTargetList.append("%s : %s" %(Dst,Src))\r
-                        self.BuildTargetList.append('\t' + self._CP_TEMPLATE_[self._FileType] %{'Src': Src, 'Dst': Dst})\r
+                        self.BuildTargetList.append('\t' + self._CP_TEMPLATE_[self._Platform] %{'Src': Src, 'Dst': Dst})\r
 \r
             FfsCmdList = Cmd[0]\r
             for index, Str in enumerate(FfsCmdList):\r
@@ -1222,7 +1232,7 @@ ${BEGIN}\t-@${create_directory_command}\n${END}\
     # Compose a dict object containing information used to do replacement in template\r
     @property\r
     def _TemplateDict(self):\r
-        Separator = self._SEP_[self._FileType]\r
+        Separator = self._SEP_[self._Platform]\r
         MyAgo = self._AutoGenObject\r
         if self._FileType not in MyAgo.CustomMakefile:\r
             EdkLogger.error('build', OPTION_NOT_SUPPORTED, "No custom makefile for %s" % self._FileType,\r
@@ -1252,7 +1262,7 @@ ${BEGIN}\t-@${create_directory_command}\n${END}\
                     ToolsDef.append("%s_%s = %s" % (Tool, Attr, MyAgo.BuildOption[Tool][Attr]))\r
             ToolsDef.append("")\r
 \r
-        MakefileName = self._FILE_NAME_[self._FileType]\r
+        MakefileName = self.getMakefileName()\r
         MakefileTemplateDict = {\r
             "makefile_header"           : self._FILE_HEADER_[self._FileType],\r
             "makefile_path"             : os.path.join("$(MODULE_BUILD_DIR)", MakefileName),\r
@@ -1285,8 +1295,8 @@ ${BEGIN}\t-@${create_directory_command}\n${END}\
             "separator"                 : Separator,\r
             "module_tool_definitions"   : ToolsDef,\r
 \r
-            "shell_command_code"        : list(self._SHELL_CMD_[self._FileType].keys()),\r
-            "shell_command"             : list(self._SHELL_CMD_[self._FileType].values()),\r
+            "shell_command_code"        : list(self._SHELL_CMD_[self._Platform].keys()),\r
+            "shell_command"             : list(self._SHELL_CMD_[self._Platform].values()),\r
 \r
             "create_directory_command"  : self.GetCreateDirectoryCommand(self.IntermediateDirectoryList),\r
             "custom_makefile_content"   : CustomMakefile\r
@@ -1413,7 +1423,7 @@ cleanlib:
     # Compose a dict object containing information used to do replacement in template\r
     @property\r
     def _TemplateDict(self):\r
-        Separator = self._SEP_[self._FileType]\r
+        Separator = self._SEP_[self._Platform]\r
 \r
         MyAgo = self._AutoGenObject\r
         if "MAKE" not in MyAgo.ToolDefinition or "PATH" not in MyAgo.ToolDefinition["MAKE"]:\r
@@ -1424,13 +1434,13 @@ cleanlib:
         self.ModuleBuildDirectoryList = self.GetModuleBuildDirectoryList()\r
         self.LibraryBuildDirectoryList = self.GetLibraryBuildDirectoryList()\r
 \r
-        MakefileName = self._FILE_NAME_[self._FileType]\r
+        MakefileName = self.getMakefileName()\r
         LibraryMakefileList = []\r
         LibraryMakeCommandList = []\r
         for D in self.LibraryBuildDirectoryList:\r
             D = self.PlaceMacro(D, {"BUILD_DIR":MyAgo.BuildDir})\r
             Makefile = os.path.join(D, MakefileName)\r
-            Command = self._MAKE_TEMPLATE_[self._FileType] % {"file":Makefile}\r
+            Command = self._MAKE_TEMPLATE_[self._Platform] % {"file":Makefile}\r
             LibraryMakefileList.append(Makefile)\r
             LibraryMakeCommandList.append(Command)\r
         self.LibraryMakeCommandList = LibraryMakeCommandList\r
@@ -1440,7 +1450,7 @@ cleanlib:
         for D in self.ModuleBuildDirectoryList:\r
             D = self.PlaceMacro(D, {"BUILD_DIR":MyAgo.BuildDir})\r
             Makefile = os.path.join(D, MakefileName)\r
-            Command = self._MAKE_TEMPLATE_[self._FileType] % {"file":Makefile}\r
+            Command = self._MAKE_TEMPLATE_[self._Platform] % {"file":Makefile}\r
             ModuleMakefileList.append(Makefile)\r
             ModuleMakeCommandList.append(Command)\r
 \r
@@ -1460,8 +1470,8 @@ cleanlib:
 \r
             "toolchain_tag"             : MyAgo.ToolChain,\r
             "build_target"              : MyAgo.BuildTarget,\r
-            "shell_command_code"        : list(self._SHELL_CMD_[self._FileType].keys()),\r
-            "shell_command"             : list(self._SHELL_CMD_[self._FileType].values()),\r
+            "shell_command_code"        : list(self._SHELL_CMD_[self._Platform].keys()),\r
+            "shell_command"             : list(self._SHELL_CMD_[self._Platform].values()),\r
             "build_architecture_list"   : MyAgo.Arch,\r
             "architecture"              : MyAgo.Arch,\r
             "separator"                 : Separator,\r
@@ -1519,7 +1529,7 @@ class TopLevelMakefile(BuildFile):
     # Compose a dict object containing information used to do replacement in template\r
     @property\r
     def _TemplateDict(self):\r
-        Separator = self._SEP_[self._FileType]\r
+        Separator = self._SEP_[self._Platform]\r
 \r
         # any platform autogen object is ok because we just need common information\r
         MyAgo = self._AutoGenObject\r
@@ -1575,10 +1585,10 @@ class TopLevelMakefile(BuildFile):
             else:\r
                 ExtraOption += " --pcd " + pcdname + '=' + pcd[3]\r
 \r
-        MakefileName = self._FILE_NAME_[self._FileType]\r
+        MakefileName = self.getMakefileName()\r
         SubBuildCommandList = []\r
         for A in MyAgo.ArchList:\r
-            Command = self._MAKE_TEMPLATE_[self._FileType] % {"file":os.path.join("$(BUILD_DIR)", A, MakefileName)}\r
+            Command = self._MAKE_TEMPLATE_[self._Platform] % {"file":os.path.join("$(BUILD_DIR)", A, MakefileName)}\r
             SubBuildCommandList.append(Command)\r
 \r
         MakefileTemplateDict = {\r
@@ -1593,8 +1603,8 @@ class TopLevelMakefile(BuildFile):
 \r
             "toolchain_tag"             : MyAgo.ToolChain,\r
             "build_target"              : MyAgo.BuildTarget,\r
-            "shell_command_code"        : list(self._SHELL_CMD_[self._FileType].keys()),\r
-            "shell_command"             : list(self._SHELL_CMD_[self._FileType].values()),\r
+            "shell_command_code"        : list(self._SHELL_CMD_[self._Platform].keys()),\r
+            "shell_command"             : list(self._SHELL_CMD_[self._Platform].values()),\r
             'arch'                      : list(MyAgo.ArchList),\r
             "build_architecture_list"   : ','.join(MyAgo.ArchList),\r
             "separator"                 : Separator,\r
index 1ca1798907ef9b46a17d8938bb2f673d5ade662f..ca9e02d19b4afad82241abb8e15845731cabd22f 100644 (file)
@@ -2,6 +2,7 @@
 # Build cache intermediate result and state\r
 #\r
 # Copyright (c) 2019 - 2020, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2020, ARM Limited. All rights reserved.<BR>\r
 # SPDX-License-Identifier: BSD-2-Clause-Patent\r
 #\r
 from Common.caching import cached_property\r
@@ -12,20 +13,6 @@ from Common.Misc import SaveFileOnChange, PathClass
 from Common.Misc import TemplateString\r
 import sys\r
 gIsFileMap = {}\r
-if sys.platform == "win32":\r
-    _INCLUDE_DEPS_TEMPLATE = TemplateString('''\r
-${BEGIN}\r
-!IF EXIST(${deps_file})\r
-!INCLUDE ${deps_file}\r
-!ENDIF\r
-${END}\r
-        ''')\r
-else:\r
-    _INCLUDE_DEPS_TEMPLATE = TemplateString('''\r
-${BEGIN}\r
--include ${deps_file}\r
-${END}\r
-        ''')\r
 \r
 DEP_FILE_TAIL = "# Updated \n"\r
 \r
@@ -59,6 +46,25 @@ class IncludesAutoGen():
 \r
     def CreateDepsInclude(self):\r
         deps_file = {'deps_file':self.deps_files}\r
+\r
+        MakePath = self.module_autogen.BuildOption.get('MAKE', {}).get('PATH')\r
+        if not MakePath:\r
+            EdkLogger.error("build", PARAMETER_MISSING, Message="No Make path available.")\r
+        elif "nmake" in MakePath:\r
+            _INCLUDE_DEPS_TEMPLATE = TemplateString('''\r
+        ${BEGIN}\r
+        !IF EXIST(${deps_file})\r
+        !INCLUDE ${deps_file}\r
+        !ENDIF\r
+        ${END}\r
+               ''')\r
+        else:\r
+            _INCLUDE_DEPS_TEMPLATE = TemplateString('''\r
+        ${BEGIN}\r
+        -include ${deps_file}\r
+        ${END}\r
+               ''')\r
+\r
         try:\r
             deps_include_str = _INCLUDE_DEPS_TEMPLATE.Replace(deps_file)\r
         except Exception as e:\r
index 7bd24dad42f8142694659861e03033fa082f2e32..d32178b00c936b9682b2cba5f1209e8efcb5c3e5 100644 (file)
@@ -2,6 +2,7 @@
 # Create makefile for MS nmake and GNU make\r
 #\r
 # Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2020, ARM Limited. All rights reserved.<BR>\r
 # SPDX-License-Identifier: BSD-2-Clause-Patent\r
 #\r
 \r
@@ -106,8 +107,9 @@ class PlatformAutoGen(AutoGen):
         self.BuildDatabase = Workspace.BuildDatabase\r
         self.DscBuildDataObj = Workspace.Platform\r
 \r
-        # flag indicating if the makefile/C-code file has been created or not\r
-        self.IsMakeFileCreated  = False\r
+        # MakeFileName is used to get the Makefile name and as a flag\r
+        # indicating whether the file has been created.\r
+        self.MakeFileName = ""\r
 \r
         self._DynamicPcdList = None    # [(TokenCName1, TokenSpaceGuidCName1), (TokenCName2, TokenSpaceGuidCName2), ...]\r
         self._NonDynamicPcdList = None # [(TokenCName1, TokenSpaceGuidCName1), (TokenCName2, TokenSpaceGuidCName2), ...]\r
@@ -191,16 +193,15 @@ class PlatformAutoGen(AutoGen):
         self.CreateLibModuelDirs()\r
 \r
     def CreateLibModuelDirs(self):\r
-        # no need to create makefile for the platform more than once\r
-        if self.IsMakeFileCreated:\r
+        # No need to create makefile for the platform more than once.\r
+        if self.MakeFileName:\r
             return\r
 \r
         # create library/module build dirs for platform\r
         Makefile = GenMake.PlatformMakefile(self)\r
         self.LibraryBuildDirectoryList = Makefile.GetLibraryBuildDirectoryList()\r
         self.ModuleBuildDirectoryList = Makefile.GetModuleBuildDirectoryList()\r
-\r
-        self.IsMakeFileCreated = True\r
+        self.MakeFileName = Makefile.getMakefileName()\r
 \r
     @property\r
     def AllPcdList(self):\r
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