X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2FAutoGen%2FGenMake.py;h=992de5490dff9ffc2fc2067b6e64449bffac8ad0;hp=942eb44cc2eecaab3656a708578f12d7587d9d74;hb=18ef4e713f2fb5d2f84d179b9861b4afee212f65;hpb=a3a4737051010a94832f7bceaa1fa414d7259da0
diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/Python/AutoGen/GenMake.py
index 942eb44cc2..992de5490d 100644
--- a/BaseTools/Source/Python/AutoGen/GenMake.py
+++ b/BaseTools/Source/Python/AutoGen/GenMake.py
@@ -1,7 +1,7 @@
## @file
# Create makefile for MS nmake and GNU make
#
-# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -22,9 +22,10 @@ from Common.LongFilePathSupport import OpenLongFilePath as open
from Common.MultipleWorkspace import MultipleWorkspace as mws
from Common.BuildToolError import *
from Common.Misc import *
-from Common.String import *
+from Common.StringUtils import *
from BuildEngine import *
import Common.GlobalData as GlobalData
+from collections import OrderedDict
## Regular expression for finding header file inclusions
gIncludePattern = re.compile(r"^[ \t]*#?[ \t]*include(?:[ \t]*(?:\\(?:\r\n|\r|\n))*[ \t]*)*(?:\(?[\"<]?[ \t]*)([-\w.\\/() \t]+)(?:[ \t]*[\">]?\)?)", re.MULTILINE | re.UNICODE | re.IGNORECASE)
@@ -143,6 +144,11 @@ class BuildFile(object):
"nmake" : 'if exist %(dir)s $(RD) %(dir)s',
"gmake" : "$(RD) %(dir)s"
}
+ ## cp if exist
+ _CP_TEMPLATE_ = {
+ "nmake" : 'if exist %(Src)s $(CP) %(Src)s %(Dst)s',
+ "gmake" : "test -f %(Src)s && $(CP) %(Src)s %(Dst)s"
+ }
_CD_TEMPLATE_ = {
"nmake" : 'if exist %(dir)s cd %(dir)s',
@@ -211,6 +217,8 @@ class BuildFile(object):
for MacroName in MacroDefinitions:
MacroValue = MacroDefinitions[MacroName]
MacroValueLength = len(MacroValue)
+ if MacroValueLength == 0:
+ continue
if MacroValueLength <= PathLength and Path.startswith(MacroValue):
Path = "$(%s)%s" % (MacroName, Path[MacroValueLength:])
break
@@ -250,6 +258,7 @@ BASE_NAME = $(MODULE_NAME)
MODULE_RELATIVE_DIR = ${module_relative_directory}
PACKAGE_RELATIVE_DIR = ${package_relative_directory}
MODULE_DIR = ${module_dir}
+FFS_OUTPUT_DIR = ${ffs_output_directory}
MODULE_ENTRY_POINT = ${module_entry_point}
ARCH_ENTRY_POINT = ${arch_entry_point}
@@ -418,8 +427,6 @@ cleanlib:
self.ResultFileList = []
self.IntermediateDirectoryList = ["$(DEBUG_DIR)", "$(OUTPUT_DIR)"]
- self.SourceFileDatabase = {} # {file type : file path}
- self.DestFileDatabase = {} # {file type : file path}
self.FileBuildTargetList = [] # [(src, target string)]
self.BuildTargetList = [] # [target string]
self.PendingBuildTargetList = [] # [FileBuildRule objects]
@@ -434,72 +441,77 @@ cleanlib:
self.LibraryMakefileList = []
self.LibraryBuildDirectoryList = []
self.SystemLibraryList = []
- self.Macros = sdict()
+ self.Macros = OrderedDict()
self.Macros["OUTPUT_DIR" ] = self._AutoGenObject.Macros["OUTPUT_DIR"]
self.Macros["DEBUG_DIR" ] = self._AutoGenObject.Macros["DEBUG_DIR"]
self.Macros["MODULE_BUILD_DIR"] = self._AutoGenObject.Macros["MODULE_BUILD_DIR"]
self.Macros["BIN_DIR" ] = self._AutoGenObject.Macros["BIN_DIR"]
self.Macros["BUILD_DIR" ] = self._AutoGenObject.Macros["BUILD_DIR"]
self.Macros["WORKSPACE" ] = self._AutoGenObject.Macros["WORKSPACE"]
+ self.Macros["FFS_OUTPUT_DIR" ] = self._AutoGenObject.Macros["FFS_OUTPUT_DIR"]
+ self.GenFfsList = ModuleAutoGen.GenFfsList
+ self.MacroList = ['FFS_OUTPUT_DIR', 'MODULE_GUID', 'OUTPUT_DIR']
+ self.FfsOutputFileList = []
# Compose a dict object containing information used to do replacement in template
def _CreateTemplateDict(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
Separator = self._SEP_[self._FileType]
# break build if no source files and binary files are found
- if len(self._AutoGenObject.SourceFileList) == 0 and len(self._AutoGenObject.BinaryFileList) == 0:
+ if len(MyAgo.SourceFileList) == 0 and len(MyAgo.BinaryFileList) == 0:
EdkLogger.error("build", AUTOGEN_ERROR, "No files to be built in module [%s, %s, %s]"
- % (self._AutoGenObject.BuildTarget, self._AutoGenObject.ToolChain, self._AutoGenObject.Arch),
- ExtraData="[%s]" % str(self._AutoGenObject))
+ % (MyAgo.BuildTarget, MyAgo.ToolChain, MyAgo.Arch),
+ ExtraData="[%s]" % str(MyAgo))
# convert dependent libraries to build command
self.ProcessDependentLibrary()
- if len(self._AutoGenObject.Module.ModuleEntryPointList) > 0:
- ModuleEntryPoint = self._AutoGenObject.Module.ModuleEntryPointList[0]
+ if len(MyAgo.Module.ModuleEntryPointList) > 0:
+ ModuleEntryPoint = MyAgo.Module.ModuleEntryPointList[0]
else:
ModuleEntryPoint = "_ModuleEntryPoint"
# Intel EBC compiler enforces EfiMain
- if self._AutoGenObject.AutoGenVersion < 0x00010005 and self._AutoGenObject.Arch == "EBC":
+ if MyAgo.AutoGenVersion < 0x00010005 and MyAgo.Arch == "EBC":
ArchEntryPoint = "EfiMain"
else:
ArchEntryPoint = ModuleEntryPoint
- if self._AutoGenObject.Arch == "EBC":
+ if MyAgo.Arch == "EBC":
# EBC compiler always use "EfiStart" as entry point. Only applies to EdkII modules
ImageEntryPoint = "EfiStart"
- elif self._AutoGenObject.AutoGenVersion < 0x00010005:
+ elif MyAgo.AutoGenVersion < 0x00010005:
# Edk modules use entry point specified in INF file
ImageEntryPoint = ModuleEntryPoint
else:
# EdkII modules always use "_ModuleEntryPoint" as entry point
ImageEntryPoint = "_ModuleEntryPoint"
- for k, v in self._AutoGenObject.Module.Defines.iteritems():
- if k not in self._AutoGenObject.Macros.keys():
- self._AutoGenObject.Macros[k] = v
+ for k, v in MyAgo.Module.Defines.iteritems():
+ if k not in MyAgo.Macros:
+ MyAgo.Macros[k] = v
- if 'MODULE_ENTRY_POINT' not in self._AutoGenObject.Macros.keys():
- self._AutoGenObject.Macros['MODULE_ENTRY_POINT'] = ModuleEntryPoint
- if 'ARCH_ENTRY_POINT' not in self._AutoGenObject.Macros.keys():
- self._AutoGenObject.Macros['ARCH_ENTRY_POINT'] = ArchEntryPoint
- if 'IMAGE_ENTRY_POINT' not in self._AutoGenObject.Macros.keys():
- self._AutoGenObject.Macros['IMAGE_ENTRY_POINT'] = ImageEntryPoint
+ if 'MODULE_ENTRY_POINT' not in MyAgo.Macros:
+ MyAgo.Macros['MODULE_ENTRY_POINT'] = ModuleEntryPoint
+ if 'ARCH_ENTRY_POINT' not in MyAgo.Macros:
+ MyAgo.Macros['ARCH_ENTRY_POINT'] = ArchEntryPoint
+ if 'IMAGE_ENTRY_POINT' not in MyAgo.Macros:
+ MyAgo.Macros['IMAGE_ENTRY_POINT'] = ImageEntryPoint
PCI_COMPRESS_Flag = False
- for k, v in self._AutoGenObject.Module.Defines.iteritems():
+ for k, v in MyAgo.Module.Defines.iteritems():
if 'PCI_COMPRESS' == k and 'TRUE' == v:
PCI_COMPRESS_Flag = True
# tools definitions
ToolsDef = []
- IncPrefix = self._INC_FLAG_[self._AutoGenObject.ToolChainFamily]
- for Tool in self._AutoGenObject.BuildOption:
- for Attr in self._AutoGenObject.BuildOption[Tool]:
- Value = self._AutoGenObject.BuildOption[Tool][Attr]
+ IncPrefix = self._INC_FLAG_[MyAgo.ToolChainFamily]
+ for Tool in MyAgo.BuildOption:
+ for Attr in MyAgo.BuildOption[Tool]:
+ Value = MyAgo.BuildOption[Tool][Attr]
if Attr == "FAMILY":
continue
elif Attr == "PATH":
@@ -510,7 +522,7 @@ cleanlib:
continue
# Remove duplicated include path, if any
if Attr == "FLAGS":
- Value = RemoveDupOption(Value, IncPrefix, self._AutoGenObject.IncludePathList)
+ Value = RemoveDupOption(Value, IncPrefix, MyAgo.IncludePathList)
if Tool == "OPTROM" and PCI_COMPRESS_Flag:
ValueList = Value.split()
if ValueList:
@@ -524,11 +536,11 @@ cleanlib:
# generate the Response file and Response flag
RespDict = self.CommandExceedLimit()
- RespFileList = os.path.join(self._AutoGenObject.OutputDir, 'respfilelist.txt')
+ RespFileList = os.path.join(MyAgo.OutputDir, 'respfilelist.txt')
if RespDict:
RespFileListContent = ''
- for Resp in RespDict.keys():
- RespFile = os.path.join(self._AutoGenObject.OutputDir, str(Resp).lower() + '.txt')
+ for Resp in RespDict:
+ RespFile = os.path.join(MyAgo.OutputDir, str(Resp).lower() + '.txt')
StrList = RespDict[Resp].split(' ')
UnexpandMacro = []
NewStr = []
@@ -549,12 +561,13 @@ cleanlib:
os.remove(RespFileList)
# convert source files and binary files to build targets
- self.ResultFileList = [str(T.Target) for T in self._AutoGenObject.CodaTargetList]
- if len(self.ResultFileList) == 0 and len(self._AutoGenObject.SourceFileList) <> 0:
+ self.ResultFileList = [str(T.Target) for T in MyAgo.CodaTargetList]
+ if len(self.ResultFileList) == 0 and len(MyAgo.SourceFileList) != 0:
EdkLogger.error("build", AUTOGEN_ERROR, "Nothing to build",
- ExtraData="[%s]" % str(self._AutoGenObject))
+ ExtraData="[%s]" % str(MyAgo))
self.ProcessBuildTargetList()
+ self.ParserGenerateFfsCmd()
# Generate macros used to represent input files
FileMacroList = [] # macro name = file list
@@ -570,7 +583,7 @@ cleanlib:
# INC_LIST is special
FileMacro = ""
IncludePathList = []
- for P in self._AutoGenObject.IncludePathList:
+ for P in MyAgo.IncludePathList:
IncludePathList.append(IncPrefix + self.PlaceMacro(P, self.Macros))
if FileBuildRule.INC_LIST_MACRO in self.ListFileMacros:
self.ListFileMacros[FileBuildRule.INC_LIST_MACRO].append(IncPrefix + P)
@@ -584,7 +597,7 @@ cleanlib:
# Generate macros used to represent files containing list of input files
for ListFileMacro in self.ListFileMacros:
- ListFileName = os.path.join(self._AutoGenObject.OutputDir, "%s.lst" % ListFileMacro.lower()[:len(ListFileMacro) - 5])
+ ListFileName = os.path.join(MyAgo.OutputDir, "%s.lst" % ListFileMacro.lower()[:len(ListFileMacro) - 5])
FileMacroList.append("%s = %s" % (ListFileMacro, ListFileName))
SaveFileOnChange(
ListFileName,
@@ -593,7 +606,7 @@ cleanlib:
)
# Edk modules need StrDefs.h for string ID
- #if self._AutoGenObject.AutoGenVersion < 0x00010005 and len(self._AutoGenObject.UnicodeFileList) > 0:
+ #if MyAgo.AutoGenVersion < 0x00010005 and len(MyAgo.UnicodeFileList) > 0:
# BcTargetList = ['strdefs']
#else:
# BcTargetList = []
@@ -605,7 +618,7 @@ cleanlib:
Command = self._MAKE_TEMPLATE_[self._FileType] % {"file":os.path.join(D, MakefileName)}
LibraryMakeCommandList.append(Command)
- package_rel_dir = self._AutoGenObject.SourceDir
+ package_rel_dir = MyAgo.SourceDir
current_dir = self.Macros["WORKSPACE"]
found = False
while not found and os.sep in package_rel_dir:
@@ -627,28 +640,29 @@ cleanlib:
"platform_version" : self.PlatformInfo.Version,
"platform_relative_directory": self.PlatformInfo.SourceDir,
"platform_output_directory" : self.PlatformInfo.OutputDir,
- "platform_dir" : self._AutoGenObject.Macros["PLATFORM_DIR"],
-
- "module_name" : self._AutoGenObject.Name,
- "module_guid" : self._AutoGenObject.Guid,
- "module_name_guid" : self._AutoGenObject._GetUniqueBaseName(),
- "module_version" : self._AutoGenObject.Version,
- "module_type" : self._AutoGenObject.ModuleType,
- "module_file" : self._AutoGenObject.MetaFile.Name,
- "module_file_base_name" : self._AutoGenObject.MetaFile.BaseName,
- "module_relative_directory" : self._AutoGenObject.SourceDir,
- "module_dir" : mws.join (self.Macros["WORKSPACE"], self._AutoGenObject.SourceDir),
+ "ffs_output_directory" : MyAgo.Macros["FFS_OUTPUT_DIR"],
+ "platform_dir" : MyAgo.Macros["PLATFORM_DIR"],
+
+ "module_name" : MyAgo.Name,
+ "module_guid" : MyAgo.Guid,
+ "module_name_guid" : MyAgo.UniqueBaseName,
+ "module_version" : MyAgo.Version,
+ "module_type" : MyAgo.ModuleType,
+ "module_file" : MyAgo.MetaFile.Name,
+ "module_file_base_name" : MyAgo.MetaFile.BaseName,
+ "module_relative_directory" : MyAgo.SourceDir,
+ "module_dir" : mws.join (self.Macros["WORKSPACE"], MyAgo.SourceDir),
"package_relative_directory": package_rel_dir,
- "module_extra_defines" : ["%s = %s" % (k, v) for k, v in self._AutoGenObject.Module.Defines.iteritems()],
+ "module_extra_defines" : ["%s = %s" % (k, v) for k, v in MyAgo.Module.Defines.iteritems()],
- "architecture" : self._AutoGenObject.Arch,
- "toolchain_tag" : self._AutoGenObject.ToolChain,
- "build_target" : self._AutoGenObject.BuildTarget,
+ "architecture" : MyAgo.Arch,
+ "toolchain_tag" : MyAgo.ToolChain,
+ "build_target" : MyAgo.BuildTarget,
"platform_build_directory" : self.PlatformInfo.BuildDir,
- "module_build_directory" : self._AutoGenObject.BuildDir,
- "module_output_directory" : self._AutoGenObject.OutputDir,
- "module_debug_directory" : self._AutoGenObject.DebugDir,
+ "module_build_directory" : MyAgo.BuildDir,
+ "module_output_directory" : MyAgo.OutputDir,
+ "module_debug_directory" : MyAgo.DebugDir,
"separator" : Separator,
"module_tool_definitions" : ToolsDef,
@@ -673,6 +687,79 @@ cleanlib:
return MakefileTemplateDict
+ def ParserGenerateFfsCmd(self):
+ #Add Ffs cmd to self.BuildTargetList
+ OutputFile = ''
+ DepsFileList = []
+
+ for Cmd in self.GenFfsList:
+ if Cmd[2]:
+ for CopyCmd in Cmd[2]:
+ Src, Dst = CopyCmd
+ Src = self.ReplaceMacro(Src)
+ Dst = self.ReplaceMacro(Dst)
+ if Dst not in self.ResultFileList:
+ self.ResultFileList.append(Dst)
+ if '%s :' %(Dst) not in self.BuildTargetList:
+ self.BuildTargetList.append("%s :" %(Dst))
+ self.BuildTargetList.append('\t' + self._CP_TEMPLATE_[self._FileType] %{'Src': Src, 'Dst': Dst})
+
+ FfsCmdList = Cmd[0]
+ for index, Str in enumerate(FfsCmdList):
+ if '-o' == Str:
+ OutputFile = FfsCmdList[index + 1]
+ if '-i' == Str:
+ if DepsFileList == []:
+ DepsFileList = [FfsCmdList[index + 1]]
+ else:
+ DepsFileList.append(FfsCmdList[index + 1])
+ DepsFileString = ' '.join(DepsFileList).strip()
+ if DepsFileString == '':
+ continue
+ OutputFile = self.ReplaceMacro(OutputFile)
+ self.ResultFileList.append(OutputFile)
+ DepsFileString = self.ReplaceMacro(DepsFileString)
+ self.BuildTargetList.append('%s : %s' % (OutputFile, DepsFileString))
+ CmdString = ' '.join(FfsCmdList).strip()
+ CmdString = self.ReplaceMacro(CmdString)
+ self.BuildTargetList.append('\t%s' % CmdString)
+
+ self.ParseSecCmd(DepsFileList, Cmd[1])
+ for SecOutputFile, SecDepsFile, SecCmd in self.FfsOutputFileList :
+ self.BuildTargetList.append('%s : %s' % (self.ReplaceMacro(SecOutputFile), self.ReplaceMacro(SecDepsFile)))
+ self.BuildTargetList.append('\t%s' % self.ReplaceMacro(SecCmd))
+ self.FfsOutputFileList = []
+
+ def ParseSecCmd(self, OutputFileList, CmdTuple):
+ for OutputFile in OutputFileList:
+ for SecCmdStr in CmdTuple:
+ SecDepsFileList = []
+ SecCmdList = SecCmdStr.split()
+ CmdName = SecCmdList[0]
+ for index, CmdItem in enumerate(SecCmdList):
+ if '-o' == CmdItem and OutputFile == SecCmdList[index + 1]:
+ index = index + 1
+ while index + 1 < len(SecCmdList):
+ if not SecCmdList[index+1].startswith('-'):
+ SecDepsFileList.append(SecCmdList[index + 1])
+ index = index + 1
+ if CmdName == 'Trim':
+ SecDepsFileList.append(os.path.join('$(DEBUG_DIR)', os.path.basename(OutputFile).replace('offset', 'efi')))
+ if OutputFile.endswith('.ui') or OutputFile.endswith('.ver'):
+ SecDepsFileList.append(os.path.join('$(MODULE_DIR)', '$(MODULE_FILE)'))
+ self.FfsOutputFileList.append((OutputFile, ' '.join(SecDepsFileList), SecCmdStr))
+ if len(SecDepsFileList) > 0:
+ self.ParseSecCmd(SecDepsFileList, CmdTuple)
+ break
+ else:
+ continue
+
+ def ReplaceMacro(self, str):
+ for Macro in self.MacroList:
+ if self._AutoGenObject.Macros[Macro] and self._AutoGenObject.Macros[Macro] in str:
+ str = str.replace(self._AutoGenObject.Macros[Macro], '$(' + Macro + ')')
+ return str
+
def CommandExceedLimit(self):
FlagDict = {
'CC' : { 'Macro' : '$(CC_FLAGS)', 'Value' : False},
@@ -706,21 +793,25 @@ cleanlib:
SingleCommandLength = len(SingleCommand)
SingleCommandList = SingleCommand.split()
if len(SingleCommandList) > 0:
- for Flag in FlagDict.keys():
+ for Flag in FlagDict:
if '$('+ Flag +')' in SingleCommandList[0]:
Tool = Flag
break
if Tool:
+ if 'PATH' not in self._AutoGenObject._BuildOption[Tool]:
+ EdkLogger.error("build", AUTOGEN_ERROR, "%s_PATH doesn't exist in %s ToolChain and %s Arch." %(Tool, self._AutoGenObject.ToolChain, self._AutoGenObject.Arch), ExtraData="[%s]" % str(self._AutoGenObject))
SingleCommandLength += len(self._AutoGenObject._BuildOption[Tool]['PATH'])
for item in SingleCommandList[1:]:
if FlagDict[Tool]['Macro'] in item:
+ if 'FLAGS' not in self._AutoGenObject._BuildOption[Tool]:
+ EdkLogger.error("build", AUTOGEN_ERROR, "%s_FLAGS doesn't exist in %s ToolChain and %s Arch." %(Tool, self._AutoGenObject.ToolChain, self._AutoGenObject.Arch), ExtraData="[%s]" % str(self._AutoGenObject))
Str = self._AutoGenObject._BuildOption[Tool]['FLAGS']
- for Option in self._AutoGenObject.BuildOption.keys():
+ for Option in self._AutoGenObject.BuildOption:
for Attr in self._AutoGenObject.BuildOption[Option]:
if Str.find(Option + '_' + Attr) != -1:
Str = Str.replace('$(' + Option + '_' + Attr + ')', self._AutoGenObject.BuildOption[Option][Attr])
while(Str.find('$(') != -1):
- for macro in self._AutoGenObject.Macros.keys():
+ for macro in self._AutoGenObject.Macros:
MacroName = '$('+ macro + ')'
if (Str.find(MacroName) != -1):
Str = Str.replace(MacroName, self._AutoGenObject.Macros[macro])
@@ -732,12 +823,12 @@ cleanlib:
SingleCommandLength += self._AutoGenObject.IncludePathLength + len(IncPrefix) * len(self._AutoGenObject._IncludePathList)
elif item.find('$(') != -1:
Str = item
- for Option in self._AutoGenObject.BuildOption.keys():
+ for Option in self._AutoGenObject.BuildOption:
for Attr in self._AutoGenObject.BuildOption[Option]:
if Str.find(Option + '_' + Attr) != -1:
Str = Str.replace('$(' + Option + '_' + Attr + ')', self._AutoGenObject.BuildOption[Option][Attr])
while(Str.find('$(') != -1):
- for macro in self._AutoGenObject.Macros.keys():
+ for macro in self._AutoGenObject.Macros:
MacroName = '$('+ macro + ')'
if (Str.find(MacroName) != -1):
Str = Str.replace(MacroName, self._AutoGenObject.Macros[macro])
@@ -750,19 +841,19 @@ cleanlib:
FlagDict[Tool]['Value'] = True
# generate the response file content by combine the FLAGS and INC
- for Flag in FlagDict.keys():
+ for Flag in FlagDict:
if FlagDict[Flag]['Value']:
Key = Flag + '_RESP'
RespMacro = FlagDict[Flag]['Macro'].replace('FLAGS', 'RESP')
Value = self._AutoGenObject.BuildOption[Flag]['FLAGS']
for inc in self._AutoGenObject._IncludePathList:
Value += ' ' + IncPrefix + inc
- for Option in self._AutoGenObject.BuildOption.keys():
+ for Option in self._AutoGenObject.BuildOption:
for Attr in self._AutoGenObject.BuildOption[Option]:
if Value.find(Option + '_' + Attr) != -1:
Value = Value.replace('$(' + Option + '_' + Attr + ')', self._AutoGenObject.BuildOption[Option][Attr])
while (Value.find('$(') != -1):
- for macro in self._AutoGenObject.Macros.keys():
+ for macro in self._AutoGenObject.Macros:
MacroName = '$('+ macro + ')'
if (Value.find(MacroName) != -1):
Value = Value.replace(MacroName, self._AutoGenObject.Macros[macro])
@@ -777,7 +868,7 @@ cleanlib:
for Target in BuildTargets:
for i, SingleCommand in enumerate(BuildTargets[Target].Commands):
if FlagDict[Flag]['Macro'] in SingleCommand:
- BuildTargets[Target].Commands[i] = SingleCommand.replace('$(INC)','').replace(FlagDict[Flag]['Macro'], RespMacro)
+ BuildTargets[Target].Commands[i] = SingleCommand.replace('$(INC)', '').replace(FlagDict[Flag]['Macro'], RespMacro)
return RespDict
def ProcessBuildTargetList(self):
@@ -815,12 +906,12 @@ cleanlib:
# skip non-C files
if File.Ext not in [".c", ".C"] or File.Name == "AutoGen.c":
continue
- elif DepSet == None:
+ elif DepSet is None:
DepSet = set(self.FileDependency[File])
else:
DepSet &= set(self.FileDependency[File])
# in case nothing in SourceFileList
- if DepSet == None:
+ if DepSet is None:
DepSet = set()
#
# Extract common files list in the dependency files
@@ -871,6 +962,8 @@ cleanlib:
# Use file list macro as dependency
if T.GenFileListMacro:
Deps.append("$(%s)" % T.FileListMacro)
+ if Type in [TAB_OBJECT_FILE, TAB_STATIC_LIBRARY]:
+ Deps.append("$(%s)" % T.ListFileMacro)
TargetDict = {
"target" : self.PlaceMacro(T.Target.Path, self.Macros),
@@ -938,7 +1031,7 @@ cleanlib:
else:
try:
Fd = open(F.Path, 'r')
- except BaseException, X:
+ except BaseException as X:
EdkLogger.error("build", FILE_OPEN_FAILURE, ExtraData=F.Path + "\n\t" + str(X))
FileContent = Fd.read()
@@ -1113,32 +1206,33 @@ ${BEGIN}\t-@${create_directory_command}\n${END}\
# Compose a dict object containing information used to do replacement in template
def _CreateTemplateDict(self):
Separator = self._SEP_[self._FileType]
- if self._FileType not in self._AutoGenObject.CustomMakefile:
+ MyAgo = self._AutoGenObject
+ if self._FileType not in MyAgo.CustomMakefile:
EdkLogger.error('build', OPTION_NOT_SUPPORTED, "No custom makefile for %s" % self._FileType,
- ExtraData="[%s]" % str(self._AutoGenObject))
+ ExtraData="[%s]" % str(MyAgo))
MakefilePath = mws.join(
- self._AutoGenObject.WorkspaceDir,
- self._AutoGenObject.CustomMakefile[self._FileType]
+ MyAgo.WorkspaceDir,
+ MyAgo.CustomMakefile[self._FileType]
)
try:
CustomMakefile = open(MakefilePath, 'r').read()
except:
- EdkLogger.error('build', FILE_OPEN_FAILURE, File=str(self._AutoGenObject),
- ExtraData=self._AutoGenObject.CustomMakefile[self._FileType])
+ EdkLogger.error('build', FILE_OPEN_FAILURE, File=str(MyAgo),
+ ExtraData=MyAgo.CustomMakefile[self._FileType])
# tools definitions
ToolsDef = []
- for Tool in self._AutoGenObject.BuildOption:
+ for Tool in MyAgo.BuildOption:
# Don't generate MAKE_FLAGS in makefile. It's put in environment variable.
if Tool == "MAKE":
continue
- for Attr in self._AutoGenObject.BuildOption[Tool]:
+ for Attr in MyAgo.BuildOption[Tool]:
if Attr == "FAMILY":
continue
elif Attr == "PATH":
- ToolsDef.append("%s = %s" % (Tool, self._AutoGenObject.BuildOption[Tool][Attr]))
+ ToolsDef.append("%s = %s" % (Tool, MyAgo.BuildOption[Tool][Attr]))
else:
- ToolsDef.append("%s_%s = %s" % (Tool, Attr, self._AutoGenObject.BuildOption[Tool][Attr]))
+ ToolsDef.append("%s_%s = %s" % (Tool, Attr, MyAgo.BuildOption[Tool][Attr]))
ToolsDef.append("")
MakefileName = self._FILE_NAME_[self._FileType]
@@ -1150,26 +1244,26 @@ ${BEGIN}\t-@${create_directory_command}\n${END}\
"platform_version" : self.PlatformInfo.Version,
"platform_relative_directory": self.PlatformInfo.SourceDir,
"platform_output_directory" : self.PlatformInfo.OutputDir,
- "platform_dir" : self._AutoGenObject.Macros["PLATFORM_DIR"],
-
- "module_name" : self._AutoGenObject.Name,
- "module_guid" : self._AutoGenObject.Guid,
- "module_name_guid" : self._AutoGenObject._GetUniqueBaseName(),
- "module_version" : self._AutoGenObject.Version,
- "module_type" : self._AutoGenObject.ModuleType,
- "module_file" : self._AutoGenObject.MetaFile,
- "module_file_base_name" : self._AutoGenObject.MetaFile.BaseName,
- "module_relative_directory" : self._AutoGenObject.SourceDir,
- "module_dir" : mws.join (self._AutoGenObject.WorkspaceDir, self._AutoGenObject.SourceDir),
-
- "architecture" : self._AutoGenObject.Arch,
- "toolchain_tag" : self._AutoGenObject.ToolChain,
- "build_target" : self._AutoGenObject.BuildTarget,
+ "platform_dir" : MyAgo.Macros["PLATFORM_DIR"],
+
+ "module_name" : MyAgo.Name,
+ "module_guid" : MyAgo.Guid,
+ "module_name_guid" : MyAgo.UniqueBaseName,
+ "module_version" : MyAgo.Version,
+ "module_type" : MyAgo.ModuleType,
+ "module_file" : MyAgo.MetaFile,
+ "module_file_base_name" : MyAgo.MetaFile.BaseName,
+ "module_relative_directory" : MyAgo.SourceDir,
+ "module_dir" : mws.join (MyAgo.WorkspaceDir, MyAgo.SourceDir),
+
+ "architecture" : MyAgo.Arch,
+ "toolchain_tag" : MyAgo.ToolChain,
+ "build_target" : MyAgo.BuildTarget,
"platform_build_directory" : self.PlatformInfo.BuildDir,
- "module_build_directory" : self._AutoGenObject.BuildDir,
- "module_output_directory" : self._AutoGenObject.OutputDir,
- "module_debug_directory" : self._AutoGenObject.DebugDir,
+ "module_build_directory" : MyAgo.BuildDir,
+ "module_output_directory" : MyAgo.OutputDir,
+ "module_debug_directory" : MyAgo.DebugDir,
"separator" : Separator,
"module_tool_definitions" : ToolsDef,
@@ -1304,10 +1398,10 @@ cleanlib:
def _CreateTemplateDict(self):
Separator = self._SEP_[self._FileType]
- PlatformInfo = self._AutoGenObject
- if "MAKE" not in PlatformInfo.ToolDefinition or "PATH" not in PlatformInfo.ToolDefinition["MAKE"]:
+ MyAgo = self._AutoGenObject
+ if "MAKE" not in MyAgo.ToolDefinition or "PATH" not in MyAgo.ToolDefinition["MAKE"]:
EdkLogger.error("build", OPTION_MISSING, "No MAKE command defined. Please check your tools_def.txt!",
- ExtraData="[%s]" % str(self._AutoGenObject))
+ ExtraData="[%s]" % str(MyAgo))
self.IntermediateDirectoryList = ["$(BUILD_DIR)"]
self.ModuleBuildDirectoryList = self.GetModuleBuildDirectoryList()
@@ -1317,7 +1411,7 @@ cleanlib:
LibraryMakefileList = []
LibraryMakeCommandList = []
for D in self.LibraryBuildDirectoryList:
- D = self.PlaceMacro(D, {"BUILD_DIR":PlatformInfo.BuildDir})
+ D = self.PlaceMacro(D, {"BUILD_DIR":MyAgo.BuildDir})
Makefile = os.path.join(D, MakefileName)
Command = self._MAKE_TEMPLATE_[self._FileType] % {"file":Makefile}
LibraryMakefileList.append(Makefile)
@@ -1327,7 +1421,7 @@ cleanlib:
ModuleMakefileList = []
ModuleMakeCommandList = []
for D in self.ModuleBuildDirectoryList:
- D = self.PlaceMacro(D, {"BUILD_DIR":PlatformInfo.BuildDir})
+ D = self.PlaceMacro(D, {"BUILD_DIR":MyAgo.BuildDir})
Makefile = os.path.join(D, MakefileName)
Command = self._MAKE_TEMPLATE_[self._FileType] % {"file":Makefile}
ModuleMakefileList.append(Makefile)
@@ -1336,23 +1430,23 @@ cleanlib:
MakefileTemplateDict = {
"makefile_header" : self._FILE_HEADER_[self._FileType],
"makefile_path" : os.path.join("$(BUILD_DIR)", MakefileName),
- "make_path" : PlatformInfo.ToolDefinition["MAKE"]["PATH"],
+ "make_path" : MyAgo.ToolDefinition["MAKE"]["PATH"],
"makefile_name" : MakefileName,
- "platform_name" : PlatformInfo.Name,
- "platform_guid" : PlatformInfo.Guid,
- "platform_version" : PlatformInfo.Version,
- "platform_file" : self._AutoGenObject.MetaFile,
- "platform_relative_directory": PlatformInfo.SourceDir,
- "platform_output_directory" : PlatformInfo.OutputDir,
- "platform_build_directory" : PlatformInfo.BuildDir,
- "platform_dir" : self._AutoGenObject.Macros["PLATFORM_DIR"],
-
- "toolchain_tag" : PlatformInfo.ToolChain,
- "build_target" : PlatformInfo.BuildTarget,
+ "platform_name" : MyAgo.Name,
+ "platform_guid" : MyAgo.Guid,
+ "platform_version" : MyAgo.Version,
+ "platform_file" : MyAgo.MetaFile,
+ "platform_relative_directory": MyAgo.SourceDir,
+ "platform_output_directory" : MyAgo.OutputDir,
+ "platform_build_directory" : MyAgo.BuildDir,
+ "platform_dir" : MyAgo.Macros["PLATFORM_DIR"],
+
+ "toolchain_tag" : MyAgo.ToolChain,
+ "build_target" : MyAgo.BuildTarget,
"shell_command_code" : self._SHELL_CMD_[self._FileType].keys(),
"shell_command" : self._SHELL_CMD_[self._FileType].values(),
- "build_architecture_list" : self._AutoGenObject.Arch,
- "architecture" : self._AutoGenObject.Arch,
+ "build_architecture_list" : MyAgo.Arch,
+ "architecture" : MyAgo.Arch,
"separator" : Separator,
"create_directory_command" : self.GetCreateDirectoryCommand(self.IntermediateDirectoryList),
"cleanall_command" : self.GetRemoveDirectoryCommand(self.IntermediateDirectoryList),
@@ -1411,20 +1505,20 @@ class TopLevelMakefile(BuildFile):
Separator = self._SEP_[self._FileType]
# any platform autogen object is ok because we just need common information
- PlatformInfo = self._AutoGenObject
+ MyAgo = self._AutoGenObject
- if "MAKE" not in PlatformInfo.ToolDefinition or "PATH" not in PlatformInfo.ToolDefinition["MAKE"]:
+ if "MAKE" not in MyAgo.ToolDefinition or "PATH" not in MyAgo.ToolDefinition["MAKE"]:
EdkLogger.error("build", OPTION_MISSING, "No MAKE command defined. Please check your tools_def.txt!",
- ExtraData="[%s]" % str(self._AutoGenObject))
+ ExtraData="[%s]" % str(MyAgo))
- for Arch in PlatformInfo.ArchList:
+ for Arch in MyAgo.ArchList:
self.IntermediateDirectoryList.append(Separator.join(["$(BUILD_DIR)", Arch]))
self.IntermediateDirectoryList.append("$(FV_DIR)")
# TRICK: for not generating GenFds call in makefile if no FDF file
MacroList = []
- if PlatformInfo.FdfFile != None and PlatformInfo.FdfFile != "":
- FdfFileList = [PlatformInfo.FdfFile]
+ if MyAgo.FdfFile is not None and MyAgo.FdfFile != "":
+ FdfFileList = [MyAgo.FdfFile]
# macros passed to GenFds
MacroList.append('"%s=%s"' % ("EFI_SOURCE", GlobalData.gEfiSource.replace('\\', '\\\\')))
MacroList.append('"%s=%s"' % ("EDK_SOURCE", GlobalData.gEdkSource.replace('\\', '\\\\')))
@@ -1453,54 +1547,52 @@ class TopLevelMakefile(BuildFile):
if GlobalData.gCaseInsensitive:
ExtraOption += " -c"
-
+ if GlobalData.gEnableGenfdsMultiThread:
+ ExtraOption += " --genfds-multi-thread"
if GlobalData.gIgnoreSource:
ExtraOption += " --ignore-sources"
- if GlobalData.BuildOptionPcd:
- for index, option in enumerate(GlobalData.gCommand):
- if "--pcd" == option and GlobalData.gCommand[index+1]:
- pcdName, pcdValue = GlobalData.gCommand[index+1].split('=')
- if pcdValue.startswith('H'):
- pcdValue = 'H' + '"' + pcdValue[1:] + '"'
- ExtraOption += " --pcd " + pcdName + '=' + pcdValue
- elif pcdValue.startswith('L'):
- pcdValue = 'L' + '"' + pcdValue[1:] + '"'
- ExtraOption += " --pcd " + pcdName + '=' + pcdValue
- else:
- ExtraOption += " --pcd " + GlobalData.gCommand[index+1]
+ for pcd in GlobalData.BuildOptionPcd:
+ if pcd[2]:
+ pcdname = '.'.join(pcd[0:3])
+ else:
+ pcdname = '.'.join(pcd[0:2])
+ if pcd[3].startswith('{'):
+ ExtraOption += " --pcd " + pcdname + '=' + 'H' + '"' + pcd[3] + '"'
+ else:
+ ExtraOption += " --pcd " + pcdname + '=' + pcd[3]
MakefileName = self._FILE_NAME_[self._FileType]
SubBuildCommandList = []
- for A in PlatformInfo.ArchList:
+ for A in MyAgo.ArchList:
Command = self._MAKE_TEMPLATE_[self._FileType] % {"file":os.path.join("$(BUILD_DIR)", A, MakefileName)}
SubBuildCommandList.append(Command)
MakefileTemplateDict = {
"makefile_header" : self._FILE_HEADER_[self._FileType],
"makefile_path" : os.path.join("$(BUILD_DIR)", MakefileName),
- "make_path" : PlatformInfo.ToolDefinition["MAKE"]["PATH"],
- "platform_name" : PlatformInfo.Name,
- "platform_guid" : PlatformInfo.Guid,
- "platform_version" : PlatformInfo.Version,
- "platform_build_directory" : PlatformInfo.BuildDir,
+ "make_path" : MyAgo.ToolDefinition["MAKE"]["PATH"],
+ "platform_name" : MyAgo.Name,
+ "platform_guid" : MyAgo.Guid,
+ "platform_version" : MyAgo.Version,
+ "platform_build_directory" : MyAgo.BuildDir,
"conf_directory" : GlobalData.gConfDirectory,
- "toolchain_tag" : PlatformInfo.ToolChain,
- "build_target" : PlatformInfo.BuildTarget,
+ "toolchain_tag" : MyAgo.ToolChain,
+ "build_target" : MyAgo.BuildTarget,
"shell_command_code" : self._SHELL_CMD_[self._FileType].keys(),
"shell_command" : self._SHELL_CMD_[self._FileType].values(),
- 'arch' : list(PlatformInfo.ArchList),
- "build_architecture_list" : ','.join(PlatformInfo.ArchList),
+ 'arch' : list(MyAgo.ArchList),
+ "build_architecture_list" : ','.join(MyAgo.ArchList),
"separator" : Separator,
"create_directory_command" : self.GetCreateDirectoryCommand(self.IntermediateDirectoryList),
"cleanall_command" : self.GetRemoveDirectoryCommand(self.IntermediateDirectoryList),
"sub_build_command" : SubBuildCommandList,
"fdf_file" : FdfFileList,
- "active_platform" : str(PlatformInfo),
- "fd" : PlatformInfo.FdTargetList,
- "fv" : PlatformInfo.FvTargetList,
- "cap" : PlatformInfo.CapTargetList,
+ "active_platform" : str(MyAgo),
+ "fd" : MyAgo.FdTargetList,
+ "fv" : MyAgo.FvTargetList,
+ "cap" : MyAgo.CapTargetList,
"extra_options" : ExtraOption,
"macro" : MacroList,
}