From nobody Thu Dec 26 01:37:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 150664824501040.10612509120108; Thu, 28 Sep 2017 18:24:05 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 8208C2095E518; Thu, 28 Sep 2017 18:20:48 -0700 (PDT) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B54AF21F30415 for ; Thu, 28 Sep 2017 18:20:46 -0700 (PDT) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Sep 2017 18:24:01 -0700 Received: from shwdeopenpsi168.ccr.corp.intel.com ([10.239.158.121]) by fmsmga001.fm.intel.com with ESMTP; 28 Sep 2017 18:23:59 -0700 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.65; helo=mga03.intel.com; envelope-from=yonghong.zhu@intel.com; receiver=edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,451,1500966000"; d="scan'208";a="1200258582" From: Yonghong Zhu To: edk2-devel@lists.01.org Date: Fri, 29 Sep 2017 09:22:44 +0800 Message-Id: <1506648164-5624-4-git-send-email-yonghong.zhu@intel.com> X-Mailer: git-send-email 2.6.1.windows.1 In-Reply-To: <1506648164-5624-1-git-send-email-yonghong.zhu@intel.com> References: <1506648164-5624-1-git-send-email-yonghong.zhu@intel.com> Subject: [edk2] [Patch 3/3] BaseTools: Update Makefile to support FFS file generation X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yunhua Feng , Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Update Makefile to support FFS file generation. Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yonghong Zhu Signed-off-by: Yunhua Feng --- BaseTools/Source/Python/AutoGen/AutoGen.py | 16 +- BaseTools/Source/Python/AutoGen/GenMake.py | 84 +++++++++ BaseTools/Source/Python/GenFds/AprioriSection.py | 16 +- BaseTools/Source/Python/GenFds/CompressSection.py | 10 +- BaseTools/Source/Python/GenFds/DataSection.py | 37 ++-- BaseTools/Source/Python/GenFds/DepexSection.py | 6 +- BaseTools/Source/Python/GenFds/EfiSection.py | 78 ++++---- BaseTools/Source/Python/GenFds/Fd.py | 24 ++- BaseTools/Source/Python/GenFds/FfsFileStatement.py | 4 +- BaseTools/Source/Python/GenFds/FfsInfStatement.py | 198 ++++++++++++-----= ---- BaseTools/Source/Python/GenFds/Fv.py | 187 ++++++++++-------= -- BaseTools/Source/Python/GenFds/FvImageSection.py | 8 +- BaseTools/Source/Python/GenFds/GenFds.py | 17 ++ .../Source/Python/GenFds/GenFdsGlobalVariable.py | 168 +++++++++++++---- BaseTools/Source/Python/GenFds/GuidSection.py | 59 +----- .../Source/Python/GenFds/OptRomFileStatement.py | 4 +- .../Source/Python/GenFds/OptRomInfStatement.py | 12 +- BaseTools/Source/Python/GenFds/OptionRom.py | 25 +-- BaseTools/Source/Python/GenFds/Region.py | 49 +++-- BaseTools/Source/Python/GenFds/Section.py | 4 +- BaseTools/Source/Python/GenFds/UiSection.py | 5 +- BaseTools/Source/Python/GenFds/VerSection.py | 9 +- BaseTools/Source/Python/build/build.py | 18 +- 23 files changed, 656 insertions(+), 382 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/= Python/AutoGen/AutoGen.py index 14eb138..981f0a6 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -2757,10 +2757,11 @@ class ModuleAutoGen(AutoGen): self._CustomMakefile =3D None self._Macro =3D None =20 self._BuildDir =3D None self._OutputDir =3D None + self._FfsOutputDir =3D None self._DebugDir =3D None self._MakeFileDir =3D None =20 self._IncludePathList =3D None self._IncludePathLength =3D 0 @@ -2873,10 +2874,11 @@ class ModuleAutoGen(AutoGen): self._Macro["PLATFORM_GUID" ] =3D self.PlatformInfo.Gu= id self._Macro["PLATFORM_VERSION" ] =3D self.PlatformInfo.Ve= rsion self._Macro["PLATFORM_RELATIVE_DIR" ] =3D self.PlatformInfo.So= urceDir self._Macro["PLATFORM_DIR" ] =3D mws.join(self.Worksp= aceDir, self.PlatformInfo.SourceDir) self._Macro["PLATFORM_OUTPUT_DIR" ] =3D self.PlatformInfo.Ou= tputDir + self._Macro["FFS_OUTPUT_DIR" ] =3D self.FfsOutputDir return self._Macro =20 ## Return the module build data object def _GetModule(self): if self._Module =3D=3D None: @@ -2963,10 +2965,19 @@ class ModuleAutoGen(AutoGen): if self._OutputDir =3D=3D None: self._OutputDir =3D path.join(self.BuildDir, "OUTPUT") CreateDirectory(self._OutputDir) return self._OutputDir =20 + ## Return the directory to store ffs file + def _GetFfsOutputDir(self): + if self._FfsOutputDir =3D=3D None: + if GlobalData.gFdfParser !=3D None: + self._FfsOutputDir =3D path.join(self.PlatformInfo.BuildDi= r, "FV", "Ffs", self.Guid + self.Name) + else: + self._FfsOutputDir =3D '' + return self._FfsOutputDir + ## Return the directory to store auto-gened source files of the mdoule def _GetDebugDir(self): if self._DebugDir =3D=3D None: self._DebugDir =3D path.join(self.BuildDir, "DEBUG") CreateDirectory(self._DebugDir) @@ -4219,20 +4230,20 @@ class ModuleAutoGen(AutoGen): ## Create makefile for the module and its dependent libraries # # @param CreateLibraryMakeFile Flag indicating if or not the = makefiles of # dependent libraries will be cr= eated # - def CreateMakeFile(self, CreateLibraryMakeFile=3DTrue): + def CreateMakeFile(self, CreateLibraryMakeFile=3DTrue, GenFfsList =3D = []): # Ignore generating makefile when it is a binary module if self.IsBinaryModule: return =20 if self.IsMakeFileCreated: return if self.CanSkip(): return - + self.GenFfsList =3D GenFfsList if not self.IsLibrary and CreateLibraryMakeFile: for LibraryAutoGen in self.LibraryAutoGenList: LibraryAutoGen.CreateMakeFile() =20 if len(self.CustomMakefile) =3D=3D 0: @@ -4452,10 +4463,11 @@ class ModuleAutoGen(AutoGen): =20 IsLibrary =3D property(_IsLibrary) IsBinaryModule =3D property(_IsBinaryModule) BuildDir =3D property(_GetBuildDir) OutputDir =3D property(_GetOutputDir) + FfsOutputDir =3D property(_GetFfsOutputDir) DebugDir =3D property(_GetDebugDir) MakeFileDir =3D property(_GetMakeFileDir) CustomMakefile =3D property(_GetCustomMakefile) =20 IncludePathList =3D property(_GetIncludePathList) diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/= Python/AutoGen/GenMake.py index 942eb44..814a503 100644 --- a/BaseTools/Source/Python/AutoGen/GenMake.py +++ b/BaseTools/Source/Python/AutoGen/GenMake.py @@ -141,10 +141,15 @@ class BuildFile(object): ## directory removal template _RD_TEMPLATE_ =3D { "nmake" : 'if exist %(dir)s $(RD) %(dir)s', "gmake" : "$(RD) %(dir)s" } + ## cp if exist + _CP_TEMPLATE_ =3D { + "nmake" : 'if exist %(Src)s $(CP) %(Src)s %(Dst)s', + "gmake" : "test -f %(Src)s && $(CP) %(Src)s %(Dst)s" + } =20 _CD_TEMPLATE_ =3D { "nmake" : 'if exist %(dir)s cd %(dir)s', "gmake" : "test -e %(dir)s && cd %(dir)s" } @@ -248,10 +253,11 @@ MODULE_FILE =3D ${module_file} MODULE_FILE_BASE_NAME =3D ${module_file_base_name} BASE_NAME =3D $(MODULE_NAME) MODULE_RELATIVE_DIR =3D ${module_relative_directory} PACKAGE_RELATIVE_DIR =3D ${package_relative_directory} MODULE_DIR =3D ${module_dir} +FFS_OUTPUT_DIR =3D ${ffs_output_directory} =20 MODULE_ENTRY_POINT =3D ${module_entry_point} ARCH_ENTRY_POINT =3D ${arch_entry_point} IMAGE_ENTRY_POINT =3D ${image_entry_point} =20 @@ -439,10 +445,14 @@ cleanlib: self.Macros["DEBUG_DIR" ] =3D self._AutoGenObject.Macros["DE= BUG_DIR"] self.Macros["MODULE_BUILD_DIR"] =3D self._AutoGenObject.Macros["MO= DULE_BUILD_DIR"] self.Macros["BIN_DIR" ] =3D self._AutoGenObject.Macros["BI= N_DIR"] self.Macros["BUILD_DIR" ] =3D self._AutoGenObject.Macros["BU= ILD_DIR"] self.Macros["WORKSPACE" ] =3D self._AutoGenObject.Macros["WO= RKSPACE"] + self.Macros["FFS_OUTPUT_DIR" ] =3D self._AutoGenObject.Macros["FF= S_OUTPUT_DIR"] + self.GenFfsList =3D ModuleAutoGen.GenFfsList + self.MacroList =3D ['FFS_OUTPUT_DIR', 'MODULE_GUID', 'OUTPUT_DIR'] + self.FfsOutputFileList =3D [] =20 # Compose a dict object containing information used to do replacement = in template def _CreateTemplateDict(self): if self._FileType not in self._SEP_: EdkLogger.error("build", PARAMETER_INVALID, "Invalid Makefile = type [%s]" % self._FileType, @@ -553,10 +563,11 @@ cleanlib: if len(self.ResultFileList) =3D=3D 0 and len(self._AutoGenObject.S= ourceFileList) <> 0: EdkLogger.error("build", AUTOGEN_ERROR, "Nothing to build", ExtraData=3D"[%s]" % str(self._AutoGenObject)) =20 self.ProcessBuildTargetList() + self.ParserGenerateFfsCmd() =20 # Generate macros used to represent input files FileMacroList =3D [] # macro name =3D file list for FileListMacro in self.FileListMacros: FileMacro =3D self._FILE_MACRO_TEMPLATE.Replace( @@ -625,10 +636,11 @@ cleanlib: "platform_name" : self.PlatformInfo.Name, "platform_guid" : self.PlatformInfo.Guid, "platform_version" : self.PlatformInfo.Version, "platform_relative_directory": self.PlatformInfo.SourceDir, "platform_output_directory" : self.PlatformInfo.OutputDir, + "ffs_output_directory" : self._AutoGenObject.Macros["FFS_= OUTPUT_DIR"], "platform_dir" : self._AutoGenObject.Macros["PLAT= FORM_DIR"], =20 "module_name" : self._AutoGenObject.Name, "module_guid" : self._AutoGenObject.Guid, "module_name_guid" : self._AutoGenObject._GetUniqueBa= seName(), @@ -671,10 +683,82 @@ cleanlib: "backward_compatible_target": BcTargetList, } =20 return MakefileTemplateDict =20 + def ParserGenerateFfsCmd(self): + #Add Ffs cmd to self.BuildTargetList + OutputFile =3D '' + DepsFileList =3D [] + + for Cmd in self.GenFfsList: + if Cmd[2]: + for CopyCmd in Cmd[2]: + Src, Dst =3D CopyCmd + Src =3D self.ReplaceMacro(Src) + Dst =3D self.ReplaceMacro(Dst) + if Dst not in self.ResultFileList: + self.ResultFileList.append('%s' % Dst) + if '%s :' %(Dst) not in self.BuildTargetList: + self.BuildTargetList.append("%s :" %(Dst)) + self.BuildTargetList.append('\t' + self._CP_TEMPLA= TE_[self._FileType] %{'Src': Src, 'Dst': Dst}) + + FfsCmdList =3D Cmd[0] + for index, Str in enumerate(FfsCmdList): + if '-o' =3D=3D Str: + OutputFile =3D FfsCmdList[index + 1] + if '-i' =3D=3D Str: + if DepsFileList =3D=3D []: + DepsFileList =3D [FfsCmdList[index + 1]] + else: + DepsFileList.append(FfsCmdList[index + 1]) + DepsFileString =3D ' '.join(DepsFileList).strip() + if DepsFileString =3D=3D '': + continue + OutputFile =3D self.ReplaceMacro(OutputFile) + self.ResultFileList.append('%s' % OutputFile) + DepsFileString =3D self.ReplaceMacro(DepsFileString) + self.BuildTargetList.append('%s : %s' % (OutputFile, DepsFileS= tring)) + CmdString =3D ' '.join(FfsCmdList).strip() + CmdString =3D self.ReplaceMacro(CmdString) + self.BuildTargetList.append('\t%s' % CmdString) + + self.ParseSecCmd(DepsFileList, Cmd[1]) + for SecOutputFile, SecDepsFile, SecCmd in self.FfsOutputFileLi= st : + self.BuildTargetList.append('%s : %s' % (self.ReplaceMacro= (SecOutputFile), self.ReplaceMacro(SecDepsFile))) + self.BuildTargetList.append('\t%s' % self.ReplaceMacro(Sec= Cmd)) + self.FfsOutputFileList =3D [] + + def ParseSecCmd(self, OutputFileList, CmdTuple): + for OutputFile in OutputFileList: + for SecCmdStr in CmdTuple: + SecDepsFileList =3D [] + SecCmdList =3D SecCmdStr.split() + CmdName =3D SecCmdList[0] + for index, CmdItem in enumerate(SecCmdList): + if '-o' =3D=3D CmdItem and OutputFile =3D=3D SecCmdLis= t[index + 1]: + index =3D index + 1 + while index + 1 < len(SecCmdList): + if not SecCmdList[index+1].startswith('-'): + SecDepsFileList.append(SecCmdList[index + = 1]) + index =3D index + 1 + if CmdName =3D=3D 'Trim': + SecDepsFileList.append(os.path.join('$(DEBUG_D= IR)', os.path.basename(OutputFile).replace('offset', 'efi'))) + if OutputFile.endswith('.ui') or OutputFile.endswi= th('.ver'): + SecDepsFileList.append(os.path.join('$(MODULE_= DIR)','$(MODULE_FILE)')) + self.FfsOutputFileList.append((OutputFile, ' '.joi= n(SecDepsFileList), SecCmdStr)) + if len(SecDepsFileList) > 0: + self.ParseSecCmd(SecDepsFileList, CmdTuple) + break + else: + continue + + def ReplaceMacro(self, str): + for Macro in self.MacroList: + str =3D str.replace(self._AutoGenObject.Macros[Macro], '$(' + = Macro + ')') + return str + def CommandExceedLimit(self): FlagDict =3D { 'CC' : { 'Macro' : '$(CC_FLAGS)', 'Value' : Fal= se}, 'PP' : { 'Macro' : '$(PP_FLAGS)', 'Value' : Fal= se}, 'APP' : { 'Macro' : '$(APP_FLAGS)', 'Value' : Fal= se}, diff --git a/BaseTools/Source/Python/GenFds/AprioriSection.py b/BaseTools/S= ource/Python/GenFds/AprioriSection.py index a2306d0..34e56b0 100644 --- a/BaseTools/Source/Python/GenFds/AprioriSection.py +++ b/BaseTools/Source/Python/GenFds/AprioriSection.py @@ -1,9 +1,9 @@ ## @file # process APRIORI file data and generate PEI/DXE APRIORI file # -# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the B= SD License # which accompanies this distribution. The full text of the license may = be found at # http://opensource.org/licenses/bsd-license.php @@ -45,11 +45,11 @@ class AprioriSection (AprioriSectionClassObject): # @param self The object pointer # @param FvName for whom apriori file generated # @param Dict dictionary contains macro and its value # @retval string Generated file name # - def GenFfs (self, FvName, Dict =3D {}): + def GenFfs (self, FvName, Dict =3D {}, IsMakefile =3D False): DXE_GUID =3D "FC510EE7-FFDC-11D4-BD41-0080C73C8881" PEI_GUID =3D "1B45CC0A-156A-428A-AF62-49864DA0E6E6" Buffer =3D StringIO.StringIO('') AprioriFileGuid =3D DXE_GUID if self.AprioriType =3D=3D "PEI": @@ -64,13 +64,16 @@ class AprioriSection (AprioriSectionClassObject): AprioriFileGuid + FvName + '.Apri' ) AprFfsFileName =3D os.path.join (OutputAprFilePath,\ AprioriFileGuid + FvName + '.Ffs') =20 Dict.update(self.DefineVarDict) + InfFileName =3D None for FfsObj in self.FfsList : Guid =3D "" if isinstance(FfsObj, FfsFileStatement.FileStatement): + if IsMakefile: + continue Guid =3D FfsObj.NameGuid else: InfFileName =3D NormPath(FfsObj.InfFileName) Arch =3D FfsObj.GetCurrentArch() =20 @@ -108,11 +111,16 @@ class AprioriSection (AprioriSectionClassObject): =20 SaveFileOnChange(OutputAprFileName, Buffer.getvalue()) =20 RawSectionFileName =3D os.path.join( OutputAprFilePath, \ AprioriFileGuid + FvName + '.raw' ) - GenFdsGlobalVariable.GenerateSection(RawSectionFileName, [OutputAp= rFileName], 'EFI_SECTION_RAW') + MakefilePath =3D None + if IsMakefile: + if not InfFileName: + return None + MakefilePath =3D InfFileName, Arch + GenFdsGlobalVariable.GenerateSection(RawSectionFileName, [OutputAp= rFileName], 'EFI_SECTION_RAW', IsMakefile=3DIsMakefile) GenFdsGlobalVariable.GenerateFfs(AprFfsFileName, [RawSectionFileNa= me], - 'EFI_FV_FILETYPE_FREEFORM', Aprio= riFileGuid) + 'EFI_FV_FILETYPE_FREEFORM', Aprior= iFileGuid, MakefilePath=3DMakefilePath) =20 return AprFfsFileName =20 diff --git a/BaseTools/Source/Python/GenFds/CompressSection.py b/BaseTools/= Source/Python/GenFds/CompressSection.py index fac58d1..64ad275 100644 --- a/BaseTools/Source/Python/GenFds/CompressSection.py +++ b/BaseTools/Source/Python/GenFds/CompressSection.py @@ -1,9 +1,9 @@ ## @file # process compress section generation # -# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the B= SD License # which accompanies this distribution. The full text of the license may = be found at # http://opensource.org/licenses/bsd-license.php @@ -51,25 +51,25 @@ class CompressSection (CompressSectionClassObject) : # @param KeyStringList Filter for inputs of section generation # @param FfsInf FfsInfStatement object that contains this sect= ion data # @param Dict dictionary contains macro and its value # @retval tuple (Generated file name, section alignment) # - def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, Ff= sInf =3D None, Dict =3D {}): + def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, Ff= sInf =3D None, Dict =3D {}, IsMakefile =3D False): =20 if FfsInf !=3D None: self.CompType =3D FfsInf.__ExtendMacro__(self.CompType) self.Alignment =3D FfsInf.__ExtendMacro__(self.Alignment) =20 SectFiles =3D tuple() Index =3D 0 for Sect in self.SectionList: Index =3D Index + 1 SecIndex =3D '%s.%d' %(SecNum, Index) - ReturnSectList, AlignValue =3D Sect.GenSection(OutputPath, Mod= uleName, SecIndex, KeyStringList, FfsInf, Dict) + ReturnSectList, AlignValue =3D Sect.GenSection(OutputPath, Mod= uleName, SecIndex, KeyStringList, FfsInf, Dict, IsMakefile=3DIsMakefile) if ReturnSectList !=3D []: for FileData in ReturnSectList: - SectFiles +=3D (FileData,) + SectFiles +=3D (FileData,) =20 =20 OutputFile =3D OutputPath + \ os.sep + \ ModuleName + \ @@ -77,11 +77,11 @@ class CompressSection (CompressSectionClassObject) : SecNum + \ Ffs.SectionSuffix['COMPRESS'] OutputFile =3D os.path.normpath(OutputFile) =20 GenFdsGlobalVariable.GenerateSection(OutputFile, SectFiles, Sectio= n.Section.SectionType['COMPRESS'], - CompressionType=3Dself.CompTy= peDict[self.CompType]) + CompressionType=3Dself.CompTy= peDict[self.CompType], IsMakefile=3DIsMakefile) OutputFileList =3D [] OutputFileList.append(OutputFile) return OutputFileList, self.Alignment =20 =20 diff --git a/BaseTools/Source/Python/GenFds/DataSection.py b/BaseTools/Sour= ce/Python/GenFds/DataSection.py index 78c0af4..2d2975f 100644 --- a/BaseTools/Source/Python/GenFds/DataSection.py +++ b/BaseTools/Source/Python/GenFds/DataSection.py @@ -46,11 +46,11 @@ class DataSection (DataSectionClassObject): # @param KeyStringList Filter for inputs of section generation # @param FfsInf FfsInfStatement object that contains this sect= ion data # @param Dict dictionary contains macro and its value # @retval tuple (Generated file name list, section alignment) # - def GenSection(self, OutputPath, ModuleName, SecNum, keyStringList, Ff= sFile =3D None, Dict =3D {}): + def GenSection(self, OutputPath, ModuleName, SecNum, keyStringList, Ff= sFile =3D None, Dict =3D {}, IsMakefile =3D False): # # Prepare the parameter of GenSection # if FfsFile !=3D None: self.SectFileName =3D GenFdsGlobalVariable.ReplaceWorkspaceMac= ro(self.SectFileName) @@ -67,14 +67,20 @@ class DataSection (DataSectionClassObject): =20 """Copy Map file to Ffs output""" Filename =3D GenFdsGlobalVariable.MacroExtend(self.SectFileName) if Filename[(len(Filename)-4):] =3D=3D '.efi': MapFile =3D Filename.replace('.efi', '.map') - if os.path.exists(MapFile): - CopyMapFile =3D os.path.join(OutputPath, ModuleName + '.ma= p') - if not os.path.exists(CopyMapFile) or (os.path.getmtime(Ma= pFile) > os.path.getmtime(CopyMapFile)): - CopyLongFilePath(MapFile, CopyMapFile) + CopyMapFile =3D os.path.join(OutputPath, ModuleName + '.map') + if IsMakefile: + if GenFdsGlobalVariable.CopyList =3D=3D []: + GenFdsGlobalVariable.CopyList =3D [(MapFile, CopyMapFi= le)] + else: + GenFdsGlobalVariable.CopyList.append((MapFile, CopyMap= File)) + else: + if os.path.exists(MapFile): + if not os.path.exists(CopyMapFile) or (os.path.getmtim= e(MapFile) > os.path.getmtime(CopyMapFile)): + CopyLongFilePath(MapFile, CopyMapFile) =20 #Get PE Section alignment when align is set to AUTO if self.Alignment =3D=3D 'Auto' and self.SecType in ('TE', 'PE32'): ImageObj =3D PeImageClass (Filename) if ImageObj.SectionAlignment < 0x400: @@ -94,26 +100,27 @@ class DataSection (DataSectionClassObject): if not os.path.exists(FileBeforeStrip) or \ (os.path.getmtime(self.SectFileName) > os.path.getmtime(Fi= leBeforeStrip)): CopyLongFilePath(self.SectFileName, FileBeforeStrip) StrippedFile =3D os.path.join(OutputPath, ModuleName + '.strip= ped') GenFdsGlobalVariable.GenerateFirmwareImage( - StrippedFile, - [GenFdsGlobalVariable.MacroExtend(self= .SectFileName, Dict)], - Strip=3DTrue - ) + StrippedFile, + [GenFdsGlobalVariable.MacroExtend(self.SectFileName, D= ict)], + Strip=3DTrue, + IsMakefile =3D IsMakefile + ) self.SectFileName =3D StrippedFile =20 if self.SecType =3D=3D 'TE': TeFile =3D os.path.join( OutputPath, ModuleName + 'Te.raw') GenFdsGlobalVariable.GenerateFirmwareImage( - TeFile, - [GenFdsGlobalVariable.MacroExtend(self= .SectFileName, Dict)], - Type=3D'te' - ) + TeFile, + [GenFdsGlobalVariable.MacroExtend(self.SectFileName, D= ict)], + Type=3D'te', + IsMakefile =3D IsMakefile + ) self.SectFileName =3D TeFile =20 OutputFile =3D os.path.join (OutputPath, ModuleName + 'SEC' + SecN= um + Ffs.SectionSuffix.get(self.SecType)) OutputFile =3D os.path.normpath(OutputFile) - - GenFdsGlobalVariable.GenerateSection(OutputFile, [self.SectFileNam= e], Section.Section.SectionType.get(self.SecType)) + GenFdsGlobalVariable.GenerateSection(OutputFile, [self.SectFileNam= e], Section.Section.SectionType.get(self.SecType), IsMakefile =3D IsMakefil= e) FileList =3D [OutputFile] return FileList, self.Alignment diff --git a/BaseTools/Source/Python/GenFds/DepexSection.py b/BaseTools/Sou= rce/Python/GenFds/DepexSection.py index 8f78c0f..1992d2a 100644 --- a/BaseTools/Source/Python/GenFds/DepexSection.py +++ b/BaseTools/Source/Python/GenFds/DepexSection.py @@ -1,9 +1,9 @@ ## @file # process depex section generation # -# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the B= SD License # which accompanies this distribution. The full text of the license may = be found at # http://opensource.org/licenses/bsd-license.php @@ -74,11 +74,11 @@ class DepexSection (DepexSectionClassObject): # @param KeyStringList Filter for inputs of section generation # @param FfsInf FfsInfStatement object that contains this sect= ion data # @param Dict dictionary contains macro and its value # @retval tuple (Generated file name list, section alignment) # - def GenSection(self, OutputPath, ModuleName, SecNum, keyStringList, Ff= sFile =3D None, Dict =3D {}): + def GenSection(self, OutputPath, ModuleName, SecNum, keyStringList, Ff= sFile =3D None, Dict =3D {}, IsMakefile =3D False): =20 if self.ExpressionProcessed =3D=3D False: self.Expression =3D self.Expression.replace("\n", " ").replace= ("\r", " ") ExpList =3D self.Expression.split() ExpGuidDict =3D {} @@ -117,8 +117,8 @@ class DepexSection (DepexSectionClassObject): Depex.Generate(InputFile) =20 OutputFile =3D os.path.join (OutputPath, ModuleName + 'SEC' + SecN= um + '.dpx') OutputFile =3D os.path.normpath(OutputFile) =20 - GenFdsGlobalVariable.GenerateSection(OutputFile, [InputFile], Sect= ion.Section.SectionType.get (SecType)) + GenFdsGlobalVariable.GenerateSection(OutputFile, [InputFile], Sect= ion.Section.SectionType.get (SecType), IsMakefile=3DIsMakefile) FileList =3D [OutputFile] return FileList, self.Alignment diff --git a/BaseTools/Source/Python/GenFds/EfiSection.py b/BaseTools/Sourc= e/Python/GenFds/EfiSection.py index 7da3c1e..d34f744 100644 --- a/BaseTools/Source/Python/GenFds/EfiSection.py +++ b/BaseTools/Source/Python/GenFds/EfiSection.py @@ -51,11 +51,11 @@ class EfiSection (EfiSectionClassObject): # @param KeyStringList Filter for inputs of section generation # @param FfsInf FfsInfStatement object that contains this sect= ion data # @param Dict dictionary contains macro and its value # @retval tuple (Generated file name list, section alignment) # - def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, Ff= sInf =3D None, Dict =3D {}) : + def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, Ff= sInf =3D None, Dict =3D {}, IsMakefile =3D False) : =20 if self.FileName !=3D None and self.FileName.startswith('PCD('): self.FileName =3D GenFdsGlobalVariable.GetPcdValue(self.FileNa= me) """Prepare the parameter of GenSection""" if FfsInf !=3D None : @@ -87,11 +87,11 @@ class EfiSection (EfiSectionClassObject): else: Filename =3D os.path.normpath(os.path.join(FfsInf.EfiOutpu= tPath, Filename)) =20 if not self.Optional: FileList.append(Filename) - elif os.path.exists(Filename): + elif '.depex' in FfsInf.FinalTargetSuffixMap or FfsInf.Depex: FileList.append(Filename) else: FileList, IsSect =3D Section.Section.GetFileList(FfsInf, self.= FileType, self.FileExtension, Dict) if IsSect : return FileList, self.Alignment @@ -117,12 +117,13 @@ class EfiSection (EfiSectionClassObject): BuildNumTuple =3D tuple() =20 Num =3D SecNum OutputFile =3D os.path.join( OutputPath, ModuleName + 'SEC= ' + str(Num) + Ffs.SectionSuffix.get(SectionType)) GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_= SECTION_VERSION', - #Ui=3DStringData,=20 - Ver=3DBuildNum) + #Ui=3DStringData, + Ver=3DBuildNum, + IsMakefile=3DIsMakefil= e) OutputFileList.append(OutputFile) =20 elif FileList !=3D []: for File in FileList: Index =3D Index + 1 @@ -133,12 +134,13 @@ class EfiSection (EfiSectionClassObject): f.close() BuildNum =3D VerString if BuildNum !=3D None and BuildNum !=3D '': BuildNumTuple =3D ('-j', BuildNum) GenFdsGlobalVariable.GenerateSection(OutputFile, [], '= EFI_SECTION_VERSION', - #Ui=3DVerString,=20 - Ver=3DBuildNum) + #Ui=3DVerString, + Ver=3DBuildNum, + IsMakefile=3DIsMak= efile) OutputFileList.append(OutputFile) =20 else: BuildNum =3D StringData if BuildNum !=3D None and BuildNum !=3D '': @@ -155,12 +157,13 @@ class EfiSection (EfiSectionClassObject): else: EdkLogger.error("GenFds", GENFDS_ERROR, "File: %s = miss Version Section value" %InfFileName) Num =3D SecNum OutputFile =3D os.path.join( OutputPath, ModuleName + 'SEC= ' + str(Num) + Ffs.SectionSuffix.get(SectionType)) GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_= SECTION_VERSION', - #Ui=3DVerString,=20 - Ver=3DBuildNum) + #Ui=3DVerString, + Ver=3DBuildNum, + IsMakefile=3DIsMakefil= e) OutputFileList.append(OutputFile) =20 # # If Section Type is 'UI' # @@ -173,11 +176,11 @@ class EfiSection (EfiSectionClassObject): =20 if InfOverrideUiString: Num =3D SecNum OutputFile =3D os.path.join( OutputPath, ModuleName + 'SEC= ' + str(Num) + Ffs.SectionSuffix.get(SectionType)) GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_= SECTION_USER_INTERFACE', - Ui=3DStringData) + Ui=3DStringData, IsMa= kefile=3DIsMakefile) OutputFileList.append(OutputFile) =20 elif FileList !=3D []: for File in FileList: Index =3D Index + 1 @@ -185,11 +188,11 @@ class EfiSection (EfiSectionClassObject): OutputFile =3D os.path.join(OutputPath, ModuleName + '= SEC' + Num + Ffs.SectionSuffix.get(SectionType)) f =3D open(File, 'r') UiString =3D f.read() f.close() GenFdsGlobalVariable.GenerateSection(OutputFile, [], '= EFI_SECTION_USER_INTERFACE', - Ui=3DUiString) + Ui=3DUiString, IsM= akefile=3DIsMakefile) OutputFileList.append(OutputFile) else: if StringData !=3D None and len(StringData) > 0: UiTuple =3D ('-n', '"' + StringData + '"') else: @@ -202,11 +205,11 @@ class EfiSection (EfiSectionClassObject): EdkLogger.error("GenFds", GENFDS_ERROR, "File: %s = miss UI Section value" %InfFileName) =20 Num =3D SecNum OutputFile =3D os.path.join( OutputPath, ModuleName + 'SEC= ' + str(Num) + Ffs.SectionSuffix.get(SectionType)) GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_= SECTION_USER_INTERFACE', - Ui=3DStringData) + Ui=3DStringData, IsMa= kefile=3DIsMakefile) OutputFileList.append(OutputFile) =20 =20 else: """If File List is empty""" @@ -236,43 +239,58 @@ class EfiSection (EfiSectionClassObject): else: Align =3D str (ImageObj.SectionAlignment / 0x1= 00000) + 'M' =20 if File[(len(File)-4):] =3D=3D '.efi': MapFile =3D File.replace('.efi', '.map') - if os.path.exists(MapFile): - CopyMapFile =3D os.path.join(OutputPath, Modul= eName + '.map') - if not os.path.exists(CopyMapFile) or \ - (os.path.getmtime(MapFile) > os.path.ge= tmtime(CopyMapFile)): - CopyLongFilePath(MapFile, CopyMapFile) + CopyMapFile =3D os.path.join(OutputPath, ModuleNam= e + '.map') + if IsMakefile: + if GenFdsGlobalVariable.CopyList =3D=3D []: + GenFdsGlobalVariable.CopyList =3D [(MapFil= e, CopyMapFile)] + else: + GenFdsGlobalVariable.CopyList.append((MapF= ile, CopyMapFile)) + else: + if os.path.exists(MapFile): + if not os.path.exists(CopyMapFile) or \ + (os.path.getmtime(MapFile) > os.pat= h.getmtime(CopyMapFile)): + CopyLongFilePath(MapFile, CopyMapFile) =20 if not NoStrip: FileBeforeStrip =3D os.path.join(OutputPath, Modul= eName + '.efi') - if not os.path.exists(FileBeforeStrip) or \ - (os.path.getmtime(File) > os.path.getmtime(Fil= eBeforeStrip)): - CopyLongFilePath(File, FileBeforeStrip) + if IsMakefile: + if GenFdsGlobalVariable.CopyList =3D=3D []: + GenFdsGlobalVariable.CopyList =3D [(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 =3D os.path.join(OutputPath, ModuleNa= me + '.stripped') GenFdsGlobalVariable.GenerateFirmwareImage( - StrippedFile, - [File], - Strip=3DTrue - ) + StrippedFile, + [File], + Strip=3DTrue, + IsMakefile =3D IsMakefile + ) File =3D StrippedFile =20 """For TE Section call GenFw to generate TE image""" =20 if SectionType =3D=3D 'TE': TeFile =3D os.path.join( OutputPath, ModuleName + = 'Te.raw') GenFdsGlobalVariable.GenerateFirmwareImage( - TeFile, - [File], - Type=3D'te' - ) + TeFile, + [File], + Type=3D'te', + IsMakefile =3D IsMakefile + ) File =3D TeFile =20 """Call GenSection""" GenFdsGlobalVariable.GenerateSection(OutputFile, - [File], - Section.Section.S= ectionType.get (SectionType) - ) + [File], + Section.Section.Se= ctionType.get (SectionType), + IsMakefile=3DIsMak= efile + ) OutputFileList.append(OutputFile) =20 return OutputFileList, Align diff --git a/BaseTools/Source/Python/GenFds/Fd.py b/BaseTools/Source/Python= /GenFds/Fd.py index f330a7e..2ce3f21 100644 --- a/BaseTools/Source/Python/GenFds/Fd.py +++ b/BaseTools/Source/Python/GenFds/Fd.py @@ -43,19 +43,20 @@ class FD(FDClassObject): # # Generate FD # # @retval string Generated FD file name # - def GenFd (self): + def GenFd (self, Flag =3D False): if self.FdUiName.upper() + 'fd' in GenFds.ImageBinDict.keys(): return GenFds.ImageBinDict[self.FdUiName.upper() + 'fd'] =20 # # Print Information # FdFileName =3D os.path.join(GenFdsGlobalVariable.FvDir, self.FdUiN= ame + '.fd') - GenFdsGlobalVariable.InfLogger("Fd File Name:%s (%s)" %(self.FdUiN= ame, FdFileName)) + if not Flag: + GenFdsGlobalVariable.InfLogger("Fd File Name:%s (%s)" %(self.F= dUiName, FdFileName)) =20 Offset =3D 0x00 for item in self.BlockSizeList: Offset =3D Offset + item[0] * item[1] if Offset !=3D self.Size: @@ -83,15 +84,17 @@ class FD(FDClassObject): if RegionObj.Offset + RegionObj.Size <=3D PreviousRegionSt= art: pass elif RegionObj.Offset <=3D PreviousRegionStart or (RegionO= bj.Offset >=3DPreviousRegionStart and RegionObj.Offset < PreviousRegionStar= t + PreviousRegionSize): pass elif RegionObj.Offset > PreviousRegionStart + PreviousRegi= onSize: - GenFdsGlobalVariable.InfLogger('Padding region startin= g from offset 0x%X, with size 0x%X' %(PreviousRegionStart + PreviousRegionS= ize, RegionObj.Offset - (PreviousRegionStart + PreviousRegionSize))) + if not Flag: + GenFdsGlobalVariable.InfLogger('Padding region sta= rting from offset 0x%X, with size 0x%X' %(PreviousRegionStart + PreviousReg= ionSize, RegionObj.Offset - (PreviousRegionStart + PreviousRegionSize))) PadRegion =3D Region.Region() PadRegion.Offset =3D PreviousRegionStart + PreviousReg= ionSize PadRegion.Size =3D RegionObj.Offset - PadRegion.Offset - PadRegion.AddToBuffer(TempFdBuffer, self.BaseAddress, = self.BlockSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDic= t, self.DefineVarDict) + if not Flag: + PadRegion.AddToBuffer(TempFdBuffer, self.BaseAddre= ss, self.BlockSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRa= wDict, self.DefineVarDict) PreviousRegionStart =3D RegionObj.Offset PreviousRegionSize =3D RegionObj.Size # # Call each region's AddToBuffer function # @@ -111,15 +114,17 @@ class FD(FDClassObject): elif RegionObj.Offset <=3D PreviousRegionStart or (RegionObj.O= ffset >=3DPreviousRegionStart and RegionObj.Offset < PreviousRegionStart + = PreviousRegionSize): EdkLogger.error("GenFds", GENFDS_ERROR, 'Region offset 0x%X overlaps with Region s= tarting from 0x%X, size 0x%X' \ % (RegionObj.Offset, PreviousRegionStart, = PreviousRegionSize)) elif RegionObj.Offset > PreviousRegionStart + PreviousRegionSi= ze: - GenFdsGlobalVariable.InfLogger('Padding region starting fr= om offset 0x%X, with size 0x%X' %(PreviousRegionStart + PreviousRegionSize,= RegionObj.Offset - (PreviousRegionStart + PreviousRegionSize))) + if not Flag: + GenFdsGlobalVariable.InfLogger('Padding region startin= g from offset 0x%X, with size 0x%X' %(PreviousRegionStart + PreviousRegionS= ize, RegionObj.Offset - (PreviousRegionStart + PreviousRegionSize))) PadRegion =3D Region.Region() PadRegion.Offset =3D PreviousRegionStart + PreviousRegionS= ize PadRegion.Size =3D RegionObj.Offset - PadRegion.Offset - PadRegion.AddToBuffer(FdBuffer, self.BaseAddress, self.Blo= ckSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict, self.= DefineVarDict) + if not Flag: + PadRegion.AddToBuffer(FdBuffer, self.BaseAddress, self= .BlockSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict, s= elf.DefineVarDict) PreviousRegionStart =3D RegionObj.Offset PreviousRegionSize =3D RegionObj.Size # # Verify current region fits within allocated FD section Size # @@ -129,17 +134,18 @@ class FD(FDClassObject): % (self.FdUiName, PreviousRegionStart, Pre= viousRegionSize)) # # Call each region's AddToBuffer function # GenFdsGlobalVariable.VerboseLogger('Call each region\'s AddToB= uffer function') - RegionObj.AddToBuffer (FdBuffer, self.BaseAddress, self.BlockS= izeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict, self.Def= ineVarDict) + RegionObj.AddToBuffer (FdBuffer, self.BaseAddress, self.BlockS= izeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict, self.Def= ineVarDict,Flag=3DFlag) # # Write the buffer contents to Fd file # GenFdsGlobalVariable.VerboseLogger('Write the buffer contents to F= d file') - SaveFileOnChange(FdFileName, FdBuffer.getvalue()) - FdBuffer.close(); + if not Flag: + SaveFileOnChange(FdFileName, FdBuffer.getvalue()) + FdBuffer.close() GenFds.ImageBinDict[self.FdUiName.upper() + 'fd'] =3D FdFileName return FdFileName =20 ## generate VTF # diff --git a/BaseTools/Source/Python/GenFds/FfsFileStatement.py b/BaseTools= /Source/Python/GenFds/FfsFileStatement.py index f76ddf4..edb1312 100644 --- a/BaseTools/Source/Python/GenFds/FfsFileStatement.py +++ b/BaseTools/Source/Python/GenFds/FfsFileStatement.py @@ -1,9 +1,9 @@ ## @file # process FFS generation from FILE statement # -# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the B= SD License # which accompanies this distribution. The full text of the license may = be found at # http://opensource.org/licenses/bsd-license.php @@ -55,11 +55,11 @@ class FileStatement (FileStatementClassObject) : # @param Dict dictionary contains macro and value pair # @param FvChildAddr Array of the inside FvImage base address # @param FvParentAddr Parent Fv base address # @retval string Generated FFS file name # - def GenFfs(self, Dict =3D {}, FvChildAddr=3D[], FvParentAddr=3DNone): + def GenFfs(self, Dict =3D {}, FvChildAddr=3D[], FvParentAddr=3DNone, I= sMakefile=3DFalse): =20 if self.NameGuid !=3D None and self.NameGuid.startswith('PCD('): PcdValue =3D GenFdsGlobalVariable.GetPcdValue(self.NameGuid) if len(PcdValue) =3D=3D 0: EdkLogger.error("GenFds", GENFDS_ERROR, '%s NOT defined.' \ diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/= Source/Python/GenFds/FfsInfStatement.py index 958cecf..aee5a2f 100644 --- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py +++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py @@ -42,10 +42,12 @@ from Common.Misc import PeImageClass from AutoGen.GenDepex import DependencyExpression from PatchPcdValue.PatchPcdValue import PatchBinaryFile from Common.LongFilePathSupport import CopyLongFilePath from Common.LongFilePathSupport import OpenLongFilePath as open import Common.GlobalData as GlobalData +from DepexSection import DepexSection +from Common.Misc import SaveFileOnChange =20 ## generate FFS from INF # # class FfsInfStatement(FfsInfStatementClassObject): @@ -70,10 +72,11 @@ class FfsInfStatement(FfsInfStatementClassObject): self.FileName =3D None self.InfFileName =3D None self.OverrideGuid =3D None self.PatchedBinFile =3D '' self.MacroDict =3D {} + self.Depex =3D False =20 ## GetFinalTargetSuffixMap() method # # Get final build target list def GetFinalTargetSuffixMap(self): @@ -318,10 +321,15 @@ class FfsInfStatement(FfsInfStatementClassObject): self.PatchPcds.append((Pcd, DefaultValue)) =20 self.InfModule =3D Inf self.PcdIsDriver =3D Inf.PcdIsDriver self.IsBinaryModule =3D Inf.IsBinaryModule + Inf._GetDepex() + Inf._GetDepexExpression() + if len(Inf._Depex.data) > 0 and len(Inf._DepexExpression.data) > 0: + self.Depex =3D True + GenFdsGlobalVariable.VerboseLogger("BaseName : %s" % self.BaseName) GenFdsGlobalVariable.VerboseLogger("ModuleGuid : %s" % self.Module= Guid) GenFdsGlobalVariable.VerboseLogger("ModuleType : %s" % self.Module= Type) GenFdsGlobalVariable.VerboseLogger("VersionString : %s" % self.Ver= sionString) GenFdsGlobalVariable.VerboseLogger("InfFileName :%s" % self.InfFil= eName) @@ -333,11 +341,11 @@ class FfsInfStatement(FfsInfStatementClassObject): self.OutputPath =3D os.path.join(GenFdsGlobalVariable.FfsDir, \ self.ModuleGuid + self.BaseName) if not os.path.exists(self.OutputPath) : os.makedirs(self.OutputPath) =20 - self.EfiOutputPath =3D self.__GetEFIOutPutPath__() + self.EfiOutputPath, self.EfiDebugPath =3D self.__GetEFIOutPutPath_= _() GenFdsGlobalVariable.VerboseLogger( "ModuelEFIPath: " + self.EfiOu= tputPath) =20 ## PatchEfiFile # # Patch EFI file with patch PCD @@ -412,16 +420,17 @@ class FfsInfStatement(FfsInfStatementClassObject): # @param Dict dictionary contains macro and value pair # @param FvChildAddr Array of the inside FvImage base address # @param FvParentAddr Parent Fv base address # @retval string Generated FFS file name # - def GenFfs(self, Dict =3D {}, FvChildAddr =3D [], FvParentAddr=3DNone): + def GenFfs(self, Dict =3D {}, FvChildAddr =3D [], FvParentAddr=3DNone,= IsMakefile=3DFalse): # # Parse Inf file get Module related information # =20 self.__InfParse__(Dict) + Arch =3D self.GetCurrentArch() SrcFile =3D mws.join( GenFdsGlobalVariable.WorkSpaceDir , self.Inf= FileName); DestFile =3D os.path.join( self.OutputPath, self.ModuleGuid + '.ff= s') =20 SrcFileDir =3D "." SrcPath =3D os.path.dirname(SrcFile) @@ -470,21 +479,23 @@ class FfsInfStatement(FfsInfStatementClassObject): if Rule.FvFileType =3D=3D 'SMM' or Rule.FvFileType =3D=3D 'SMM= _CORE': EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "Framework= SMM module doesn't support SMM or SMM_CORE FV file type", File=3Dself.InfF= ileName) # # For the rule only has simpleFile # + MakefilePath =3D None + if IsMakefile: + MakefilePath =3D self.InfFileName, Arch if isinstance (Rule, RuleSimpleFile.RuleSimpleFile) : - SectionOutputList =3D self.__GenSimpleFileSection__(Rule) - FfsOutput =3D self.__GenSimpleFileFfs__(Rule, SectionOutputLis= t) + SectionOutputList =3D self.__GenSimpleFileSection__(Rule, IsMa= kefile=3DIsMakefile) + FfsOutput =3D self.__GenSimpleFileFfs__(Rule, SectionOutputLis= t, MakefilePath=3DMakefilePath) return FfsOutput # # For Rule has ComplexFile # elif isinstance(Rule, RuleComplexFile.RuleComplexFile): - InputSectList, InputSectAlignments =3D self.__GenComplexFileSe= ction__(Rule, FvChildAddr, FvParentAddr) - FfsOutput =3D self.__GenComplexFileFfs__(Rule, InputSectList, = InputSectAlignments) - + InputSectList, InputSectAlignments =3D self.__GenComplexFileSe= ction__(Rule, FvChildAddr, FvParentAddr, IsMakefile=3DIsMakefile) + FfsOutput =3D self.__GenComplexFileFfs__(Rule, InputSectList, = InputSectAlignments, MakefilePath=3DMakefilePath) return FfsOutput =20 ## __ExtendMacro__() method # # Replace macro with its value @@ -649,10 +660,11 @@ class FfsInfStatement(FfsInfStatementClassObject): # @retval string Path that output files from this INF go to # def __GetEFIOutPutPath__(self): Arch =3D '' OutputPath =3D '' + DebugPath =3D '' (ModulePath, FileName) =3D os.path.split(self.InfFileName) Index =3D FileName.rfind('.') FileName =3D FileName[0:Index] if self.OverrideGuid: FileName =3D self.OverrideGuid @@ -664,22 +676,29 @@ class FfsInfStatement(FfsInfStatementClassObject): Arch , ModulePath, FileName, 'OUTPUT' ) + DebugPath =3D os.path.join(GenFdsGlobalVariable.OutputDirDict[Arch= ], + Arch , + ModulePath, + FileName, + 'DEBUG' + ) OutputPath =3D os.path.realpath(OutputPath) - return OutputPath + DebugPath =3D os.path.realpath(DebugPath) + return OutputPath, DebugPath =20 ## __GenSimpleFileSection__() method # # Generate section by specified file name or a list of files with fi= le extension # # @param self The object pointer # @param Rule The rule object used to generate section # @retval string File name of the generated section file # - def __GenSimpleFileSection__(self, Rule): + def __GenSimpleFileSection__(self, Rule, IsMakefile =3D False): # # Prepare the parameter of GenSection # FileList =3D [] OutputFileList =3D [] @@ -741,26 +760,27 @@ class FfsInfStatement(FfsInfStatementClassObject): if not os.path.exists(FileBeforeStrip) or \ (os.path.getmtime(File) > os.path.getmtime(File= BeforeStrip)): CopyLongFilePath(File, FileBeforeStrip) StrippedFile =3D os.path.join(self.OutputPath, ModuleN= ame + '.stipped') GenFdsGlobalVariable.GenerateFirmwareImage( - StrippedFile, - [File], - Strip=3DTrue - ) + StrippedFile, + [File], + Strip=3DTrue, + IsMakefile=3DIsMakefile + ) File =3D StrippedFile =20 if SectionType =3D=3D 'TE': TeFile =3D os.path.join( self.OutputPath, self.ModuleG= uid + 'Te.raw') GenFdsGlobalVariable.GenerateFirmwareImage( - TeFile, - [File], - Type=3D'te' - ) + TeFile, + [File], + Type=3D'te', + IsMakefile=3DIsMakefile + ) File =3D TeFile - - GenFdsGlobalVariable.GenerateSection(OutputFile, [File], S= ection.Section.SectionType[SectionType]) + GenFdsGlobalVariable.GenerateSection(OutputFile, [File], S= ection.Section.SectionType[SectionType], IsMakefile=3DIsMakefile) OutputFileList.append(OutputFile) else: SecNum =3D '%d' %Index GenSecOutputFile=3D self.__ExtendMacro__(Rule.NameGuid) + \ Ffs.Ffs.SectionSuffix[SectionType] + 'SEC' += SecNum @@ -783,26 +803,27 @@ class FfsInfStatement(FfsInfStatementClassObject): (os.path.getmtime(GenSecInputFile) > os.path.getmti= me(FileBeforeStrip)): CopyLongFilePath(GenSecInputFile, FileBeforeStrip) =20 StrippedFile =3D os.path.join(self.OutputPath, ModuleName = + '.stipped') GenFdsGlobalVariable.GenerateFirmwareImage( - StrippedFile, - [GenSecInputFile], - Strip=3DTrue - ) + StrippedFile, + [GenSecInputFile], + Strip=3DTrue, + IsMakefile=3DIsMakefile + ) GenSecInputFile =3D StrippedFile =20 if SectionType =3D=3D 'TE': TeFile =3D os.path.join( self.OutputPath, self.ModuleGuid = + 'Te.raw') GenFdsGlobalVariable.GenerateFirmwareImage( - TeFile, - [GenSecInputFile], - Type=3D'te' - ) + TeFile, + [GenSecInputFile], + Type=3D'te', + IsMakefile=3DIsMakefile + ) GenSecInputFile =3D TeFile - - GenFdsGlobalVariable.GenerateSection(OutputFile, [GenSecInputF= ile], Section.Section.SectionType[SectionType]) + GenFdsGlobalVariable.GenerateSection(OutputFile, [GenSecInputF= ile], Section.Section.SectionType[SectionType], IsMakefile=3DIsMakefile) OutputFileList.append(OutputFile) =20 return OutputFileList =20 ## __GenSimpleFileFfs__() method @@ -812,11 +833,11 @@ class FfsInfStatement(FfsInfStatementClassObject): # @param self The object pointer # @param Rule The rule object used to generate section # @param InputFileList The output file list from GenSection # @retval string Generated FFS file name # - def __GenSimpleFileFfs__(self, Rule, InputFileList): + def __GenSimpleFileFfs__(self, Rule, InputFileList, MakefilePath =3D N= one): FfsOutput =3D self.OutputPath + \ os.sep + \ self.__ExtendMacro__(Rule.NameGuid) + \ '.ffs' =20 @@ -838,16 +859,17 @@ class FfsInfStatement(FfsInfStatementClassObject): if len(RegistryGuidStr) =3D=3D 0: EdkLogger.error("GenFds", GENFDS_ERROR, 'GUID value for %s= in wrong format.' \ % (Rule.NameGuid)) self.ModuleGuid =3D RegistryGuidStr =20 - GenFdsGlobalVariable.GenerateFfs(FfsOutput, InputSection, - Ffs.Ffs.FdfFvFileTypeToFileType[R= ule.FvFileType], - self.ModuleGuid, Fixed=3DRule.Fix= ed, - CheckSum=3DRule.CheckSum, Align= =3DRule.Alignment, - SectionAlign=3DSectionAlignments - ) + GenFdsGlobalVariable.GenerateFfs(FfsOutput, InputSection, + Ffs.Ffs.FdfFvFileTypeToFileTy= pe[Rule.FvFileType], + self.ModuleGuid, Fixed=3DRule= .Fixed, + CheckSum=3DRule.CheckSum, Ali= gn=3DRule.Alignment, + SectionAlign=3DSectionAlignme= nts, + MakefilePath=3DMakefilePath + ) return FfsOutput =20 ## __GenComplexFileSection__() method # # Generate section by sections in Rule @@ -856,40 +878,42 @@ class FfsInfStatement(FfsInfStatementClassObject): # @param Rule The rule object used to generate section # @param FvChildAddr Array of the inside FvImage base address # @param FvParentAddr Parent Fv base address # @retval string File name of the generated section file # - def __GenComplexFileSection__(self, Rule, FvChildAddr, FvParentAddr): + def __GenComplexFileSection__(self, Rule, FvChildAddr, FvParentAddr, I= sMakefile =3D False): if self.ModuleType in ('SEC', 'PEI_CORE', 'PEIM'): if Rule.KeepReloc !=3D None: self.KeepRelocFromRule =3D Rule.KeepReloc SectFiles =3D [] SectAlignments =3D [] Index =3D 1 - HasGneratedFlag =3D False + HasGeneratedFlag =3D False if self.PcdIsDriver =3D=3D 'PEI_PCD_DRIVER': if self.IsBinaryModule: PcdExDbFileName =3D os.path.join(GenFdsGlobalVariable.FvDi= r, "PEIPcdDataBase.raw") else: PcdExDbFileName =3D os.path.join(self.EfiOutputPath, "PEIP= cdDataBase.raw") PcdExDbSecName =3D os.path.join(self.OutputPath, "PEIPcdDataBa= seSec.raw") GenFdsGlobalVariable.GenerateSection(PcdExDbSecName, [PcdExDbFileName], "EFI_SECTION_RAW", + IsMakefile =3D IsMakefile ) SectFiles.append(PcdExDbSecName) SectAlignments.append(None) elif self.PcdIsDriver =3D=3D 'DXE_PCD_DRIVER': if self.IsBinaryModule: PcdExDbFileName =3D os.path.join(GenFdsGlobalVariable.FvDi= r, "DXEPcdDataBase.raw") else: PcdExDbFileName =3D os.path.join(self.EfiOutputPath, "DXEP= cdDataBase.raw") PcdExDbSecName =3D os.path.join(self.OutputPath, "DXEPcdDataBa= seSec.raw") GenFdsGlobalVariable.GenerateSection(PcdExDbSecName, - [PcdExDbFileName], - "EFI_SECTION_RAW", - ) + [PcdExDbFileName], + "EFI_SECTION_RAW", + IsMakefile =3D IsMakefile + ) SectFiles.append(PcdExDbSecName) SectAlignments.append(None) for Sect in Rule.SectionList: SecIndex =3D '%d' %Index SectList =3D [] @@ -915,15 +939,15 @@ class FfsInfStatement(FfsInfStatementClassObject): Sect.FvAddr =3D FvChildAddr if FvParentAddr !=3D None and isinstance(Sect, GuidSection): Sect.FvParentAddr =3D FvParentAddr =20 if Rule.KeyStringList !=3D []: - SectList, Align =3D Sect.GenSection(self.OutputPath , self= .ModuleGuid, SecIndex, Rule.KeyStringList, self) + SectList, Align =3D Sect.GenSection(self.OutputPath , self= .ModuleGuid, SecIndex, Rule.KeyStringList, self, IsMakefile =3D IsMakefile) else : - SectList, Align =3D Sect.GenSection(self.OutputPath , self= .ModuleGuid, SecIndex, self.KeyStringList, self) + SectList, Align =3D Sect.GenSection(self.OutputPath , self= .ModuleGuid, SecIndex, self.KeyStringList, self, IsMakefile =3D IsMakefile) =20 - if not HasGneratedFlag: + if not HasGeneratedFlag: UniVfrOffsetFileSection =3D "" =20 ModuleFileName =3D mws.join(GenFdsGlobalVariable.WorkSpace= Dir, self.InfFileName) InfData =3D GenFdsGlobalVariable.WorkSpace.BuildObject[Pat= hClass(ModuleFileName), self.CurrentArch] # # Search the source list in InfData to find if there are .= vfr file exist. @@ -942,31 +966,44 @@ class FfsInfStatement(FfsInfStatementClassObject): # VfrUniBaseName["UniOffsetName"] =3D (self.BaseName= + "Strings") =20 =20 if len(VfrUniBaseName) > 0: - VfrUniOffsetList =3D self.__GetBuildOutputMapFileVfrUn= iInfo(VfrUniBaseName) - # - # Generate the Raw data of raw section - # - if VfrUniOffsetList: - os.path.join( self.OutputPath, self.BaseName + '.o= ffset') - UniVfrOffsetFileName =3D os.path.join( self.Ou= tputPath, self.BaseName + '.offset') - UniVfrOffsetFileSection =3D os.path.join( self.Ou= tputPath, self.BaseName + 'Offset' + '.raw') - - self.__GenUniVfrOffsetFile (VfrUniOffsetList, UniV= frOffsetFileName) - - UniVfrOffsetFileNameList =3D [] - UniVfrOffsetFileNameList.append(UniVfrOffsetFileNa= me) - """Call GenSection""" - GenFdsGlobalVariable.GenerateSection(UniVfrOffsetF= ileSection, - UniVfrOffsetF= ileNameList, - "EFI_SECTION_= RAW" - ) - os.remove(UniVfrOffsetFileName) + if IsMakefile: + if InfData.BuildType !=3D 'UEFI_HII': + UniVfrOffsetFileName =3D os.path.join(self.Out= putPath, self.BaseName + '.offset') + UniVfrOffsetFileSection =3D os.path.join(self.= OutputPath, self.BaseName + 'Offset' + '.raw') + UniVfrOffsetFileNameList =3D [] + UniVfrOffsetFileNameList.append(UniVfrOffsetFi= leName) + TrimCmd =3D "Trim --Vfr-Uni-Offset -o %s --Mod= uleName=3D%s --DebugDir=3D%s " % (UniVfrOffsetFileName, self.BaseName, self= .EfiDebugPath) + GenFdsGlobalVariable.SecCmdList.append(TrimCmd) + GenFdsGlobalVariable.GenerateSection(UniVfrOff= setFileSection, + [UniVfrOff= setFileName], + "EFI_SECTI= ON_RAW", + IsMakefile= =3D True + ) + else: + VfrUniOffsetList =3D self.__GetBuildOutputMapFileV= frUniInfo(VfrUniBaseName) + # + # Generate the Raw data of raw section + # + if VfrUniOffsetList: + UniVfrOffsetFileName =3D os.path.join(self.Out= putPath, self.BaseName + '.offset') + UniVfrOffsetFileSection =3D os.path.join(self.= OutputPath, self.BaseName + 'Offset' + '.raw') + self.__GenUniVfrOffsetFile (VfrUniOffsetList, = UniVfrOffsetFileName) + UniVfrOffsetFileNameList =3D [] + UniVfrOffsetFileNameList.append(UniVfrOffsetFi= leName) + """Call GenSection""" + + GenFdsGlobalVariable.GenerateSection(UniVfrOff= setFileSection, + UniVfrOff= setFileNameList, + "EFI_SECT= ION_RAW" + ) + #os.remove(UniVfrOffsetFileName) + if UniVfrOffsetFileSection: SectList.append(UniVfrOffsetFileSection) - HasGneratedFlag =3D True + HasGeneratedFlag =3D True =20 for SecName in SectList : SectFiles.append(SecName) SectAlignments.append(Align) Index =3D Index + 1 @@ -979,11 +1016,11 @@ class FfsInfStatement(FfsInfStatementClassObject): # @param self The object pointer # @param Rule The rule object used to generate section # @param InputFileList The output file list from GenSection # @retval string Generated FFS file name # - def __GenComplexFileFfs__(self, Rule, InputFile, Alignments): + def __GenComplexFileFfs__(self, Rule, InputFile, Alignments, MakefileP= ath =3D None): =20 if Rule.NameGuid !=3D None and Rule.NameGuid.startswith('PCD('): PcdValue =3D GenFdsGlobalVariable.GetPcdValue(Rule.NameGuid) if len(PcdValue) =3D=3D 0: EdkLogger.error("GenFds", GENFDS_ERROR, '%s NOT defined.' \ @@ -996,15 +1033,16 @@ class FfsInfStatement(FfsInfStatementClassObject): % (Rule.NameGuid)) self.ModuleGuid =3D RegistryGuidStr =20 FfsOutput =3D os.path.join( self.OutputPath, self.ModuleGuid + '.f= fs') GenFdsGlobalVariable.GenerateFfs(FfsOutput, InputFile, - Ffs.Ffs.FdfFvFileTypeToFileType[R= ule.FvFileType], - self.ModuleGuid, Fixed=3DRule.Fix= ed, - CheckSum=3DRule.CheckSum, Align= =3DRule.Alignment, - SectionAlign=3DAlignments - ) + Ffs.Ffs.FdfFvFileTypeToFileTy= pe[Rule.FvFileType], + self.ModuleGuid, Fixed=3DRule= .Fixed, + CheckSum=3DRule.CheckSum, Ali= gn=3DRule.Alignment, + SectionAlign=3DAlignments, + MakefilePath=3DMakefilePath + ) return FfsOutput =20 ## __GetGenFfsCmdParameter__() method # # Create parameter string for GenFfs @@ -1046,16 +1084,11 @@ class FfsInfStatement(FfsInfStatementClassObject): # @param self The object pointer # @param VfrUniOffsetList A list contain the VFR/UNI offsets= in the EFI image file. # @param UniVfrOffsetFileName The output offset file name. # def __GenUniVfrOffsetFile(self, VfrUniOffsetList, UniVfrOffsetFileName= ): - =20 - try: - fInputfile =3D open(UniVfrOffsetFileName, "wb+", 0) - except: - EdkLogger.error("GenFds", FILE_OPEN_FAILURE, "File open failed= for %s" %UniVfrOffsetFileName,None) - =20 + # Use a instance of StringIO to cache data fStringIO =3D StringIO.StringIO('') =20 =20 for Item in VfrUniOffsetList: if (Item[0].find("Strings") !=3D -1): @@ -1083,20 +1116,13 @@ class FfsInfStatement(FfsInfStatementClassObject): fStringIO.write (VfrValue) =20 # # write data into file. # - try : =20 - fInputfile.write (fStringIO.getvalue()) + try : + SaveFileOnChange(UniVfrOffsetFileName, fStringIO.getvalue()) except: EdkLogger.error("GenFds", FILE_WRITE_FAILURE, "Write data to f= ile %s failed, please check whether the file been locked or using by other = applications." %UniVfrOffsetFileName,None) =20 fStringIO.close () - fInputfile.close () - =20 - =20 - =20 - =20 - =20 - =20 - =20 + =20 diff --git a/BaseTools/Source/Python/GenFds/Fv.py b/BaseTools/Source/Python= /GenFds/Fv.py index 4b03adc..bfa78b1 100644 --- a/BaseTools/Source/Python/GenFds/Fv.py +++ b/BaseTools/Source/Python/GenFds/Fv.py @@ -20,10 +20,11 @@ import subprocess import StringIO from struct import * =20 import Ffs import AprioriSection +import FfsFileStatement from GenFdsGlobalVariable import GenFdsGlobalVariable from GenFds import GenFds from CommonDataClass.FdfClass import FvClassObject from Common.Misc import SaveFileOnChange from Common.LongFilePathSupport import CopyLongFilePath @@ -64,11 +65,11 @@ class FV (FvClassObject): # @param ErasePolarity Flash erase polarity # @param VtfDict VTF objects # @param MacroDict macro value pair # @retval string Generated FV file path # - def AddToBuffer (self, Buffer, BaseAddress=3DNone, BlockSize=3D None, = BlockNum=3DNone, ErasePloarity=3D'1', VtfDict=3DNone, MacroDict =3D {}) : + def AddToBuffer (self, Buffer, BaseAddress=3DNone, BlockSize=3D None, = BlockNum=3DNone, ErasePloarity=3D'1', VtfDict=3DNone, MacroDict =3D {}, Fla= g=3DFalse) : =20 if BaseAddress =3D=3D None and self.UiFvName.upper() + 'fv' in Gen= Fds.ImageBinDict.keys(): return GenFds.ImageBinDict[self.UiFvName.upper() + 'fv'] =20 # @@ -85,135 +86,143 @@ class FV (FvClassObject): continue elif RegionData.upper() + 'fv' in GenFds.Image= BinDict.keys(): continue elif self.UiFvName.upper() =3D=3D RegionData.u= pper(): GenFdsGlobalVariable.ErrorLogger("Capsule = %s in FD region can't contain a FV %s in FD region." % (self.CapsuleName, s= elf.UiFvName.upper())) - - GenFdsGlobalVariable.InfLogger( "\nGenerating %s FV" %self.UiFvNam= e) + if not Flag: + GenFdsGlobalVariable.InfLogger( "\nGenerating %s FV" %self.UiF= vName) GenFdsGlobalVariable.LargeFileInFvFlags.append(False) FFSGuid =3D None =20 if self.FvBaseAddress !=3D None: BaseAddress =3D self.FvBaseAddress - - self.__InitializeInf__(BaseAddress, BlockSize, BlockNum, ErasePloa= rity, VtfDict) + if not Flag: + self.__InitializeInf__(BaseAddress, BlockSize, BlockNum, Erase= Ploarity, VtfDict) # # First Process the Apriori section # MacroDict.update(self.DefineVarDict) =20 GenFdsGlobalVariable.VerboseLogger('First generate Apriori file !') FfsFileList =3D [] for AprSection in self.AprioriSectionList: - FileName =3D AprSection.GenFfs (self.UiFvName, MacroDict) + FileName =3D AprSection.GenFfs (self.UiFvName, MacroDict, IsMa= kefile=3DFlag) FfsFileList.append(FileName) # Add Apriori file name to Inf file - self.FvInfFile.writelines("EFI_FILE_NAME =3D " + \ - FileName + \ - T_CHAR_LF) + if not Flag: + self.FvInfFile.writelines("EFI_FILE_NAME =3D " + \ + FileName + \ + T_CHAR_LF) =20 # Process Modules in FfsList for FfsFile in self.FfsList : - FileName =3D FfsFile.GenFfs(MacroDict, FvParentAddr=3DBaseAddr= ess) + if Flag: + if isinstance(FfsFile, FfsFileStatement.FileStatement): + continue + FileName =3D FfsFile.GenFfs(MacroDict, FvParentAddr=3DBaseAddr= ess, IsMakefile=3DFlag) FfsFileList.append(FileName) - self.FvInfFile.writelines("EFI_FILE_NAME =3D " + \ - FileName + \ - T_CHAR_LF) - - SaveFileOnChange(self.InfFileName, self.FvInfFile.getvalue(), Fals= e) - self.FvInfFile.close() + if not Flag: + self.FvInfFile.writelines("EFI_FILE_NAME =3D " + \ + FileName + \ + T_CHAR_LF) + if not Flag: + SaveFileOnChange(self.InfFileName, self.FvInfFile.getvalue(), = False) + self.FvInfFile.close() # # Call GenFv tool # FvOutputFile =3D os.path.join(GenFdsGlobalVariable.FvDir, self.UiF= vName) FvOutputFile =3D FvOutputFile + '.Fv' # BUGBUG: FvOutputFile could be specified from FDF file (FV sectio= n, CreateFile statement) if self.CreateFileName !=3D None: FvOutputFile =3D self.CreateFileName =20 + if Flag: + GenFds.ImageBinDict[self.UiFvName.upper() + 'fv'] =3D FvOutput= File + return FvOutputFile + FvInfoFileName =3D os.path.join(GenFdsGlobalVariable.FfsDir, self.= UiFvName + '.inf') - CopyLongFilePath(GenFdsGlobalVariable.FvAddressFileName, FvInfoFil= eName) - OrigFvInfo =3D None - if os.path.exists (FvInfoFileName): - OrigFvInfo =3D open(FvInfoFileName, 'r').read() - if GenFdsGlobalVariable.LargeFileInFvFlags[-1]: - FFSGuid =3D GenFdsGlobalVariable.EFI_FIRMWARE_FILE_SYSTEM3_GUI= D; - GenFdsGlobalVariable.GenerateFirmwareVolume( - FvOutputFile, - [self.InfFileName], - AddressFile=3DFvInfoFileName, - FfsList=3DFfsFileList, - ForceRebase=3Dself.FvForceRebase, - FileSystemGuid=3DFFSGuid - ) + if not Flag: + CopyLongFilePath(GenFdsGlobalVariable.FvAddressFileName, FvInf= oFileName) + OrigFvInfo =3D None + if os.path.exists (FvInfoFileName): + OrigFvInfo =3D open(FvInfoFileName, 'r').read() + if GenFdsGlobalVariable.LargeFileInFvFlags[-1]: + FFSGuid =3D GenFdsGlobalVariable.EFI_FIRMWARE_FILE_SYSTEM3= _GUID + GenFdsGlobalVariable.GenerateFirmwareVolume( + FvOutputFile, + [self.InfFileName], + AddressFile=3DFvInfoFileName, + FfsList=3DFfsFileList, + ForceRebase=3Dself.FvForceRebase, + FileSystemGuid=3DFFSGuid + ) =20 - NewFvInfo =3D None - if os.path.exists (FvInfoFileName): - NewFvInfo =3D open(FvInfoFileName, 'r').read() - if NewFvInfo !=3D None and NewFvInfo !=3D OrigFvInfo: - FvChildAddr =3D [] - AddFileObj =3D open(FvInfoFileName, 'r') - AddrStrings =3D AddFileObj.readlines() - AddrKeyFound =3D False - for AddrString in AddrStrings: - if AddrKeyFound: - #get base address for the inside FvImage - FvChildAddr.append (AddrString) - elif AddrString.find ("[FV_BASE_ADDRESS]") !=3D -1: - AddrKeyFound =3D True - AddFileObj.close() + NewFvInfo =3D None + if os.path.exists (FvInfoFileName): + NewFvInfo =3D open(FvInfoFileName, 'r').read() + if NewFvInfo !=3D None and NewFvInfo !=3D OrigFvInfo: + FvChildAddr =3D [] + AddFileObj =3D open(FvInfoFileName, 'r') + AddrStrings =3D AddFileObj.readlines() + AddrKeyFound =3D False + for AddrString in AddrStrings: + if AddrKeyFound: + #get base address for the inside FvImage + FvChildAddr.append (AddrString) + elif AddrString.find ("[FV_BASE_ADDRESS]") !=3D -1: + AddrKeyFound =3D True + AddFileObj.close() =20 - if FvChildAddr !=3D []: - # Update Ffs again - for FfsFile in self.FfsList : - FileName =3D FfsFile.GenFfs(MacroDict, FvChildAddr, Ba= seAddress) - =20 - if GenFdsGlobalVariable.LargeFileInFvFlags[-1]: - FFSGuid =3D GenFdsGlobalVariable.EFI_FIRMWARE_FILE_SYS= TEM3_GUID; - #Update GenFv again - GenFdsGlobalVariable.GenerateFirmwareVolume( - FvOutputFile, - [self.InfFileName], - AddressFile=3DFvInfoFileName, - FfsList=3DFfsFileList, - ForceRebase=3Dself.FvForceRebase, - FileSystemGuid=3DFFSGuid - ) + if FvChildAddr !=3D []: + # Update Ffs again + for FfsFile in self.FfsList : + FileName =3D FfsFile.GenFfs(MacroDict, FvChildAddr= , BaseAddress, IsMakefile=3DFlag) =20 - # - # Write the Fv contents to Buffer - # - if os.path.isfile(FvOutputFile): - FvFileObj =3D open ( FvOutputFile,'rb') + if GenFdsGlobalVariable.LargeFileInFvFlags[-1]: + FFSGuid =3D GenFdsGlobalVariable.EFI_FIRMWARE_FILE= _SYSTEM3_GUID; + #Update GenFv again + GenFdsGlobalVariable.GenerateFirmwareVolume( + FvOutputFile, + [self.InfFileName], + AddressFile=3DFvInfoFileNa= me, + FfsList=3DFfsFileList, + ForceRebase=3Dself.FvForce= Rebase, + FileSystemGuid=3DFFSGuid + ) =20 - GenFdsGlobalVariable.VerboseLogger( "\nGenerate %s FV Successf= ully" %self.UiFvName) - GenFdsGlobalVariable.SharpCounter =3D 0 + # + # Write the Fv contents to Buffer + # + if os.path.isfile(FvOutputFile): + FvFileObj =3D open(FvOutputFile, 'rb') + GenFdsGlobalVariable.VerboseLogger("\nGenerate %s FV Succe= ssfully" % self.UiFvName) + GenFdsGlobalVariable.SharpCounter =3D 0 =20 - Buffer.write(FvFileObj.read()) - FvFileObj.seek(0) - # PI FvHeader is 0x48 byte - FvHeaderBuffer =3D FvFileObj.read(0x48) - # FV alignment position. - FvAlignmentValue =3D 1 << (ord (FvHeaderBuffer[0x2E]) & 0x1F) - # FvAlignmentValue is larger than or equal to 1K - if FvAlignmentValue >=3D 0x400: - if FvAlignmentValue >=3D 0x100000: - #The max alignment supported by FFS is 16M. - if FvAlignmentValue >=3D 0x1000000: - self.FvAlignment =3D "16M" + Buffer.write(FvFileObj.read()) + FvFileObj.seek(0) + # PI FvHeader is 0x48 byte + FvHeaderBuffer =3D FvFileObj.read(0x48) + # FV alignment position. + FvAlignmentValue =3D 1 << (ord(FvHeaderBuffer[0x2E]) & 0x1= F) + if FvAlignmentValue >=3D 0x400: + if FvAlignmentValue >=3D 0x100000: + if FvAlignmentValue >=3D 0x1000000: + #The max alignment supported by FFS is 16M. + self.FvAlignment =3D "16M" + else: + self.FvAlignment =3D str(FvAlignmentValue / 0x= 100000) + "M" else: - self.FvAlignment =3D str(FvAlignmentValue / 0x1000= 00) + "M" + self.FvAlignment =3D str(FvAlignmentValue / 0x400)= + "K" else: - self.FvAlignment =3D str (FvAlignmentValue / 0x400) + = "K" + # FvAlignmentValue is less than 1K + self.FvAlignment =3D str (FvAlignmentValue) + FvFileObj.close() + GenFds.ImageBinDict[self.UiFvName.upper() + 'fv'] =3D FvOu= tputFile + GenFdsGlobalVariable.LargeFileInFvFlags.pop() else: - # FvAlignmentValue is less than 1K - self.FvAlignment =3D str (FvAlignmentValue) - FvFileObj.close() - GenFds.ImageBinDict[self.UiFvName.upper() + 'fv'] =3D FvOutput= File - GenFdsGlobalVariable.LargeFileInFvFlags.pop() - else: - GenFdsGlobalVariable.ErrorLogger("Failed to generate %s FV fil= e." %self.UiFvName) + GenFdsGlobalVariable.ErrorLogger("Failed to generate %s FV= file." %self.UiFvName) return FvOutputFile =20 ## _GetBlockSize() # # Calculate FV's block size diff --git a/BaseTools/Source/Python/GenFds/FvImageSection.py b/BaseTools/S= ource/Python/GenFds/FvImageSection.py index 68f17c3..916ff91 100644 --- a/BaseTools/Source/Python/GenFds/FvImageSection.py +++ b/BaseTools/Source/Python/GenFds/FvImageSection.py @@ -48,11 +48,11 @@ class FvImageSection(FvImageSectionClassObject): # @param KeyStringList Filter for inputs of section generation # @param FfsInf FfsInfStatement object that contains this sect= ion data # @param Dict dictionary contains macro and its value # @retval tuple (Generated file name, section alignment) # - def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, Ff= sInf =3D None, Dict =3D {}): + def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, Ff= sInf =3D None, Dict =3D {}, IsMakefile =3D False): =20 OutputFileList =3D [] if self.FvFileType !=3D None: FileList, IsSect =3D Section.Section.GetFileList(FfsInf, self.= FvFileType, self.FvFileExtension) if IsSect : @@ -73,11 +73,11 @@ class FvImageSection(FvImageSectionClassObject): FvFileObj.close() if FvAlignmentValue > MaxFvAlignment: MaxFvAlignment =3D FvAlignmentValue =20 OutputFile =3D os.path.join(OutputPath, ModuleName + 'SEC'= + Num + Ffs.SectionSuffix.get("FV_IMAGE")) - GenFdsGlobalVariable.GenerateSection(OutputFile, [FvFileNa= me], 'EFI_SECTION_FIRMWARE_VOLUME_IMAGE') + GenFdsGlobalVariable.GenerateSection(OutputFile, [FvFileNa= me], 'EFI_SECTION_FIRMWARE_VOLUME_IMAGE', IsMakefile=3DIsMakefile) OutputFileList.append(OutputFile) =20 # MaxFvAlignment is larger than or equal to 1K if MaxFvAlignment >=3D 0x400: if MaxFvAlignment >=3D 0x100000: @@ -99,11 +99,11 @@ class FvImageSection(FvImageSectionClassObject): if self.FvName !=3D None: Buffer =3D StringIO.StringIO('') Fv =3D GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(self.= FvName) if Fv !=3D None: self.Fv =3D Fv - FvFileName =3D Fv.AddToBuffer(Buffer, self.FvAddr, MacroDi= ct =3D Dict) + FvFileName =3D Fv.AddToBuffer(Buffer, self.FvAddr, MacroDi= ct =3D Dict, Flag=3DIsMakefile) if Fv.FvAlignment !=3D None: if self.Alignment =3D=3D None: self.Alignment =3D Fv.FvAlignment else: if GenFdsGlobalVariable.GetAlignment (Fv.FvAlignme= nt) > GenFdsGlobalVariable.GetAlignment (self.Alignment): @@ -137,9 +137,9 @@ class FvImageSection(FvImageSectionClassObject): =20 # # Prepare the parameter of GenSection # OutputFile =3D os.path.join(OutputPath, ModuleName + 'SEC' + S= ecNum + Ffs.SectionSuffix.get("FV_IMAGE")) - GenFdsGlobalVariable.GenerateSection(OutputFile, [FvFileName],= 'EFI_SECTION_FIRMWARE_VOLUME_IMAGE') + GenFdsGlobalVariable.GenerateSection(OutputFile, [FvFileName],= 'EFI_SECTION_FIRMWARE_VOLUME_IMAGE', IsMakefile=3DIsMakefile) OutputFileList.append(OutputFile) =20 return OutputFileList, self.Alignment diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Py= thon/GenFds/GenFds.py index 277da35..bedfaac 100644 --- a/BaseTools/Source/Python/GenFds/GenFds.py +++ b/BaseTools/Source/Python/GenFds/GenFds.py @@ -606,10 +606,27 @@ class GenFds : if GenFdsGlobalVariable.FdfParser.Profile.OptRomDict !=3D {}: GenFdsGlobalVariable.VerboseLogger("\n Generate all Option= ROM!") for DriverName in GenFdsGlobalVariable.FdfParser.Profile.O= ptRomDict.keys(): OptRomObj =3D GenFdsGlobalVariable.FdfParser.Profile.O= ptRomDict[DriverName] OptRomObj.AddToBuffer(None) + @staticmethod + def GenFfsMakefile(OutputDir, FdfParser, WorkSpace, ArchList, GlobalDa= ta): + GenFdsGlobalVariable.SetEnv(FdfParser, WorkSpace, ArchList, Global= Data) + for FdName in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys(): + FdObj =3D GenFdsGlobalVariable.FdfParser.Profile.FdDict[FdName] + FdObj.GenFd(Flag=3DTrue) + + for FvName in GenFdsGlobalVariable.FdfParser.Profile.FvDict.keys(): + FvObj =3D GenFdsGlobalVariable.FdfParser.Profile.FvDict[FvName] + FvObj.AddToBuffer(Buffer=3DNone, Flag=3DTrue) + + if GenFdsGlobalVariable.FdfParser.Profile.OptRomDict !=3D {}: + for DriverName in GenFdsGlobalVariable.FdfParser.Profile.OptRo= mDict.keys(): + OptRomObj =3D GenFdsGlobalVariable.FdfParser.Profile.OptRo= mDict[DriverName] + OptRomObj.AddToBuffer(Buffer=3DNone, Flag=3DTrue) + + return GenFdsGlobalVariable.FfsCmdDict =20 ## GetFvBlockSize() # # @param FvObj Whose block size to get # @retval int Block size value diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py b/BaseT= ools/Source/Python/GenFds/GenFdsGlobalVariable.py index 83996be..1d7e78f 100644 --- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py +++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py @@ -67,10 +67,13 @@ class GenFdsGlobalVariable: =20 BuildRuleFamily =3D "MSFT" ToolChainFamily =3D "MSFT" __BuildRuleDatabase =3D None GuidToolDefinition =3D {} + FfsCmdDict =3D {} + SecCmdList =3D [] + CopyList =3D [] =20 # # The list whose element are flags to indicate if large FFS or SECTION= files exist in FV. # At the beginning of each generation of FV, false flag is appended to= the list, # after the call to GenerateSection returns, check the size of the out= put file, @@ -262,10 +265,14 @@ class GenFdsGlobalVariable: =20 RuleChain.append(FileType) SourceList.extend(Target.Outputs) LastTarget =3D Target FileType =3D DataType.TAB_UNKNOWN_FILE + for Cmd in Target.Commands: + if "$(CP)" =3D=3D Cmd.split()[0]: + CpTarget =3D Cmd.split()[2] + TargetList.add(CpTarget) =20 return list(TargetList) =20 ## SetDir() # @@ -315,10 +322,75 @@ class GenFdsGlobalVariable: RtAddress + \ T_CHAR_LF) =20 FvAddressFile.close() =20 + def SetEnv(FdfParser, WorkSpace, ArchList, GlobalData): + GenFdsGlobalVariable.FdfParser =3D FdfParser + GenFdsGlobalVariable.WorkSpace =3D WorkSpace + GenFdsGlobalVariable.ArchList =3D ArchList + GenFdsGlobalVariable.ToolChainTag =3D GlobalData.gGlobalDefines["T= OOL_CHAIN_TAG"] + GenFdsGlobalVariable.TargetName =3D GlobalData.gGlobalDefines["TAR= GET"] + GenFdsGlobalVariable.ActivePlatform =3D GlobalData.gActivePlatform + GenFdsGlobalVariable.EdkSourceDir =3D GlobalData.gGlobalDefines["E= DK_SOURCE"] + GenFdsGlobalVariable.ConfDir =3D GlobalData.gConfDirectory + for Arch in ArchList: + GenFdsGlobalVariable.OutputDirDict[Arch] =3D os.path.normpath( + os.path.join(GlobalData.gWorkspace, + WorkSpace.BuildObject[GenFdsGlobalVariable.Ac= tivePlatform, Arch,GlobalData.gGlobalDefines['TARGET'], + GlobalData.gGlobalDefines['TOOLCHAIN']].Outpu= tDirectory, + GlobalData.gGlobalDefines['TARGET'] +'_' + Gl= obalData.gGlobalDefines['TOOLCHAIN'])) + GenFdsGlobalVariable.OutputDirFromDscDict[Arch] =3D os.path.no= rmpath( + WorkSpace.BuildObject[GenFdsGlobalVariable.Ac= tivePlatform, Arch, + GlobalData.gGlobalDefines['TARGET'], GlobalDa= ta.gGlobalDefines['TOOLCHAIN']].OutputDirectory) + GenFdsGlobalVariable.PlatformName =3D WorkSpace.BuildObject[Ge= nFdsGlobalVariable.ActivePlatform, Arch, + Glob= alData.gGlobalDefines['TARGET'], + Glob= alData.gGlobalDefines['TOOLCHAIN']].PlatformName + GenFdsGlobalVariable.FvDir =3D os.path.join(GenFdsGlobalVariable.O= utputDirDict[ArchList[0]], 'FV') + if not os.path.exists(GenFdsGlobalVariable.FvDir): + os.makedirs(GenFdsGlobalVariable.FvDir) + GenFdsGlobalVariable.FfsDir =3D os.path.join(GenFdsGlobalVariable.= FvDir, 'Ffs') + if not os.path.exists(GenFdsGlobalVariable.FfsDir): + os.makedirs(GenFdsGlobalVariable.FfsDir) + + T_CHAR_LF =3D '\n' + # + # Create FV Address inf file + # + GenFdsGlobalVariable.FvAddressFileName =3D os.path.join(GenFdsGlob= alVariable.FfsDir, 'FvAddress.inf') + FvAddressFile =3D open(GenFdsGlobalVariable.FvAddressFileName, 'w') + # + # Add [Options] + # + FvAddressFile.writelines("[options]" + T_CHAR_LF) + BsAddress =3D '0' + for Arch in ArchList: + BsAddress =3D GenFdsGlobalVariable.WorkSpace.BuildObject[GenFd= sGlobalVariable.ActivePlatform, Arch, + GlobalD= ata.gGlobalDefines['TARGET'], + GlobalD= ata.gGlobalDefines["TOOL_CHAIN_TAG"]].BsBaseAddress + if BsAddress: + break + + FvAddressFile.writelines("EFI_BOOT_DRIVER_BASE_ADDRESS =3D " + \ + BsAddress + \ + T_CHAR_LF) + + RtAddress =3D '0' + for Arch in ArchList: + if GenFdsGlobalVariable.WorkSpace.BuildObject[ + GenFdsGlobalVariable.ActivePlatform, Arch, GlobalData.gGlo= balDefines['TARGET'], + GlobalData.gGlobalDefines["TOOL_CHAIN_TAG"]].RtBaseAddress: + RtAddress =3D GenFdsGlobalVariable.WorkSpace.BuildObject[ + GenFdsGlobalVariable.ActivePlatform, Arch, GlobalData.= gGlobalDefines['TARGET'], + GlobalData.gGlobalDefines["TOOL_CHAIN_TAG"]].RtBaseAdd= ress + + FvAddressFile.writelines("EFI_RUNTIME_DRIVER_BASE_ADDRESS =3D " + \ + RtAddress + \ + T_CHAR_LF) + + FvAddressFile.close() + ## ReplaceWorkspaceMacro() # # @param String String that may contain macro # def ReplaceWorkspaceMacro(String): @@ -361,11 +433,11 @@ class GenFdsGlobalVariable: return True return False =20 @staticmethod def GenerateSection(Output, Input, Type=3DNone, CompressionType=3DNone= , Guid=3DNone, - GuidHdrLen=3DNone, GuidAttr=3D[], Ui=3DNone, Ver= =3DNone, InputAlign=3DNone, BuildNumber=3DNone): + GuidHdrLen=3DNone, GuidAttr=3D[], Ui=3DNone, Ver= =3DNone, InputAlign=3DNone, BuildNumber=3DNone, IsMakefile=3DFalse): Cmd =3D ["GenSec"] if Type not in [None, '']: Cmd +=3D ["-s", Type] if CompressionType not in [None, '']: Cmd +=3D ["-c", CompressionType] @@ -383,40 +455,53 @@ class GenFdsGlobalVariable: Cmd +=3D ["--sectionalign", SecAlign] =20 CommandFile =3D Output + '.txt' if Ui not in [None, '']: #Cmd +=3D ["-n", '"' + Ui + '"'] - SectionData =3D array.array('B', [0, 0, 0, 0]) - SectionData.fromstring(Ui.encode("utf_16_le")) - SectionData.append(0) - SectionData.append(0) - Len =3D len(SectionData) - GenFdsGlobalVariable.SectionHeader.pack_into(SectionData, 0, L= en & 0xff, (Len >> 8) & 0xff, (Len >> 16) & 0xff, 0x15) - SaveFileOnChange(Output, SectionData.tostring()) + if IsMakefile: + Cmd +=3D ["-n", "$(MODULE_NAME)"] + Cmd +=3D ["-o", Output] + #SaveFileOnChange(CommandFile, ' '.join(Cmd), False) + if ' '.join(Cmd).strip() not in GenFdsGlobalVariable.SecCm= dList: + GenFdsGlobalVariable.SecCmdList.append(' '.join(Cmd).s= trip()) + else: + SectionData =3D array.array('B', [0, 0, 0, 0]) + SectionData.fromstring(Ui.encode("utf_16_le")) + SectionData.append(0) + SectionData.append(0) + Len =3D len(SectionData) + GenFdsGlobalVariable.SectionHeader.pack_into(SectionData, = 0, Len & 0xff, (Len >> 8) & 0xff, (Len >> 16) & 0xff, 0x15) + SaveFileOnChange(Output, SectionData.tostring()) + elif Ver not in [None, '']: Cmd +=3D ["-n", Ver] if BuildNumber: Cmd +=3D ["-j", BuildNumber] Cmd +=3D ["-o", Output] =20 SaveFileOnChange(CommandFile, ' '.join(Cmd), False) - if not GenFdsGlobalVariable.NeedsUpdate(Output, list(Input) + = [CommandFile]): - return - - GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate= section") + if IsMakefile: + if ' '.join(Cmd).strip() not in GenFdsGlobalVariable.SecCm= dList: + GenFdsGlobalVariable.SecCmdList.append(' '.join(Cmd).s= trip()) + else: + if not GenFdsGlobalVariable.NeedsUpdate(Output, list(Input= ) + [CommandFile]): + return + GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to gene= rate section") else: Cmd +=3D ["-o", Output] Cmd +=3D Input =20 SaveFileOnChange(CommandFile, ' '.join(Cmd), False) - if GenFdsGlobalVariable.NeedsUpdate(Output, list(Input) + [Com= mandFile]): + if IsMakefile: + if ' '.join(Cmd).strip() not in GenFdsGlobalVariable.SecCm= dList: + GenFdsGlobalVariable.SecCmdList.append(' '.join(Cmd).s= trip()) + elif GenFdsGlobalVariable.NeedsUpdate(Output, list(Input)): GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s ne= eds update because of newer %s" % (Output, Input)) GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to gene= rate section") - - if (os.path.getsize(Output) >=3D GenFdsGlobalVariable.LARGE_FI= LE_SIZE and - GenFdsGlobalVariable.LargeFileInFvFlags): - GenFdsGlobalVariable.LargeFileInFvFlags[-1] =3D True=20 + if (os.path.getsize(Output) >=3D GenFdsGlobalVariable.LARG= E_FILE_SIZE and + GenFdsGlobalVariable.LargeFileInFvFlags): + GenFdsGlobalVariable.LargeFileInFvFlags[-1] =3D True =20 @staticmethod def GetAlignment (AlignString): if AlignString =3D=3D None: return 0 @@ -427,11 +512,11 @@ class GenFdsGlobalVariable: else: return int (AlignString) =20 @staticmethod def GenerateFfs(Output, Input, Type, Guid, Fixed=3DFalse, CheckSum=3DF= alse, Align=3DNone, - SectionAlign=3DNone): + SectionAlign=3DNone, MakefilePath=3DNone): Cmd =3D ["GenFfs", "-t", Type, "-g", Guid] mFfsValidAlign =3D ["0", "8", "16", "128", "512", "1K", "4K", "32K= ", "64K", "128K", "256K", "512K", "1M", "2M", "4M", "8M", "16M"] if Fixed =3D=3D True: Cmd +=3D ["-x"] if CheckSum: @@ -451,15 +536,21 @@ class GenFdsGlobalVariable: if SectionAlign not in [None, '', []] and SectionAlign[I] not = in [None, '']: Cmd +=3D ("-n", SectionAlign[I]) =20 CommandFile =3D Output + '.txt' SaveFileOnChange(CommandFile, ' '.join(Cmd), False) - if not GenFdsGlobalVariable.NeedsUpdate(Output, list(Input) + [Com= mandFile]): - return - GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs upda= te because of newer %s" % (Output, Input)) =20 - GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate FFS= ") + GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs upda= te because of newer %s" % (Output, Input)) + if MakefilePath: + if (tuple(Cmd),tuple(GenFdsGlobalVariable.SecCmdList),tuple(Ge= nFdsGlobalVariable.CopyList)) not in GenFdsGlobalVariable.FfsCmdDict.keys(): + GenFdsGlobalVariable.FfsCmdDict[tuple(Cmd), tuple(GenFdsGl= obalVariable.SecCmdList), tuple(GenFdsGlobalVariable.CopyList)] =3D Makefil= ePath + GenFdsGlobalVariable.SecCmdList =3D [] + GenFdsGlobalVariable.CopyList =3D [] + else: + if not GenFdsGlobalVariable.NeedsUpdate(Output, list(Input)): + return + GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate= FFS") =20 @staticmethod def GenerateFirmwareVolume(Output, Input, BaseAddress=3DNone, ForceReb= ase=3DNone, Capsule=3DFalse, Dump=3DFalse, AddressFile=3DNone, MapFile=3DNone, FfsList= =3D[], FileSystemGuid=3DNone): if not GenFdsGlobalVariable.NeedsUpdate(Output, Input+FfsList): @@ -509,12 +600,12 @@ class GenFdsGlobalVariable: GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate VTF= ") =20 @staticmethod def GenerateFirmwareImage(Output, Input, Type=3D"efi", SubType=3DNone,= Zero=3DFalse, Strip=3DFalse, Replace=3DFalse, TimeStamp=3D= None, Join=3DFalse, - Align=3DNone, Padding=3DNone, Convert=3DFals= e): - if not GenFdsGlobalVariable.NeedsUpdate(Output, Input): + Align=3DNone, Padding=3DNone, Convert=3DFals= e, IsMakefile=3DFalse): + if not GenFdsGlobalVariable.NeedsUpdate(Output, Input) and not IsM= akefile: return GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs upda= te because of newer %s" % (Output, Input)) =20 Cmd =3D ["GenFw"] if Type.lower() =3D=3D "te": @@ -537,16 +628,19 @@ class GenFdsGlobalVariable: Cmd +=3D ["-j"] if Convert: Cmd +=3D ["-m"] Cmd +=3D ["-o", Output] Cmd +=3D Input - - GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate fir= mware image") + if IsMakefile: + if " ".join(Cmd).strip() not in GenFdsGlobalVariable.SecCmdLis= t: + GenFdsGlobalVariable.SecCmdList.append(" ".join(Cmd).strip= ()) + else: + GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate= firmware image") =20 @staticmethod def GenerateOptionRom(Output, EfiInput, BinaryInput, Compress=3DFalse,= ClassCode=3DNone, - Revision=3DNone, DeviceId=3DNone, VendorId=3DNone): + Revision=3DNone, DeviceId=3DNone, VendorId=3DNone,= IsMakefile=3DFalse): InputList =3D [] =20 Cmd =3D ["EfiRom"] if len(EfiInput) > 0: =20 if Compress: @@ -563,11 +657,11 @@ class GenFdsGlobalVariable: for BinFile in BinaryInput: Cmd +=3D [BinFile] InputList.append (BinFile) =20 # Check List - if not GenFdsGlobalVariable.NeedsUpdate(Output, InputList): + if not GenFdsGlobalVariable.NeedsUpdate(Output, InputList) and not= IsMakefile: return GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs upda= te because of newer %s" % (Output, InputList)) =20 if ClassCode !=3D None: Cmd +=3D ["-l", ClassCode] @@ -577,24 +671,31 @@ class GenFdsGlobalVariable: Cmd +=3D ["-i", DeviceId] if VendorId !=3D None: Cmd +=3D ["-f", VendorId] =20 Cmd +=3D ["-o", Output] - GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate opt= ion rom") + if IsMakefile: + if " ".join(Cmd).strip() not in GenFdsGlobalVariable.SecCmdLis= t: + GenFdsGlobalVariable.SecCmdList.append(" ".join(Cmd).strip= ()) + else: + GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate= option rom") =20 @staticmethod - def GuidTool(Output, Input, ToolPath, Options=3D'', returnValue=3D[]): - if not GenFdsGlobalVariable.NeedsUpdate(Output, Input): + def GuidTool(Output, Input, ToolPath, Options=3D'', returnValue=3D[], = IsMakefile=3DFalse): + if not GenFdsGlobalVariable.NeedsUpdate(Output, Input) and not IsM= akefile: return GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs upda= te because of newer %s" % (Output, Input)) =20 Cmd =3D [ToolPath, ] Cmd +=3D Options.split(' ') Cmd +=3D ["-o", Output] Cmd +=3D Input - - GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to call " + Too= lPath, returnValue) + if IsMakefile: + if " ".join(Cmd).strip() not in GenFdsGlobalVariable.SecCmdLis= t: + GenFdsGlobalVariable.SecCmdList.append(" ".join(Cmd).strip= ()) + else: + GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to call " += ToolPath, returnValue) =20 def CallExternalTool (cmd, errorMess, returnValue=3D[]): =20 if type(cmd) not in (tuple, list): GenFdsGlobalVariable.ErrorLogger("ToolError! Invalid paramete= r type in call to CallExternalTool") @@ -725,10 +826,11 @@ class GenFdsGlobalVariable: return PcdValue =20 return PcdValue =20 SetDir =3D staticmethod(SetDir) + SetEnv =3D staticmethod(SetEnv) ReplaceWorkspaceMacro =3D staticmethod(ReplaceWorkspaceMacro) CallExternalTool =3D staticmethod(CallExternalTool) VerboseLogger =3D staticmethod(VerboseLogger) InfLogger =3D staticmethod(InfLogger) ErrorLogger =3D staticmethod(ErrorLogger) diff --git a/BaseTools/Source/Python/GenFds/GuidSection.py b/BaseTools/Sour= ce/Python/GenFds/GuidSection.py index f199dcd..4eb149a 100644 --- a/BaseTools/Source/Python/GenFds/GuidSection.py +++ b/BaseTools/Source/Python/GenFds/GuidSection.py @@ -1,9 +1,9 @@ ## @file # process GUIDed section generation # -# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the B= SD License # which accompanies this distribution. The full text of the license may = be found at # http://opensource.org/licenses/bsd-license.php @@ -52,11 +52,11 @@ class GuidSection(GuidSectionClassObject) : # @param KeyStringList Filter for inputs of section generation # @param FfsInf FfsInfStatement object that contains this sect= ion data # @param Dict dictionary contains macro and its value # @retval tuple (Generated file name, section alignment) # - def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, Ff= sInf=3DNone, Dict=3D{}): + def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, Ff= sInf=3DNone, Dict=3D{}, IsMakefile=3DFalse): # # Generate all section # self.KeyStringList =3D KeyStringList self.CurrentArchList =3D GenFdsGlobalVariable.ArchList @@ -92,11 +92,11 @@ class GuidSection(GuidSectionClassObject) : Sect.FvAddr =3D self.FvAddr.pop(0) self.IncludeFvSection =3D True elif isinstance(Sect, GuidSection): Sect.FvAddr =3D self.FvAddr Sect.FvParentAddr =3D self.FvParentAddr - ReturnSectList, align =3D Sect.GenSection(OutputPath, ModuleNa= me, SecIndex, KeyStringList, FfsInf, Dict) + ReturnSectList, align =3D Sect.GenSection(OutputPath, ModuleNa= me, SecIndex, KeyStringList, FfsInf, Dict, IsMakefile=3DIsMakefile) if isinstance(Sect, GuidSection): if Sect.IncludeFvSection: self.IncludeFvSection =3D Sect.IncludeFvSection =20 if align !=3D None: @@ -135,11 +135,11 @@ class GuidSection(GuidSectionClassObject) : # If not have GUID , call default # GENCRC32 section # if self.NameGuid =3D=3D None : GenFdsGlobalVariable.VerboseLogger("Use GenSection function Ge= nerate CRC32 Section") - GenFdsGlobalVariable.GenerateSection(OutputFile, SectFile, Sec= tion.Section.SectionType[self.SectionType], InputAlign=3DSectAlign) + GenFdsGlobalVariable.GenerateSection(OutputFile, SectFile, Sec= tion.Section.SectionType[self.SectionType], InputAlign=3DSectAlign, IsMakef= ile=3DIsMakefile) OutputFileList =3D [] OutputFileList.append(OutputFile) return OutputFileList, self.Alignment #or GUID not in External Tool List elif ExternalTool =3D=3D None: @@ -147,11 +147,11 @@ class GuidSection(GuidSectionClassObject) : else: DummyFile =3D OutputFile + ".dummy" # # Call GenSection with DUMMY section type. # - GenFdsGlobalVariable.GenerateSection(DummyFile, SectFile, Inpu= tAlign=3DSectAlign) + GenFdsGlobalVariable.GenerateSection(DummyFile, SectFile, Inpu= tAlign=3DSectAlign, IsMakefile=3DIsMakefile) # # Use external tool process the Output # TempFile =3D OutputPath + \ os.sep + \ @@ -170,79 +170,36 @@ class GuidSection(GuidSectionClassObject) : =20 FirstCall =3D False CmdOption =3D '-e' if ExternalOption !=3D None: CmdOption =3D CmdOption + ' ' + ExternalOption - if self.ProcessRequired not in ("TRUE", "1") and self.IncludeF= vSection and not FvAddrIsSet and self.FvParentAddr !=3D None: - #FirstCall is only set for the encapsulated flash FV image= without process required attribute. - FirstCall =3D True - # - # Call external tool - # - ReturnValue =3D [1] - if FirstCall: - #first try to call the guided tool with -z option and CmdO= ption for the no process required guided tool. - GenFdsGlobalVariable.GuidTool(TempFile, [DummyFile], Exter= nalTool, '-z' + ' ' + CmdOption, ReturnValue) =20 - # - # when no call or first call failed, ReturnValue are not 1. - # Call the guided tool with CmdOption - # - if ReturnValue[0] !=3D 0: - FirstCall =3D False - ReturnValue[0] =3D 0 - GenFdsGlobalVariable.GuidTool(TempFile, [DummyFile], Exter= nalTool, CmdOption) + GenFdsGlobalVariable.GuidTool(TempFile, [DummyFile], ExternalT= ool, CmdOption, IsMakefile=3DIsMakefile) # # There is external tool which does not follow standard rule w= hich return nonzero if tool fails # The output file has to be checked # - if not os.path.exists(TempFile): + if not IsMakefile and not os.path.exists(TempFile): EdkLogger.error("GenFds", COMMAND_FAILURE, 'Fail to call %= s, no output file was generated' % ExternalTool) =20 - FileHandleIn =3D open(DummyFile, 'rb') - FileHandleIn.seek(0, 2) - InputFileSize =3D FileHandleIn.tell() - - FileHandleOut =3D open(TempFile, 'rb') - FileHandleOut.seek(0, 2) - TempFileSize =3D FileHandleOut.tell() =20 Attribute =3D [] HeaderLength =3D None if self.ExtraHeaderSize !=3D -1: HeaderLength =3D str(self.ExtraHeaderSize) =20 - if self.ProcessRequired =3D=3D "NONE" and HeaderLength =3D=3D = None: - if TempFileSize > InputFileSize: - FileHandleIn.seek(0) - BufferIn =3D FileHandleIn.read() - FileHandleOut.seek(0) - BufferOut =3D FileHandleOut.read() - if BufferIn =3D=3D BufferOut[TempFileSize - InputFileS= ize:]: - HeaderLength =3D str(TempFileSize - InputFileSize) - #auto sec guided attribute with process required - if HeaderLength =3D=3D None: - Attribute.append('PROCESSING_REQUIRED') - - FileHandleIn.close() - FileHandleOut.close() - - if FirstCall and 'PROCESSING_REQUIRED' in Attribute: - # Guided data by -z option on first call is the process re= quired data. Call the guided tool with the real option. - GenFdsGlobalVariable.GuidTool(TempFile, [DummyFile], Exter= nalTool, CmdOption) - # # Call Gensection Add Section Header # if self.ProcessRequired in ("TRUE", "1"): if 'PROCESSING_REQUIRED' not in Attribute: Attribute.append('PROCESSING_REQUIRED') =20 if self.AuthStatusValid in ("TRUE", "1"): Attribute.append('AUTH_STATUS_VALID') GenFdsGlobalVariable.GenerateSection(OutputFile, [TempFile], S= ection.Section.SectionType['GUIDED'], - Guid=3Dself.NameGuid, Gui= dAttr=3DAttribute, GuidHdrLen=3DHeaderLength) + Guid=3Dself.NameGuid, Gui= dAttr=3DAttribute, GuidHdrLen=3DHeaderLength, IsMakefile=3DIsMakefile) OutputFileList =3D [] OutputFileList.append(OutputFile) if 'PROCESSING_REQUIRED' in Attribute: # reset guided section alignment to none for the processed= required guided data self.Alignment =3D None diff --git a/BaseTools/Source/Python/GenFds/OptRomFileStatement.py b/BaseTo= ols/Source/Python/GenFds/OptRomFileStatement.py index 5e3273d..ab4fae6 100644 --- a/BaseTools/Source/Python/GenFds/OptRomFileStatement.py +++ b/BaseTools/Source/Python/GenFds/OptRomFileStatement.py @@ -1,9 +1,9 @@ ## @file # process OptionROM generation from FILE statement # -# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the B= SD License # which accompanies this distribution. The full text of the license may = be found at # http://opensource.org/licenses/bsd-license.php @@ -37,11 +37,11 @@ class OptRomFileStatement: # # @param self The object pointer # @param Dict dictionary contains macro and value pair # @retval string Generated FFS file name # - def GenFfs(self, Dict =3D {}): + def GenFfs(self, Dict =3D {}, IsMakefile=3DFalse): =20 if self.FileName !=3D None: self.FileName =3D GenFdsGlobalVariable.ReplaceWorkspaceMacro(s= elf.FileName) =20 return self.FileName diff --git a/BaseTools/Source/Python/GenFds/OptRomInfStatement.py b/BaseToo= ls/Source/Python/GenFds/OptRomInfStatement.py index 069414d..80c4bba 100644 --- a/BaseTools/Source/Python/GenFds/OptRomInfStatement.py +++ b/BaseTools/Source/Python/GenFds/OptRomInfStatement.py @@ -1,9 +1,9 @@ ## @file # process OptionROM generation from INF statement # -# Copyright (c) 2007, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the B= SD License # which accompanies this distribution. The full text of the license may = be found at # http://opensource.org/licenses/bsd-license.php @@ -79,11 +79,11 @@ class OptRomInfStatement (FfsInfStatement): # Generate FFS # # @param self The object pointer # @retval string Generated .efi file name # - def GenFfs(self): + def GenFfs(self, IsMakefile=3DFalse): # # Parse Inf file get Module related information # =20 self.__InfParse__() @@ -96,28 +96,28 @@ class OptRomInfStatement (FfsInfStatement): #FileType =3D Ffs.Ffs.ModuleTypeToFileType[Rule.ModuleType] # # For the rule only has simpleFile # if isinstance (Rule, RuleSimpleFile.RuleSimpleFile) : - EfiOutputList =3D self.__GenSimpleFileSection__(Rule) + EfiOutputList =3D self.__GenSimpleFileSection__(Rule, IsMakefi= le=3DIsMakefile) return EfiOutputList # # For Rule has ComplexFile # elif isinstance(Rule, RuleComplexFile.RuleComplexFile): - EfiOutputList =3D self.__GenComplexFileSection__(Rule) + EfiOutputList =3D self.__GenComplexFileSection__(Rule, IsMakef= ile=3DIsMakefile) return EfiOutputList =20 ## __GenSimpleFileSection__() method # # Get .efi files according to simple rule. # # @param self The object pointer # @param Rule The rule object used to generate section # @retval string File name of the generated section file # - def __GenSimpleFileSection__(self, Rule): + def __GenSimpleFileSection__(self, Rule, IsMakefile =3D False): # # Prepare the parameter of GenSection # =20 OutputFileList =3D [] @@ -136,11 +136,11 @@ class OptRomInfStatement (FfsInfStatement): # # @param self The object pointer # @param Rule The rule object used to generate section # @retval string File name of the generated section file # - def __GenComplexFileSection__(self, Rule): + def __GenComplexFileSection__(self, Rule, IsMakefile=3DFalse): =20 OutputFileList =3D [] for Sect in Rule.SectionList: if Sect.SectionType =3D=3D 'PE32': if Sect.FileName !=3D None: diff --git a/BaseTools/Source/Python/GenFds/OptionRom.py b/BaseTools/Source= /Python/GenFds/OptionRom.py index 7886a7c..2e61a38 100644 --- a/BaseTools/Source/Python/GenFds/OptionRom.py +++ b/BaseTools/Source/Python/GenFds/OptionRom.py @@ -1,9 +1,9 @@ ## @file # process OptionROM generation # -# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the B= SD License # which accompanies this distribution. The full text of the license may = be found at # http://opensource.org/licenses/bsd-license.php @@ -47,22 +47,22 @@ class OPTIONROM (OptionRomClassObject): # # @param self The object pointer # @param Buffer The buffer generated OptROM data will be put # @retval string Generated OptROM file path # - def AddToBuffer (self, Buffer) : - - GenFdsGlobalVariable.InfLogger( "\nGenerating %s Option ROM ..." %= self.DriverName) + def AddToBuffer (self, Buffer, Flag=3DFalse) : + if not Flag: + GenFdsGlobalVariable.InfLogger( "\nGenerating %s Option ROM ..= ." %self.DriverName) =20 EfiFileList =3D [] BinFileList =3D [] =20 # Process Modules in FfsList for FfsFile in self.FfsList : =20 if isinstance(FfsFile, OptRomInfStatement.OptRomInfStatement): - FilePathNameList =3D FfsFile.GenFfs() + FilePathNameList =3D FfsFile.GenFfs(IsMakefile=3DFlag) if len(FilePathNameList) =3D=3D 0: EdkLogger.error("GenFds", GENFDS_ERROR, "Module %s not= produce .efi files, so NO file could be put into option ROM." % (FfsFile.I= nfFileName)) if FfsFile.OverrideAttribs =3D=3D None: EfiFileList.extend(FilePathNameList) else: @@ -77,14 +77,15 @@ class OPTIONROM (OptionRomClassObject): [],=20 FfsFile.Overrid= eAttribs.NeedCompress,=20 FfsFile.Overrid= eAttribs.PciClassCode,=20 FfsFile.Overrid= eAttribs.PciRevision,=20 FfsFile.Overrid= eAttribs.PciDeviceId,=20 - FfsFile.Overrid= eAttribs.PciVendorId) + FfsFile.Overrid= eAttribs.PciVendorId, + IsMakefile =3D = Flag) BinFileList.append(TmpOutputFile) else: - FilePathName =3D FfsFile.GenFfs() + FilePathName =3D FfsFile.GenFfs(IsMakefile=3DFlag) if FfsFile.OverrideAttribs !=3D None: FileName =3D os.path.basename(FilePathName) TmpOutputDir =3D os.path.join(GenFdsGlobalVariable.FvD= ir, self.DriverName, FfsFile.CurrentArch) if not os.path.exists(TmpOutputDir) : os.makedirs(TmpOutputDir) @@ -95,11 +96,12 @@ class OPTIONROM (OptionRomClassObject): [],=20 FfsFile.Overrid= eAttribs.NeedCompress,=20 FfsFile.Overrid= eAttribs.PciClassCode,=20 FfsFile.Overrid= eAttribs.PciRevision,=20 FfsFile.Overrid= eAttribs.PciDeviceId,=20 - FfsFile.Overrid= eAttribs.PciVendorId) + FfsFile.Overrid= eAttribs.PciVendorId, + IsMakefile=3DFl= ag) BinFileList.append(TmpOutputFile) else: if FfsFile.FileType =3D=3D 'EFI': EfiFileList.append(FilePathName) else: @@ -112,14 +114,15 @@ class OPTIONROM (OptionRomClassObject): OutputFile =3D OutputFile + '.rom' =20 GenFdsGlobalVariable.GenerateOptionRom( OutputFile, EfiFileList, - BinFileList - ) + BinFileList, + IsMakefile=3DFlag) =20 - GenFdsGlobalVariable.InfLogger( "\nGenerate %s Option ROM Successf= ully" %self.DriverName) + if not Flag: + GenFdsGlobalVariable.InfLogger( "\nGenerate %s Option ROM Succ= essfully" %self.DriverName) GenFdsGlobalVariable.SharpCounter =3D 0 =20 return OutputFile =20 class OverrideAttribs: diff --git a/BaseTools/Source/Python/GenFds/Region.py b/BaseTools/Source/Py= thon/GenFds/Region.py index 945c548..c946758 100644 --- a/BaseTools/Source/Python/GenFds/Region.py +++ b/BaseTools/Source/Python/GenFds/Region.py @@ -1,9 +1,9 @@ ## @file # process FD Region generation # -# Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the B= SD License # which accompanies this distribution. The full text of the license may = be found at # http://opensource.org/licenses/bsd-license.php @@ -72,15 +72,18 @@ class Region(RegionClassObject): # @param VtfDict VTF objects # @param MacroDict macro value pair # @retval string Generated FV file path # =20 - def AddToBuffer(self, Buffer, BaseAddress, BlockSizeList, ErasePolarit= y, ImageBinDict, vtfDict=3DNone, MacroDict=3D{}): + def AddToBuffer(self, Buffer, BaseAddress, BlockSizeList, ErasePolarit= y, ImageBinDict, vtfDict=3DNone, MacroDict=3D{}, Flag=3DFalse): Size =3D self.Size - GenFdsGlobalVariable.InfLogger('\nGenerate Region at Offset 0x%X' = % self.Offset) - GenFdsGlobalVariable.InfLogger(" Region Size =3D 0x%X" % Size) + if not Flag: + GenFdsGlobalVariable.InfLogger('\nGenerate Region at Offset 0x= %X' % self.Offset) + GenFdsGlobalVariable.InfLogger(" Region Size =3D 0x%X" % Siz= e) GenFdsGlobalVariable.SharpCounter =3D 0 + if Flag and (self.RegionType !=3D 'FV'): + return =20 if self.RegionType =3D=3D 'FV': # # Get Fv from FvDict # @@ -89,30 +92,33 @@ class Region(RegionClassObject): FvOffset =3D 0 for RegionData in self.RegionDataList: FileName =3D None if RegionData.endswith(".fv"): RegionData =3D GenFdsGlobalVariable.MacroExtend(Region= Data, MacroDict) - GenFdsGlobalVariable.InfLogger(' Region FV File Name= =3D .fv : %s' % RegionData) + if not Flag: + GenFdsGlobalVariable.InfLogger(' Region FV File = Name =3D .fv : %s' % RegionData) if RegionData[1] !=3D ':' : RegionData =3D mws.join (GenFdsGlobalVariable.Work= SpaceDir, RegionData) if not os.path.exists(RegionData): EdkLogger.error("GenFds", FILE_NOT_FOUND, ExtraDat= a=3DRegionData) =20 FileName =3D RegionData elif RegionData.upper() + 'fv' in ImageBinDict.keys(): - GenFdsGlobalVariable.InfLogger(' Region Name =3D FV') + if not Flag: + GenFdsGlobalVariable.InfLogger(' Region Name =3D= FV') FileName =3D ImageBinDict[RegionData.upper() + 'fv'] else: # # Generate FvImage. # FvObj =3D None if RegionData.upper() in GenFdsGlobalVariable.FdfParse= r.Profile.FvDict.keys(): FvObj =3D GenFdsGlobalVariable.FdfParser.Profile.F= vDict.get(RegionData.upper()) =20 if FvObj !=3D None : - GenFdsGlobalVariable.InfLogger(' Region Name =3D= FV') + if not Flag: + GenFdsGlobalVariable.InfLogger(' Region Name= =3D FV') # # Call GenFv tool # self.BlockInfoOfRegion(BlockSizeList, FvObj) self.FvAddress =3D self.FvAddress + FvOffset @@ -122,11 +128,14 @@ class Region(RegionClassObject): "FV (%s) is NOT %s Aligned!" %= (FvObj.UiFvName, FvObj.FvAlignment)) FvBuffer =3D StringIO.StringIO('') FvBaseAddress =3D '0x%X' % self.FvAddress BlockSize =3D None BlockNum =3D None - FvObj.AddToBuffer(FvBuffer, FvBaseAddress, BlockSi= ze, BlockNum, ErasePolarity, vtfDict) + FvObj.AddToBuffer(FvBuffer, FvBaseAddress, BlockSi= ze, BlockNum, ErasePolarity, vtfDict, Flag=3DFlag) + if Flag: + continue + if FvBuffer.len > Size: FvBuffer.close() EdkLogger.error("GenFds", GENFDS_ERROR, "Size of FV (%s) is larger tha= n Region Size 0x%X specified." % (RegionData, Size)) # @@ -140,24 +149,26 @@ class Region(RegionClassObject): else: EdkLogger.error("GenFds", GENFDS_ERROR, "FV (%s) i= s NOT described in FDF file!" % (RegionData)) # # Add the exist Fv image into FD buffer # - if FileName !=3D None: - FileLength =3D os.stat(FileName)[ST_SIZE] - if FileLength > Size: - EdkLogger.error("GenFds", GENFDS_ERROR, - "Size of FV File (%s) is larger th= an Region Size 0x%X specified." \ - % (RegionData, Size)) - BinFile =3D open(FileName, 'rb') - Buffer.write(BinFile.read()) - BinFile.close() - Size =3D Size - FileLength + if not Flag: + if FileName !=3D None: + FileLength =3D os.stat(FileName)[ST_SIZE] + if FileLength > Size: + EdkLogger.error("GenFds", GENFDS_ERROR, + "Size of FV File (%s) is large= r than Region Size 0x%X specified." \ + % (RegionData, Size)) + BinFile =3D open(FileName, 'rb') + Buffer.write(BinFile.read()) + BinFile.close() + Size =3D Size - FileLength # # Pad the left buffer # - self.PadBuffer(Buffer, ErasePolarity, Size) + if not Flag: + self.PadBuffer(Buffer, ErasePolarity, Size) =20 if self.RegionType =3D=3D 'CAPSULE': # # Get Capsule from Capsule Dict # diff --git a/BaseTools/Source/Python/GenFds/Section.py b/BaseTools/Source/P= ython/GenFds/Section.py index 942dd5c..4c1aaac 100644 --- a/BaseTools/Source/Python/GenFds/Section.py +++ b/BaseTools/Source/Python/GenFds/Section.py @@ -1,9 +1,9 @@ ## @file # section base class # -# Copyright (c) 2007-2015, Intel Corporation. All rights reserved.
+# Copyright (c) 2007-2017, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the B= SD License # which accompanies this distribution. The full text of the license may = be found at # http://opensource.org/licenses/bsd-license.php @@ -139,11 +139,11 @@ class Section (SectionClassObject): else: GenFdsGlobalVariable.VerboseLogger ("\nFile Type \= '%s\' of File %s in %s is not same with file type \'%s\' from Rule in FDF" = %(File.Type, File.File, FfsInf.InfFileName, FileType)) else: GenFdsGlobalVariable.InfLogger ("\nCurrent ARCH \'%s\'= of File %s is not in the Support Arch Scope of %s specified by INF %s in F= DF" %(FfsInf.CurrentArch, File.File, File.Arch, FfsInf.InfFileName)) =20 - if Suffix !=3D None and os.path.exists(FfsInf.EfiOutputPath): + if Suffix !=3D None: # # Get Makefile path and time stamp # MakefileDir =3D FfsInf.EfiOutputPath[:-len('OUTPUT')] Makefile =3D os.path.join(MakefileDir, 'Makefile') diff --git a/BaseTools/Source/Python/GenFds/UiSection.py b/BaseTools/Source= /Python/GenFds/UiSection.py index 419e1ee..4f6926f 100644 --- a/BaseTools/Source/Python/GenFds/UiSection.py +++ b/BaseTools/Source/Python/GenFds/UiSection.py @@ -46,11 +46,11 @@ class UiSection (UiSectionClassObject): # @param KeyStringList Filter for inputs of section generation # @param FfsInf FfsInfStatement object that contains this sect= ion data # @param Dict dictionary contains macro and its value # @retval tuple (Generated file name, section alignment) # - def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, Ff= sInf=3DNone, Dict=3D{}): + def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, Ff= sInf=3DNone, Dict=3D{}, IsMakefile =3D False): # # Prepare the parameter of GenSection # if FfsInf !=3D None: self.Alignment =3D FfsInf.__ExtendMacro__(self.Alignment) @@ -67,11 +67,10 @@ class UiSection (UiSectionClassObject): FileObj =3D open(FileNameStr, 'r') NameString =3D FileObj.read() FileObj.close() else: NameString =3D '' - - GenFdsGlobalVariable.GenerateSection(OutputFile, None, 'EFI_SECTIO= N_USER_INTERFACE', Ui=3DNameString) + GenFdsGlobalVariable.GenerateSection(OutputFile, None, 'EFI_SECTIO= N_USER_INTERFACE', Ui=3DNameString, IsMakefile=3DIsMakefile) =20 OutputFileList =3D [] OutputFileList.append(OutputFile) return OutputFileList, self.Alignment diff --git a/BaseTools/Source/Python/GenFds/VerSection.py b/BaseTools/Sourc= e/Python/GenFds/VerSection.py index ad995d3..e290299 100644 --- a/BaseTools/Source/Python/GenFds/VerSection.py +++ b/BaseTools/Source/Python/GenFds/VerSection.py @@ -1,9 +1,9 @@ ## @file # process Version section generation # -# Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the B= SD License # which accompanies this distribution. The full text of the license may = be found at # http://opensource.org/licenses/bsd-license.php @@ -46,11 +46,11 @@ class VerSection (VerSectionClassObject): # @param KeyStringList Filter for inputs of section generation # @param FfsInf FfsInfStatement object that contains this sect= ion data # @param Dict dictionary contains macro and its value # @retval tuple (Generated file name, section alignment) # - def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, Ff= sInf=3DNone, Dict=3D{}): + def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, Ff= sInf=3DNone, Dict=3D{}, IsMakefile =3D False): # # Prepare the parameter of GenSection # if FfsInf !=3D None: self.Alignment =3D FfsInf.__ExtendMacro__(self.Alignment) @@ -63,21 +63,20 @@ class VerSection (VerSectionClassObject): OutputFile =3D os.path.normpath(OutputFile) =20 # Get String Data StringData =3D '' if self.StringData !=3D None: - StringData =3D self.StringData + StringData =3D self.StringData elif self.FileName !=3D None: FileNameStr =3D GenFdsGlobalVariable.ReplaceWorkspaceMacro(sel= f.FileName) FileNameStr =3D GenFdsGlobalVariable.MacroExtend(FileNameStr, = Dict) FileObj =3D open(FileNameStr, 'r') StringData =3D FileObj.read() StringData =3D '"' + StringData + '"' FileObj.close() else: StringData =3D '' - GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_= VERSION', - Ver=3DStringData, BuildNumber= =3Dself.BuildNum) + Ver=3DStringData, BuildNumber= =3Dself.BuildNum, IsMakefile=3DIsMakefile) OutputFileList =3D [] OutputFileList.append(OutputFile) return OutputFileList, self.Alignment diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Pyth= on/build/build.py index 13d8e50..cb6c732 100644 --- a/BaseTools/Source/Python/build/build.py +++ b/BaseTools/Source/Python/build/build.py @@ -48,10 +48,11 @@ from BuildReport import BuildReport from GenPatchPcdTable.GenPatchPcdTable import * from PatchPcdValue.PatchPcdValue import * =20 import Common.EdkLogger import Common.GlobalData as GlobalData +from GenFds.GenFds import GenFds =20 # Version and Copyright VersionNumber =3D "0.60" + ' ' + gBUILD_VERSION __version__ =3D "%prog Version " + VersionNumber __copyright__ =3D "Copyright (c) 2007 - 2017, Intel Corporation All right= s reserved." @@ -1960,10 +1961,21 @@ class Build(): self.Fdf =3D Wa.FdfFile self.LoadFixAddress =3D Wa.Platform.LoadFixAddress self.BuildReport.AddPlatformReport(Wa) Wa.CreateMakeFile(False) =20 + # Add ffs build to makefile + CmdListDict =3D {} + if self.Fdf: + GenFfsDict =3D GenFds.GenFfsMakefile('', GlobalData.gF= dfParser, self.Db, self.ArchList, GlobalData) + for Cmd in GenFfsDict: + tmpInf, tmpArch =3D GenFfsDict[Cmd] + if (tmpInf, tmpArch) not in CmdListDict.keys(): + CmdListDict[tmpInf, tmpArch] =3D [Cmd] + else: + CmdListDict[tmpInf, tmpArch].append(Cmd) + # multi-thread exit flag ExitFlag =3D threading.Event() ExitFlag.clear() self.AutoGenTime +=3D int(round((time.time() - WorkspaceAu= toGenTime))) for Arch in Wa.ArchList: @@ -1998,11 +2010,15 @@ class Build(): Ma.CreateCodeFile(True) if self.Target =3D=3D "genc": continue =20 if not self.SkipAutoGen or self.Target =3D=3D = 'genmake': - Ma.CreateMakeFile(True) + if CmdListDict and self.Fdf and (Module.Fi= le, Arch) in CmdListDict: + Ma.CreateMakeFile(True, CmdListDict[Mo= dule.File, Arch]) + del CmdListDict[Module.File, Arch] + else: + Ma.CreateMakeFile(True) if self.Target =3D=3D "genmake": continue self.BuildModules.append(Ma) self.Progress.Stop("done!") self.AutoGenTime +=3D int(round((time.time() - AutoGen= Start))) --=20 2.6.1.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel