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 6A34F226EA5A1 for ; Fri, 20 Apr 2018 08:51:56 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Apr 2018 08:51:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,302,1520924400"; d="scan'208";a="44811589" Received: from jcarsey-desk1.amr.corp.intel.com ([10.7.159.144]) by orsmga003.jf.intel.com with ESMTP; 20 Apr 2018 08:51:53 -0700 From: Jaben Carsey To: edk2-devel@lists.01.org Cc: Liming Gao , Yonghong Zhu Date: Fri, 20 Apr 2018 08:51:35 -0700 Message-Id: X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: References: In-Reply-To: References: Subject: [PATCH v1 15/27] BaseTools: Share a dictionary instead of keeping multiples 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: , X-List-Received-Date: Fri, 20 Apr 2018 15:51:57 -0000 Move a dictionary to a shared location and use from there Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey --- BaseTools/Source/Python/Common/DataType.py | 15 ++++++++++++ BaseTools/Source/Python/Workspace/InfBuildData.py | 24 ++------------------ BaseTools/Source/Python/build/BuildReport.py | 19 ++-------------- 3 files changed, 19 insertions(+), 39 deletions(-) diff --git a/BaseTools/Source/Python/Common/DataType.py b/BaseTools/Source/Python/Common/DataType.py index 06e8defcf927..ab9acb417331 100644 --- a/BaseTools/Source/Python/Common/DataType.py +++ b/BaseTools/Source/Python/Common/DataType.py @@ -92,6 +92,21 @@ EDK_COMPONENT_TYPE_APPLICATION = 'APPLICATION' EDK_NAME = 'EDK' EDKII_NAME = 'EDKII' +COMPONENT_TO_MODULE_MAP_DICT = { + "LIBRARY" : SUP_MODULE_BASE, + "SECURITY_CORE" : SUP_MODULE_SEC, + SUP_MODULE_PEI_CORE : SUP_MODULE_PEI_CORE, + "COMBINED_PEIM_DRIVER" : SUP_MODULE_PEIM, + "PIC_PEIM" : SUP_MODULE_PEIM, + "RELOCATABLE_PEIM" : SUP_MODULE_PEIM, + "PE32_PEIM" : SUP_MODULE_PEIM, + "BS_DRIVER" : SUP_MODULE_DXE_DRIVER, + "RT_DRIVER" : SUP_MODULE_DXE_RUNTIME_DRIVER, + "SAL_RT_DRIVER" : SUP_MODULE_DXE_SAL_DRIVER, + "APPLICATION" : SUP_MODULE_UEFI_APPLICATION, + "LOGO" : SUP_MODULE_BASE, +} + BINARY_FILE_TYPE_FW = 'FW' BINARY_FILE_TYPE_GUID = 'GUID' BINARY_FILE_TYPE_PREEFORM = 'PREEFORM' diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py b/BaseTools/Source/Python/Workspace/InfBuildData.py index f2d36d0ee0d4..d64a281a98f7 100644 --- a/BaseTools/Source/Python/Workspace/InfBuildData.py +++ b/BaseTools/Source/Python/Workspace/InfBuildData.py @@ -66,26 +66,6 @@ class InfBuildData(ModuleBuildClassObject): TAB_COMPONENTS_SOURCE_OVERRIDE_PATH : "_SourceOverridePath", } - # dict used to convert Component type to Module type - _MODULE_TYPE_ = { - "LIBRARY" : SUP_MODULE_BASE, - "SECURITY_CORE" : SUP_MODULE_SEC, - SUP_MODULE_PEI_CORE : SUP_MODULE_PEI_CORE, - "COMBINED_PEIM_DRIVER" : SUP_MODULE_PEIM, - "PIC_PEIM" : SUP_MODULE_PEIM, - "RELOCATABLE_PEIM" : SUP_MODULE_PEIM, - "PE32_PEIM" : SUP_MODULE_PEIM, - "BS_DRIVER" : SUP_MODULE_DXE_DRIVER, - "RT_DRIVER" : SUP_MODULE_DXE_RUNTIME_DRIVER, - "SAL_RT_DRIVER" : SUP_MODULE_DXE_SAL_DRIVER, - SUP_MODULE_DXE_SMM_DRIVER : SUP_MODULE_DXE_SMM_DRIVER, - # "SMM_DRIVER" : SUP_MODULE_DXE_SMM_DRIVER, - # "BS_DRIVER" : SUP_MODULE_DXE_SMM_DRIVER, - # "BS_DRIVER" : SUP_MODULE_UEFI_DRIVER, - "APPLICATION" : SUP_MODULE_UEFI_APPLICATION, - "LOGO" : SUP_MODULE_BASE, - } - # regular expression for converting XXX_FLAGS in [nmake] section to new type _NMAKE_FLAG_PATTERN_ = re.compile("(?:EBC_)?([A-Z]+)_(?:STD_|PROJ_|ARCH_)?FLAGS(?:_DLL|_ASL|_EXE)?", re.UNICODE) # dict used to convert old tool name used in [nmake] section to new ones @@ -362,8 +342,8 @@ class InfBuildData(ModuleBuildClassObject): EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE, "COMPONENT_TYPE is not given", File=self.MetaFile) self._BuildType = self._ComponentType.upper() - if self._ComponentType in self._MODULE_TYPE_: - self._ModuleType = self._MODULE_TYPE_[self._ComponentType] + if self._ComponentType in COMPONENT_TO_MODULE_MAP_DICT: + self._ModuleType = COMPONENT_TO_MODULE_MAP_DICT[self._ComponentType] if self._ComponentType == 'LIBRARY': self._LibraryClass = [LibraryClassObject(self._BaseName, SUP_MODULE_LIST)] # make use some [nmake] section macros diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Source/Python/build/BuildReport.py index 2dfd78cb9538..5846c2870d2e 100644 --- a/BaseTools/Source/Python/build/BuildReport.py +++ b/BaseTools/Source/Python/build/BuildReport.py @@ -47,21 +47,6 @@ from Common.DataType import * import collections from Common.Expression import * -gComponentType2ModuleType = { - "LIBRARY" : SUP_MODULE_BASE, - "SECURITY_CORE" : SUP_MODULE_SEC, - SUP_MODULE_PEI_CORE : SUP_MODULE_PEI_CORE, - "COMBINED_PEIM_DRIVER" : SUP_MODULE_PEIM, - "PIC_PEIM" : SUP_MODULE_PEIM, - "RELOCATABLE_PEIM" : SUP_MODULE_PEIM, - "PE32_PEIM" : SUP_MODULE_PEIM, - "BS_DRIVER" : SUP_MODULE_DXE_DRIVER, - "RT_DRIVER" : SUP_MODULE_DXE_RUNTIME_DRIVER, - "SAL_RT_DRIVER" : SUP_MODULE_DXE_SAL_DRIVER, - "APPLICATION" : SUP_MODULE_UEFI_APPLICATION, - "LOGO" : SUP_MODULE_BASE, -} - ## Pattern to extract contents in EDK DXS files gDxsDependencyPattern = re.compile(r"DEPENDENCY_START(.+)DEPENDENCY_END", re.DOTALL) @@ -422,7 +407,7 @@ class DepexReport(object): self._DepexFileName = os.path.join(M.BuildDir, "OUTPUT", M.Module.BaseName + ".depex") ModuleType = M.ModuleType if not ModuleType: - ModuleType = gComponentType2ModuleType.get(M.ComponentType, "") + ModuleType = COMPONENT_TO_MODULE_MAP_DICT.get(M.ComponentType, "") if ModuleType in [SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MODULE_DXE_CORE, SUP_MODULE_SMM_CORE, SUP_MODULE_MM_CORE_STANDALONE, SUP_MODULE_UEFI_APPLICATION]: return @@ -587,7 +572,7 @@ class ModuleReport(object): if not M.IsLibrary: ModuleType = M.ModuleType if not ModuleType: - ModuleType = gComponentType2ModuleType.get(M.ComponentType, "") + ModuleType = COMPONENT_TO_MODULE_MAP_DICT.get(M.ComponentType, "") # # If a module complies to PI 1.1, promote Module type to "SMM_DRIVER" # -- 2.16.2.windows.1