From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=fail (domain: intel.com, ip: , mailfrom: christian.rodriguez@intel.com) Received: from mga17.intel.com (mga17.intel.com []) by groups.io with SMTP; Thu, 04 Apr 2019 09:04:51 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Apr 2019 09:04:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,308,1549958400"; d="scan'208";a="220580134" Received: from rodrigu3-desk.amr.corp.intel.com ([10.7.163.75]) by orsmga001.jf.intel.com with ESMTP; 04 Apr 2019 09:04:50 -0700 From: "Christian Rodriguez" To: devel@edk2.groups.io Cc: Bob Feng , Liming Gao , Yonghong Zhu Subject: [Patch V2 2/4] BaseTools: Fix corner-cases of --hash feature Date: Thu, 4 Apr 2019 09:04:21 -0700 Message-Id: <20190404160423.5268-3-christian.rodriguez@intel.com> X-Mailer: git-send-email 2.19.1.windows.1 In-Reply-To: <20190404160423.5268-1-christian.rodriguez@intel.com> References: <20190404160423.5268-1-christian.rodriguez@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1680 Re-order hashing operations so we don't do redundant hashes. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Christian Rodriguez Cc: Bob Feng Cc: Liming Gao Cc: Yonghong Zhu --- BaseTools/Source/Python/AutoGen/AutoGen.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index 792bc99f54..b516404696 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -661,7 +661,7 @@ class WorkspaceAutoGen(AutoGen): # # Generate Package level hash value # - GlobalData.gPackageHash[Arch] = {} + GlobalData.gPackageHash = {} if GlobalData.gUseHashCache: for Pkg in Pkgs: self._GenPkgLevelHash(Pkg) @@ -747,7 +747,7 @@ class WorkspaceAutoGen(AutoGen): return True def _GenPkgLevelHash(self, Pkg): - if Pkg.PackageName in GlobalData.gPackageHash[Pkg.Arch]: + if Pkg.PackageName in GlobalData.gPackageHash: return PkgDir = os.path.join(self.BuildDir, Pkg.Arch, Pkg.PackageName) @@ -770,7 +770,7 @@ class WorkspaceAutoGen(AutoGen): f.close() m.update(Content) SaveFileOnChange(HashFile, m.hexdigest(), False) - GlobalData.gPackageHash[Pkg.Arch][Pkg.PackageName] = m.hexdigest() + GlobalData.gPackageHash[Pkg.PackageName] = m.hexdigest() def _GetMetaFiles(self, Target, Toolchain, Arch): AllWorkSpaceMetaFiles = set() @@ -4092,14 +4092,16 @@ class ModuleAutoGen(AutoGen): def GenModuleHash(self): if self.Arch not in GlobalData.gModuleHash: GlobalData.gModuleHash[self.Arch] = {} + if self.Name in GlobalData.gModuleHash[self.Arch] and GlobalData.gBinCacheSource and self.AttemptModuleCacheCopy(): + return False m = hashlib.md5() # Add Platform level hash m.update(GlobalData.gPlatformHash.encode('utf-8')) # Add Package level hash if self.DependentPackageList: for Pkg in sorted(self.DependentPackageList, key=lambda x: x.PackageName): - if Pkg.PackageName in GlobalData.gPackageHash[self.Arch]: - m.update(GlobalData.gPackageHash[self.Arch][Pkg.PackageName].encode('utf-8')) + if Pkg.PackageName in GlobalData.gPackageHash: + m.update(GlobalData.gPackageHash[Pkg.PackageName].encode('utf-8')) # Add Library hash if self.LibraryAutoGenList: @@ -4124,9 +4126,8 @@ class ModuleAutoGen(AutoGen): ModuleHashFile = path.join(self.BuildDir, self.Name + ".hash") if self.Name not in GlobalData.gModuleHash[self.Arch]: GlobalData.gModuleHash[self.Arch][self.Name] = m.hexdigest() - if GlobalData.gBinCacheSource: - if self.AttemptModuleCacheCopy(): - return False + if GlobalData.gBinCacheSource and self.AttemptModuleCacheCopy(): + return False return SaveFileOnChange(ModuleHashFile, m.hexdigest(), False) ## Decide whether we can skip the ModuleAutoGen process -- 2.19.1.windows.1