public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch 2/2] BaseTools: Move Build Cache related function out of CreateAsBuiltInf
@ 2019-06-24  1:51 Bob Feng
  2019-06-24  7:19 ` Steven Shi
  0 siblings, 1 reply; 2+ messages in thread
From: Bob Feng @ 2019-06-24  1:51 UTC (permalink / raw)
  To: devel; +Cc: Bob Feng, Steven Shi, Liming Gao, Christian Rodriguez

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1932
There are two functions in current CreateAsBuiltInf, Copy Binary files
to build cache folder and create asbuild inf file.

This patch is to separate UpdateBuildCache and CreateAsBuiltInf into
two functions.

Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Steven Shi <steven.shi@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Christian Rodriguez <christian.rodriguez@intel.com>
---
 BaseTools/Source/Python/AutoGen/AutoGen.py | 68 +++++++++++++++++++++++++++++++++++++-------------------------------
 BaseTools/Source/Python/build/build.py     | 28 ++++++++++++++++++++++------
 2 files changed, 59 insertions(+), 37 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 45b81ed660..e8e09dc8a3 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -3577,23 +3577,41 @@ class ModuleAutoGen(AutoGen):
 
         fStringIO.close ()
         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):
-        self.OutputFile = set()
 
         if self.IsAsBuiltInfCreated:
             return
 
         # Skip INF file generation for libraries
         if self.IsLibrary:
-            # Only store the library cache if needed
-            if GlobalData.gBinCacheDest:
-                self.CopyModuleToCache()
             return
 
         # Skip the following code for modules with no source files
         if not self.SourceFileList:
             return
@@ -3710,11 +3728,10 @@ class ModuleAutoGen(AutoGen):
 
         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('/')
-            self.OutputFile.add(File)
             if os.path.isabs(File):
                 File = File.replace('\\', '/').strip('/').replace(OutputDir, '').strip('/')
             if Item.Target.Ext.lower() == '.aml':
                 AsBuiltInfDict['binary_item'].append('ASL|' + File)
             elif Item.Target.Ext.lower() == '.acpi':
@@ -3726,28 +3743,25 @@ class ModuleAutoGen(AutoGen):
         if not self.DepexGenerated:
             DepexFile = os.path.join(self.OutputDir, self.Name + '.depex')
             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]:
                 AsBuiltInfDict['binary_item'].append('DXE_DEPEX|' + self.Name + '.depex')
             elif self.ModuleType in [SUP_MODULE_DXE_SMM_DRIVER]:
                 AsBuiltInfDict['binary_item'].append('SMM_DEPEX|' + self.Name + '.depex')
 
         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)):
             if HeaderComments[Index].find('@BinaryHeader') != -1:
                 HeaderComments[Index] = HeaderComments[Index].replace('@BinaryHeader', '@file')
@@ -3912,43 +3926,35 @@ class ModuleAutoGen(AutoGen):
         AsBuiltInf.Append(gAsBuiltInfHeaderString.Replace(AsBuiltInfDict))
 
         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.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):
             CopyFileOnChange(HashFile, FileDir)
-        if not self.IsLibrary:
-            ModuleFile = path.join(self.OutputDir, self.Name + '.inf')
-            if os.path.exists(ModuleFile):
-                CopyFileOnChange(ModuleFile, FileDir)
-        else:
-            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('/')
-                self.OutputFile.add(File)
+        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)
-                    CopyFileOnChange(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
         if self.IsBinaryModule:
             return False
diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/build/build.py
index 3ece4d4c61..8c3315619a 100644
--- a/BaseTools/Source/Python/build/build.py
+++ b/BaseTools/Source/Python/build/build.py
@@ -1248,10 +1248,13 @@ class Build():
         # build modules
         if BuildModule:
             BuildCommand = BuildCommand + [Target]
             LaunchCommand(BuildCommand, AutoGenObject.MakeFileDir)
             self.CreateAsBuiltInf()
+            if GlobalData.gBinCacheDest:
+                self.UpdateBuildCache()
+            self.BuildModules = []
             return True
 
         # build library
         if Target == 'libraries':
             for Lib in AutoGenObject.LibraryBuildDirectoryList:
@@ -1266,10 +1269,13 @@ class Build():
                 LaunchCommand(NewBuildCommand, AutoGenObject.MakeFileDir)
             for Mod in AutoGenObject.ModuleBuildDirectoryList:
                 NewBuildCommand = BuildCommand + ['-f', os.path.normpath(os.path.join(Mod, makefile)), 'pbuild']
                 LaunchCommand(NewBuildCommand, AutoGenObject.MakeFileDir)
             self.CreateAsBuiltInf()
+            if GlobalData.gBinCacheDest:
+                self.UpdateBuildCache()
+            self.BuildModules = []
             return True
 
         # cleanlib
         if Target == 'cleanlib':
             for Lib in AutoGenObject.LibraryBuildDirectoryList:
@@ -1359,10 +1365,13 @@ class Build():
         if BuildModule:
             if Target != 'fds':
                 BuildCommand = BuildCommand + [Target]
             AutoGenObject.BuildTime = LaunchCommand(BuildCommand, AutoGenObject.MakeFileDir)
             self.CreateAsBuiltInf()
+            if GlobalData.gBinCacheDest:
+                self.UpdateBuildCache()
+            self.BuildModules = []
             return True
 
         # genfds
         if Target == 'fds':
             if GenFdsApi(AutoGenObject.GenFdsCommandDict, self.Db):
@@ -1872,10 +1881,13 @@ class Build():
 
                 MakeContiue = time.time()
                 ExitFlag.set()
                 BuildTask.WaitForComplete()
                 self.CreateAsBuiltInf()
+                if GlobalData.gBinCacheDest:
+                    self.UpdateBuildCache()
+                self.BuildModules = []
                 self.MakeTime += int(round((time.time() - MakeContiue)))
                 if BuildTask.HasError():
                     self.invalidateHash()
                     EdkLogger.error("build", BUILD_ERROR, "Failed to build module", ExtraData=GlobalData.gBuildingModule)
 
@@ -2072,10 +2084,13 @@ class Build():
                 # to exit if all tasks are completed
                 #
                 ExitFlag.set()
                 BuildTask.WaitForComplete()
                 self.CreateAsBuiltInf()
+                if GlobalData.gBinCacheDest:
+                    self.UpdateBuildCache()
+                self.BuildModules = []
                 self.MakeTime += int(round((time.time() - MakeContiue)))
                 #
                 # Check for build error, and raise exception if one
                 # has been signaled.
                 #
@@ -2211,28 +2226,29 @@ class Build():
 
         if self.Target == 'cleanall':
             RemoveDirectory(os.path.dirname(GlobalData.gDatabasePath), True)
 
     def CreateAsBuiltInf(self):
+        for Module in self.BuildModules:
+            Module.CreateAsBuiltInf()
+
+    def UpdateBuildCache(self):
         all_lib_set = set()
         all_mod_set = set()
         for Module in self.BuildModules:
-            Module.CreateAsBuiltInf()
+            Module.CopyModuleToCache()
             all_mod_set.add(Module)
         for Module in self.HashSkipModules:
-            if  GlobalData.gBinCacheDest:
-                Module.CopyModuleToCache()
+            Module.CopyModuleToCache()
             all_mod_set.add(Module)
         for Module in all_mod_set:
             for lib in Module.LibraryAutoGenList:
                 all_lib_set.add(lib)
         for lib in all_lib_set:
-            if  GlobalData.gBinCacheDest:
-                lib.CopyModuleToCache()
+            lib.CopyModuleToCache()
         all_lib_set.clear()
         all_mod_set.clear()
-        self.BuildModules = []
         self.HashSkipModules = []
     ## Do some clean-up works when error occurred
     def Relinquish(self):
         OldLogLevel = EdkLogger.GetLevel()
         EdkLogger.SetLevel(EdkLogger.ERROR)
-- 
2.20.1.windows.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Patch 2/2] BaseTools: Move Build Cache related function out of CreateAsBuiltInf
  2019-06-24  1:51 [Patch 2/2] BaseTools: Move Build Cache related function out of CreateAsBuiltInf Bob Feng
@ 2019-06-24  7:19 ` Steven Shi
  0 siblings, 0 replies; 2+ messages in thread
