]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/GenFds/Section.py
BaseTools: use predefined constants instead of local strings
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / Section.py
index d26f464ab97be7e4fecefb0e68bf8c25686fda63..4b368b3ada9de1d1cf8daec76d29bedcd9a68509 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # section base class\r
 #\r
-#  Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2007-2018, Intel Corporation. All rights reserved.<BR>\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
 #\r
 from CommonDataClass.FdfClass import SectionClassObject\r
 from GenFdsGlobalVariable import GenFdsGlobalVariable\r
-import os, glob\r
+import Common.LongFilePathOs as os, glob\r
 from Common import EdkLogger\r
 from Common.BuildToolError import *\r
+from Common.DataType import TAB_ARCH_COMMON\r
 \r
 ## section base class\r
 #\r
@@ -110,28 +111,27 @@ class Section (SectionClassObject):
     #   @param  Dict        dictionary contains macro and its value\r
     #   @retval tuple       (File list, boolean)\r
     #\r
-    def GetFileList(FfsInf, FileType, FileExtension, Dict = {}):\r
-        if FileType in Section.SectFileType.keys() :\r
-            IsSect = True\r
-        else :\r
-            IsSect = False\r
+    def GetFileList(FfsInf, FileType, FileExtension, Dict = {}, IsMakefile=False):\r
+        IsSect = FileType in Section.SectFileType\r
 \r
-        if FileExtension != None:\r
+        if FileExtension is not None:\r
             Suffix = FileExtension\r
         elif IsSect :\r
             Suffix = Section.SectionType.get(FileType)\r
         else:\r
             Suffix = Section.BinFileType.get(FileType)\r
-        if FfsInf == None:\r
+        if FfsInf is None:\r
             EdkLogger.error("GenFds", GENFDS_ERROR, 'Inf File does not exist!')\r
 \r
         FileList = []\r
-        if FileType != None:\r
+        if FileType is not None:\r
             for File in FfsInf.BinFileList:\r
-                if File.Arch == "COMMON" or FfsInf.CurrentArch == File.Arch:\r
-                    if File.Type == FileType or (int(FfsInf.PiSpecVersion, 16) >= 0x0001000A and FileType == 'DXE_DPEX'and File.Type == 'SMM_DEPEX'):\r
+                if File.Arch == TAB_ARCH_COMMON or FfsInf.CurrentArch == File.Arch:\r
+                    if File.Type == FileType or (int(FfsInf.PiSpecVersion, 16) >= 0x0001000A \\r
+                                                 and FileType == 'DXE_DPEX'and File.Type == 'SMM_DEPEX') \\r
+                                                 or (FileType == 'TE'and File.Type == 'PE32'):\r
                         if '*' in FfsInf.TargetOverrideList or File.Target == '*' or File.Target in FfsInf.TargetOverrideList or FfsInf.TargetOverrideList == []:\r
-                            FileList.append(File.Path)\r
+                            FileList.append(FfsInf.PatchEfiFile(File.Path, File.Type))\r
                         else:\r
                             GenFdsGlobalVariable.InfLogger ("\nBuild Target \'%s\' of File %s is not in the Scope of %s specified by INF %s in FDF" %(File.Target, File.File, FfsInf.TargetOverrideList, FfsInf.InfFileName))\r
                     else:\r
@@ -139,11 +139,28 @@ class Section (SectionClassObject):
                 else:\r
                     GenFdsGlobalVariable.InfLogger ("\nCurrent ARCH \'%s\' of File %s is not in the Support Arch Scope of %s specified by INF %s in FDF" %(FfsInf.CurrentArch, File.File, File.Arch, FfsInf.InfFileName))\r
 \r
-        if Suffix != None:\r
-            for File in FfsInf.GetFinalBuildTargetList():\r
-                if os.path.splitext(File)[1] in (Suffix):\r
-                    FileList.append(File)\r
-\r
+        if (not IsMakefile and Suffix is not None and os.path.exists(FfsInf.EfiOutputPath)) or (IsMakefile and Suffix is not None):\r
+            #\r
+            # Get Makefile path and time stamp\r
+            #\r
+            MakefileDir = FfsInf.EfiOutputPath[:-len('OUTPUT')]\r
+            Makefile = os.path.join(MakefileDir, 'Makefile')\r
+            if not os.path.exists(Makefile):\r
+                Makefile = os.path.join(MakefileDir, 'GNUmakefile')\r
+            if os.path.exists(Makefile):\r
+                # Update to search files with suffix in all sub-dirs.\r
+                Tuple = os.walk(FfsInf.EfiOutputPath)\r
+                for Dirpath, Dirnames, Filenames in Tuple:\r
+                    for F in Filenames:\r
+                        if os.path.splitext(F)[1] == Suffix:\r
+                            FullName = os.path.join(Dirpath, F)\r
+                            if os.path.getmtime(FullName) > os.path.getmtime(Makefile):\r
+                                FileList.append(FullName)\r
+            if not FileList:\r
+                SuffixMap = FfsInf.GetFinalTargetSuffixMap()\r
+                if Suffix in SuffixMap:\r
+                    FileList.extend(SuffixMap[Suffix])\r
+                \r
         #Process the file lists is alphabetical for a same section type\r
         if len (FileList) > 1:\r
             FileList.sort()\r