From nobody Fri Nov 1 03:33:52 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 Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1522789412676745.3299779913327; Tue, 3 Apr 2018 14:03:32 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 258D4226085BF; Tue, 3 Apr 2018 14:03:15 -0700 (PDT) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (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 52285226C7C35 for ; Tue, 3 Apr 2018 14:03:12 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Apr 2018 14:03:11 -0700 Received: from jcarsey-desk1.amr.corp.intel.com ([10.7.159.144]) by orsmga002.jf.intel.com with ESMTP; 03 Apr 2018 14:03:11 -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=134.134.136.31; helo=mga06.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.48,402,1517904000"; d="scan'208";a="47710175" From: Jaben Carsey To: edk2-devel@lists.01.org Date: Tue, 3 Apr 2018 14:03:08 -0700 Message-Id: <17db4173ab0c73eb8791ebef3ea0916c5e52a230.1522789210.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 08/10] BaseTools: use combined version of OrderedDict X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 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: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" since we need order and a default entry, use collections dicts to auto generate. Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey --- BaseTools/Source/Python/Workspace/WorkspaceCommon.py | 18 +++++++++++-----= -- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py b/BaseToo= ls/Source/Python/Workspace/WorkspaceCommon.py index abe34cf9a071..8c27b4ad5b9b 100644 --- a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py +++ b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py @@ -12,11 +12,17 @@ # =20 from Common.Misc import sdict +from collections import OrderedDict, defaultdict from Common.DataType import SUP_MODULE_USER_DEFINED from BuildClassObject import LibraryClassObject import Common.GlobalData as GlobalData from Workspace.BuildClassObject import StructurePcd =20 +class OrderedListDict(OrderedDict, defaultdict): + def __init__(self, *args, **kwargs): + super(OrderedListDict, self).__init__(*args, **kwargs) + self.default_factory =3D list + ## Get all packages from platform for specified arch, target and toolchain # # @param Platform: DscBuildData instance @@ -106,7 +112,7 @@ def _GetModuleLibraryInstances(Module, Platform, BuildD= atabase, Arch, Target, To # EdkII module LibraryConsumerList =3D [Module] Constructor =3D [] - ConsumedByList =3D sdict() + ConsumedByList =3D OrderedListDict() LibraryInstance =3D sdict() =20 while len(LibraryConsumerList) > 0: @@ -145,8 +151,6 @@ def _GetModuleLibraryInstances(Module, Platform, BuildD= atabase, Arch, Target, To if LibraryModule.ConstructorList !=3D [] and LibraryModule not= in Constructor: Constructor.append(LibraryModule) =20 - if LibraryModule not in ConsumedByList: - ConsumedByList[LibraryModule] =3D [] # don't add current module itself to consumer list if M !=3D Module: if M in ConsumedByList[LibraryModule]: @@ -164,7 +168,7 @@ def _GetModuleLibraryInstances(Module, Platform, BuildD= atabase, Arch, Target, To for LibraryClassName in LibraryInstance: M =3D LibraryInstance[LibraryClassName] LibraryList.append(M) - if ConsumedByList[M] =3D=3D []: + if len(ConsumedByList[M]) =3D=3D 0: Q.append(M) =20 # @@ -185,7 +189,7 @@ def _GetModuleLibraryInstances(Module, Platform, BuildD= atabase, Arch, Target, To # remove edge e from the graph if Node has no construc= tor ConsumedByList[Item].remove(Node) EdgeRemoved =3D True - if ConsumedByList[Item] =3D=3D []: + if len(ConsumedByList[Item]) =3D=3D 0: # insert Item into Q Q.insert(0, Item) break @@ -207,7 +211,7 @@ def _GetModuleLibraryInstances(Module, Platform, BuildD= atabase, Arch, Target, To # remove edge e from the graph ConsumedByList[Item].remove(Node) =20 - if ConsumedByList[Item] !=3D []: + if len(ConsumedByList[Item]) !=3D 0: continue # insert Item into Q, if Item has no other incoming edges Q.insert(0, Item) @@ -216,7 +220,7 @@ def _GetModuleLibraryInstances(Module, Platform, BuildD= atabase, Arch, Target, To # if any remaining node Item in the graph has a constructor and an inc= oming edge, then the graph has a cycle # for Item in LibraryList: - if ConsumedByList[Item] !=3D [] and Item in Constructor and len(Co= nstructor) > 1: + if len(ConsumedByList[Item]) !=3D 0 and Item in Constructor and le= n(Constructor) > 1: return [] if Item not in SortedLibraryList: SortedLibraryList.append(Item) --=20 2.16.2.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel