From nobody Tue May 7 11:21:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+41150+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+41150+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1558447992; cv=none; d=zoho.com; s=zohoarc; b=fZIy1wFz1tmT780EAkKIkzra6SIWGNVGVSLEHXJTI4+p07cQk4A6yz/VPO60+HDMdMiATcP0QyfL0ByETUfuGI5U5tUZV0ZxyoHMmpQe2XjJ3CefdgMremZFmhH2wLmLPdzf9jRkac8yB+jT6HWcMbVFmWGVExRqhl3dgMAE7dU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558447992; h=Content-Transfer-Encoding:Cc:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To:ARC-Authentication-Results; bh=ecbHN4D+KRSlWI0qgTAe8TMyX7rQT72dPWzpeM8SYww=; b=bdH3nwaymNUHoswfyhNuCQp718HNE0O7lXQj5VZdkk0jphiEyhOxKeSRwPULwcF0htZ21AB/AYX+y98CreKi90gRKFd335iUq/L+tYwi9ucsMf4ZZVqXq+LA9LohgxW51JEVqiTfzDQA3Z1KuPeBr5waqlxt7SJ3OMWOl1uSjlE= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+41150+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1558447992246737.4703193914177; Tue, 21 May 2019 07:13:12 -0700 (PDT) Return-Path: X-Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by groups.io with SMTP; Tue, 21 May 2019 07:13:11 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 May 2019 07:13:10 -0700 X-ExtLoop1: 1 X-Received: from rodrigu3-desk.amr.corp.intel.com ([10.7.163.75]) by orsmga005.jf.intel.com with ESMTP; 21 May 2019 07:13:10 -0700 From: "Christian Rodriguez" To: devel@edk2.groups.io Cc: Bob Feng , Liming Gao , Yonghong Zhu Subject: [edk2-devel] [PATCH] BaseTools: Add a checking for Sources section in INF file Date: Tue, 21 May 2019 07:13:08 -0700 Message-Id: <20190521141308.12144-1-christian.rodriguez@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,christian.rodriguez@intel.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1558447991; bh=8ZmXtRIUEEvI/4KAkieEF2PFUO9gWOVyquggZmhjiVY=; h=Cc:Date:From:Reply-To:Subject:To; b=DwB3arz0EnuBgctsuq1dnAshxZwWMXbfEBT4aOnvO0jkduGoKrH++N4PQ6KNmuMrLTb Ugiyrmf1vduJ5HZh+Ey4/JCyp2znnCLXzejC8It6FqUMZK65BPFn0SOyun8wJ4cU+yZe8 9CHBPx5XS1BWImjzCb9LADB701k3hsKxjJc= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1804 In the Edk2 INF spec 3.9, it states, All HII Unicode format files must be listed in [Sources] section. Add a check to see if [Sources] section lists all the "source" type files of a module. Performance impact should be minimal with this patch since information is already being fetched for Makefile purposes. All other information is already cached in memory. No extra IO time is needed. Signed-off-by: Christian Rodriguez Cc: Bob Feng Cc: Liming Gao Cc: Yonghong Zhu --- BaseTools/Source/Python/AutoGen/AutoGen.py | 6 ++++-- BaseTools/Source/Python/AutoGen/GenMake.py | 45 ++++++++++++++++++++++++= +++++++++++++++++++++ BaseTools/Source/Python/Common/GlobalData.py | 3 ++- BaseTools/Source/Python/build/build.py | 66 ++++++++++++++++++++++++= ++++++++++++++++-------------------------- 4 files changed, 91 insertions(+), 29 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/= Python/AutoGen/AutoGen.py index a843f294b9..0bc27fb2b3 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -3989,7 +3989,8 @@ class ModuleAutoGen(AutoGen): for LibraryAutoGen in self.LibraryAutoGenList: LibraryAutoGen.CreateMakeFile() =20 - if self.CanSkip(): + # Don't enable if hash feature enabled, CanSkip uses timestamps to= determine build skipping + if not GlobalData.gUseHashCache and self.CanSkip(): return =20 if len(self.CustomMakefile) =3D=3D 0: @@ -4032,7 +4033,8 @@ class ModuleAutoGen(AutoGen): for LibraryAutoGen in self.LibraryAutoGenList: LibraryAutoGen.CreateCodeFile() =20 - if self.CanSkip(): + # Don't enable if hash feature enabled, CanSkip uses timestamps to= determine build skipping + if not GlobalData.gUseHashCache and self.CanSkip(): return =20 AutoGenList =3D [] diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/= Python/AutoGen/GenMake.py index 0e0f9fd9b0..8765ffa188 100644 --- a/BaseTools/Source/Python/AutoGen/GenMake.py +++ b/BaseTools/Source/Python/AutoGen/GenMake.py @@ -905,6 +905,51 @@ cleanlib: ForceIncludedFile, self._AutoGenObject.IncludePathList + = self._AutoGenObject.BuildOptionIncPathList ) + + # Only do it during hashing feature for now to save time on clean = build + # Conditional can be removed to happen on all builds for MetaFile = compliance + if GlobalData.gUseHashCache: + # Check if header files are listed in metafile + # Get a list of unique module header source files from MetaFile + headerFilesInMetaFileSet =3D set() + for aFile in self._AutoGenObject.SourceFileList: + aFileName =3D str(aFile) + if not aFileName.endswith('.h'): + continue + headerFilesInMetaFileSet.add(aFileName.lower()) + + # Get a list of unique module autogen files + localAutoGenFileSet =3D set() + for aFile in self._AutoGenObject.AutoGenFileList: + localAutoGenFileSet.add(str(aFile).lower()) + + # Get a list of unique module dependency header files + # Exclude autogen files and files not in the source directory + headerFileDependencySet =3D set() + localSourceDir =3D str(self._AutoGenObject.SourceDir).lower() + for Dependency in FileDependencyDict.values(): + for aFile in Dependency: + aFileName =3D str(aFile).lower() + if not aFileName.endswith('.h'): + continue + if aFileName in localAutoGenFileSet: + continue + if localSourceDir not in aFileName: + continue + headerFileDependencySet.add(aFileName) + + # Ensure that gModuleBuildTracking has been initialized per ar= chitecture + if self._AutoGenObject.Arch not in GlobalData.gModuleBuildTrac= king: + GlobalData.gModuleBuildTracking[self._AutoGenObject.Arch] = =3D dict() + + # Check if a module dependency header file is missing from the= module's MetaFile + for aFile in headerFileDependencySet: + if aFile not in headerFilesInMetaFileSet: + GlobalData.gModuleBuildTracking[self._AutoGenObject.Ar= ch][self._AutoGenObject] =3D 'FAIL_METAFILE' + EdkLogger.warn("build","Module MetaFile [Sources] is m= issing local header!", + ExtraData =3D "Local Header: " + aFile + "= not found in " + self._AutoGenObject.MetaFile.Path + ) + DepSet =3D None for File,Dependency in FileDependencyDict.items(): if not Dependency: diff --git a/BaseTools/Source/Python/Common/GlobalData.py b/BaseTools/Sourc= e/Python/Common/GlobalData.py index 95e28a988f..bd45a43728 100644 --- a/BaseTools/Source/Python/Common/GlobalData.py +++ b/BaseTools/Source/Python/Common/GlobalData.py @@ -110,7 +110,8 @@ gEnableGenfdsMultiThread =3D False gSikpAutoGenCache =3D set() =20 # Dictionary for tracking Module build status as success or failure -# False -> Fail : True -> Success +# Top Dict: Key: Arch Type Value: Dictionary +# Second Dict: Key: AutoGen Obj Value: 'SUCCESS'\'FAIL'\'FAIL_METAFILE' gModuleBuildTracking =3D dict() =20 # Dictionary of booleans that dictate whether a module or diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Pyth= on/build/build.py index 027061191c..0a58dd16ef 100644 --- a/BaseTools/Source/Python/build/build.py +++ b/BaseTools/Source/Python/build/build.py @@ -625,8 +625,16 @@ class BuildTask: BuildTask._ErrorFlag.set() BuildTask._ErrorMessage =3D "%s broken\n %s [%s]" % \ (threading.currentThread().getName()= , Command, WorkingDir) - if self.BuildItem.BuildObject in GlobalData.gModuleBuildTracking a= nd not BuildTask._ErrorFlag.isSet(): - GlobalData.gModuleBuildTracking[self.BuildItem.BuildObject] = =3D True + + # Set the value used by hash invalidation flow in GlobalData.gModu= leBuildTracking to 'SUCCESS' + # If Module or Lib is being tracked, it did not fail header check = test, and built successfully + if (self.BuildItem.BuildObject.Arch in GlobalData.gModuleBuildTrac= king and + self.BuildItem.BuildObject in GlobalData.gModuleBuildTracking[s= elf.BuildItem.BuildObject.Arch] and + GlobalData.gModuleBuildTracking[self.BuildItem.BuildObject.Arch= ][self.BuildItem.BuildObject] !=3D 'FAIL_METAFILE' and + not BuildTask._ErrorFlag.isSet() + ): + GlobalData.gModuleBuildTracking[self.BuildItem.BuildObject.Arc= h][self.BuildItem.BuildObject] =3D 'SUCCESS' + # indicate there's a thread is available for another build task BuildTask._RunningQueueLock.acquire() BuildTask._RunningQueue.pop(self.BuildItem) @@ -1154,27 +1162,27 @@ class Build(): # # def invalidateHash(self): - # GlobalData.gModuleBuildTracking contains only modules that canno= t be skipped by hash - for moduleAutoGenObj in GlobalData.gModuleBuildTracking.keys(): - # False =3D=3D FAIL : True =3D=3D Success - # Skip invalidating for Successful module builds - if GlobalData.gModuleBuildTracking[moduleAutoGenObj] =3D=3D Tr= ue: - continue + # GlobalData.gModuleBuildTracking contains only modules or libs th= at cannot be skipped by hash + for moduleAutoGenObjArch in GlobalData.gModuleBuildTracking.keys(): + for moduleAutoGenObj in GlobalData.gModuleBuildTracking[module= AutoGenObjArch].keys(): + # Skip invalidating for Successful Module/Lib builds + if GlobalData.gModuleBuildTracking[moduleAutoGenObjArch][m= oduleAutoGenObj] =3D=3D 'SUCCESS': + continue =20 - # The module failed to build or failed to start building, from= this point on + # The module failed to build, failed to start building, or= failed the header check test from this point on =20 - # Remove .hash from build - if GlobalData.gUseHashCache: - ModuleHashFile =3D path.join(moduleAutoGenObj.BuildDir, mo= duleAutoGenObj.Name + ".hash") - if os.path.exists(ModuleHashFile): - os.remove(ModuleHashFile) + # Remove .hash from build + if GlobalData.gUseHashCache: + ModuleHashFile =3D os.path.join(moduleAutoGenObj.Build= Dir, moduleAutoGenObj.Name + ".hash") + if os.path.exists(ModuleHashFile): + os.remove(ModuleHashFile) =20 - # Remove .hash file from cache - if GlobalData.gBinCacheDest: - FileDir =3D path.join(GlobalData.gBinCacheDest, moduleAuto= GenObj.Arch, moduleAutoGenObj.SourceDir, moduleAutoGenObj.MetaFile.BaseName) - HashFile =3D path.join(FileDir, moduleAutoGenObj.Name + '.= hash') - if os.path.exists(HashFile): - os.remove(HashFile) + # Remove .hash file from cache + if GlobalData.gUseHashCache and GlobalData.gBinCacheDest: + FileDir =3D os.path.join(GlobalData.gBinCacheDest, mod= uleAutoGenObj.Arch, moduleAutoGenObj.SourceDir, moduleAutoGenObj.MetaFile.B= aseName) + HashFile =3D os.path.join(FileDir, moduleAutoGenObj.Na= me + '.hash') + if os.path.exists(HashFile): + os.remove(HashFile) =20 ## Build a module or platform # @@ -1833,9 +1841,11 @@ class Build(): if self.Target =3D=3D "genmake": return True self.BuildModules.append(Ma) - # Initialize all modules in tracking to False = (FAIL) - if Ma not in GlobalData.gModuleBuildTracking: - GlobalData.gModuleBuildTracking[Ma] =3D Fa= lse + # Initialize all modules in tracking to 'FAIL' + if Ma.Arch not in GlobalData.gModuleBuildTrack= ing: + GlobalData.gModuleBuildTracking[Ma.Arch] = =3D dict() + if Ma not in GlobalData.gModuleBuildTracking[M= a.Arch]: + GlobalData.gModuleBuildTracking[Ma.Arch][M= a] =3D 'FAIL' self.AutoGenTime +=3D int(round((time.time() - AutoGen= Start))) MakeStart =3D time.time() for Ma in self.BuildModules: @@ -1919,6 +1929,7 @@ class Build(): # Save MAP buffer into MAP file. # self._SaveMapFile (MapBuffer, Wa) + self.invalidateHash() =20 def _GenFfsCmd(self,ArchList): # convert dictionary of Cmd:(Inf,Arch) @@ -2017,9 +2028,11 @@ class Build(): if self.Target =3D=3D "genmake": continue self.BuildModules.append(Ma) - # Initialize all modules in tracking to False (FAI= L) - if Ma not in GlobalData.gModuleBuildTracking: - GlobalData.gModuleBuildTracking[Ma] =3D False + # Initialize all modules in tracking to 'FAIL' + if Ma.Arch not in GlobalData.gModuleBuildTracking: + GlobalData.gModuleBuildTracking[Ma.Arch] =3D d= ict() + if Ma not in GlobalData.gModuleBuildTracking[Ma.Ar= ch]: + GlobalData.gModuleBuildTracking[Ma.Arch][Ma] = =3D 'FAIL' self.Progress.Stop("done!") self.AutoGenTime +=3D int(round((time.time() - AutoGen= Start))) MakeStart =3D time.time() @@ -2107,6 +2120,7 @@ class Build(): # Save MAP buffer into MAP file. # self._SaveMapFile(MapBuffer, Wa) + self.invalidateHash() =20 ## Generate GuidedSectionTools.txt in the FV directories. # --=20 2.19.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#41150): https://edk2.groups.io/g/devel/message/41150 Mute This Topic: https://groups.io/mt/31697075/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-