Revision: 17509
http://sourceforge.net/p/edk2/code/17509
Author: lgao4
Date: 2015-05-26 10:32:07 +0000 (Tue, 26 May 2015)
Log Message:
-----------
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 <[email protected]>
Reviewed-by: Liming Gao <[email protected]>
Modified Paths:
--------------
trunk/edk2/BaseTools/Source/Python/AutoGen/AutoGen.py
trunk/edk2/BaseTools/Source/Python/AutoGen/BuildEngine.py
trunk/edk2/BaseTools/Source/Python/Common/DataType.py
Modified: trunk/edk2/BaseTools/Source/Python/AutoGen/AutoGen.py
===================================================================
--- trunk/edk2/BaseTools/Source/Python/AutoGen/AutoGen.py 2015-05-26
07:41:30 UTC (rev 17508)
+++ trunk/edk2/BaseTools/Source/Python/AutoGen/AutoGen.py 2015-05-26
10:32:07 UTC (rev 17509)
@@ -2082,6 +2082,13 @@
else:
PlatformModuleOptions = {}
+ BuildRuleOrder = None
+ for Options in [self.ToolDefinition, ModuleOptions, PlatformOptions,
PlatformModuleOptions]:
+ for Tool in Options:
+ for Attr in Options[Tool]:
+ if Attr == TAB_TOD_DEFINES_BUILDRULEORDER:
+ BuildRuleOrder = Options[Tool][Attr]
+
AllTools = set(ModuleOptions.keys() + PlatformOptions.keys() +
PlatformModuleOptions.keys() + self.ToolDefinition.keys())
BuildOptions = {}
for Tool in AllTools:
@@ -2093,6 +2100,11 @@
continue
for Attr in Options[Tool]:
Value = Options[Tool][Attr]
+ #
+ # Do not generate it in Makefile
+ #
+ if Attr == TAB_TOD_DEFINES_BUILDRULEORDER:
+ continue
if Attr not in BuildOptions[Tool]:
BuildOptions[Tool][Attr] = ""
# check if override is indicated
@@ -2107,7 +2119,7 @@
if 'BUILD' not in BuildOptions:
BuildOptions['BUILD'] = {}
BuildOptions['BUILD']['FLAGS'] = self.Workspace.UniFlag
- return BuildOptions
+ return BuildOptions, BuildRuleOrder
Platform = property(_GetPlatform)
Name = property(_GetName)
@@ -2195,6 +2207,7 @@
self.DepexGenerated = False
self.BuildDatabase = self.Workspace.BuildDatabase
+ self.BuildRuleOrder = None
self._Module = None
self._Name = None
@@ -2587,7 +2600,9 @@
#
def _GetModuleBuildOption(self):
if self._BuildOption == None:
- self._BuildOption = self.PlatformInfo.ApplyBuildOption(self.Module)
+ self._BuildOption, self.BuildRuleOrder =
self.PlatformInfo.ApplyBuildOption(self.Module)
+ if self.BuildRuleOrder:
+ self.BuildRuleOrder = ['.%s' % Ext for Ext in
self.BuildRuleOrder.split()]
return self._BuildOption
## Get include path list from tool option for the module build
@@ -2746,6 +2761,11 @@
RuleChain = []
SourceList = [File]
Index = 0
+ #
+ # Make sure to get build rule order value
+ #
+ self._GetModuleBuildOption()
+
while Index < len(SourceList):
Source = SourceList[Index]
Index = Index + 1
@@ -2779,7 +2799,7 @@
self._FinalBuildTargetList.add(LastTarget)
break
- Target = RuleObject.Apply(Source)
+ Target = RuleObject.Apply(Source, self.BuildRuleOrder)
if not Target:
if LastTarget:
self._FinalBuildTargetList.add(LastTarget)
Modified: trunk/edk2/BaseTools/Source/Python/AutoGen/BuildEngine.py
===================================================================
--- trunk/edk2/BaseTools/Source/Python/AutoGen/BuildEngine.py 2015-05-26
07:41:30 UTC (rev 17508)
+++ trunk/edk2/BaseTools/Source/Python/AutoGen/BuildEngine.py 2015-05-26
10:32:07 UTC (rev 17509)
@@ -220,7 +220,7 @@
#
# @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 @@
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 @@
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
Modified: trunk/edk2/BaseTools/Source/Python/Common/DataType.py
===================================================================
--- trunk/edk2/BaseTools/Source/Python/Common/DataType.py 2015-05-26
07:41:30 UTC (rev 17508)
+++ trunk/edk2/BaseTools/Source/Python/Common/DataType.py 2015-05-26
10:32:07 UTC (rev 17509)
@@ -432,6 +432,7 @@
TAB_TOD_DEFINES_COMMAND_TYPE = 'COMMAND_TYPE'
TAB_TOD_DEFINES_FAMILY = 'FAMILY'
TAB_TOD_DEFINES_BUILDRULEFAMILY = 'BUILDRULEFAMILY'
+TAB_TOD_DEFINES_BUILDRULEORDER = 'BUILDRULEORDER'
#
# Conditional Statements
------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits