]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: refactor to not overcreate ModuleAutoGen objects
authorCarsey, Jaben <jaben.carsey@intel.com>
Mon, 10 Sep 2018 22:18:08 +0000 (06:18 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Thu, 20 Sep 2018 14:18:08 +0000 (22:18 +0800)
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>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
BaseTools/Source/Python/AutoGen/AutoGen.py

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