]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/AutoGen/BuildEngine.py
BaseTools: Implement BUILDRULEORDER for tools_def
[mirror_edk2.git] / BaseTools / Source / Python / AutoGen / BuildEngine.py
index b3083d0395f3f692e27f2156302029112b605108..ee1d3c89f292d3cbbcdc96bbd57845c130b3bb0f 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # The engine for building files\r
 #\r
-# Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
 ##\r
 # Import Modules\r
 #\r
-import os\r
+import Common.LongFilePathOs as os\r
 import re\r
 import copy\r
 import string\r
+from Common.LongFilePathSupport import OpenLongFilePath as open\r
 \r
 from Common.GlobalData import *\r
 from Common.BuildToolError import *\r
@@ -219,7 +220,7 @@ class FileBuildRule:
     #\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
@@ -280,13 +281,20 @@ class FileBuildRule:
 \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
@@ -297,6 +305,14 @@ class FileBuildRule:
             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