From nobody Mon Dec 23 11:12:10 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 1518153450003301.64285549832016; Thu, 8 Feb 2018 21:17:30 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id B0B02223DB7B3; Thu, 8 Feb 2018 21:11:42 -0800 (PST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (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 42089223DB78E for ; Thu, 8 Feb 2018 21:11:41 -0800 (PST) Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Feb 2018 21:17:26 -0800 Received: from shwdeopenpsi105.ccr.corp.intel.com ([10.239.9.129]) by orsmga007.jf.intel.com with ESMTP; 08 Feb 2018 21:17:24 -0800 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=192.55.52.43; helo=mga05.intel.com; envelope-from=bob.c.feng@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,482,1511856000"; d="scan'208";a="16395969" From: BobCF To: edk2-devel@lists.01.org Date: Fri, 9 Feb 2018 13:17:14 +0800 Message-Id: <20180209051714.3996-1-bob.c.feng@intel.com> X-Mailer: git-send-email 2.14.3.windows.1 Subject: [edk2] [Patch] BaseTools: Improve build performance X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: 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" Add cache for building PcdValueInit.c. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/GenFds/GenFds.py | 1 + BaseTools/Source/Python/Workspace/DscBuildData.py | 150 +++++++++++-------= ---- 2 files changed, 78 insertions(+), 73 deletions(-) diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Py= thon/GenFds/GenFds.py index dcba9f24cb..cd705630a3 100644 --- a/BaseTools/Source/Python/GenFds/GenFds.py +++ b/BaseTools/Source/Python/GenFds/GenFds.py @@ -324,10 +324,11 @@ def main(): EdkLogger.error("GenFds", FORMAT_I= NVALID, "The FV %s's region is specified in multiple FD with different valu= e." %FvObj.UiFvName) else: FvObj.FvRegionInFD =3D RegionObj.Size RegionObj.BlockInfoOfRegion(FdObj.Bloc= kSizeList, FvObj) =20 + GlobalData.BuildOptionPcd =3D Options.OptionPcd if Options.Opt= ionPcd else {} """Call GenFds""" GenFds.GenFd('', FdfParserObj, BuildWorkSpace, ArchList) =20 """Generate GUID cross reference file""" GenFds.GenerateGuidXRefFile(BuildWorkSpace, ArchList, FdfParserObj) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/= Source/Python/Workspace/DscBuildData.py index 0da3efbb43..70dd83cfbc 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -35,10 +35,11 @@ from Common.Misc import ProcessDuplicatedInf import re from Common.Parsing import IsValidWord from Common.VariableAttributes import VariableAttributes import Common.GlobalData as GlobalData import subprocess +from Common.Misc import SaveFileOnChange from Workspace.BuildClassObject import PlatformBuildClassObject, Structure= Pcd, PcdClassObject, ModuleBuildClassObject =20 # # Treat CHAR16 as a synonym for UINT16. CHAR16 support is required for VF= R C structs # @@ -154,12 +155,14 @@ class DscBuildData(PlatformBuildClassObject): self._Target =3D Target self._Toolchain =3D Toolchain self._ToolChainFamily =3D None self._Clear() self._HandleOverridePath() + self.WorkspaceDir =3D "" if os.getenv("WORKSPACE"): self.OutputPath =3D os.path.join(os.getenv("WORKSPACE"), 'Buil= d', PcdValueInitName) + self.WorkspaceDir =3D os.getenv("WORKSPACE") else: self.OutputPath =3D os.path.dirname(self.DscFile) self.DefaultStores =3D None self.SkuIdMgr =3D SkuClass(self.SkuName, self.SkuIds) =20 @@ -1289,11 +1292,11 @@ class DscBuildData(PlatformBuildClassObject): str_pcd_obj_str.DefaultFromDSC =3D {skuname:{defaultst= ore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, st= r_pcd_obj.SkuInfoList[skuname].HiiDefaultValue) for defaultstore in Default= Stores} for skuname in str_pcd_obj.SkuInfoList} else: str_pcd_obj_str.DefaultFromDSC =3D {skuname:{defaultst= ore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, st= r_pcd_obj.SkuInfoList[skuname].DefaultValue) for defaultstore in DefaultSto= res} for skuname in str_pcd_obj.SkuInfoList} for str_pcd_data in StrPcdSet[str_pcd]: if str_pcd_data[3] in SkuIds: - str_pcd_obj_str.AddOverrideValue(str_pcd_data[2], = str(str_pcd_data[6]), 'DEFAULT' if str_pcd_data[3] =3D=3D 'COMMON' else str= _pcd_data[3],'STANDARD' if str_pcd_data[4] =3D=3D 'COMMON' else str_pcd_dat= a[4], self.MetaFile.File,LineNo=3Dstr_pcd_data[5]) + str_pcd_obj_str.AddOverrideValue(str_pcd_data[2], = str(str_pcd_data[6]), 'DEFAULT' if str_pcd_data[3] =3D=3D 'COMMON' else str= _pcd_data[3],'STANDARD' if str_pcd_data[4] =3D=3D 'COMMON' else str_pcd_dat= a[4], self.MetaFile.File if self.WorkspaceDir not in self.MetaFile.File els= e self.MetaFile.File[len(self.WorkspaceDir) if self.WorkspaceDir.endswith(o= s.path.sep) else len(self.WorkspaceDir)+1:],LineNo=3Dstr_pcd_data[5]) S_pcd_set[str_pcd[1], str_pcd[0]] =3D str_pcd_obj_str else: EdkLogger.error('build', PARSER_ERROR, "Pcd (%s.%s) defined in DSC is not declared in= DEC files. Arch: ['%s']" % (str_pcd[0], str_pcd[1], self._Arch), File=3Dself.MetaFile,Line =3D StrPcdSet[str_pc= d][0][5]) @@ -1781,14 +1784,14 @@ class DscBuildData(PlatformBuildClassObject): for IncludeFile in Pcd.StructuredPcdIncludeFile: if IncludeFile not in Includes: Includes[IncludeFile] =3D True CApp =3D CApp + '#include <%s>\n' % (IncludeFile) CApp =3D CApp + '\n' - for PcdName in StructuredPcds: Pcd =3D StructuredPcds[PcdName] - if not Pcd.SkuOverrideValues: + if not Pcd.SkuOverrideValues or Pcd.Type in [self._PCD_TYPE_ST= RING_[MODEL_PCD_FIXED_AT_BUILD], + self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODU= LE]]: InitByteValue, CApp =3D self.GenerateInitializeFunc(self.S= kuIdMgr.SystemSkuId, 'STANDARD', Pcd, InitByteValue, CApp) else: for SkuName in self.SkuIdMgr.SkuOverrideOrder(): if SkuName not in Pcd.SkuOverrideValues: continue @@ -1800,11 +1803,11 @@ class DscBuildData(PlatformBuildClassObject): CApp =3D CApp + 'PcdEntryPoint(\n' CApp =3D CApp + ' VOID\n' CApp =3D CApp + ' )\n' CApp =3D CApp + '{\n' for Pcd in StructuredPcds.values(): - if not Pcd.SkuOverrideValues: + if not Pcd.SkuOverrideValues or Pcd.Type in [self._PCD_TYPE_ST= RING_[MODEL_PCD_FIXED_AT_BUILD],self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_= IN_MODULE]]: CApp =3D CApp + ' Initialize_%s_%s_%s_%s();\n' % (self.Sk= uIdMgr.SystemSkuId, 'STANDARD', Pcd.TokenSpaceGuidCName, Pcd.TokenCName) else: for SkuName in self.SkuIdMgr.SkuOverrideOrder(): if SkuName not in Pcd.SkuOverrideValues: continue @@ -1815,13 +1818,11 @@ class DscBuildData(PlatformBuildClassObject): CApp =3D CApp + PcdMainCEntry + '\n' =20 if not os.path.exists(self.OutputPath): os.makedirs(self.OutputPath) CAppBaseFileName =3D os.path.join(self.OutputPath, PcdValueInitNam= e) - File =3D open (CAppBaseFileName + '.c', 'w') - File.write(CApp) - File.close() + SaveFileOnChange(CAppBaseFileName + '.c', CApp, False) =20 MakeApp =3D PcdMakefileHeader if sys.platform =3D=3D "win32": MakeApp =3D MakeApp + 'ARCH =3D IA32\nAPPNAME =3D %s\n' % (Pcd= ValueInitName) + 'OBJECTS =3D %s\%s.obj\n' % (self.OutputPath, PcdValueInit= Name) + 'INC =3D ' else: @@ -1897,92 +1898,95 @@ class DscBuildData(PlatformBuildClassObject): MakeApp +=3D CC_FLAGS =20 if sys.platform =3D=3D "win32": MakeApp =3D MakeApp + PcdMakefileEnd MakeFileName =3D os.path.join(self.OutputPath, 'Makefile') - File =3D open (MakeFileName, 'w') - File.write(MakeApp) - File.close() + SaveFileOnChange(MakeFileName, MakeApp, False) =20 InputValueFile =3D os.path.join(self.OutputPath, 'Input.txt') OutputValueFile =3D os.path.join(self.OutputPath, 'Output.txt') - File =3D open (InputValueFile, 'w') - File.write(InitByteValue) - File.close() - - Messages =3D '' - if sys.platform =3D=3D "win32": - MakeCommand =3D 'nmake clean & nmake -f %s' % (MakeFileName) - returncode, StdOut, StdErr =3D self.ExecuteCommand (MakeComman= d) - Messages =3D StdOut - else: - MakeCommand =3D 'make clean & make -f %s' % (MakeFileName) - returncode, StdOut, StdErr =3D self.ExecuteCommand (MakeComman= d) - Messages =3D StdErr - Messages =3D Messages.split('\n') - MessageGroup =3D [] - if returncode <>0: - CAppBaseFileName =3D os.path.join(self.OutputPath, PcdValueIni= tName) - File =3D open (CAppBaseFileName + '.c', 'r') - FileData =3D File.readlines() - File.close() - for Message in Messages: - if " error" in Message or "warning" in Message: - FileInfo =3D Message.strip().split('(') - if len (FileInfo) > 1: - FileName =3D FileInfo [0] - FileLine =3D FileInfo [1].split (')')[0] - else: - FileInfo =3D Message.strip().split(':') - FileName =3D FileInfo [0] - FileLine =3D FileInfo [1] - if FileLine.isdigit(): - error_line =3D FileData[int (FileLine) - 1] - if r"//" in error_line: - c_line,dsc_line =3D error_line.split(r"//") - else: - dsc_line =3D error_line - message_itmes =3D Message.split(":") - Index =3D 0 - if "PcdValueInit.c" not in Message: - break - else: - for item in message_itmes: - if "PcdValueInit.c" in item: - Index =3D message_itmes.index(item) - message_itmes[Index] =3D dsc_line.stri= p() - break - MessageGroup.append(":".join(message_itmes[Ind= ex:]).strip()) - continue - else: - MessageGroup.append(Message) - if MessageGroup: - EdkLogger.error("build", PCD_STRUCTURE_PCD_ERROR, "\n".joi= n(MessageGroup) ) - else: - EdkLogger.error('Build', COMMAND_FAILURE, 'Can not execute= command: %s' % MakeCommand) + SaveFileOnChange(InputValueFile, InitByteValue, False) =20 PcdValueInitExe =3D PcdValueInitName if not sys.platform =3D=3D "win32": PcdValueInitExe =3D os.path.join(os.getenv("EDK_TOOLS_PATH"), = 'Source', 'C', 'bin', PcdValueInitName) - - Command =3D PcdValueInitExe + ' -i %s -o %s' % (InputValueFile, Ou= tputValueFile) - returncode, StdOut, StdErr =3D self.ExecuteCommand (Command) - if returncode <> 0: - EdkLogger.warn('Build', COMMAND_FAILURE, 'Can not collect outp= ut from command: %s' % Command) - FileBuffer =3D [] else: - File =3D open (OutputValueFile, 'r') - FileBuffer =3D File.readlines() - File.close() + PcdValueInitExe =3D os.path.join(os.getenv("EDK_TOOLS_PATH"), = 'Bin', 'Win32', PcdValueInitName) +".exe" + if not os.path.exists(PcdValueInitExe) or self.NeedUpdateOutput(Ou= tputValueFile, CAppBaseFileName + '.c'): + Messages =3D '' + if sys.platform =3D=3D "win32": + MakeCommand =3D 'nmake clean & nmake -f %s' % (MakeFileNam= e) + returncode, StdOut, StdErr =3D self.ExecuteCommand (MakeCo= mmand) + Messages =3D StdOut + else: + MakeCommand =3D 'make clean & make -f %s' % (MakeFileName) + returncode, StdOut, StdErr =3D self.ExecuteCommand (MakeCo= mmand) + Messages =3D StdErr + Messages =3D Messages.split('\n') + MessageGroup =3D [] + if returncode <>0: + CAppBaseFileName =3D os.path.join(self.OutputPath, PcdValu= eInitName) + File =3D open (CAppBaseFileName + '.c', 'r') + FileData =3D File.readlines() + File.close() + for Message in Messages: + if " error" in Message or "warning" in Message: + FileInfo =3D Message.strip().split('(') + if len (FileInfo) > 1: + FileName =3D FileInfo [0] + FileLine =3D FileInfo [1].split (')')[0] + else: + FileInfo =3D Message.strip().split(':') + FileName =3D FileInfo [0] + FileLine =3D FileInfo [1] + if FileLine.isdigit(): + error_line =3D FileData[int (FileLine) - 1] + if r"//" in error_line: + c_line,dsc_line =3D error_line.split(r"//") + else: + dsc_line =3D error_line + message_itmes =3D Message.split(":") + Index =3D 0 + if "PcdValueInit.c" not in Message: + break + else: + for item in message_itmes: + if "PcdValueInit.c" in item: + Index =3D message_itmes.index(item) + message_itmes[Index] =3D dsc_line.= strip() + break + MessageGroup.append(":".join(message_itmes= [Index:]).strip()) + continue + else: + MessageGroup.append(Message) + if MessageGroup: + EdkLogger.error("build", PCD_STRUCTURE_PCD_ERROR, "\n"= .join(MessageGroup) ) + else: + EdkLogger.error('Build', COMMAND_FAILURE, 'Can not exe= cute command: %s' % MakeCommand) + Command =3D PcdValueInitExe + ' -i %s -o %s' % (InputValueFile= , OutputValueFile) + returncode, StdOut, StdErr =3D self.ExecuteCommand (Command) + if returncode <> 0: + EdkLogger.warn('Build', COMMAND_FAILURE, 'Can not collect = output from command: %s' % Command) + + File =3D open (OutputValueFile, 'r') + FileBuffer =3D File.readlines() + File.close() =20 StructurePcdSet =3D [] for Pcd in FileBuffer: PcdValue =3D Pcd.split ('|') PcdInfo =3D PcdValue[0].split ('.') StructurePcdSet.append((PcdInfo[0],PcdInfo[1], PcdInfo[2], Pcd= Info[3], PcdValue[2].strip())) return StructurePcdSet =20 + def NeedUpdateOutput(self,OutputFile, ValueCFile): + if not os.path.exists(OutputFile): + return True + if os.stat(OutputFile).st_mtime <=3D os.stat(ValueCFile).st_mtime: + return True + return False + ## Retrieve dynamic PCD settings # # @param Type PCD type # # @retval a dict object contains settings of given PCD type --=20 2.14.3.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel