From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (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 A32D91A1E31 for ; Wed, 5 Oct 2016 16:46:52 -0700 (PDT) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga105.jf.intel.com with ESMTP; 05 Oct 2016 16:46:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,451,1473145200"; d="scan'208";a="16631718" Received: from mdkinney-mobl.amr.corp.intel.com ([10.232.96.21]) by fmsmga006.fm.intel.com with ESMTP; 05 Oct 2016 16:46:52 -0700 From: Michael Kinney To: edk2-devel@lists.01.org Cc: Kelly Steele , Yonghong Zhu , Liming Gao Date: Wed, 5 Oct 2016 16:46:49 -0700 Message-Id: <1475711209-10200-1-git-send-email-michael.d.kinney@intel.com> X-Mailer: git-send-email 2.6.3.windows.1 Subject: [Patch] BaseTools/GenFds: Support FMP Payload files generated during build X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Oct 2016 23:46:52 -0000 https://bugzilla.tianocore.org/show_bug.cgi?id=132 This patch allows FILE DATA statements in [FmpPayload] sections to refer to a file that does not exist at the time the FDF file is parsed. There are cases where these FILE DATA statements refer to FD or FV images that are generated as part of the build and those FD or FV image files are not present when FDF file is parsed. These files are required to be present when the FMP Payload is generated. Skip the file present verification step for FILE DATA statements in [FmpPayload] sections if the file path referenced is in the $(OUTPUT_DIRECTORY). Perform this verification step when the FMP Payload is generated. Cc: Kelly Steele Cc: Yonghong Zhu Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Michael Kinney --- BaseTools/Source/Python/GenFds/Capsule.py | 8 ++++++ BaseTools/Source/Python/GenFds/CapsuleData.py | 9 +++++++ BaseTools/Source/Python/GenFds/FdfParser.py | 38 ++++++++++++++++++--------- 3 files changed, 43 insertions(+), 12 deletions(-) diff --git a/BaseTools/Source/Python/GenFds/Capsule.py b/BaseTools/Source/Python/GenFds/Capsule.py index c98c054..31c414f 100644 --- a/BaseTools/Source/Python/GenFds/Capsule.py +++ b/BaseTools/Source/Python/GenFds/Capsule.py @@ -28,6 +28,8 @@ from struct import pack from GenFds import FindExtendTool from Common import EdkLogger from Common.BuildToolError import * +from Common.Misc import PathClass +from Common.String import NormPath T_CHAR_LF = '\n' @@ -142,6 +144,12 @@ class Capsule (CapsuleClassObject) : File.close() for fmp in self.FmpPayloadList: if fmp.Certificate_Guid: + # + # Verify that ImageFile exists + # + ErrorCode, ErrorInfo = PathClass(NormPath(fmp.ImageFile), GenFdsGlobalVariable.WorkSpaceDir).Validate() + if ErrorCode != 0: + EdkLogger.error("GenFds", ErrorCode, ExtraData=ErrorInfo) ExternalTool, ExternalOption = FindExtendTool([], GenFdsGlobalVariable.ArchList, fmp.Certificate_Guid) CmdOption = '' CapInputFile = fmp.ImageFile diff --git a/BaseTools/Source/Python/GenFds/CapsuleData.py b/BaseTools/Source/Python/GenFds/CapsuleData.py index 07cc198..7cbe351 100644 --- a/BaseTools/Source/Python/GenFds/CapsuleData.py +++ b/BaseTools/Source/Python/GenFds/CapsuleData.py @@ -22,6 +22,9 @@ from struct import pack import os from Common.Misc import SaveFileOnChange import uuid +from Common import EdkLogger +from Common.Misc import PathClass +from Common.String import NormPath ## base class for capsule data # @@ -194,6 +197,12 @@ class CapsulePayload(CapsuleData): ImageFileSize += 32 VendorFileSize = 0 if self.VendorCodeFile: + # + # Verify that VendorCodeFile exists + # + ErrorCode, ErrorInfo = PathClass(NormPath(self.VendorCodeFile), GenFdsGlobalVariable.WorkSpaceDir).Validate() + if ErrorCode != 0: + EdkLogger.error("GenFds", ErrorCode, ExtraData=ErrorInfo) VendorFileSize = os.path.getsize(self.VendorCodeFile) # diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py index 02ae7c9..2038a37 100644 --- a/BaseTools/Source/Python/GenFds/FdfParser.py +++ b/BaseTools/Source/Python/GenFds/FdfParser.py @@ -3037,17 +3037,21 @@ class FdfParser: ## __VerifyFile # # Check if file exists or not: - # If current phase if GenFds, the file must exist; - # If current phase is AutoGen and the file is not in $(OUTPUT_DIRECTORY), the file must exist + # If current phase is AutoGen or FmpPayload is True, and the file is not in $(OUTPUT_DIRECTORY), + # then the file must exist # @param FileName: File path to be verified. + # @param FmpPayload: If True, then FileName is from a raw file statement in an [FmpPayload] section + # and FileName is only required to be present if FileName is not in OUTPUT_DIRECTORY # - def __VerifyFile(self, FileName): + def __VerifyFile(self, FileName, FmpPayload = False): if FileName.replace('$(WORKSPACE)', '').find('$') != -1: return - if not GlobalData.gAutoGenPhase or not self.__GetMacroValue("OUTPUT_DIRECTORY") in FileName: - ErrorCode, ErrorInfo = PathClass(NormPath(FileName), GenFdsGlobalVariable.WorkSpaceDir).Validate() - if ErrorCode != 0: - EdkLogger.error("GenFds", ErrorCode, ExtraData=ErrorInfo) + if GlobalData.gAutoGenPhase or FmpPayload: + if self.__GetMacroValue("OUTPUT_DIRECTORY") in FileName: + return + ErrorCode, ErrorInfo = PathClass(NormPath(FileName), GenFdsGlobalVariable.WorkSpaceDir).Validate() + if ErrorCode != 0: + EdkLogger.error("GenFds", ErrorCode, ExtraData=ErrorInfo) ## __GetCglSection() method # @@ -3259,14 +3263,14 @@ class FdfParser: FmpKeyList.remove('MONOTONIC_COUNT') if FmpKeyList: raise Warning("Missing keywords %s in FMP payload section." % ', '.join(FmpKeyList), self.FileName, self.CurrentLineNumber) - ImageFile = self.__ParseRawFileStatement() + ImageFile = self.__ParseRawFileStatement(FmpPayload = True) if not ImageFile: raise Warning("Missing image file in FMP payload section.", self.FileName, self.CurrentLineNumber) FmpData.ImageFile = ImageFile - VendorCodeFile = self.__ParseRawFileStatement() + VendorCodeFile = self.__ParseRawFileStatement(FmpPayload = True) if VendorCodeFile: FmpData.VendorCodeFile = VendorCodeFile - AdditionalFile = self.__ParseRawFileStatement() + AdditionalFile = self.__ParseRawFileStatement(FmpPayload = True) if AdditionalFile: raise Warning("At most one Image file and one Vendor code file are allowed in FMP payload section.", self.FileName, self.CurrentLineNumber) self.Profile.FmpPayloadDict[FmpUiName] = FmpData @@ -3476,7 +3480,17 @@ class FdfParser: CapsuleObj.FmpPayloadList.append(self.Profile.FmpPayloadDict[Payload]) return True - def __ParseRawFileStatement(self): + ## __ParseRawFileStatement() method + # + # Parse and return the file path from a raw file statement of the form + # + # FILE DATA = + # + # @param self The object pointer + # @param FmpPayload If True, then the raw file statement being parsed + # is from an [FmpPayload] section. + # + def __ParseRawFileStatement(self, FmpPayload = False): if not self.__IsKeyword("FILE"): return None @@ -3491,7 +3505,7 @@ class FdfParser: raise Warning("expected File name", self.FileName, self.CurrentLineNumber) AnyFileName = self.__Token - self.__VerifyFile(AnyFileName) + self.__VerifyFile(AnyFileName, FmpPayload) return AnyFileName -- 2.6.3.windows.1