From nobody Thu May 2 04:48:17 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+41283+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+41283+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1558627570; cv=none; d=zoho.com; s=zohoarc; b=F4pxdmzkT8WXLAIJWk3eRDSz05bLFAEMyeIxvYkE5CwVajDvqHBcqxNG8r5IcAN9eqGTOU/X+Qj+P/YOmXgq4GVbLfiNrh+eHAwDoLwbH4DeVi0OuGQBFG3pQzrHz9unjbHyB7TEtKV71zrpRDUx5fykgMz6VmBGYAZU6KvZp9k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558627570; h=Content-Transfer-Encoding:Cc:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To:ARC-Authentication-Results; bh=CNkC4IJGKo+8bUrM6seTcdm3AKQ9WAHEg3RCI0KAFfs=; b=HiJanTtCC0y3mZE6o2q9QeAp+HO3lqkq9fQK5omAVaM2pqf9LG+D0jKSWiryfmVYbhs36airStBqKw7Gr/Ydc0kC80ATOuiCJOeJtWof1BPMfvj5dAMRyB5FojxAGqfWGPF/ih6sHV0+e/DmeSvnM0dOESEfPV/DxE/etkP1YEA= 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+41283+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 1558627570029602.7677564885914; Thu, 23 May 2019 09:06:10 -0700 (PDT) Return-Path: X-Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by groups.io with SMTP; Thu, 23 May 2019 09:06:09 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 May 2019 09:06:08 -0700 X-ExtLoop1: 1 X-Received: from rodrigu3-desk.amr.corp.intel.com ([10.7.163.75]) by orsmga007.jf.intel.com with ESMTP; 23 May 2019 09:06:08 -0700 From: "Christian Rodriguez" To: devel@edk2.groups.io Cc: Bob Feng , Liming Gao , Yonghong Zhu Subject: [edk2-devel] [Patch V2] BaseTools: Add a checking for Sources section in INF file Date: Thu, 23 May 2019 09:06:04 -0700 Message-Id: <20190523160604.15944-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=1558627569; bh=Yb32sWwEulNBkXYKO2s4ym9jXPwiKXWyEsRBJF7o1aI=; h=Cc:Date:From:Reply-To:Subject:To; b=WtqTGgQQOFBvKoywoCe+FaB7fv5JZfSQe6EUhB+LcS6CchDQv2fJQI2vCqqYlqva5MC g2z9ta7uJixs4vcsJhS1f/CYO1N1YTdKU2awyJRKpMZkpqwXqXNvunnYIW7fQFGtq3h1M uu+iOP3WxmYcirCmlKhJ2Z9qO+Cbjffd+0E= 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 V2: Enable check for all builds, move conditional to hash invalidation 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 | 44 +++++++++++++ BaseTools/Source/Python/Common/GlobalData.py | 3 +- BaseTools/Source/Python/build/build.py | 65 ++++++++++++-------- 4 files changed, 91 insertions(+), 27 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..212ca0fa7f 100644 --- a/BaseTools/Source/Python/AutoGen/GenMake.py +++ b/BaseTools/Source/Python/AutoGen/GenMake.py @@ -905,6 +905,50 @@ cleanlib: ForceIncludedFile, self._AutoGenObject.IncludePathList + = self._AutoGenObject.BuildOptionIncPathList ) + + # 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 archit= ecture + if self._AutoGenObject.Arch not in GlobalData.gModuleBuildTracking: + GlobalData.gModuleBuildTracking[self._AutoGenObject.Arch] =3D = dict() + + # Check if a module dependency header file is missing from the mod= ule's MetaFile + for aFile in headerFileDependencySet: + if aFile in headerFilesInMetaFileSet: + continue + if GlobalData.gUseHashCache: + GlobalData.gModuleBuildTracking[self._AutoGenObject.Arch][= self._AutoGenObject] =3D 'FAIL_METAFILE' + EdkLogger.warn("build","Module MetaFile [Sources] is missing l= ocal header!", + ExtraData =3D "Local Header: " + aFile + " not fou= nd 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 a8b4ce7375..d147e02dc6 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,30 @@ 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 + # Only for hashing feature + if not GlobalData.gUseHashCache: + return + + # 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") + # Remove .hash from build + ModuleHashFile =3D os.path.join(moduleAutoGenObj.BuildDir,= 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.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 # @@ -1829,9 +1840,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: @@ -1915,6 +1928,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) @@ -2013,9 +2027,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() @@ -2103,6 +2119,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 (#41283): https://edk2.groups.io/g/devel/message/41283 Mute This Topic: https://groups.io/mt/31732696/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-