diff options
author | Carsey, Jaben </o=Intel/ou=Americas01/cn=Workers/cn=Carsey, Jaben> | 2018-04-06 07:13:51 +0800 |
---|---|---|
committer | Yonghong Zhu <yonghong.zhu@intel.com> | 2018-04-10 10:05:11 +0800 |
commit | a993dc03abf55bac0eead1efea7c4d15b8b8894a (patch) | |
tree | ee3165d60bdda5770c1d4493be10dc0a5d62f053 | |
parent | eb2c0b2c80fc684f7ff230daf99b9f0d2fb77d4a (diff) | |
download | edk2-a993dc03abf55bac0eead1efea7c4d15b8b8894a.zip edk2-a993dc03abf55bac0eead1efea7c4d15b8b8894a.tar.gz edk2-a993dc03abf55bac0eead1efea7c4d15b8b8894a.tar.bz2 |
BaseTools: defaultdict(set) allows us to just add to the set
New sets will get created automatically when needed
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@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>
-rw-r--r-- | BaseTools/Source/Python/AutoGen/AutoGen.py | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index 6b47aa2..cf6dcc6 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -46,6 +46,7 @@ import datetime import hashlib
from GenVar import VariableMgr,var_info
from collections import OrderedDict
+from collections import defaultdict
## Regular expression for splitting Dependency Expression string into tokens
gDepexTokenPattern = re.compile("(\(|\)|\w+| \S+\.inf)")
@@ -3483,8 +3484,8 @@ class ModuleAutoGen(AutoGen): if self._BuildTargets is None:
self._IntroBuildTargetList = set()
self._FinalBuildTargetList = set()
- self._BuildTargets = {}
- self._FileTypes = {}
+ self._BuildTargets = defaultdict(set)
+ self._FileTypes = defaultdict(set)
SubDirectory = os.path.join(self.OutputDir, File.SubDir)
if not os.path.exists(SubDirectory):
@@ -3521,8 +3522,6 @@ class ModuleAutoGen(AutoGen): break
FileType = RuleObject.SourceFileType
- if FileType not in self._FileTypes:
- self._FileTypes[FileType] = set()
self._FileTypes[FileType].add(Source)
# stop at STATIC_LIBRARY for library
@@ -3540,8 +3539,6 @@ class ModuleAutoGen(AutoGen): # Only do build for target with outputs
self._FinalBuildTargetList.add(Target)
- if FileType not in self._BuildTargets:
- self._BuildTargets[FileType] = set()
self._BuildTargets[FileType].add(Target)
if not Source.IsBinary and Source == File:
@@ -3560,8 +3557,8 @@ class ModuleAutoGen(AutoGen): if self._BuildTargets is None:
self._IntroBuildTargetList = set()
self._FinalBuildTargetList = set()
- self._BuildTargets = {}
- self._FileTypes = {}
+ self._BuildTargets = defaultdict(set)
+ self._FileTypes = defaultdict(set)
#TRICK: call _GetSourceFileList to apply build rule for source files
if self.SourceFileList:
|