From nobody Thu Sep 19 00:54:12 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1533309086904753.3979239624803; Fri, 3 Aug 2018 08:11:26 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id CF2AA210D852B; Fri, 3 Aug 2018 08:11:18 -0700 (PDT) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (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 6B11C210D83F6 for ; Fri, 3 Aug 2018 08:11:17 -0700 (PDT) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Aug 2018 08:11:16 -0700 Received: from jcarsey-desk1.amr.corp.intel.com ([10.7.159.144]) by orsmga004.jf.intel.com with ESMTP; 03 Aug 2018 08:11:16 -0700 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.136; helo=mga12.intel.com; envelope-from=jaben.carsey@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,439,1526367600"; d="scan'208";a="221541448" From: Jaben Carsey To: edk2-devel@lists.01.org Date: Fri, 3 Aug 2018 08:11:08 -0700 Message-Id: <718ca2724d8e08de0e94c2d30c719ccd8e1a85d6.1533308890.git.jaben.carsey@intel.com> X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: References: In-Reply-To: References: Subject: [edk2] [PATCH v1 3/5] BaseTools: AutoGen refactor to iterate less X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RDMRC_1 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Don't iterate over new dictionaries with one item Create the data and then add to dictionary. Note: if you diff ignoring whitespace changes you can more easily see the relevant changes. Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey --- BaseTools/Source/Python/AutoGen/AutoGen.py | 138 ++++++++++---------- 1 file changed, 66 insertions(+), 72 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/= Python/AutoGen/AutoGen.py index 55c84fe4fbc2..7c67f40bff00 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -2983,80 +2983,74 @@ class ModuleAutoGen(AutoGen): if self.DxsFile or self.IsLibrary or TAB_DEPENDENCY_EXPRESSION_FIL= E in self.FileTypes: return {} =20 - RetVal =3D {self.ModuleType:[]} - - for ModuleType in RetVal: - DepexList =3D RetVal[ModuleType] - # - # Append depex from dependent libraries, if not "BEFORE", "AFT= ER" expresion - # - for M in [self.Module] + self.DependentLibraryList: - Inherited =3D False - for D in M.Depex[self.Arch, ModuleType]: - if DepexList !=3D []: - DepexList.append('AND') - DepexList.append('(') - #replace D with value if D is FixedAtBuild PCD - NewList =3D [] - for item in D: - if '.' not in item: - NewList.append(item) + DepexList =3D [] + # + # Append depex from dependent libraries, if not "BEFORE", "AFTER" = expresion + # + for M in [self.Module] + self.DependentLibraryList: + Inherited =3D False + for D in M.Depex[self.Arch, self.ModuleType]: + if DepexList !=3D []: + DepexList.append('AND') + DepexList.append('(') + #replace D with value if D is FixedAtBuild PCD + NewList =3D [] + for item in D: + if '.' not in item: + NewList.append(item) + else: + if item not in self._FixedPcdVoidTypeDict: + EdkLogger.error("build", FORMAT_INVALID, "{} u= sed in [Depex] section should be used as FixedAtBuild type and VOID* datum = type in the module.".format(item)) else: - if item not in self._FixedPcdVoidTypeDict: - EdkLogger.error("build", FORMAT_INVALID, "= {} used in [Depex] section should be used as FixedAtBuild type and VOID* da= tum type in the module.".format(item)) - else: - Value =3D self._FixedPcdVoidTypeDict[item] - if len(Value.split(',')) !=3D 16: - EdkLogger.error("build", FORMAT_INVALI= D, - "{} used in [Depex] se= ction should be used as FixedAtBuild type and VOID* datum type and 16 bytes= in the module.".format(item)) - NewList.append(Value) - DepexList.extend(NewList) - if DepexList[-1] =3D=3D 'END': # no need of a END at = this time - DepexList.pop() - DepexList.append(')') - Inherited =3D True - if Inherited: - EdkLogger.verbose("DEPEX[%s] (+%s) =3D %s" % (self.Nam= e, M.BaseName, DepexList)) - if 'BEFORE' in DepexList or 'AFTER' in DepexList: - break - if len(DepexList) > 0: - EdkLogger.verbose('') - return RetVal - - ## Merge dependency expression - # - # @retval list The token list of the dependency expression af= ter parsed - # - @cached_property - def DepexExpressionTokenList(self): - if self.DxsFile or self.IsLibrary or TAB_DEPENDENCY_EXPRESSION_FIL= E in self.FileTypes: - return {} - - RetVal =3D {self.ModuleType:''} - - for ModuleType in RetVal: - DepexExpressionString =3D RetVal[ModuleType] - # - # Append depex from dependent libraries, if not "BEFORE", "AFT= ER" expresion - # - for M in [self.Module] + self.DependentLibraryList: - Inherited =3D False - for D in M.DepexExpression[self.Arch, ModuleType]: - if DepexExpressionString !=3D '': - DepexExpressionString +=3D ' AND ' - DepexExpressionString +=3D '(' - DepexExpressionString +=3D D - DepexExpressionString =3D DepexExpressionString.rstrip= ('END').strip() - DepexExpressionString +=3D ')' - Inherited =3D True - if Inherited: - EdkLogger.verbose("DEPEX[%s] (+%s) =3D %s" % (self.Nam= e, M.BaseName, DepexExpressionString)) - if 'BEFORE' in DepexExpressionString or 'AFTER' in DepexEx= pressionString: - break - if len(DepexExpressionString) > 0: + Value =3D self._FixedPcdVoidTypeDict[item] + if len(Value.split(',')) !=3D 16: + EdkLogger.error("build", FORMAT_INVALID, + "{} used in [Depex] sectio= n should be used as FixedAtBuild type and VOID* datum type and 16 bytes in = the module.".format(item)) + NewList.append(Value) + DepexList.extend(NewList) + if DepexList[-1] =3D=3D 'END': # no need of a END at this= time + DepexList.pop() + DepexList.append(')') + Inherited =3D True + if Inherited: + EdkLogger.verbose("DEPEX[%s] (+%s) =3D %s" % (self.Name, M= .BaseName, DepexList)) + if 'BEFORE' in DepexList or 'AFTER' in DepexList: + break + if len(DepexList) > 0: EdkLogger.verbose('') - RetVal[ModuleType] =3D DepexExpressionString - return RetVal + return {self.ModuleType:DepexList} + + ## Merge dependency expression + # + # @retval list The token list of the dependency expression af= ter parsed + # + @cached_property + def DepexExpressionTokenList(self): + if self.DxsFile or self.IsLibrary or TAB_DEPENDENCY_EXPRESSION_FIL= E in self.FileTypes: + return {} + + DepexExpressionString =3D '' + # + # Append depex from dependent libraries, if not "BEFORE", "AFTER" = expresion + # + for M in [self.Module] + self.DependentLibraryList: + Inherited =3D False + for D in M.DepexExpression[self.Arch, self.ModuleType]: + if DepexExpressionString !=3D '': + DepexExpressionString +=3D ' AND ' + DepexExpressionString +=3D '(' + DepexExpressionString +=3D D + DepexExpressionString =3D DepexExpressionString.rstrip('EN= D').strip() + DepexExpressionString +=3D ')' + Inherited =3D True + if Inherited: + EdkLogger.verbose("DEPEX[%s] (+%s) =3D %s" % (self.Name, M= .BaseName, DepexExpressionString)) + if 'BEFORE' in DepexExpressionString or 'AFTER' in DepexExpres= sionString: + break + if len(DepexExpressionString) > 0: + EdkLogger.verbose('') + + return {self.ModuleType:DepexExpressionString} =20 # Get the tiano core user extension, it is contain dependent library. # @retval: a list contain tiano core userextension. --=20 2.16.2.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel