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