From: Steven Shi @ 2019-06-24  7:19 UTC (permalink / raw)
  To: Feng, Bob C, devel@edk2.groups.io; +Cc: Gao, Liming, Rodriguez, Christian

Reviewed-by: Steven Shi <steven.shi@intel.com>

> -----Original Message-----
> From: Feng, Bob C
> Sent: Monday, June 24, 2019 9:52 AM
> To: devel@edk2.groups.io
> Cc: Feng, Bob C <bob.c.feng@intel.com>; Shi, Steven <steven.shi@intel.com>;
> Gao, Liming <liming.gao@intel.com>; Rodriguez, Christian
> <christian.rodriguez@intel.com>
> Subject: [Patch 2/2] BaseTools: Move Build Cache related function out of
> CreateAsBuiltInf
> 
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1932
> There are two functions in current CreateAsBuiltInf, Copy Binary files
> to build cache folder and create asbuild inf file.
> 
> This patch is to separate UpdateBuildCache and CreateAsBuiltInf into
> two functions.
> 
> Signed-off-by: Bob Feng <bob.c.feng@intel.com>
> Cc: Steven Shi <steven.shi@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Christian Rodriguez <christian.rodriguez@intel.com>
> ---
>  BaseTools/Source/Python/AutoGen/AutoGen.py | 68
> +++++++++++++++++++++++++++++++++++++-------------------------------
>  BaseTools/Source/Python/build/build.py     | 28 ++++++++++++++++++++++----
> --
>  2 files changed, 59 insertions(+), 37 deletions(-)
> 
> diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py
> b/BaseTools/Source/Python/AutoGen/AutoGen.py
> index 45b81ed660..e8e09dc8a3 100644
> --- a/BaseTools/Source/Python/AutoGen/AutoGen.py
> +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
> @@ -3577,23 +3577,41 @@ class ModuleAutoGen(AutoGen):
> 
>          fStringIO.close ()
>          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):
> -        self.OutputFile = set()
> 
>          if self.IsAsBuiltInfCreated:
>              return
> 
>          # Skip INF file generation for libraries
>          if self.IsLibrary:
> -            # Only store the library cache if needed
> -            if GlobalData.gBinCacheDest:
> -                self.CopyModuleToCache()
>              return
> 
>          # Skip the following code for modules with no source files
>          if not self.SourceFileList:
>              return
> @@ -3710,11 +3728,10 @@ class ModuleAutoGen(AutoGen):
> 
>          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('/')
> -            self.OutputFile.add(File)
>              if os.path.isabs(File):
>                  File = File.replace('\\', '/').strip('/').replace(OutputDir, '').strip('/')
>              if Item.Target.Ext.lower() == '.aml':
>                  AsBuiltInfDict['binary_item'].append('ASL|' + File)
>              elif Item.Target.Ext.lower() == '.acpi':
> @@ -3726,28 +3743,25 @@ class ModuleAutoGen(AutoGen):
>          if not self.DepexGenerated:
>              DepexFile = os.path.join(self.OutputDir, self.Name + '.depex')
>              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]:
>                  AsBuiltInfDict['binary_item'].append('DXE_DEPEX|' + self.Name +
> '.depex')
>              elif self.ModuleType in [SUP_MODULE_DXE_SMM_DRIVER]:
>                  AsBuiltInfDict['binary_item'].append('SMM_DEPEX|' + self.Name +
> '.depex')
> 
>          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)):
>              if HeaderComments[Index].find('@BinaryHeader') != -1:
>                  HeaderComments[Index] =
> HeaderComments[Index].replace('@BinaryHeader', '@file')
> @@ -3912,43 +3926,35 @@ class ModuleAutoGen(AutoGen):
>          AsBuiltInf.Append(gAsBuiltInfHeaderString.Replace(AsBuiltInfDict))
> 
>          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.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):
>              CopyFileOnChange(HashFile, FileDir)
> -        if not self.IsLibrary:
> -            ModuleFile = path.join(self.OutputDir, self.Name + '.inf')
> -            if os.path.exists(ModuleFile):
> -                CopyFileOnChange(ModuleFile, FileDir)
> -        else:
> -            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('/')
> -                self.OutputFile.add(File)
> +        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)
> -                    CopyFileOnChange(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
>          if self.IsBinaryModule:
>              return False
> diff --git a/BaseTools/Source/Python/build/build.py
> b/BaseTools/Source/Python/build/build.py
> index 3ece4d4c61..8c3315619a 100644
> --- a/BaseTools/Source/Python/build/build.py
> +++ b/BaseTools/Source/Python/build/build.py
> @@ -1248,10 +1248,13 @@ class Build():
>          # build modules
>          if BuildModule:
>              BuildCommand = BuildCommand + [Target]
>              LaunchCommand(BuildCommand, AutoGenObject.MakeFileDir)
>              self.CreateAsBuiltInf()
> +            if GlobalData.gBinCacheDest:
> +                self.UpdateBuildCache()
> +            self.BuildModules = []
>              return True
> 
>          # build library
>          if Target == 'libraries':
>              for Lib in AutoGenObject.LibraryBuildDirectoryList:
> @@ -1266,10 +1269,13 @@ class Build():
>                  LaunchCommand(NewBuildCommand, AutoGenObject.MakeFileDir)
>              for Mod in AutoGenObject.ModuleBuildDirectoryList:
>                  NewBuildCommand = BuildCommand + ['-f',
> os.path.normpath(os.path.join(Mod, makefile)), 'pbuild']
>                  LaunchCommand(NewBuildCommand, AutoGenObject.MakeFileDir)
>              self.CreateAsBuiltInf()
> +            if GlobalData.gBinCacheDest:
> +                self.UpdateBuildCache()
> +            self.BuildModules = []
>              return True
> 
>          # cleanlib
>          if Target == 'cleanlib':
>              for Lib in AutoGenObject.LibraryBuildDirectoryList:
> @@ -1359,10 +1365,13 @@ class Build():
>          if BuildModule:
>              if Target != 'fds':
>                  BuildCommand = BuildCommand + [Target]
>              AutoGenObject.BuildTime = LaunchCommand(BuildCommand,
> AutoGenObject.MakeFileDir)
>              self.CreateAsBuiltInf()
> +            if GlobalData.gBinCacheDest:
> +                self.UpdateBuildCache()
> +            self.BuildModules = []
>              return True
> 
>          # genfds
>          if Target == 'fds':
>              if GenFdsApi(AutoGenObject.GenFdsCommandDict, self.Db):
> @@ -1872,10 +1881,13 @@ class Build():
> 
>                  MakeContiue = time.time()
>                  ExitFlag.set()
>                  BuildTask.WaitForComplete()
>                  self.CreateAsBuiltInf()
> +                if GlobalData.gBinCacheDest:
> +                    self.UpdateBuildCache()
> +                self.BuildModules = []
>                  self.MakeTime += int(round((time.time() - MakeContiue)))
>                  if BuildTask.HasError():
>                      self.invalidateHash()
>                      EdkLogger.error("build", BUILD_ERROR, "Failed to build module",
> ExtraData=GlobalData.gBuildingModule)
> 
> @@ -2072,10 +2084,13 @@ class Build():
>                  # to exit if all tasks are completed
>                  #
>                  ExitFlag.set()
>                  BuildTask.WaitForComplete()
>                  self.CreateAsBuiltInf()
> +                if GlobalData.gBinCacheDest:
> +                    self.UpdateBuildCache()
> +                self.BuildModules = []
>                  self.MakeTime += int(round((time.time() - MakeContiue)))
>                  #
>                  # Check for build error, and raise exception if one
>                  # has been signaled.
>                  #
> @@ -2211,28 +2226,29 @@ class Build():
> 
>          if self.Target == 'cleanall':
>              RemoveDirectory(os.path.dirname(GlobalData.gDatabasePath), True)
> 
>      def CreateAsBuiltInf(self):
> +        for Module in self.BuildModules:
> +            Module.CreateAsBuiltInf()
> +
> +    def UpdateBuildCache(self):
>          all_lib_set = set()
>          all_mod_set = set()
>          for Module in self.BuildModules:
> -            Module.CreateAsBuiltInf()
> +            Module.CopyModuleToCache()
>              all_mod_set.add(Module)
>          for Module in self.HashSkipModules:
> -            if  GlobalData.gBinCacheDest:
> -                Module.CopyModuleToCache()
> +            Module.CopyModuleToCache()
>              all_mod_set.add(Module)
>          for Module in all_mod_set:
>              for lib in Module.LibraryAutoGenList:
>                  all_lib_set.add(lib)
>          for lib in all_lib_set:
> -            if  GlobalData.gBinCacheDest:
> -                lib.CopyModuleToCache()
> +            lib.CopyModuleToCache()
>          all_lib_set.clear()
>          all_mod_set.clear()
> -        self.BuildModules = []
>          self.HashSkipModules = []
>      ## Do some clean-up works when error occurred
>      def Relinquish(self):
>          OldLogLevel = EdkLogger.GetLevel()
>          EdkLogger.SetLevel(EdkLogger.ERROR)
> --
> 2.20.1.windows.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-06-24  7:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-24  1:51 [Patch 2/2] BaseTools: Move Build Cache related function out of CreateAsBuiltInf Bob Feng
2019-06-24  7:19 ` Steven Shi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox