X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;ds=sidebyside;f=BaseTools%2FSource%2FPython%2FGenFds%2FEfiSection.py;h=7b3b71719147c9e7e61315a327bdd09638be230d;hb=37de70b764200718cc39a21abc491c335e3da7b3;hp=ad953facb98f04166c9065e56943d70f4c4e11cb;hpb=52302d4dee589a5df43a464420c9fe68ba83937d;p=mirror_edk2.git diff --git a/BaseTools/Source/Python/GenFds/EfiSection.py b/BaseTools/Source/Python/GenFds/EfiSection.py index ad953facb9..7b3b717191 100644 --- a/BaseTools/Source/Python/GenFds/EfiSection.py +++ b/BaseTools/Source/Python/GenFds/EfiSection.py @@ -1,9 +1,9 @@ ## @file # process rule section generation # -# Copyright (c) 2007, Intel Corporation +# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
# -# All rights reserved. This program and the accompanying materials +# 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 @@ -20,12 +20,13 @@ import Section from GenFdsGlobalVariable import GenFdsGlobalVariable import subprocess from Ffs import Ffs -import os +import Common.LongFilePathOs as os from CommonDataClass.FdfClass import EfiSectionClassObject -import shutil from Common import EdkLogger from Common.BuildToolError import * from Common.Misc import PeImageClass +from Common.LongFilePathSupport import OpenLongFilePath as open +from Common.LongFilePathSupport import CopyLongFilePath ## generate rule section # @@ -52,7 +53,7 @@ class EfiSection (EfiSectionClassObject): # @param Dict dictionary contains macro and its value # @retval tuple (Generated file name list, section alignment) # - def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf = None, Dict = {}) : + def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf = None, Dict = {}, IsMakefile = False) : if self.FileName != None and self.FileName.startswith('PCD('): self.FileName = GenFdsGlobalVariable.GetPcdValue(self.FileName) @@ -80,22 +81,25 @@ class EfiSection (EfiSectionClassObject): FileList = [] if Filename != None: Filename = GenFdsGlobalVariable.MacroExtend(Filename, Dict) - # check if the path is absolute or relative - if os.path.isabs(Filename): - Filename = os.path.normpath(Filename) - else: - Filename = os.path.normpath(os.path.join(FfsInf.EfiOutputPath, Filename)) + # check if the path is absolute or relative + if os.path.isabs(Filename): + Filename = os.path.normpath(Filename) + else: + Filename = os.path.normpath(os.path.join(FfsInf.EfiOutputPath, Filename)) if not self.Optional: FileList.append(Filename) elif os.path.exists(Filename): FileList.append(Filename) + elif '.depex' in FfsInf.FinalTargetSuffixMap or FfsInf.Depex: + FileList.append(Filename) else: FileList, IsSect = Section.Section.GetFileList(FfsInf, self.FileType, self.FileExtension, Dict) if IsSect : return FileList, self.Alignment Index = 0 + Align = self.Alignment """ If Section type is 'VERSION'""" OutputFileList = [] @@ -117,8 +121,9 @@ class EfiSection (EfiSectionClassObject): Num = SecNum OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + str(Num) + Ffs.SectionSuffix.get(SectionType)) GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_VERSION', - #Ui=StringData, - Ver=BuildNum) + #Ui=StringData, + Ver=BuildNum, + IsMakefile=IsMakefile) OutputFileList.append(OutputFile) elif FileList != []: @@ -133,8 +138,9 @@ class EfiSection (EfiSectionClassObject): if BuildNum != None and BuildNum != '': BuildNumTuple = ('-j', BuildNum) GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_VERSION', - #Ui=VerString, - Ver=BuildNum) + #Ui=VerString, + Ver=BuildNum, + IsMakefile=IsMakefile) OutputFileList.append(OutputFile) else: @@ -155,8 +161,9 @@ class EfiSection (EfiSectionClassObject): Num = SecNum OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + str(Num) + Ffs.SectionSuffix.get(SectionType)) GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_VERSION', - #Ui=VerString, - Ver=BuildNum) + #Ui=VerString, + Ver=BuildNum, + IsMakefile=IsMakefile) OutputFileList.append(OutputFile) # @@ -173,7 +180,7 @@ class EfiSection (EfiSectionClassObject): Num = SecNum OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + str(Num) + Ffs.SectionSuffix.get(SectionType)) GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_USER_INTERFACE', - Ui=StringData) + Ui=StringData, IsMakefile=IsMakefile) OutputFileList.append(OutputFile) elif FileList != []: @@ -185,7 +192,7 @@ class EfiSection (EfiSectionClassObject): UiString = f.read() f.close() GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_USER_INTERFACE', - Ui=UiString) + Ui=UiString, IsMakefile=IsMakefile) OutputFileList.append(OutputFile) else: if StringData != None and len(StringData) > 0: @@ -202,7 +209,7 @@ class EfiSection (EfiSectionClassObject): Num = SecNum OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + str(Num) + Ffs.SectionSuffix.get(SectionType)) GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_USER_INTERFACE', - Ui=StringData) + Ui=StringData, IsMakefile=IsMakefile) OutputFileList.append(OutputFile) @@ -210,10 +217,10 @@ class EfiSection (EfiSectionClassObject): """If File List is empty""" if FileList == [] : if self.Optional == True: - GenFdsGlobalVariable.VerboseLogger( "Optional Section don't exist!") - return [], None + GenFdsGlobalVariable.VerboseLogger("Optional Section don't exist!") + return [], None else: - EdkLogger.error("GenFds", GENFDS_ERROR, "Output file for %s section could not be found for %s" % (SectionType, InfFileName)) + EdkLogger.error("GenFds", GENFDS_ERROR, "Output file for %s section could not be found for %s" % (SectionType, InfFileName)) else: """Convert the File to Section file one by one """ @@ -228,29 +235,44 @@ class EfiSection (EfiSectionClassObject): if self.Alignment == 'Auto' and (SectionType == 'PE32' or SectionType == 'TE'): ImageObj = PeImageClass (File) if ImageObj.SectionAlignment < 0x400: - self.Alignment = str (ImageObj.SectionAlignment) + Align = str (ImageObj.SectionAlignment) + elif ImageObj.SectionAlignment < 0x100000: + Align = str (ImageObj.SectionAlignment / 0x400) + 'K' else: - self.Alignment = str (ImageObj.SectionAlignment / 0x400) + 'K' + Align = str (ImageObj.SectionAlignment / 0x100000) + 'M' if File[(len(File)-4):] == '.efi': MapFile = File.replace('.efi', '.map') - if os.path.exists(MapFile): - CopyMapFile = os.path.join(OutputPath, ModuleName + '.map') - if not os.path.exists(CopyMapFile) or \ - (os.path.getmtime(MapFile) > os.path.getmtime(CopyMapFile)): - shutil.copyfile(MapFile, CopyMapFile) + CopyMapFile = os.path.join(OutputPath, ModuleName + '.map') + if IsMakefile: + if GenFdsGlobalVariable.CopyList == []: + GenFdsGlobalVariable.CopyList = [(MapFile, CopyMapFile)] + else: + GenFdsGlobalVariable.CopyList.append((MapFile, CopyMapFile)) + else: + if os.path.exists(MapFile): + if not os.path.exists(CopyMapFile) or \ + (os.path.getmtime(MapFile) > os.path.getmtime(CopyMapFile)): + CopyLongFilePath(MapFile, CopyMapFile) if not NoStrip: FileBeforeStrip = os.path.join(OutputPath, ModuleName + '.efi') - if not os.path.exists(FileBeforeStrip) or \ - (os.path.getmtime(File) > os.path.getmtime(FileBeforeStrip)): - shutil.copyfile(File, FileBeforeStrip) + if IsMakefile: + if GenFdsGlobalVariable.CopyList == []: + GenFdsGlobalVariable.CopyList = [(File, FileBeforeStrip)] + else: + GenFdsGlobalVariable.CopyList.append((File, FileBeforeStrip)) + else: + if not os.path.exists(FileBeforeStrip) or \ + (os.path.getmtime(File) > os.path.getmtime(FileBeforeStrip)): + CopyLongFilePath(File, FileBeforeStrip) StrippedFile = os.path.join(OutputPath, ModuleName + '.stripped') GenFdsGlobalVariable.GenerateFirmwareImage( - StrippedFile, - [File], - Strip=True - ) + StrippedFile, + [File], + Strip=True, + IsMakefile = IsMakefile + ) File = StrippedFile """For TE Section call GenFw to generate TE image""" @@ -258,17 +280,19 @@ class EfiSection (EfiSectionClassObject): if SectionType == 'TE': TeFile = os.path.join( OutputPath, ModuleName + 'Te.raw') GenFdsGlobalVariable.GenerateFirmwareImage( - TeFile, - [File], - Type='te' - ) + TeFile, + [File], + Type='te', + IsMakefile = IsMakefile + ) File = TeFile """Call GenSection""" GenFdsGlobalVariable.GenerateSection(OutputFile, - [File], - Section.Section.SectionType.get (SectionType) - ) + [File], + Section.Section.SectionType.get (SectionType), + IsMakefile=IsMakefile + ) OutputFileList.append(OutputFile) - return OutputFileList, self.Alignment + return OutputFileList, Align