From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.100; helo=mga07.intel.com; envelope-from=jaben.carsey@intel.com; receiver=edk2-devel@lists.01.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 57B1D21106C75 for ; Wed, 29 Aug 2018 08:50:31 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Aug 2018 08:50:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,303,1531810800"; d="scan'208";a="85959644" Received: from jcarsey-desk1.amr.corp.intel.com ([10.7.159.144]) by orsmga001.jf.intel.com with ESMTP; 29 Aug 2018 08:50:30 -0700 From: Jaben Carsey To: edk2-devel@lists.01.org Cc: Liming Gao , Yonghong Zhu , Bob Feng Date: Wed, 29 Aug 2018 08:45:43 -0700 Message-Id: X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: References: In-Reply-To: References: Subject: [PATCH v1 8/9] BaseTools: refactor to not overcreate ModuleAutoGen objects X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Aug 2018 15:50:31 -0000 currently created for 3 different purposes and saved once. this makes it created once and saved and then referenced. Cc: Liming Gao Cc: Yonghong Zhu Cc: Bob Feng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey --- 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