BaseTools: Enhance Bin Cache database to support save the cache
authorRodriguez, Christian <christian.rodriguez@intel.com>
Thu, 18 Apr 2019 14:16:10 +0000 (22:16 +0800)
committerFeng, Bob C <bob.c.feng@intel.com>
Mon, 22 Apr 2019 08:50:24 +0000 (16:50 +0800)
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1726

V2: Added the platform name to the path
Add more level sub-directories in the database to support save
the cache for multiple platforms with multiple tool-chains and
targets, just like edk2 Build output.

Signed-off-by: Christian Rodriguez <christian.rodriguez@intel.com>
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
BaseTools/Source/Python/AutoGen/AutoGen.py

index 8648fc4..31721a6 100644 (file)
@@ -3897,18 +3897,17 @@ class ModuleAutoGen(AutoGen):
             self.CopyModuleToCache()\r
 \r
     def CopyModuleToCache(self):\r
-        FileDir = path.join(GlobalData.gBinCacheDest, self.Arch, self.SourceDir, self.MetaFile.BaseName)\r
+        FileDir = path.join(GlobalData.gBinCacheDest, self.PlatformInfo.Name, self.BuildTarget + "_" + self.ToolChain, self.Arch, self.SourceDir, self.MetaFile.BaseName)\r
         CreateDirectory (FileDir)\r
         HashFile = path.join(self.BuildDir, self.Name + '.hash')\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.IsLibrary:\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
-            Ma = self.BuildDatabase[PathClass(ModuleFile), self.Arch, self.BuildTarget, self.ToolChain]\r
+            Ma = self.BuildDatabase[self.MetaFile, self.Arch, self.BuildTarget, self.ToolChain]\r
             self.OutputFile = Ma.Binaries\r
         if self.OutputFile:\r
             for File in self.OutputFile:\r
@@ -3930,7 +3929,7 @@ class ModuleAutoGen(AutoGen):
         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
+        FileDir = path.join(GlobalData.gBinCacheSource, self.PlatformInfo.Name, self.BuildTarget + "_" + self.ToolChain, self.Arch, self.SourceDir, self.MetaFile.BaseName)\r
         HashFile = path.join(FileDir, self.Name + '.hash')\r
         if os.path.exists(HashFile):\r
             f = open(HashFile, 'r')\r