]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/AutoGen/AutoGen.py
BaseTools: Move Build Cache related function out of CreateAsBuiltInf
[mirror_edk2.git] / BaseTools / Source / Python / AutoGen / AutoGen.py
index 45b81ed660e9d7815b83c65f45e5331e39d35da8..e8e09dc8a3660e7543d524ec068623dd4a955359 100644 (file)
@@ -3579,19 +3579,37 @@ class ModuleAutoGen(AutoGen):
         fInputfile.close ()\r
         return OutputName\r
 \r
+    @cached_property\r
+    def OutputFile(self):\r
+        retVal = set()\r
+        OutputDir = self.OutputDir.replace('\\', '/').strip('/')\r
+        DebugDir = self.DebugDir.replace('\\', '/').strip('/')\r
+        for Item in self.CodaTargetList:\r
+            File = Item.Target.Path.replace('\\', '/').strip('/').replace(DebugDir, '').replace(OutputDir, '').strip('/')\r
+            retVal.add(File)\r
+        if self.DepexGenerated:\r
+            retVal.add(self.Name + '.depex')\r
+\r
+        Bin = self._GenOffsetBin()\r
+        if Bin:\r
+            retVal.add(Bin)\r
+\r
+        for Root, Dirs, Files in os.walk(OutputDir):\r
+            for File in Files:\r
+                if File.lower().endswith('.pdb'):\r
+                    retVal.add(File)\r
+\r
+        return retVal\r
+\r
     ## Create AsBuilt INF file the module\r
     #\r
     def CreateAsBuiltInf(self):\r
-        self.OutputFile = set()\r
 \r
         if self.IsAsBuiltInfCreated:\r
             return\r
 \r
         # Skip INF file generation for libraries\r
         if self.IsLibrary:\r
-            # Only store the library cache if needed\r
-            if GlobalData.gBinCacheDest:\r
-                self.CopyModuleToCache()\r
             return\r
 \r
         # Skip the following code for modules with no source files\r
@@ -3712,7 +3730,6 @@ class ModuleAutoGen(AutoGen):
         DebugDir = self.DebugDir.replace('\\', '/').strip('/')\r
         for Item in self.CodaTargetList:\r
             File = Item.Target.Path.replace('\\', '/').strip('/').replace(DebugDir, '').replace(OutputDir, '').strip('/')\r
-            self.OutputFile.add(File)\r
             if os.path.isabs(File):\r
                 File = File.replace('\\', '/').strip('/').replace(OutputDir, '').strip('/')\r
             if Item.Target.Ext.lower() == '.aml':\r
@@ -3728,7 +3745,6 @@ class ModuleAutoGen(AutoGen):
             if os.path.exists(DepexFile):\r
                 self.DepexGenerated = True\r
         if self.DepexGenerated:\r
-            self.OutputFile.add(self.Name + '.depex')\r
             if self.ModuleType in [SUP_MODULE_PEIM]:\r
                 AsBuiltInfDict['binary_item'].append('PEI_DEPEX|' + self.Name + '.depex')\r
             elif self.ModuleType in [SUP_MODULE_DXE_DRIVER, SUP_MODULE_DXE_RUNTIME_DRIVER, SUP_MODULE_DXE_SAL_DRIVER, SUP_MODULE_UEFI_DRIVER]:\r
@@ -3739,13 +3755,11 @@ class ModuleAutoGen(AutoGen):
         Bin = self._GenOffsetBin()\r
         if Bin:\r
             AsBuiltInfDict['binary_item'].append('BIN|%s' % Bin)\r
-            self.OutputFile.add(Bin)\r
 \r
         for Root, Dirs, Files in os.walk(OutputDir):\r
             for File in Files:\r
                 if File.lower().endswith('.pdb'):\r
                     AsBuiltInfDict['binary_item'].append('DISPOSABLE|' + File)\r
-                    self.OutputFile.add(File)\r
         HeaderComments = self.Module.HeaderComments\r
         StartPos = 0\r
         for Index in range(len(HeaderComments)):\r
@@ -3914,8 +3928,6 @@ class ModuleAutoGen(AutoGen):
         SaveFileOnChange(os.path.join(self.OutputDir, self.Name + '.inf'), str(AsBuiltInf), False)\r
 \r
         self.IsAsBuiltInfCreated = True\r
-        if GlobalData.gBinCacheDest:\r
-            self.CopyModuleToCache()\r
 \r
     def CopyModuleToCache(self):\r
         FileDir = path.join(GlobalData.gBinCacheDest, self.PlatformInfo.OutputDir, self.BuildTarget + "_" + self.ToolChain, self.Arch, self.SourceDir, self.MetaFile.BaseName)\r
@@ -3923,30 +3935,24 @@ class ModuleAutoGen(AutoGen):
         HashFile = path.join(self.BuildDir, self.Name + '.hash')\r
         if os.path.exists(HashFile):\r
             CopyFileOnChange(HashFile, FileDir)\r
-        if not self.IsLibrary:\r
-            ModuleFile = path.join(self.OutputDir, self.Name + '.inf')\r
-            if os.path.exists(ModuleFile):\r
-                CopyFileOnChange(ModuleFile, FileDir)\r
-        else:\r
-            OutputDir = self.OutputDir.replace('\\', '/').strip('/')\r
-            DebugDir = self.DebugDir.replace('\\', '/').strip('/')\r
-            for Item in self.CodaTargetList:\r
-                File = Item.Target.Path.replace('\\', '/').strip('/').replace(DebugDir, '').replace(OutputDir, '').strip('/')\r
-                self.OutputFile.add(File)\r
+        ModuleFile = path.join(self.OutputDir, self.Name + '.inf')\r
+        if os.path.exists(ModuleFile):\r
+            CopyFileOnChange(ModuleFile, FileDir)\r
+\r
         if not self.OutputFile:\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
-                File = str(File)\r
-                if not os.path.isabs(File):\r
-                    File = os.path.join(self.OutputDir, File)\r
-                if os.path.exists(File):\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
-                    CopyFileOnChange(File, destination_dir)\r
+\r
+        for File in self.OutputFile:\r
+            File = str(File)\r
+            if not os.path.isabs(File):\r
+                File = os.path.join(self.OutputDir, File)\r
+            if os.path.exists(File):\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
+                CopyFileOnChange(File, destination_dir)\r
 \r
     def AttemptModuleCacheCopy(self):\r
         # If library or Module is binary do not skip by hash\r