- self.CacheCopyFile(FileDir, self.OutputDir, File)\r
-\r
- def SaveHashChainFileToCache(self, gDict):\r
- if not GlobalData.gBinCacheDest:\r
- return False\r
-\r
- self.GenPreMakefileHash(gDict)\r
- if not (self.MetaFile.Path, self.Arch) in gDict or \\r
- not gDict[(self.MetaFile.Path, self.Arch)].PreMakefileHashHexDigest:\r
- EdkLogger.quiet("[cache warning]: Cannot generate PreMakefileHash for module: %s[%s]" % (self.MetaFile.Path, self.Arch))\r
- return False\r
-\r
- self.GenMakeHash(gDict)\r
- if not (self.MetaFile.Path, self.Arch) in gDict or \\r
- not gDict[(self.MetaFile.Path, self.Arch)].MakeHashChain or \\r
- not gDict[(self.MetaFile.Path, self.Arch)].MakeHashHexDigest:\r
- EdkLogger.quiet("[cache warning]: Cannot generate MakeHashChain for module: %s[%s]" % (self.MetaFile.Path, self.Arch))\r
- return False\r
-\r
- # save the hash chain list as cache file\r
- MakeHashStr = str(GlobalData.gCacheIR[(self.MetaFile.Path, self.Arch)].MakeHashHexDigest)\r
- CacheDestDir = path.join(GlobalData.gBinCacheDest, self.PlatformInfo.OutputDir, self.BuildTarget + "_" + self.ToolChain, self.Arch, self.SourceDir, self.MetaFile.BaseName)\r
- CacheHashDestDir = path.join(CacheDestDir, MakeHashStr)\r
- ModuleHashPair = path.join(CacheDestDir, self.Name + ".ModuleHashPair")\r
- MakeHashChain = path.join(CacheHashDestDir, self.Name + ".MakeHashChain")\r
- ModuleFilesChain = path.join(CacheHashDestDir, self.Name + ".ModuleFilesChain")\r
-\r
- # save the HashChainDict as json file\r
- CreateDirectory (CacheDestDir)\r
- CreateDirectory (CacheHashDestDir)\r
- try:\r
- ModuleHashPairList = [] # tuple list: [tuple(PreMakefileHash, MakeHash)]\r
- if os.path.exists(ModuleHashPair):\r
- with open(ModuleHashPair, 'r') as f:\r
- ModuleHashPairList = json.load(f)\r
- PreMakeHash = gDict[(self.MetaFile.Path, self.Arch)].PreMakefileHashHexDigest\r
- MakeHash = gDict[(self.MetaFile.Path, self.Arch)].MakeHashHexDigest\r
- ModuleHashPairList.append((PreMakeHash, MakeHash))\r
- ModuleHashPairList = list(set(map(tuple, ModuleHashPairList)))\r
- with open(ModuleHashPair, 'w') as f:\r
- json.dump(ModuleHashPairList, f, indent=2)\r
- except:\r
- EdkLogger.quiet("[cache warning]: fail to save ModuleHashPair file in cache: %s" % ModuleHashPair)\r
- return False\r
-\r
- try:\r
- with open(MakeHashChain, 'w') as f:\r
- json.dump(gDict[(self.MetaFile.Path, self.Arch)].MakeHashChain, f, indent=2)\r
- except:\r
- EdkLogger.quiet("[cache warning]: fail to save MakeHashChain file in cache: %s" % MakeHashChain)\r
- return False\r
-\r
- try:\r
- with open(ModuleFilesChain, 'w') as f:\r
- json.dump(gDict[(self.MetaFile.Path, self.Arch)].ModuleFilesChain, f, indent=2)\r
- except:\r
- EdkLogger.quiet("[cache warning]: fail to save ModuleFilesChain file in cache: %s" % ModuleFilesChain)\r
- return False\r
-\r
- # save the autogenfile and makefile for debug usage\r
- CacheDebugDir = path.join(CacheHashDestDir, "CacheDebug")\r
- CreateDirectory (CacheDebugDir)\r
- CopyFileOnChange(gDict[(self.MetaFile.Path, self.Arch)].MakefilePath, CacheDebugDir)\r
- if gDict[(self.MetaFile.Path, self.Arch)].AutoGenFileList:\r
- for File in gDict[(self.MetaFile.Path, self.Arch)].AutoGenFileList:\r
- CopyFileOnChange(str(File), CacheDebugDir)\r
-\r
- return True\r
-\r