X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2FAutoGen%2FGenMake.py;h=60bd625cd2b1f7d88b2722b52cb05b51c8d70374;hb=0f228f19fb40ffe60b13962ff639917435c562a9;hp=64eedfaa1223dbdc562573613cec8ee3c09260c7;hpb=1be2ed90a20618d71ddf34b8a07d038da0b36854;p=mirror_edk2.git
diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/Python/AutoGen/GenMake.py
index 64eedfaa12..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 - 2014, 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
@@ -19,7 +19,7 @@ import string
import re
import os.path as path
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 *
@@ -27,7 +27,7 @@ from BuildEngine import *
import Common.GlobalData as GlobalData
## 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)
+gIncludePattern = re.compile(r"^[ \t]*#?[ \t]*include(?:[ \t]*(?:\\(?:\r\n|\r|\n))*[ \t]*)*(?:\(?[\"<]?[ \t]*)([-\w.\\/() \t]+)(?:[ \t]*[\">]?\)?)", re.MULTILINE | re.UNICODE | re.IGNORECASE)
## Regular expression for matching macro used in header file inclusion
gMacroPattern = re.compile("([_A-Z][_A-Z0-9]*)[ \t]*\((.+)\)", re.UNICODE)
@@ -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
@@ -233,7 +240,7 @@ PLATFORM_NAME = ${platform_name}
PLATFORM_GUID = ${platform_guid}
PLATFORM_VERSION = ${platform_version}
PLATFORM_RELATIVE_DIR = ${platform_relative_directory}
-PLATFORM_DIR = $(WORKSPACE)${separator}${platform_relative_directory}
+PLATFORM_DIR = ${platform_dir}
PLATFORM_OUTPUT_DIR = ${platform_output_directory}
#
@@ -241,13 +248,16 @@ PLATFORM_OUTPUT_DIR = ${platform_output_directory}
#
MODULE_NAME = ${module_name}
MODULE_GUID = ${module_guid}
+MODULE_NAME_GUID = ${module_name_guid}
MODULE_VERSION = ${module_version}
MODULE_TYPE = ${module_type}
MODULE_FILE = ${module_file}
MODULE_FILE_BASE_NAME = ${module_file_base_name}
BASE_NAME = $(MODULE_NAME)
MODULE_RELATIVE_DIR = ${module_relative_directory}
-MODULE_DIR = $(WORKSPACE)${separator}${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}
@@ -384,7 +394,7 @@ ${END}
#
clean:
\t${BEGIN}${clean_command}
-\t${END}
+\t${END}\t$(RM) AutoGenTimeStamp
#
# clean all generated files
@@ -393,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
@@ -438,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):
@@ -475,6 +490,22 @@ cleanlib:
# 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
+
+ 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
+
+ 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]
@@ -492,16 +523,51 @@ 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("")
+ # generate the Response file and Response flag
+ RespDict = self.CommandExceedLimit()
+ RespFileList = os.path.join(self._AutoGenObject.OutputDir, 'respfilelist.txt')
+ if RespDict:
+ RespFileListContent = ''
+ for Resp in RespDict.keys():
+ RespFile = os.path.join(self._AutoGenObject.OutputDir, str(Resp).lower() + '.txt')
+ StrList = RespDict[Resp].split(' ')
+ UnexpandMacro = []
+ NewStr = []
+ for Str in StrList:
+ if '$' in Str:
+ UnexpandMacro.append(Str)
+ else:
+ NewStr.append(Str)
+ UnexpandMacroStr = ' '.join(UnexpandMacro)
+ NewRespStr = ' '.join(NewStr)
+ SaveFileOnChange(RespFile, NewRespStr, False)
+ ToolsDef.append("%s = %s" % (Resp, UnexpandMacroStr + ' @' + RespFile))
+ RespFileListContent += '@' + RespFile + os.linesep
+ RespFileListContent += NewRespStr + os.linesep
+ SaveFileOnChange(RespFileList, RespFileListContent, False)
+ else:
+ if os.path.exists(RespFileList):
+ 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:
+ if len(self.ResultFileList) == 0 and len(self._AutoGenObject.SourceFileList) <> 0:
EdkLogger.error("build", AUTOGEN_ERROR, "Nothing to build",
ExtraData="[%s]" % str(self._AutoGenObject))
self.ProcessBuildTargetList()
+ self.ParserGenerateFfsCmd()
# Generate macros used to represent input files
FileMacroList = [] # macro name = file list
@@ -518,9 +584,9 @@ cleanlib:
FileMacro = ""
IncludePathList = []
for P in self._AutoGenObject.IncludePathList:
- IncludePathList.append(IncPrefix+self.PlaceMacro(P, self.Macros))
+ 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)
+ self.ListFileMacros[FileBuildRule.INC_LIST_MACRO].append(IncPrefix + P)
FileMacro += self._FILE_MACRO_TEMPLATE.Replace(
{
"macro_name" : "INC",
@@ -531,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(self._AutoGenObject.OutputDir, "%s.lst" % ListFileMacro.lower()[:len(ListFileMacro) - 5])
FileMacroList.append("%s = %s" % (ListFileMacro, ListFileName))
SaveFileOnChange(
ListFileName,
@@ -552,6 +618,19 @@ cleanlib:
Command = self._MAKE_TEMPLATE_[self._FileType] % {"file":os.path.join(D, MakefileName)}
LibraryMakeCommandList.append(Command)
+ package_rel_dir = self._AutoGenObject.SourceDir
+ current_dir = self.Macros["WORKSPACE"]
+ found = False
+ 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])
+ 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 = {
"makefile_header" : self._FILE_HEADER_[self._FileType],
"makefile_path" : os.path.join("$(MODULE_BUILD_DIR)", MakefileName),
@@ -561,15 +640,20 @@ 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,
"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_extra_defines" : ["%s = %s" % (k, v) for k,v in self._AutoGenObject.Module.Defines.iteritems()],
+ "module_dir" : mws.join (self.Macros["WORKSPACE"], self._AutoGenObject.SourceDir),
+ "package_relative_directory": package_rel_dir,
+ "module_extra_defines" : ["%s = %s" % (k, v) for k, v in self._AutoGenObject.Module.Defines.iteritems()],
"architecture" : self._AutoGenObject.Arch,
"toolchain_tag" : self._AutoGenObject.ToolChain,
@@ -603,6 +687,190 @@ 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},
+ 'PP' : { 'Macro' : '$(PP_FLAGS)', 'Value' : False},
+ 'APP' : { 'Macro' : '$(APP_FLAGS)', 'Value' : False},
+ 'ASLPP' : { 'Macro' : '$(ASLPP_FLAGS)', 'Value' : False},
+ 'VFRPP' : { 'Macro' : '$(VFRPP_FLAGS)', 'Value' : False},
+ 'ASM' : { 'Macro' : '$(ASM_FLAGS)', 'Value' : False},
+ 'ASLCC' : { 'Macro' : '$(ASLCC_FLAGS)', 'Value' : False},
+ }
+
+ RespDict = {}
+ FileTypeList = []
+ IncPrefix = self._INC_FLAG_[self._AutoGenObject.ToolChainFamily]
+
+ # base on the source files to decide the file type
+ for File in self._AutoGenObject.SourceFileList:
+ for type in self._AutoGenObject.FileTypes:
+ if File in self._AutoGenObject.FileTypes[type]:
+ if type not in FileTypeList:
+ FileTypeList.append(type)
+
+ # calculate the command-line length
+ if FileTypeList:
+ for type in FileTypeList:
+ BuildTargets = self._AutoGenObject.BuildRules[type].BuildTargets
+ for Target in BuildTargets:
+ CommandList = BuildTargets[Target].Commands
+ for SingleCommand in CommandList:
+ Tool = ''
+ SingleCommandLength = len(SingleCommand)
+ SingleCommandList = SingleCommand.split()
+ if len(SingleCommandList) > 0:
+ for Flag in FlagDict.keys():
+ 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 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():
+ MacroName = '$('+ macro + ')'
+ if (Str.find(MacroName) != -1):
+ Str = Str.replace(MacroName, self._AutoGenObject.Macros[macro])
+ break
+ else:
+ break
+ SingleCommandLength += len(Str)
+ elif '$(INC)' in item:
+ SingleCommandLength += self._AutoGenObject.IncludePathLength + len(IncPrefix) * len(self._AutoGenObject._IncludePathList)
+ elif item.find('$(') != -1:
+ Str = item
+ for Option in self._AutoGenObject.BuildOption.keys():
+ 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():
+ MacroName = '$('+ macro + ')'
+ if (Str.find(MacroName) != -1):
+ Str = Str.replace(MacroName, self._AutoGenObject.Macros[macro])
+ break
+ else:
+ break
+ SingleCommandLength += len(Str)
+
+ if SingleCommandLength > GlobalData.gCommandMaxLength:
+ FlagDict[Tool]['Value'] = True
+
+ # generate the response file content by combine the FLAGS and INC
+ for Flag in FlagDict.keys():
+ 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 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():
+ MacroName = '$('+ macro + ')'
+ if (Value.find(MacroName) != -1):
+ Value = Value.replace(MacroName, self._AutoGenObject.Macros[macro])
+ break
+ else:
+ break
+
+ 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:
+ BuildTargets[Target].Commands[i] = SingleCommand.replace('$(INC)','').replace(FlagDict[Flag]['Macro'], RespMacro)
+ return RespDict
+
def ProcessBuildTargetList(self):
#
# Search dependency file list for each source file
@@ -612,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,
@@ -625,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
@@ -673,7 +951,8 @@ cleanlib:
NewFile = self.PlaceMacro(str(F), self.Macros)
# In order to use file list macro as dependency
if T.GenListFile:
- self.ListFileMacros[T.ListFileMacro].append(str(F))
+ # gnu tools need forward slash path separater, even on Windows
+ self.ListFileMacros[T.ListFileMacro].append(str(F).replace ('\\', '/'))
self.FileListMacros[T.FileListMacro].append(NewFile)
elif T.GenFileListMacro:
self.FileListMacros[T.FileListMacro].append(NewFile)
@@ -683,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),
@@ -694,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
#
@@ -750,7 +1032,7 @@ cleanlib:
try:
Fd = open(F.Path, 'r')
except BaseException, X:
- EdkLogger.error("build", FILE_OPEN_FAILURE, ExtraData=F.Path+"\n\t"+str(X))
+ EdkLogger.error("build", FILE_OPEN_FAILURE, ExtraData=F.Path + "\n\t" + str(X))
FileContent = Fd.read()
Fd.close()
@@ -831,7 +1113,7 @@ PLATFORM_NAME = ${platform_name}
PLATFORM_GUID = ${platform_guid}
PLATFORM_VERSION = ${platform_version}
PLATFORM_RELATIVE_DIR = ${platform_relative_directory}
-PLATFORM_DIR = $(WORKSPACE)${separator}${platform_relative_directory}
+PLATFORM_DIR = ${platform_dir}
PLATFORM_OUTPUT_DIR = ${platform_output_directory}
#
@@ -839,13 +1121,14 @@ PLATFORM_OUTPUT_DIR = ${platform_output_directory}
#
MODULE_NAME = ${module_name}
MODULE_GUID = ${module_guid}
+MODULE_NAME_GUID = ${module_name_guid}
MODULE_VERSION = ${module_version}
MODULE_TYPE = ${module_type}
MODULE_FILE = ${module_file}
MODULE_FILE_BASE_NAME = ${module_file_base_name}
BASE_NAME = $(MODULE_NAME)
MODULE_RELATIVE_DIR = ${module_relative_directory}
-MODULE_DIR = $(WORKSPACE)${separator}${module_relative_directory}
+MODULE_DIR = ${module_dir}
#
# Build Configuration Macro Definition
@@ -926,7 +1209,7 @@ ${BEGIN}\t-@${create_directory_command}\n${END}\
if self._FileType not in self._AutoGenObject.CustomMakefile:
EdkLogger.error('build', OPTION_NOT_SUPPORTED, "No custom makefile for %s" % self._FileType,
ExtraData="[%s]" % str(self._AutoGenObject))
- MakefilePath = os.path.join(
+ MakefilePath = mws.join(
self._AutoGenObject.WorkspaceDir,
self._AutoGenObject.CustomMakefile[self._FileType]
)
@@ -960,14 +1243,17 @@ ${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,
@@ -1010,7 +1296,7 @@ PLATFORM_NAME = ${platform_name}
PLATFORM_GUID = ${platform_guid}
PLATFORM_VERSION = ${platform_version}
PLATFORM_FILE = ${platform_file}
-PLATFORM_DIR = $(WORKSPACE)${separator}${platform_relative_directory}
+PLATFORM_DIR = ${platform_dir}
PLATFORM_OUTPUT_DIR = ${platform_output_directory}
#
@@ -1105,6 +1391,7 @@ cleanlib:
self.IntermediateDirectoryList = []
self.ModuleBuildDirectoryList = []
self.LibraryBuildDirectoryList = []
+ self.LibraryMakeCommandList = []
# Compose a dict object containing information used to do replacement in template
def _CreateTemplateDict(self):
@@ -1128,6 +1415,7 @@ cleanlib:
Command = self._MAKE_TEMPLATE_[self._FileType] % {"file":Makefile}
LibraryMakefileList.append(Makefile)
LibraryMakeCommandList.append(Command)
+ self.LibraryMakeCommandList = LibraryMakeCommandList
ModuleMakefileList = []
ModuleMakeCommandList = []
@@ -1150,6 +1438,7 @@ cleanlib:
"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,
@@ -1175,7 +1464,8 @@ cleanlib:
def GetModuleBuildDirectoryList(self):
DirList = []
for ModuleAutoGen in self._AutoGenObject.ModuleAutoGenList:
- DirList.append(os.path.join(self._AutoGenObject.BuildDir, ModuleAutoGen.BuildDir))
+ if not ModuleAutoGen.IsBinaryModule:
+ DirList.append(os.path.join(self._AutoGenObject.BuildDir, ModuleAutoGen.BuildDir))
return DirList
## Get the root directory list for intermediate files of all libraries build
@@ -1185,7 +1475,8 @@ cleanlib:
def GetLibraryBuildDirectoryList(self):
DirList = []
for LibraryAutoGen in self._AutoGenObject.LibraryAutoGenList:
- DirList.append(os.path.join(self._AutoGenObject.BuildDir, LibraryAutoGen.BuildDir))
+ if not LibraryAutoGen.IsBinaryModule:
+ DirList.append(os.path.join(self._AutoGenObject.BuildDir, LibraryAutoGen.BuildDir))
return DirList
_TemplateDict = property(_CreateTemplateDict)
@@ -1198,99 +1489,7 @@ cleanlib:
#
class TopLevelMakefile(BuildFile):
## template used to generate toplevel makefile
- _TEMPLATE_ = TemplateString('''\
-${makefile_header}
-
-#
-# Platform Macro Definition
-#
-PLATFORM_NAME = ${platform_name}
-PLATFORM_GUID = ${platform_guid}
-PLATFORM_VERSION = ${platform_version}
-
-#
-# Build Configuration Macro Definition
-#
-TOOLCHAIN = ${toolchain_tag}
-TOOLCHAIN_TAG = ${toolchain_tag}
-TARGET = ${build_target}
-
-#
-# Build Directory Macro Definition
-#
-BUILD_DIR = ${platform_build_directory}
-FV_DIR = ${platform_build_directory}${separator}FV
-
-#
-# Shell Command Macro
-#
-${BEGIN}${shell_command_code} = ${shell_command}
-${END}
-
-MAKE = ${make_path}
-MAKE_FILE = ${makefile_path}
-
-#
-# Default target
-#
-all: modules fds
-
-#
-# Initialization target: print build information and create necessary directories
-#
-init:
-\t-@
-\t${BEGIN}-@${create_directory_command}
-\t${END}
-#
-# library build target
-#
-libraries: init
-${BEGIN}\t@cd $(BUILD_DIR)${separator}${arch} && "$(MAKE)" $(MAKE_FLAGS) libraries
-${END}\t@cd $(BUILD_DIR)
-
-#
-# module build target
-#
-modules: init
-${BEGIN}\t@cd $(BUILD_DIR)${separator}${arch} && "$(MAKE)" $(MAKE_FLAGS) modules
-${END}\t@cd $(BUILD_DIR)
-
-#
-# Flash Device Image Target
-#
-fds: init
-\t-@cd $(FV_DIR)
-${BEGIN}\tGenFds -f ${fdf_file} -o $(BUILD_DIR) -t $(TOOLCHAIN) -b $(TARGET) -p ${active_platform} -a ${build_architecture_list} ${extra_options}${END}${BEGIN} -r ${fd} ${END}${BEGIN} -i ${fv} ${END}${BEGIN} -C ${cap} ${END}${BEGIN} -D ${macro} ${END}
-
-#
-# run command for emulator platform only
-#
-run:
-\tcd $(BUILD_DIR)${separator}IA32 && ".${separator}SecMain"
-\tcd $(BUILD_DIR)
-
-#
-# Clean intermediate files
-#
-clean:
-${BEGIN}\t-@${sub_build_command} clean
-${END}\t@cd $(BUILD_DIR)
-
-#
-# Clean all generated files except to makefile
-#
-cleanall:
-${BEGIN}\t${cleanall_command}
-${END}
-
-#
-# Clean all library files
-#
-cleanlib:
-${BEGIN}\t-@${sub_build_command} cleanlib
-${END}\t@cd $(BUILD_DIR)\n
-''')
+ _TEMPLATE_ = TemplateString('''${BEGIN}\tGenFds -f ${fdf_file} --conf=${conf_directory} -o ${platform_build_directory} -t ${toolchain_tag} -b ${build_target} -p ${active_platform} -a ${build_architecture_list} ${extra_options}${END}${BEGIN} -r ${fd} ${END}${BEGIN} -i ${fv} ${END}${BEGIN} -C ${cap} ${END}${BEGIN} -D ${macro} ${END}''')
## Constructor of TopLevelMakefile
#
@@ -1347,6 +1546,20 @@ ${END}\t@cd $(BUILD_DIR)\n
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 = []
@@ -1362,6 +1575,7 @@ ${END}\t@cd $(BUILD_DIR)\n
"platform_guid" : PlatformInfo.Guid,
"platform_version" : PlatformInfo.Version,
"platform_build_directory" : PlatformInfo.BuildDir,
+ "conf_directory" : GlobalData.gConfDirectory,
"toolchain_tag" : PlatformInfo.ToolChain,
"build_target" : PlatformInfo.BuildTarget,
@@ -1391,7 +1605,8 @@ ${END}\t@cd $(BUILD_DIR)\n
def GetModuleBuildDirectoryList(self):
DirList = []
for ModuleAutoGen in self._AutoGenObject.ModuleAutoGenList:
- DirList.append(os.path.join(self._AutoGenObject.BuildDir, ModuleAutoGen.BuildDir))
+ if not ModuleAutoGen.IsBinaryModule:
+ DirList.append(os.path.join(self._AutoGenObject.BuildDir, ModuleAutoGen.BuildDir))
return DirList
## Get the root directory list for intermediate files of all libraries build
@@ -1401,7 +1616,8 @@ ${END}\t@cd $(BUILD_DIR)\n
def GetLibraryBuildDirectoryList(self):
DirList = []
for LibraryAutoGen in self._AutoGenObject.LibraryAutoGenList:
- DirList.append(os.path.join(self._AutoGenObject.BuildDir, LibraryAutoGen.BuildDir))
+ if not LibraryAutoGen.IsBinaryModule:
+ DirList.append(os.path.join(self._AutoGenObject.BuildDir, LibraryAutoGen.BuildDir))
return DirList
_TemplateDict = property(_CreateTemplateDict)