X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2FGenFds%2FDataSection.py;h=29caa00c0d8dc4ff6031afa600c3d7e80b0e81ed;hp=ba3677ed89db77ad558166a24f1dac74eaaf78df;hb=92beb1e4c73a40a708c7c0cade5c7cee314b3887;hpb=1be2ed90a20618d71ddf34b8a07d038da0b36854 diff --git a/BaseTools/Source/Python/GenFds/DataSection.py b/BaseTools/Source/Python/GenFds/DataSection.py index ba3677ed89..29caa00c0d 100644 --- a/BaseTools/Source/Python/GenFds/DataSection.py +++ b/BaseTools/Source/Python/GenFds/DataSection.py @@ -1,7 +1,7 @@ ## @file # process data section generation # -# 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 @@ -23,6 +23,7 @@ import Common.LongFilePathOs as os from CommonDataClass.FdfClass import DataSectionClassObject from Common.Misc import PeImageClass from Common.LongFilePathSupport import CopyLongFilePath +from Common.DataType import * ## generate data section # @@ -48,11 +49,11 @@ class DataSection (DataSectionClassObject): # @param Dict dictionary contains macro and its value # @retval tuple (Generated file name list, section alignment) # - def GenSection(self, OutputPath, ModuleName, SecNum, keyStringList, FfsFile = None, Dict = {}): + def GenSection(self, OutputPath, ModuleName, SecNum, keyStringList, FfsFile = None, Dict = {}, IsMakefile = False): # # Prepare the parameter of GenSection # - if FfsFile != None: + if FfsFile is not None: self.SectFileName = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.SectFileName) self.SectFileName = GenFdsGlobalVariable.MacroExtend(self.SectFileName, Dict, FfsFile.CurrentArch) else: @@ -69,22 +70,30 @@ class DataSection (DataSectionClassObject): Filename = GenFdsGlobalVariable.MacroExtend(self.SectFileName) if Filename[(len(Filename)-4):] == '.efi': MapFile = Filename.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)): - CopyLongFilePath(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) #Get PE Section alignment when align is set to AUTO - if self.Alignment == 'Auto' and self.SecType in ('TE', 'PE32'): + if self.Alignment == 'Auto' and self.SecType in (BINARY_FILE_TYPE_TE, BINARY_FILE_TYPE_PE32): ImageObj = PeImageClass (Filename) if ImageObj.SectionAlignment < 0x400: self.Alignment = str (ImageObj.SectionAlignment) - else: + elif ImageObj.SectionAlignment < 0x100000: self.Alignment = str (ImageObj.SectionAlignment / 0x400) + 'K' + else: + self.Alignment = str (ImageObj.SectionAlignment / 0x100000) + 'M' NoStrip = True - if self.SecType in ('TE', 'PE32'): - if self.KeepReloc != None: + if self.SecType in (BINARY_FILE_TYPE_TE, BINARY_FILE_TYPE_PE32): + if self.KeepReloc is not None: NoStrip = self.KeepReloc if not NoStrip: @@ -94,24 +103,25 @@ class DataSection (DataSectionClassObject): CopyLongFilePath(self.SectFileName, FileBeforeStrip) StrippedFile = os.path.join(OutputPath, ModuleName + '.stripped') GenFdsGlobalVariable.GenerateFirmwareImage( - StrippedFile, - [GenFdsGlobalVariable.MacroExtend(self.SectFileName, Dict)], - Strip=True - ) + StrippedFile, + [GenFdsGlobalVariable.MacroExtend(self.SectFileName, Dict)], + Strip=True, + IsMakefile = IsMakefile + ) self.SectFileName = StrippedFile - if self.SecType == 'TE': + if self.SecType == BINARY_FILE_TYPE_TE: TeFile = os.path.join( OutputPath, ModuleName + 'Te.raw') GenFdsGlobalVariable.GenerateFirmwareImage( - TeFile, - [GenFdsGlobalVariable.MacroExtend(self.SectFileName, Dict)], - Type='te' - ) + TeFile, + [GenFdsGlobalVariable.MacroExtend(self.SectFileName, Dict)], + Type='te', + IsMakefile = IsMakefile + ) self.SectFileName = TeFile - OutputFile = os.path.join (OutputPath, ModuleName + 'SEC' + SecNum + Ffs.SectionSuffix.get(self.SecType)) + OutputFile = os.path.join (OutputPath, ModuleName + SUP_MODULE_SEC + SecNum + Ffs.SectionSuffix.get(self.SecType)) OutputFile = os.path.normpath(OutputFile) - - GenFdsGlobalVariable.GenerateSection(OutputFile, [self.SectFileName], Section.Section.SectionType.get(self.SecType)) + GenFdsGlobalVariable.GenerateSection(OutputFile, [self.SectFileName], Section.Section.SectionType.get(self.SecType), IsMakefile = IsMakefile) FileList = [OutputFile] return FileList, self.Alignment