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>,
	Bob Feng <bob.c.feng@intel.com>
Subject: [PATCH v1 8/9] BaseTools: refactor to not overcreate ModuleAutoGen objects
Date: Wed, 29 Aug 2018 08:45:43 -0700	[thread overview]
Message-ID: <fbf7b4437b68a199f77fd7fabb35245f545e9383.1535557474.git.jaben.carsey@intel.com> (raw)
In-Reply-To: <cover.1535557474.git.jaben.carsey@intel.com>
In-Reply-To: <cover.1535557474.git.jaben.carsey@intel.com>

currently created for 3 different purposes and saved once.
this makes it created once and saved and then referenced.

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

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
index b8ee9980ae39..ebc2a202338f 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -1085,21 +1085,19 @@ class PlatformAutoGen(AutoGen):
     def GenFdsCommand(self):
         return self.Workspace.GenFdsCommand
 
-    ## Create makefile for the platform and mdoules in it
+    ## Create makefile for the platform and modules in it
     #
     #   @param      CreateModuleMakeFile    Flag indicating if the makefile for
     #                                       modules will be created as well
     #
     def CreateMakeFile(self, CreateModuleMakeFile=False, FfsCommand = {}):
         if CreateModuleMakeFile:
-            for ModuleFile in self.Platform.Modules:
-                Ma = ModuleAutoGen(self.Workspace, ModuleFile, self.BuildTarget,
-                                   self.ToolChain, self.Arch, self.MetaFile)
-                if (ModuleFile.File, self.Arch) in FfsCommand:
-                    Ma.CreateMakeFile(True, FfsCommand[ModuleFile.File, self.Arch])
+            for Ma in self._MaList:
+                key = (Ma.MetaFile.File, self.Arch)
+                if key in FfsCommand:
+                    Ma.CreateMakeFile(True, FfsCommand[key])
                 else:
                     Ma.CreateMakeFile(True)
-                #Ma.CreateAsBuiltInf()
 
         # no need to create makefile for the platform more than once
         if self.IsMakeFileCreated:
@@ -1231,16 +1229,11 @@ class PlatformAutoGen(AutoGen):
         for InfName in self._AsBuildInfList:
             InfName = mws.join(self.WorkspaceDir, InfName)
             FdfModuleList.append(os.path.normpath(InfName))
-        for F in self.Platform.Modules.keys():
-            M = ModuleAutoGen(self.Workspace, F, self.BuildTarget, self.ToolChain, self.Arch, self.MetaFile)
-            #GuidValue.update(M.Guids)
-
-            self.Platform.Modules[F].M = M
-
+        for M in self._MaList:
             for PcdFromModule in M.ModulePcdList + M.LibraryPcdList:
                 # make sure that the "VOID*" kind of datum has MaxDatumSize set
                 if PcdFromModule.DatumType == TAB_VOID and not PcdFromModule.MaxDatumSize:
-                    NoDatumTypePcdList.add("%s.%s [%s]" % (PcdFromModule.TokenSpaceGuidCName, PcdFromModule.TokenCName, F))
+                    NoDatumTypePcdList.add("%s.%s [%s]" % (PcdFromModule.TokenSpaceGuidCName, PcdFromModule.TokenCName, M.MetaFile))
 
                 # Check the PCD from Binary INF or Source INF
                 if M.IsBinaryModule == True:
@@ -1250,7 +1243,7 @@ class PlatformAutoGen(AutoGen):
                 PcdFromModule.IsFromDsc = (PcdFromModule.TokenCName, PcdFromModule.TokenSpaceGuidCName) in self.Platform.Pcds
 
                 if PcdFromModule.Type in PCD_DYNAMIC_TYPE_SET or PcdFromModule.Type in PCD_DYNAMIC_EX_TYPE_SET:
-                    if F.Path not in FdfModuleList:
+                    if M.MetaFile.Path not in FdfModuleList:
                         # If one of the Source built modules listed in the DSC is not listed
                         # in FDF modules, and the INF lists a PCD can only use the PcdsDynamic
                         # access method (it is only listed in the DEC file that declares the
@@ -1930,19 +1923,25 @@ class PlatformAutoGen(AutoGen):
             TokenNumber += 1
         return RetVal
 
+    @cached_property
+    def _MaList(self):
+        for ModuleFile in self.Platform.Modules:
+            Ma = ModuleAutoGen(
+                  self.Workspace,
+                  ModuleFile,
+                  self.BuildTarget,
+                  self.ToolChain,
+                  self.Arch,
+                  self.MetaFile
+                  )
+            ModuleFile.M = Ma
+        return [x.M for x in self.Platform.Modules]
+
     ## Summarize ModuleAutoGen objects of all modules to be built for this platform
     @cached_property
     def ModuleAutoGenList(self):
         RetVal = []
-        for ModuleFile in self.Platform.Modules:
-            Ma = ModuleAutoGen(
-                    self.Workspace,
-                    ModuleFile,
-                    self.BuildTarget,
-                    self.ToolChain,
-                    self.Arch,
-                    self.MetaFile
-                    )
+        for Ma in self._MaList:
             if Ma not in RetVal:
                 RetVal.append(Ma)
         return RetVal
@@ -1951,15 +1950,7 @@ class PlatformAutoGen(AutoGen):
     @cached_property
     def LibraryAutoGenList(self):
         RetVal = []
-        for ModuleFile in self.Platform.Modules:
-            Ma = ModuleAutoGen(
-                    self.Workspace,
-                    ModuleFile,
-                    self.BuildTarget,
-                    self.ToolChain,
-                    self.Arch,
-                    self.MetaFile
-                    )
+        for Ma in self._MaList:
             for La in Ma.LibraryAutoGenList:
                 if La not in RetVal:
                     RetVal.append(La)
-- 
2.16.2.windows.1



  parent reply	other threads:[~2018-08-29 15:50 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-29 15:45 [PATCH v1 0/9] BaseTools: refactor Workspace classes Jaben Carsey
2018-08-29 15:45 ` [PATCH v1 1/9] BaseTools: Refactor PlatformAutoGen Jaben Carsey
2018-08-29 15:45 ` [PATCH v1 2/9] BaseTools: AutoGen refactor WorkspaceAutoGen class Jaben Carsey
2018-08-29 15:45 ` [PATCH v1 3/9] BaseTools: AutoGen - refactor class properties Jaben Carsey
2018-08-29 15:45 ` [PATCH v1 4/9] BaseTools: " Jaben Carsey
2018-08-29 15:45 ` [PATCH v1 5/9] BaseTools: Workspace classes refactor properties Jaben Carsey
2018-08-29 15:45 ` [PATCH v1 6/9] BaseTools: refactor Build Database objects Jaben Carsey
2018-08-29 15:45 ` [PATCH v1 7/9] BaseTools: Don't save unused workspace data Jaben Carsey
2018-08-29 15:45 ` Jaben Carsey [this message]
2018-08-29 15:45 ` [PATCH v1 9/9] BaseTools: refactor to cache InfBuildData data Jaben Carsey

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=fbf7b4437b68a199f77fd7fabb35245f545e9383.1535557474.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