BaseTools: Implement BUILDRULEORDER for tools_def
This feature allows the toolchain to choose a preference for source file extensions in tools_def.txt. The first extension is given the highest priority. Here is an example usage for tools_def.txt: *_*_*_*_BUILDRULEORDER = nasm Nasm NASM asm Asm ASM S s *_XCODE5_*_*_BUILDRULEORDER = S s nasm Nasm NASM Now, if a .inf lists these sources: 1.nasm, 1.asm and 1.S All toolchains, except XCODE5 will use the 1.nasm file. The XCODE5 toolchain will use the 1.S file. Note that the build_rule.txt file also impacts the decision, because, for instance there is no build rule for .asm files on GCC toolchains. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yingke Liu <yingke.d.liu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17509 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@ -220,7 +220,7 @@ class FileBuildRule:
|
||||
#
|
||||
# @retval tuple (Source file in full path, List of individual sourcefiles, Destionation file, List of build commands)
|
||||
#
|
||||
def Apply(self, SourceFile):
|
||||
def Apply(self, SourceFile, BuildRuleOrder=None):
|
||||
if not self.CommandList or not self.DestFileList:
|
||||
return None
|
||||
|
||||
@ -281,13 +281,20 @@ class FileBuildRule:
|
||||
|
||||
if DstFile[0] in self.BuildTargets:
|
||||
TargetDesc = self.BuildTargets[DstFile[0]]
|
||||
TargetDesc.AddInput(SourceFile)
|
||||
if BuildRuleOrder and SourceFile.Ext in BuildRuleOrder:
|
||||
Index = BuildRuleOrder.index(SourceFile.Ext)
|
||||
for Input in TargetDesc.Inputs:
|
||||
if Input.Ext not in BuildRuleOrder or BuildRuleOrder.index(Input.Ext) > Index:
|
||||
#
|
||||
# Command line should be regenerated since some macros are different
|
||||
#
|
||||
CommandList = self._BuildCommand(BuildRulePlaceholderDict)
|
||||
TargetDesc._Init([SourceFile], DstFile, CommandList, self.ExtraSourceFileList)
|
||||
break
|
||||
else:
|
||||
TargetDesc.AddInput(SourceFile)
|
||||
else:
|
||||
CommandList = []
|
||||
for CommandString in self.CommandList:
|
||||
CommandString = string.Template(CommandString).safe_substitute(BuildRulePlaceholderDict)
|
||||
CommandString = string.Template(CommandString).safe_substitute(BuildRulePlaceholderDict)
|
||||
CommandList.append(CommandString)
|
||||
CommandList = self._BuildCommand(BuildRulePlaceholderDict)
|
||||
TargetDesc = TargetDescBlock([SourceFile], DstFile, CommandList, self.ExtraSourceFileList)
|
||||
TargetDesc.ListFileMacro = self.ListFileMacro
|
||||
TargetDesc.FileListMacro = self.FileListMacro
|
||||
@ -298,6 +305,14 @@ class FileBuildRule:
|
||||
self.BuildTargets[DstFile[0]] = TargetDesc
|
||||
return TargetDesc
|
||||
|
||||
def _BuildCommand(self, Macros):
|
||||
CommandList = []
|
||||
for CommandString in self.CommandList:
|
||||
CommandString = string.Template(CommandString).safe_substitute(Macros)
|
||||
CommandString = string.Template(CommandString).safe_substitute(Macros)
|
||||
CommandList.append(CommandString)
|
||||
return CommandList
|
||||
|
||||
## Class for build rules
|
||||
#
|
||||
# BuildRule class parses rules defined in a file or passed by caller, and converts
|
||||
|
Reference in New Issue
Block a user