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.20; helo=mga02.intel.com; envelope-from=jaben.carsey@intel.com; receiver=edk2-devel@lists.01.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 1D5382098EA76 for ; Thu, 19 Jul 2018 10:58:35 -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 orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Jul 2018 10:58:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,375,1526367600"; d="scan'208";a="74179172" Received: from jcarsey-desk1.amr.corp.intel.com ([10.7.159.144]) by orsmga001.jf.intel.com with ESMTP; 19 Jul 2018 10:58:33 -0700 From: Jaben Carsey To: edk2-devel@lists.01.org Cc: Liming Gao , Yonghong Zhu Date: Thu, 19 Jul 2018 10:57:39 -0700 Message-Id: X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: References: Subject: [PATCH v1 1/1] BaseTools: AutoGen - change class variable to funciton variable 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: , X-List-Received-Date: Thu, 19 Jul 2018 17:58:35 -0000 This variable is only used in one function, make it local there. Also when iterating on the variable, use dict.items() to get value instead of re-looking up the value multiple times. Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey --- BaseTools/Source/Python/AutoGen/GenMake.py | 25 ++++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/Python/AutoGen/GenMake.py index 992de5490dff..f1fe5514f3f2 100644 --- a/BaseTools/Source/Python/AutoGen/GenMake.py +++ b/BaseTools/Source/Python/AutoGen/GenMake.py @@ -435,7 +435,6 @@ cleanlib: self.ListFileMacros = {} self.FileCache = {} - self.FileDependency = [] self.LibraryBuildCommandList = [] self.LibraryFileList = [] self.LibraryMakefileList = [] @@ -890,26 +889,26 @@ cleanlib: if Item in SourceFileList: SourceFileList.remove(Item) - self.FileDependency = self.GetFileDependency( + FileDependencyDict = self.GetFileDependency( SourceFileList, ForceIncludedFile, self._AutoGenObject.IncludePathList + self._AutoGenObject.BuildOptionIncPathList ) DepSet = None - for File in self.FileDependency: - if not self.FileDependency[File]: - self.FileDependency[File] = ['$(FORCE_REBUILD)'] + for File,Dependency in FileDependencyDict.items(): + if not Dependency: + FileDependencyDict[File] = ['$(FORCE_REBUILD)'] continue - self._AutoGenObject.AutoGenDepSet |= set(self.FileDependency[File]) + self._AutoGenObject.AutoGenDepSet |= set(Dependency) # skip non-C files if File.Ext not in [".c", ".C"] or File.Name == "AutoGen.c": continue elif DepSet is None: - DepSet = set(self.FileDependency[File]) + DepSet = set(Dependency) else: - DepSet &= set(self.FileDependency[File]) + DepSet &= set(Dependency) # in case nothing in SourceFileList if DepSet is None: DepSet = set() @@ -919,13 +918,13 @@ cleanlib: for File in DepSet: self.CommonFileDependency.append(self.PlaceMacro(File.Path, self.Macros)) - for File in self.FileDependency: + for File in FileDependencyDict: # skip non-C files if File.Ext not in [".c", ".C"] or File.Name == "AutoGen.c": continue - NewDepSet = set(self.FileDependency[File]) + NewDepSet = set(FileDependencyDict[File]) NewDepSet -= DepSet - self.FileDependency[File] = ["$(COMMON_DEPS)"] + list(NewDepSet) + FileDependencyDict[File] = ["$(COMMON_DEPS)"] + list(NewDepSet) # Convert target description object to target string in makefile for Type in self._AutoGenObject.Targets: @@ -943,8 +942,8 @@ cleanlib: for Dep in T.Dependencies: Deps.append(self.PlaceMacro(str(Dep), self.Macros)) # Add inclusion-dependencies - if len(T.Inputs) == 1 and T.Inputs[0] in self.FileDependency: - for F in self.FileDependency[T.Inputs[0]]: + if len(T.Inputs) == 1 and T.Inputs[0] in FileDependencyDict: + for F in FileDependencyDict[T.Inputs[0]]: Deps.append(self.PlaceMacro(str(F), self.Macros)) # Add source-dependencies for F in T.Inputs: -- 2.16.2.windows.1