#\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
\r
# find the build_rule_version\r
if Line and Line[0] == "#" and Line.find(TAB_BUILD_RULE_VERSION) <> -1:\r
- if Line.find("=") <> -1 and Line.find("=") < (len(Line)-1) and (Line[(Line.find("=") + 1):]).split():\r
+ if Line.find("=") <> -1 and Line.find("=") < (len(Line) - 1) and (Line[(Line.find("=") + 1):]).split():\r
self._FileVersion = (Line[(Line.find("=") + 1):]).split()[0]\r
# skip empty or comment line\r
if Line == "" or Line[0] == "#":\r
if TokenList[0] == "BUILD":\r
if len(TokenList) == 1:\r
EdkLogger.error("build", FORMAT_INVALID, "Invalid rule section",\r
- File=self.RuleFile, Line=LineIndex+1,\r
+ File=self.RuleFile, Line=LineIndex + 1,\r
ExtraData=self.RuleContent[LineIndex])\r
\r
FileType = TokenList[1]\r
if FileType == '':\r
EdkLogger.error("build", FORMAT_INVALID, "No file type given",\r
- File=self.RuleFile, Line=LineIndex+1,\r
+ File=self.RuleFile, Line=LineIndex + 1,\r
ExtraData=self.RuleContent[LineIndex])\r
if self._FileTypePattern.match(FileType) == None:\r
- EdkLogger.error("build", FORMAT_INVALID, File=self.RuleFile, Line=LineIndex+1,\r
+ EdkLogger.error("build", FORMAT_INVALID, File=self.RuleFile, Line=LineIndex + 1,\r
ExtraData="Only character, number (non-first character), '_' and '-' are allowed in file type")\r
# new format: File-Type.Build-Type.Arch\r
else:\r
elif FileType != TokenList[0]:\r
EdkLogger.error("build", FORMAT_INVALID,\r
"Different file types are not allowed in the same rule section",\r
- File=self.RuleFile, Line=LineIndex+1,\r
+ File=self.RuleFile, Line=LineIndex + 1,\r
ExtraData=self.RuleContent[LineIndex])\r
if len(TokenList) > 1:\r
BuildType = TokenList[1]\r
if 'COMMON' in self._BuildTypeList and len(self._BuildTypeList) > 1:\r
EdkLogger.error("build", FORMAT_INVALID,\r
"Specific build types must not be mixed with common one",\r
- File=self.RuleFile, Line=LineIndex+1,\r
+ File=self.RuleFile, Line=LineIndex + 1,\r
ExtraData=self.RuleContent[LineIndex])\r
if 'COMMON' in self._ArchList and len(self._ArchList) > 1:\r
EdkLogger.error("build", FORMAT_INVALID,\r
"Specific ARCH must not be mixed with common one",\r
- File=self.RuleFile, Line=LineIndex+1,\r
+ File=self.RuleFile, Line=LineIndex + 1,\r
ExtraData=self.RuleContent[LineIndex])\r
\r
self._FileType = FileType\r
elif SectionType != Type:\r
EdkLogger.error("build", FORMAT_INVALID,\r
"Two different section types are not allowed in the same sub-section",\r
- File=self.RuleFile, Line=LineIndex+1,\r
+ File=self.RuleFile, Line=LineIndex + 1,\r
ExtraData=self.RuleContent[LineIndex])\r
\r
if len(TokenList) > 1:\r
if 'COMMON' in FamilyList and len(FamilyList) > 1:\r
EdkLogger.error("build", FORMAT_INVALID,\r
"Specific tool chain family should not be mixed with general one",\r
- File=self.RuleFile, Line=LineIndex+1,\r
+ File=self.RuleFile, Line=LineIndex + 1,\r
ExtraData=self.RuleContent[LineIndex])\r
if self._State not in self._StateHandler:\r
- EdkLogger.error("build", FORMAT_INVALID, File=self.RuleFile, Line=LineIndex+1,\r
+ EdkLogger.error("build", FORMAT_INVALID, File=self.RuleFile, Line=LineIndex + 1,\r
ExtraData="Unknown subsection: %s" % self.RuleContent[LineIndex])\r
## Parse <InputFile> sub-section\r
#\r