X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2FGenFds%2FSection.py;h=b2389566349855b8bedb9f22d5dbfa99c9ba968d;hp=e32041d6a5fadf943a06fee93afe07c499815d38;hb=04797875d1d53e53e31eca4fa01bc3cf6929f39c;hpb=1be2ed90a20618d71ddf34b8a07d038da0b36854 diff --git a/BaseTools/Source/Python/GenFds/Section.py b/BaseTools/Source/Python/GenFds/Section.py index e32041d6a5..b238956634 100644 --- a/BaseTools/Source/Python/GenFds/Section.py +++ b/BaseTools/Source/Python/GenFds/Section.py @@ -1,25 +1,21 @@ ## @file # section base class # -# Copyright (c) 2007-2014, Intel Corporation. All rights reserved.
+# Copyright (c) 2007-2018, Intel Corporation. All rights reserved.
# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# SPDX-License-Identifier: BSD-2-Clause-Patent # ## # Import Modules # +from __future__ import absolute_import from CommonDataClass.FdfClass import SectionClassObject -from GenFdsGlobalVariable import GenFdsGlobalVariable +from .GenFdsGlobalVariable import GenFdsGlobalVariable import Common.LongFilePathOs as os, glob from Common import EdkLogger from Common.BuildToolError import * +from Common.DataType import * ## section base class # @@ -28,37 +24,37 @@ class Section (SectionClassObject): SectionType = { 'RAW' : 'EFI_SECTION_RAW', 'FREEFORM' : 'EFI_SECTION_FREEFORM_SUBTYPE_GUID', - 'PE32' : 'EFI_SECTION_PE32', - 'PIC' : 'EFI_SECTION_PIC', - 'TE' : 'EFI_SECTION_TE', + BINARY_FILE_TYPE_PE32 : 'EFI_SECTION_PE32', + BINARY_FILE_TYPE_PIC : 'EFI_SECTION_PIC', + BINARY_FILE_TYPE_TE : 'EFI_SECTION_TE', 'FV_IMAGE' : 'EFI_SECTION_FIRMWARE_VOLUME_IMAGE', - 'DXE_DEPEX' : 'EFI_SECTION_DXE_DEPEX', - 'PEI_DEPEX' : 'EFI_SECTION_PEI_DEPEX', + BINARY_FILE_TYPE_DXE_DEPEX : 'EFI_SECTION_DXE_DEPEX', + BINARY_FILE_TYPE_PEI_DEPEX : 'EFI_SECTION_PEI_DEPEX', 'GUIDED' : 'EFI_SECTION_GUID_DEFINED', 'COMPRESS' : 'EFI_SECTION_COMPRESSION', - 'UI' : 'EFI_SECTION_USER_INTERFACE', - 'SMM_DEPEX' : 'EFI_SECTION_SMM_DEPEX' + BINARY_FILE_TYPE_UI : 'EFI_SECTION_USER_INTERFACE', + BINARY_FILE_TYPE_SMM_DEPEX : 'EFI_SECTION_SMM_DEPEX' } BinFileType = { - 'GUID' : '.guid', + BINARY_FILE_TYPE_GUID : '.guid', 'ACPI' : '.acpi', 'ASL' : '.asl' , - 'UEFI_APP' : '.app', - 'LIB' : '.lib', - 'PE32' : '.pe32', - 'PIC' : '.pic', - 'PEI_DEPEX' : '.depex', + BINARY_FILE_TYPE_UEFI_APP : '.app', + BINARY_FILE_TYPE_LIB : '.lib', + BINARY_FILE_TYPE_PE32 : '.pe32', + BINARY_FILE_TYPE_PIC : '.pic', + BINARY_FILE_TYPE_PEI_DEPEX : '.depex', 'SEC_PEI_DEPEX' : '.depex', - 'TE' : '.te', - 'UNI_VER' : '.ver', - 'VER' : '.ver', - 'UNI_UI' : '.ui', - 'UI' : '.ui', - 'BIN' : '.bin', + BINARY_FILE_TYPE_TE : '.te', + BINARY_FILE_TYPE_UNI_VER : '.ver', + BINARY_FILE_TYPE_VER : '.ver', + BINARY_FILE_TYPE_UNI_UI : '.ui', + BINARY_FILE_TYPE_UI : '.ui', + BINARY_FILE_TYPE_BIN : '.bin', 'RAW' : '.raw', 'COMPAT16' : '.comp16', - 'FV' : '.fv' + BINARY_FILE_TYPE_FV : '.fv' } SectFileType = { @@ -110,28 +106,27 @@ class Section (SectionClassObject): # @param Dict dictionary contains macro and its value # @retval tuple (File list, boolean) # - def GetFileList(FfsInf, FileType, FileExtension, Dict = {}): - if FileType in Section.SectFileType.keys() : - IsSect = True - else : - IsSect = False + def GetFileList(FfsInf, FileType, FileExtension, Dict = None, IsMakefile=False, SectionType=None): + IsSect = FileType in Section.SectFileType - if FileExtension != None: + if FileExtension is not None: Suffix = FileExtension elif IsSect : Suffix = Section.SectionType.get(FileType) else: Suffix = Section.BinFileType.get(FileType) - if FfsInf == None: + if FfsInf is None: EdkLogger.error("GenFds", GENFDS_ERROR, 'Inf File does not exist!') FileList = [] - if FileType != None: + if FileType is not None: for File in FfsInf.BinFileList: - if File.Arch == "COMMON" or FfsInf.CurrentArch == File.Arch: - if File.Type == FileType or (int(FfsInf.PiSpecVersion, 16) >= 0x0001000A and FileType == 'DXE_DPEX'and File.Type == 'SMM_DEPEX'): - if '*' in FfsInf.TargetOverrideList or File.Target == '*' or File.Target in FfsInf.TargetOverrideList or FfsInf.TargetOverrideList == []: - FileList.append(FfsInf.PatchEfiFile(File.Path)) + if File.Arch == TAB_ARCH_COMMON or FfsInf.CurrentArch == File.Arch: + if File.Type == FileType or (int(FfsInf.PiSpecVersion, 16) >= 0x0001000A \ + and FileType == 'DXE_DPEX' and File.Type == BINARY_FILE_TYPE_SMM_DEPEX) \ + or (FileType == BINARY_FILE_TYPE_TE and File.Type == BINARY_FILE_TYPE_PE32): + if TAB_STAR in FfsInf.TargetOverrideList or File.Target == TAB_STAR or File.Target in FfsInf.TargetOverrideList or FfsInf.TargetOverrideList == []: + FileList.append(FfsInf.PatchEfiFile(File.Path, File.Type)) else: 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)) else: @@ -139,10 +134,32 @@ class Section (SectionClassObject): else: 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)) - if Suffix != None: - SuffixMap = FfsInf.GetFinalTargetSuffixMap() - if Suffix in SuffixMap: - FileList.extend(SuffixMap[Suffix]) + elif FileType is None and SectionType == BINARY_FILE_TYPE_RAW: + for File in FfsInf.BinFileList: + if File.Ext == Suffix: + FileList.append(File.Path) + + if (not IsMakefile and Suffix is not None and os.path.exists(FfsInf.EfiOutputPath)) or (IsMakefile and Suffix is not None): + # + # Get Makefile path and time stamp + # + MakefileDir = FfsInf.EfiOutputPath[:-len('OUTPUT')] + Makefile = os.path.join(MakefileDir, 'Makefile') + if not os.path.exists(Makefile): + Makefile = os.path.join(MakefileDir, 'GNUmakefile') + if os.path.exists(Makefile): + # Update to search files with suffix in all sub-dirs. + Tuple = os.walk(FfsInf.EfiOutputPath) + for Dirpath, Dirnames, Filenames in Tuple: + for F in Filenames: + if os.path.splitext(F)[1] == Suffix: + FullName = os.path.join(Dirpath, F) + if os.path.getmtime(FullName) > os.path.getmtime(Makefile): + FileList.append(FullName) + if not FileList: + SuffixMap = FfsInf.GetFinalTargetSuffixMap() + if Suffix in SuffixMap: + FileList.extend(SuffixMap[Suffix]) #Process the file lists is alphabetical for a same section type if len (FileList) > 1: