From nobody Thu May 2 20:19:16 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 1517987017950679.0215569564646; Tue, 6 Feb 2018 23:03:37 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 6ABD321F0DA42; Tue, 6 Feb 2018 22:57:51 -0800 (PST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (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 F22D0223972DF for ; Tue, 6 Feb 2018 22:57:49 -0800 (PST) Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Feb 2018 23:03:32 -0800 Received: from shwdeopenpsi105.ccr.corp.intel.com ([10.239.9.129]) by fmsmga007.fm.intel.com with ESMTP; 06 Feb 2018 23:03:31 -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.88; helo=mga01.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,471,1511856000"; d="scan'208";a="15933518" From: BobCF To: edk2-devel@lists.01.org Date: Wed, 7 Feb 2018 15:03:24 +0800 Message-Id: <20180207070324.7656-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: Yonghong Zhu Cc: Liming Gao --- BaseTools/Source/Python/Workspace/DscBuildData.py | 140 +++++++++++-------= ---- 1 file changed, 71 insertions(+), 69 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/= Source/Python/Workspace/DscBuildData.py index 0da3efbb43..6d8486aa19 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 # @@ -1815,13 +1816,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 +1896,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