# Copyright (c) 2018, Hewlett Packard Enterprise Development, L.P.<BR>\r
# Copyright (c) 2019, American Megatrends, Inc. All rights reserved.<BR>\r
#\r
-# This program and the accompanying materials\r
-# are licensed and made available under the terms and conditions of the BSD License\r
-# which accompanies this distribution. The full text of the license may be found at\r
-# http://opensource.org/licenses/bsd-license.php\r
-#\r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+# SPDX-License-Identifier: BSD-2-Clause-Patent\r
#\r
\r
## Import Modules\r
#\r
# Generate Package level hash value\r
#\r
- GlobalData.gPackageHash[Arch] = {}\r
+ GlobalData.gPackageHash = {}\r
if GlobalData.gUseHashCache:\r
for Pkg in Pkgs:\r
self._GenPkgLevelHash(Pkg)\r
return True\r
\r
def _GenPkgLevelHash(self, Pkg):\r
- if Pkg.PackageName in GlobalData.gPackageHash[Pkg.Arch]:\r
+ if Pkg.PackageName in GlobalData.gPackageHash:\r
return\r
\r
PkgDir = os.path.join(self.BuildDir, Pkg.Arch, Pkg.PackageName)\r
f.close()\r
m.update(Content)\r
SaveFileOnChange(HashFile, m.hexdigest(), False)\r
- GlobalData.gPackageHash[Pkg.Arch][Pkg.PackageName] = m.hexdigest()\r
+ GlobalData.gPackageHash[Pkg.PackageName] = m.hexdigest()\r
\r
def _GetMetaFiles(self, Target, Toolchain, Arch):\r
AllWorkSpaceMetaFiles = set()\r
FileDir = path.join(GlobalData.gBinCacheDest, self.Arch, self.SourceDir, self.MetaFile.BaseName)\r
CreateDirectory (FileDir)\r
HashFile = path.join(self.BuildDir, self.Name + '.hash')\r
- ModuleFile = path.join(self.OutputDir, self.Name + '.inf')\r
if os.path.exists(HashFile):\r
shutil.copy2(HashFile, FileDir)\r
+ if self.IsLibrary:\r
+ return\r
+ ModuleFile = path.join(self.OutputDir, self.Name + '.inf')\r
if os.path.exists(ModuleFile):\r
shutil.copy2(ModuleFile, FileDir)\r
if not self.OutputFile:\r
if not os.path.isabs(File):\r
File = os.path.join(self.OutputDir, File)\r
if os.path.exists(File):\r
- shutil.copy2(File, FileDir)\r
+ sub_dir = os.path.relpath(File, self.OutputDir)\r
+ destination_file = os.path.join(FileDir, sub_dir)\r
+ destination_dir = os.path.dirname(destination_file)\r
+ CreateDirectory(destination_dir)\r
+ shutil.copy2(File, destination_dir)\r
\r
def AttemptModuleCacheCopy(self):\r
+ # If library or Module is binary do not skip by hash\r
if self.IsBinaryModule:\r
return False\r
+ # .inc is contains binary information so do not skip by hash as well\r
+ for f_ext in self.SourceFileList:\r
+ if '.inc' in str(f_ext):\r
+ return False\r
FileDir = path.join(GlobalData.gBinCacheSource, self.Arch, self.SourceDir, self.MetaFile.BaseName)\r
HashFile = path.join(FileDir, self.Name + '.hash')\r
if os.path.exists(HashFile):\r
shutil.copy2(HashFile, self.BuildDir)\r
else:\r
File = path.join(root, f)\r
- shutil.copy2(File, self.OutputDir)\r
+ sub_dir = os.path.relpath(File, FileDir)\r
+ destination_file = os.path.join(self.OutputDir, sub_dir)\r
+ destination_dir = os.path.dirname(destination_file)\r
+ CreateDirectory(destination_dir)\r
+ shutil.copy2(File, destination_dir)\r
if self.Name == "PcdPeim" or self.Name == "PcdDxe":\r
CreatePcdDatabaseCode(self, TemplateString(), TemplateString())\r
return True\r
def GenModuleHash(self):\r
if self.Arch not in GlobalData.gModuleHash:\r
GlobalData.gModuleHash[self.Arch] = {}\r
+ if self.Name in GlobalData.gModuleHash[self.Arch] and GlobalData.gBinCacheSource and self.AttemptModuleCacheCopy():\r
+ return False\r
m = hashlib.md5()\r
# Add Platform level hash\r
m.update(GlobalData.gPlatformHash.encode('utf-8'))\r
# Add Package level hash\r
if self.DependentPackageList:\r
for Pkg in sorted(self.DependentPackageList, key=lambda x: x.PackageName):\r
- if Pkg.PackageName in GlobalData.gPackageHash[self.Arch]:\r
- m.update(GlobalData.gPackageHash[self.Arch][Pkg.PackageName].encode('utf-8'))\r
+ if Pkg.PackageName in GlobalData.gPackageHash:\r
+ m.update(GlobalData.gPackageHash[Pkg.PackageName].encode('utf-8'))\r
\r
# Add Library hash\r
if self.LibraryAutoGenList:\r
ModuleHashFile = path.join(self.BuildDir, self.Name + ".hash")\r
if self.Name not in GlobalData.gModuleHash[self.Arch]:\r
GlobalData.gModuleHash[self.Arch][self.Name] = m.hexdigest()\r
- if GlobalData.gBinCacheSource:\r
- if self.AttemptModuleCacheCopy():\r
- return False\r
+ if GlobalData.gBinCacheSource and self.AttemptModuleCacheCopy():\r
+ return False\r
return SaveFileOnChange(ModuleHashFile, m.hexdigest(), False)\r
\r
## Decide whether we can skip the ModuleAutoGen process\r
def CanSkipbyHash(self):\r
+ # If library or Module is binary do not skip by hash\r
+ if self.IsBinaryModule:\r
+ return False\r
+ # .inc is contains binary information so do not skip by hash as well\r
+ for f_ext in self.SourceFileList:\r
+ if '.inc' in str(f_ext):\r
+ return False\r
if GlobalData.gUseHashCache:\r
+ # If there is a valid hash or function generated a valid hash; function will return False\r
+ # and the statement below will return True\r
return not self.GenModuleHash()\r
return False\r
\r