]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: process the files by the priority in BUILDRULEORDER
authorYonghong Zhu <yonghong.zhu@intel.com>
Tue, 19 Jan 2016 12:58:52 +0000 (12:58 +0000)
committeryzhu52 <yzhu52@Edk2>
Tue, 19 Jan 2016 12:58:52 +0000 (12:58 +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@19686 6f19259b-4bc3-4df7-8a09-765794883524

BaseTools/Source/Python/AutoGen/AutoGen.py

index abac47758d36dea5692dbc26d883b3c75d22d634..e9f4888aa19946c5f13beb0b0425e4266bd45a09 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # Generate AutoGen.h, AutoGen.c and *.depex files\r
 #\r
-# Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2007 - 2016, 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
@@ -2741,9 +2741,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 and SingleFile.Ext in self.BuildRules:\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