BaseTools: process the files by the priority in BUILDRULEORDER
authorYonghong Zhu <yonghong.zhu@intel.com>
Mon, 7 Dec 2015 09:09:31 +0000 (09:09 +0000)
committeryzhu52 <yzhu52@Edk2>
Mon, 7 Dec 2015 09:09:31 +0000 (09:09 +0000)
By the BUILDRULEORDER feature to process files listed in INF [Sources]
sections in priority order, if a filename is listed with multiple
extensions, the tools will use only the file that matches the first
extension in the space separated list.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19143 6f19259b-4bc3-4df7-8a09-765794883524

BaseTools/Source/Python/AutoGen/AutoGen.py

index 4c627dfb555a1c5d2287b8d2f0063441a5950e03..cf0b4466f9925f563a8e927fcf76d2477d602248 100644 (file)
@@ -2713,9 +2713,36 @@ class ModuleAutoGen(AutoGen):
                 if F.Dir not in self.IncludePathList and self.AutoGenVersion >= 0x00010005:\r
                     self.IncludePathList.insert(0, F.Dir)\r
                 self._SourceFileList.append(F)\r
+\r
+            self._MatchBuildRuleOrder(self._SourceFileList)\r
+\r
+            for F in self._SourceFileList:\r
                 self._ApplyBuildRule(F, TAB_UNKNOWN_FILE)\r
         return self._SourceFileList\r
 \r
+    def _MatchBuildRuleOrder(self, FileList):\r
+        Order_Dict = {}\r
+        self._GetModuleBuildOption()\r
+        for SingleFile in FileList:\r
+            if self.BuildRuleOrder and SingleFile.Ext in self.BuildRuleOrder:\r
+                key = SingleFile.Path.split(SingleFile.Ext)[0]\r
+                if key in Order_Dict:\r
+                    Order_Dict[key].append(SingleFile.Ext)\r
+                else:\r
+                    Order_Dict[key] = [SingleFile.Ext]\r
+\r
+        RemoveList = []\r
+        for F in Order_Dict:\r
+            if len(Order_Dict[F]) > 1:\r
+                Order_Dict[F].sort(key=lambda i: self.BuildRuleOrder.index(i))\r
+                for Ext in Order_Dict[F][1:]:\r
+                    RemoveList.append(F + Ext)\r
+                   \r
+        for item in RemoveList:\r
+            FileList.remove(item)\r
+\r
+        return FileList\r
+\r
     ## Return the list of unicode files\r
     def _GetUnicodeFileList(self):\r
         if self._UnicodeFileList == None:\r