X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2FAutoGen%2FGenMake.py;h=60bd625cd2b1f7d88b2722b52cb05b51c8d70374;hb=0f228f19fb40ffe60b13962ff639917435c562a9;hp=287046a5a8ac6960ce14ed520cca09717eccff92;hpb=017fb1cd4c5e3c8b914eb217ac1760223687dad7;p=mirror_edk2.git
diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/Python/AutoGen/GenMake.py
index 287046a5a8..60bd625cd2 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 - 2016, 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
@@ -143,6 +143,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 +216,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 +257,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}
@@ -386,7 +394,7 @@ ${END}
#
clean:
\t${BEGIN}${clean_command}
-\t${END}
+\t${END}\t$(RM) AutoGenTimeStamp
#
# clean all generated files
@@ -395,6 +403,7 @@ cleanall:
${BEGIN}\t${cleanall_command}
${END}\t$(RM) *.pdb *.idb > NUL 2>&1
\t$(RM) $(BIN_DIR)${separator}$(MODULE_NAME).efi
+\t$(RM) AutoGenTimeStamp
#
# clean all dependent libraries built
@@ -440,6 +449,10 @@ cleanlib:
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):
@@ -488,6 +501,11 @@ cleanlib:
if 'IMAGE_ENTRY_POINT' not in self._AutoGenObject.Macros.keys():
self._AutoGenObject.Macros['IMAGE_ENTRY_POINT'] = ImageEntryPoint
+ PCI_COMPRESS_Flag = False
+ for k, v in self._AutoGenObject.Module.Defines.iteritems():
+ if 'PCI_COMPRESS' == k and 'TRUE' == v:
+ PCI_COMPRESS_Flag = True
+
# tools definitions
ToolsDef = []
IncPrefix = self._INC_FLAG_[self._AutoGenObject.ToolChainFamily]
@@ -505,6 +523,14 @@ cleanlib:
# Remove duplicated include path, if any
if Attr == "FLAGS":
Value = RemoveDupOption(Value, IncPrefix, self._AutoGenObject.IncludePathList)
+ if Tool == "OPTROM" and PCI_COMPRESS_Flag:
+ ValueList = Value.split()
+ if ValueList:
+ for i, v in enumerate(ValueList):
+ if '-e' == v:
+ ValueList[i] = '-ec'
+ Value = ' '.join(ValueList)
+
ToolsDef.append("%s_%s = %s" % (Tool, Attr, Value))
ToolsDef.append("")
@@ -541,6 +567,7 @@ cleanlib:
ExtraData="[%s]" % str(self._AutoGenObject))
self.ProcessBuildTargetList()
+ self.ParserGenerateFfsCmd()
# Generate macros used to represent input files
FileMacroList = [] # macro name = file list
@@ -597,10 +624,11 @@ cleanlib:
while not found and os.sep in package_rel_dir:
index = package_rel_dir.index(os.sep)
current_dir = mws.join(current_dir, package_rel_dir[:index])
- for fl in os.listdir(current_dir):
- if fl.endswith('.dec'):
- found = True
- break
+ if os.path.exists(current_dir):
+ for fl in os.listdir(current_dir):
+ if fl.endswith('.dec'):
+ found = True
+ break
package_rel_dir = package_rel_dir[index + 1:]
MakefileTemplateDict = {
@@ -612,6 +640,7 @@ cleanlib:
"platform_version" : self.PlatformInfo.Version,
"platform_relative_directory": self.PlatformInfo.SourceDir,
"platform_output_directory" : self.PlatformInfo.OutputDir,
+ "ffs_output_directory" : self._AutoGenObject.Macros["FFS_OUTPUT_DIR"],
"platform_dir" : self._AutoGenObject.Macros["PLATFORM_DIR"],
"module_name" : self._AutoGenObject.Name,
@@ -658,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('%s' % 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('%s' % 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},
@@ -696,9 +798,13 @@ cleanlib:
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 Attr in self._AutoGenObject.BuildOption[Option]:
@@ -754,7 +860,11 @@ cleanlib:
break
else:
break
- RespDict[Key] = Value
+
+ if self._AutoGenObject.ToolChainFamily == 'GCC':
+ RespDict[Key] = Value.replace('\\', '/')
+ else:
+ RespDict[Key] = Value
for Target in BuildTargets:
for i, SingleCommand in enumerate(BuildTargets[Target].Commands):
if FlagDict[Flag]['Macro'] in SingleCommand:
@@ -770,8 +880,15 @@ cleanlib:
if File.Ext == '.h':
ForceIncludedFile.append(File)
SourceFileList = []
+ OutPutFileList = []
for Target in self._AutoGenObject.IntroTargetList:
SourceFileList.extend(Target.Inputs)
+ OutPutFileList.extend(Target.Outputs)
+
+ if OutPutFileList:
+ for Item in OutPutFileList:
+ if Item in SourceFileList:
+ SourceFileList.remove(Item)
self.FileDependency = self.GetFileDependency(
SourceFileList,
@@ -783,6 +900,9 @@ cleanlib:
if not self.FileDependency[File]:
self.FileDependency[File] = ['$(FORCE_REBUILD)']
continue
+
+ self._AutoGenObject.AutoGenDepSet |= set(self.FileDependency[File])
+
# skip non-C files
if File.Ext not in [".c", ".C"] or File.Name == "AutoGen.c":
continue
@@ -842,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),
@@ -853,7 +975,8 @@ cleanlib:
## For creating makefile targets for dependent libraries
def ProcessDependentLibrary(self):
for LibraryAutoGen in self._AutoGenObject.LibraryAutoGenList:
- self.LibraryBuildDirectoryList.append(self.PlaceMacro(LibraryAutoGen.BuildDir, self.Macros))
+ if not LibraryAutoGen.IsBinaryModule:
+ self.LibraryBuildDirectoryList.append(self.PlaceMacro(LibraryAutoGen.BuildDir, self.Macros))
## Return a list containing source file's dependencies
#
@@ -990,7 +1113,7 @@ PLATFORM_NAME = ${platform_name}
PLATFORM_GUID = ${platform_guid}
PLATFORM_VERSION = ${platform_version}
PLATFORM_RELATIVE_DIR = ${platform_relative_directory}
-PLATFORM_DIR = $(platform_dir)
+PLATFORM_DIR = ${platform_dir}
PLATFORM_OUTPUT_DIR = ${platform_output_directory}
#
@@ -1173,7 +1296,7 @@ PLATFORM_NAME = ${platform_name}
PLATFORM_GUID = ${platform_guid}
PLATFORM_VERSION = ${platform_version}
PLATFORM_FILE = ${platform_file}
-PLATFORM_DIR = $(platform_dir)
+PLATFORM_DIR = ${platform_dir}
PLATFORM_OUTPUT_DIR = ${platform_output_directory}
#
@@ -1423,10 +1546,21 @@ class TopLevelMakefile(BuildFile):
if GlobalData.gCaseInsensitive:
ExtraOption += " -c"
-
+ if GlobalData.gEnableGenfdsMultiThread:
+ ExtraOption += " --genfds-multi-thread"
if GlobalData.gIgnoreSource:
ExtraOption += " --ignore-sources"
+ 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: