X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2FAutoGen%2FAutoGen.py;h=a2077c551608e77ed13d5ea5a9278efe2e1029a8;hb=2d53d54a5bf5f9ba9379e465f49ac9cdc55035de;hp=a843f294b94a5e9d643147fc008ee42789583d4d;hpb=a7ef158b07524f9afd0cefa3180aeac0fcb6e436;p=mirror_edk2.git diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index a843f294b9..a2077c5516 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -1166,6 +1166,17 @@ class PlatformAutoGen(AutoGen): return True + ## hash() operator of PlatformAutoGen + # + # The platform file path and arch string will be used to represent + # hash value of this object + # + # @retval int Hash value of the platform file path and arch + # + @cached_class_function + def __hash__(self): + return hash((self.MetaFile, self.Arch)) + @cached_class_function def __repr__(self): return "%s [%s]" % (self.MetaFile, self.Arch) @@ -2579,6 +2590,16 @@ class ModuleAutoGen(AutoGen): self.ReferenceModules = [] self.ConstPcd = {} + ## hash() operator of ModuleAutoGen + # + # The module file path and arch string will be used to represent + # hash value of this object + # + # @retval int Hash value of the module file path and arch + # + @cached_class_function + def __hash__(self): + return hash((self.MetaFile, self.Arch)) def __repr__(self): return "%s [%s]" % (self.MetaFile, self.Arch) @@ -3009,7 +3030,7 @@ class ModuleAutoGen(AutoGen): IncPathList = [NormPath(Path, self.Macros) for Path in BuildOptIncludeRegEx.findall(FlagOption)] else: # - # RVCT may specify a list of directory seperated by commas + # RVCT may specify a list of directory separated by commas # IncPathList = [] for Path in BuildOptIncludeRegEx.findall(FlagOption): @@ -3558,18 +3579,36 @@ class ModuleAutoGen(AutoGen): fInputfile.close () return OutputName + @cached_property + def OutputFile(self): + retVal = set() + OutputDir = self.OutputDir.replace('\\', '/').strip('/') + DebugDir = self.DebugDir.replace('\\', '/').strip('/') + for Item in self.CodaTargetList: + File = Item.Target.Path.replace('\\', '/').strip('/').replace(DebugDir, '').replace(OutputDir, '').strip('/') + retVal.add(File) + if self.DepexGenerated: + retVal.add(self.Name + '.depex') + + Bin = self._GenOffsetBin() + if Bin: + retVal.add(Bin) + + for Root, Dirs, Files in os.walk(OutputDir): + for File in Files: + if File.lower().endswith('.pdb'): + retVal.add(File) + + return retVal + ## Create AsBuilt INF file the module # - def CreateAsBuiltInf(self, IsOnlyCopy = False): - self.OutputFile = set() - if IsOnlyCopy and GlobalData.gBinCacheDest: - self.CopyModuleToCache() - return + def CreateAsBuiltInf(self): if self.IsAsBuiltInfCreated: return - # Skip the following code for libraries + # Skip INF file generation for libraries if self.IsLibrary: return @@ -3691,7 +3730,6 @@ class ModuleAutoGen(AutoGen): DebugDir = self.DebugDir.replace('\\', '/').strip('/') for Item in self.CodaTargetList: File = Item.Target.Path.replace('\\', '/').strip('/').replace(DebugDir, '').replace(OutputDir, '').strip('/') - self.OutputFile.add(File) if os.path.isabs(File): File = File.replace('\\', '/').strip('/').replace(OutputDir, '').strip('/') if Item.Target.Ext.lower() == '.aml': @@ -3707,7 +3745,6 @@ class ModuleAutoGen(AutoGen): if os.path.exists(DepexFile): self.DepexGenerated = True if self.DepexGenerated: - self.OutputFile.add(self.Name + '.depex') if self.ModuleType in [SUP_MODULE_PEIM]: AsBuiltInfDict['binary_item'].append('PEI_DEPEX|' + self.Name + '.depex') elif self.ModuleType in [SUP_MODULE_DXE_DRIVER, SUP_MODULE_DXE_RUNTIME_DRIVER, SUP_MODULE_DXE_SAL_DRIVER, SUP_MODULE_UEFI_DRIVER]: @@ -3718,13 +3755,11 @@ class ModuleAutoGen(AutoGen): Bin = self._GenOffsetBin() if Bin: AsBuiltInfDict['binary_item'].append('BIN|%s' % Bin) - self.OutputFile.add(Bin) for Root, Dirs, Files in os.walk(OutputDir): for File in Files: if File.lower().endswith('.pdb'): AsBuiltInfDict['binary_item'].append('DISPOSABLE|' + File) - self.OutputFile.add(File) HeaderComments = self.Module.HeaderComments StartPos = 0 for Index in range(len(HeaderComments)): @@ -3893,33 +3928,31 @@ class ModuleAutoGen(AutoGen): SaveFileOnChange(os.path.join(self.OutputDir, self.Name + '.inf'), str(AsBuiltInf), False) self.IsAsBuiltInfCreated = True - if GlobalData.gBinCacheDest: - self.CopyModuleToCache() def CopyModuleToCache(self): - FileDir = path.join(GlobalData.gBinCacheDest, self.PlatformInfo.Name, self.BuildTarget + "_" + self.ToolChain, self.Arch, self.SourceDir, self.MetaFile.BaseName) + FileDir = path.join(GlobalData.gBinCacheDest, self.PlatformInfo.OutputDir, self.BuildTarget + "_" + self.ToolChain, self.Arch, self.SourceDir, self.MetaFile.BaseName) CreateDirectory (FileDir) HashFile = path.join(self.BuildDir, self.Name + '.hash') if os.path.exists(HashFile): - shutil.copy2(HashFile, FileDir) - if not self.IsLibrary: - ModuleFile = path.join(self.OutputDir, self.Name + '.inf') - if os.path.exists(ModuleFile): - shutil.copy2(ModuleFile, FileDir) + CopyFileOnChange(HashFile, FileDir) + ModuleFile = path.join(self.OutputDir, self.Name + '.inf') + if os.path.exists(ModuleFile): + CopyFileOnChange(ModuleFile, FileDir) + if not self.OutputFile: Ma = self.BuildDatabase[self.MetaFile, self.Arch, self.BuildTarget, self.ToolChain] self.OutputFile = Ma.Binaries - if self.OutputFile: - for File in self.OutputFile: - File = str(File) - if not os.path.isabs(File): - File = os.path.join(self.OutputDir, File) - if os.path.exists(File): - sub_dir = os.path.relpath(File, self.OutputDir) - destination_file = os.path.join(FileDir, sub_dir) - destination_dir = os.path.dirname(destination_file) - CreateDirectory(destination_dir) - shutil.copy2(File, destination_dir) + + for File in self.OutputFile: + File = str(File) + if not os.path.isabs(File): + File = os.path.join(self.OutputDir, File) + if os.path.exists(File): + sub_dir = os.path.relpath(File, self.OutputDir) + destination_file = os.path.join(FileDir, sub_dir) + destination_dir = os.path.dirname(destination_file) + CreateDirectory(destination_dir) + CopyFileOnChange(File, destination_dir) def AttemptModuleCacheCopy(self): # If library or Module is binary do not skip by hash @@ -3929,7 +3962,7 @@ class ModuleAutoGen(AutoGen): for f_ext in self.SourceFileList: if '.inc' in str(f_ext): return False - FileDir = path.join(GlobalData.gBinCacheSource, self.PlatformInfo.Name, self.BuildTarget + "_" + self.ToolChain, self.Arch, self.SourceDir, self.MetaFile.BaseName) + FileDir = path.join(GlobalData.gBinCacheSource, self.PlatformInfo.OutputDir, self.BuildTarget + "_" + self.ToolChain, self.Arch, self.SourceDir, self.MetaFile.BaseName) HashFile = path.join(FileDir, self.Name + '.hash') if os.path.exists(HashFile): f = open(HashFile, 'r') @@ -3941,14 +3974,14 @@ class ModuleAutoGen(AutoGen): for root, dir, files in os.walk(FileDir): for f in files: if self.Name + '.hash' in f: - shutil.copy2(HashFile, self.BuildDir) + CopyFileOnChange(HashFile, self.BuildDir) else: File = path.join(root, f) sub_dir = os.path.relpath(File, FileDir) destination_file = os.path.join(self.OutputDir, sub_dir) destination_dir = os.path.dirname(destination_file) CreateDirectory(destination_dir) - shutil.copy2(File, destination_dir) + CopyFileOnChange(File, destination_dir) if self.Name == "PcdPeim" or self.Name == "PcdDxe": CreatePcdDatabaseCode(self, TemplateString(), TemplateString()) return True @@ -3961,7 +3994,7 @@ class ModuleAutoGen(AutoGen): # @cached_class_function def CreateMakeFile(self, CreateLibraryMakeFile=True, GenFfsList = []): - # nest this function inside it's only caller. + # nest this function inside its only caller. def CreateTimeStamp(): FileSet = {self.MetaFile.Path} @@ -3989,7 +4022,8 @@ class ModuleAutoGen(AutoGen): for LibraryAutoGen in self.LibraryAutoGenList: LibraryAutoGen.CreateMakeFile() - 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 if len(self.CustomMakefile) == 0: @@ -4032,7 +4066,8 @@ class ModuleAutoGen(AutoGen): for LibraryAutoGen in self.LibraryAutoGenList: LibraryAutoGen.CreateCodeFile() - 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 AutoGenList = []