public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Jaben Carsey <jaben.carsey@intel.com>
To: edk2-devel@lists.01.org
Cc: Liming Gao <liming.gao@intel.com>, Yonghong Zhu <yonghong.zhu@intel.com>
Subject: [PATCH v1 2/5] BaseTools: AutoGen - tag a function as cachable
Date: Fri,  3 Aug 2018 08:11:07 -0700	[thread overview]
Message-ID: <f8d67fc3fe5f86dc400b0532a25f6ce2faeff412.1533308890.git.jaben.carsey@intel.com> (raw)
In-Reply-To: <cover.1533308890.git.jaben.carsey@intel.com>
In-Reply-To: <cover.1533308890.git.jaben.carsey@intel.com>

MakeFile generation is once per module, so mark it as such.
also move the time stamp creation function inside as it's
only called from one place.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
---
 BaseTools/Source/Python/AutoGen/AutoGen.py | 46 ++++++++++----------
 1 file changed, 22 insertions(+), 24 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 1515a52758de..55c84fe4fbc2 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -54,7 +54,7 @@ from collections import OrderedDict
 from collections import defaultdict
 from Workspace.WorkspaceCommon import OrderedListDict
 
-from Common.caching import cached_property
+from Common.caching import cached_property, cached_class_function
 
 ## Regular expression for splitting Dependency Expression string into tokens
 gDepexTokenPattern = re.compile("(\(|\)|\w+| \S+\.inf)")
@@ -2677,7 +2677,6 @@ class ModuleAutoGen(AutoGen):
         self.ToolChainFamily = self.PlatformInfo.ToolChainFamily
         self.BuildRuleFamily = self.PlatformInfo.BuildRuleFamily
 
-        self.IsMakeFileCreated = False
         self.IsCodeFileCreated = False
         self.IsAsBuiltInfCreated = False
         self.DepexGenerated = False
@@ -4084,13 +4083,31 @@ class ModuleAutoGen(AutoGen):
     #   @param      CreateLibraryMakeFile   Flag indicating if or not the makefiles of
     #                                       dependent libraries will be created
     #
+    @cached_class_function
     def CreateMakeFile(self, CreateLibraryMakeFile=True, GenFfsList = []):
+        # nest this function inside it's only caller.
+        def CreateTimeStamp():
+            FileSet = {self.MetaFile.Path}
+
+            for SourceFile in self.Module.Sources:
+                FileSet.add (SourceFile.Path)
+
+            for Lib in self.DependentLibraryList:
+                FileSet.add (Lib.MetaFile.Path)
+
+            for f in self.AutoGenDepSet:
+                FileSet.add (f.Path)
+
+            if os.path.exists (self.TimeStampPath):
+                os.remove (self.TimeStampPath)
+            with open(self.TimeStampPath, 'w+') as file:
+                for f in FileSet:
+                    print(f, file=file)
+
         # Ignore generating makefile when it is a binary module
         if self.IsBinaryModule:
             return
 
-        if self.IsMakeFileCreated:
-            return
         self.GenFfsList = GenFfsList
         if not self.IsLibrary and CreateLibraryMakeFile:
             for LibraryAutoGen in self.LibraryAutoGenList:
@@ -4110,8 +4127,7 @@ class ModuleAutoGen(AutoGen):
             EdkLogger.debug(EdkLogger.DEBUG_9, "Skipped the generation of makefile for module %s [%s]" %
                             (self.Name, self.Arch))
 
-        self.CreateTimeStamp()
-        self.IsMakeFileCreated = True
+        CreateTimeStamp()
 
     def CopyBinaryFiles(self):
         for File in self.Module.Binaries:
@@ -4284,21 +4300,3 @@ class ModuleAutoGen(AutoGen):
     @cached_property
     def TimeStampPath(self):
         return os.path.join(self.MakeFileDir, 'AutoGenTimeStamp')
-
-    def CreateTimeStamp(self):
-        FileSet = {self.MetaFile.Path}
-
-        for SourceFile in self.Module.Sources:
-            FileSet.add (SourceFile.Path)
-
-        for Lib in self.DependentLibraryList:
-            FileSet.add (Lib.MetaFile.Path)
-
-        for f in self.AutoGenDepSet:
-            FileSet.add (f.Path)
-
-        if os.path.exists (self.TimeStampPath):
-            os.remove (self.TimeStampPath)
-        with open(self.TimeStampPath, 'w+') as file:
-            for f in FileSet:
-                print(f, file=file)
-- 
2.16.2.windows.1



  parent reply	other threads:[~2018-08-03 15:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-03 15:11 [PATCH v1 0/5] Refactor AutoGen - class ModuleAutoGen Jaben Carsey
2018-08-03 15:11 ` [PATCH v1 1/5] BaseTools: AutoGen refactor ModuleAutoGen caching Jaben Carsey
2018-08-03 15:11 ` Jaben Carsey [this message]
2018-08-03 15:11 ` [PATCH v1 3/5] BaseTools: AutoGen refactor to iterate less Jaben Carsey
2018-08-03 15:46 ` [PATCH v1 0/5] Refactor AutoGen - class ModuleAutoGen Carsey, Jaben
2018-08-13  1:21   ` Zhu, Yonghong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f8d67fc3fe5f86dc400b0532a25f6ce2faeff412.1533308890.git.jaben.carsey@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox