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
else:\r
PlatformModuleOptions = {}\r
\r
+ BuildRuleOrder = None\r
+ for Options in [self.ToolDefinition, ModuleOptions, PlatformOptions, PlatformModuleOptions]:\r
+ for Tool in Options:\r
+ for Attr in Options[Tool]:\r
+ if Attr == TAB_TOD_DEFINES_BUILDRULEORDER:\r
+ BuildRuleOrder = Options[Tool][Attr]\r
+\r
AllTools = set(ModuleOptions.keys() + PlatformOptions.keys() + PlatformModuleOptions.keys() + self.ToolDefinition.keys())\r
BuildOptions = {}\r
for Tool in AllTools:\r
continue\r
for Attr in Options[Tool]:\r
Value = Options[Tool][Attr]\r
+ #\r
+ # Do not generate it in Makefile\r
+ #\r
+ if Attr == TAB_TOD_DEFINES_BUILDRULEORDER:\r
+ continue\r
if Attr not in BuildOptions[Tool]:\r
BuildOptions[Tool][Attr] = ""\r
# check if override is indicated\r
if 'BUILD' not in BuildOptions:\r
BuildOptions['BUILD'] = {}\r
BuildOptions['BUILD']['FLAGS'] = self.Workspace.UniFlag\r
- return BuildOptions\r
+ return BuildOptions, BuildRuleOrder\r
\r
Platform = property(_GetPlatform)\r
Name = property(_GetName)\r
self.DepexGenerated = False\r
\r
self.BuildDatabase = self.Workspace.BuildDatabase\r
+ self.BuildRuleOrder = None\r
\r
self._Module = None\r
self._Name = None\r
#\r
def _GetModuleBuildOption(self):\r
if self._BuildOption == None:\r
- self._BuildOption = self.PlatformInfo.ApplyBuildOption(self.Module)\r
+ self._BuildOption, self.BuildRuleOrder = self.PlatformInfo.ApplyBuildOption(self.Module)\r
+ if self.BuildRuleOrder:\r
+ self.BuildRuleOrder = ['.%s' % Ext for Ext in self.BuildRuleOrder.split()]\r
return self._BuildOption\r
\r
## Get include path list from tool option for the module build\r
RuleChain = []\r
SourceList = [File]\r
Index = 0\r
+ #\r
+ # Make sure to get build rule order value\r
+ #\r
+ self._GetModuleBuildOption()\r
+\r
while Index < len(SourceList):\r
Source = SourceList[Index]\r
Index = Index + 1\r
self._FinalBuildTargetList.add(LastTarget)\r
break\r
\r
- Target = RuleObject.Apply(Source)\r
+ Target = RuleObject.Apply(Source, self.BuildRuleOrder)\r
if not Target:\r
if LastTarget:\r
self._FinalBuildTargetList.add(LastTarget)\r
#\r
# @retval tuple (Source file in full path, List of individual sourcefiles, Destionation file, List of build commands)\r
#\r
- def Apply(self, SourceFile):\r
+ def Apply(self, SourceFile, BuildRuleOrder=None):\r
if not self.CommandList or not self.DestFileList:\r
return None\r
\r
\r
if DstFile[0] in self.BuildTargets:\r
TargetDesc = self.BuildTargets[DstFile[0]]\r
- TargetDesc.AddInput(SourceFile)\r
+ if BuildRuleOrder and SourceFile.Ext in BuildRuleOrder:\r
+ Index = BuildRuleOrder.index(SourceFile.Ext)\r
+ for Input in TargetDesc.Inputs:\r
+ if Input.Ext not in BuildRuleOrder or BuildRuleOrder.index(Input.Ext) > Index:\r
+ #\r
+ # Command line should be regenerated since some macros are different\r
+ #\r
+ CommandList = self._BuildCommand(BuildRulePlaceholderDict)\r
+ TargetDesc._Init([SourceFile], DstFile, CommandList, self.ExtraSourceFileList)\r
+ break\r
+ else:\r
+ TargetDesc.AddInput(SourceFile)\r
else:\r
- CommandList = []\r
- for CommandString in self.CommandList:\r
- CommandString = string.Template(CommandString).safe_substitute(BuildRulePlaceholderDict)\r
- CommandString = string.Template(CommandString).safe_substitute(BuildRulePlaceholderDict)\r
- CommandList.append(CommandString)\r
+ CommandList = self._BuildCommand(BuildRulePlaceholderDict)\r
TargetDesc = TargetDescBlock([SourceFile], DstFile, CommandList, self.ExtraSourceFileList)\r
TargetDesc.ListFileMacro = self.ListFileMacro\r
TargetDesc.FileListMacro = self.FileListMacro\r
self.BuildTargets[DstFile[0]] = TargetDesc\r
return TargetDesc\r
\r
+ def _BuildCommand(self, Macros):\r
+ CommandList = []\r
+ for CommandString in self.CommandList:\r
+ CommandString = string.Template(CommandString).safe_substitute(Macros)\r
+ CommandString = string.Template(CommandString).safe_substitute(Macros)\r
+ CommandList.append(CommandString)\r
+ return CommandList\r
+\r
## Class for build rules\r
#\r
# BuildRule class parses rules defined in a file or passed by caller, and converts\r
TAB_TOD_DEFINES_COMMAND_TYPE = 'COMMAND_TYPE'\r
TAB_TOD_DEFINES_FAMILY = 'FAMILY'\r
TAB_TOD_DEFINES_BUILDRULEFAMILY = 'BUILDRULEFAMILY'\r
+TAB_TOD_DEFINES_BUILDRULEORDER = 'BUILDRULEORDER'\r
\r
#\r
# Conditional Statements\r