Re: [edk2] [PATCH v2 13/27] BaseTools: replace string constants used for module types

2018-04-27 Thread Zhu, Yonghong
Reviewed-by: Yonghong Zhu  

Best Regards,
Zhu Yonghong


-Original Message-
From: Carsey, Jaben 
Sent: Friday, April 27, 2018 12:58 AM
To: edk2-devel@lists.01.org
Cc: Gao, Liming ; Zhu, Yonghong 
Subject: [PATCH v2 13/27] BaseTools: replace string constants used for module 
types

replace raw strings in the code (note: except UPT) with constants.
SUP_MODULE_BASE was 'BASE'
SUP_MODULE_SEC was 'SEC'
SUP_MODULE_PEI_CORE was 'PEI_CORE'
SUP_MODULE_PEIM was 'PEIM'
SUP_MODULE_DXE_CORE was 'DXE_CORE'
SUP_MODULE_DXE_DRIVER was 'DXE_DRIVER'
SUP_MODULE_DXE_RUNTIME_DRIVER was 'DXE_RUNTIME_DRIVER'
SUP_MODULE_DXE_SAL_DRIVER was 'DXE_SAL_DRIVER'
SUP_MODULE_DXE_SMM_DRIVER was 'DXE_SMM_DRIVER'
SUP_MODULE_UEFI_DRIVER was 'UEFI_DRIVER'
SUP_MODULE_UEFI_APPLICATION was 'UEFI_APPLICATION'
SUP_MODULE_USER_DEFINED was 'USER_DEFINED'
SUP_MODULE_SMM_CORE was 'SMM_CORE'
SUP_MODULE_MM_STANDALONE was 'MM_STANDALONE'
SUP_MODULE_MM_CORE_STANDALONE was 'MM_CORE_STANDALONE'

v2 - fix Yonghong's comments.

Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey 
---
 BaseTools/Source/Python/AutoGen/AutoGen.py   |  20 ++--
 BaseTools/Source/Python/AutoGen/BuildEngine.py   |  10 +-
 BaseTools/Source/Python/AutoGen/GenC.py  | 120 ++--
 BaseTools/Source/Python/AutoGen/GenDepex.py  |  33 +++---
 BaseTools/Source/Python/Common/DataType.py   |   2 +-
 BaseTools/Source/Python/Ecc/Check.py |   6 +-
 BaseTools/Source/Python/GenFds/CompressSection.py|   3 +-
 BaseTools/Source/Python/GenFds/DataSection.py|   5 +-
 BaseTools/Source/Python/GenFds/DepexSection.py   |  11 +-
 BaseTools/Source/Python/GenFds/EfiSection.py |  17 +--
 BaseTools/Source/Python/GenFds/FdfParser.py  |  16 +--
 BaseTools/Source/Python/GenFds/Ffs.py|  41 +++
 BaseTools/Source/Python/GenFds/FfsInfStatement.py|  30 ++---
 BaseTools/Source/Python/GenFds/FvImageSection.py |   5 +-
 BaseTools/Source/Python/GenFds/GuidSection.py|   5 +-
 BaseTools/Source/Python/GenFds/UiSection.py  |   3 +-
 BaseTools/Source/Python/GenFds/VerSection.py |   3 +-
 BaseTools/Source/Python/Workspace/InfBuildData.py|  48 
 BaseTools/Source/Python/Workspace/WorkspaceCommon.py |   2 +-
 BaseTools/Source/Python/build/BuildReport.py |  56 -
 BaseTools/Source/Python/build/build.py   |  10 +-
 21 files changed, 228 insertions(+), 218 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py 
b/BaseTools/Source/Python/AutoGen/AutoGen.py
index dc82075c5876..2811952fe1d3 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -1430,7 +1430,7 @@ class PlatformAutoGen(AutoGen):
 # used by DXE module, it should be stored in DXE PCD 
database.
 # The default Phase is DXE
 #
-if M.ModuleType in ["PEIM", "PEI_CORE"]:
+if M.ModuleType in [SUP_MODULE_PEIM, SUP_MODULE_PEI_CORE]:
 PcdFromModule.Phase = "PEI"
 if PcdFromModule not in self._DynaPcdList_:
 self._DynaPcdList_.append(PcdFromModule)
@@ -1472,7 +1472,7 @@ class PlatformAutoGen(AutoGen):
 # make sure that the "VOID*" kind of datum has 
MaxDatumSize set
 if PcdFromModule.DatumType == TAB_VOID and 
PcdFromModule.MaxDatumSize in [None, '']:
 NoDatumTypePcdList.add("%s.%s [%s]" % 
(PcdFromModule.TokenSpaceGuidCName, PcdFromModule.TokenCName, InfName))
-if M.ModuleType in ["PEIM", "PEI_CORE"]:
+if M.ModuleType in [SUP_MODULE_PEIM, SUP_MODULE_PEI_CORE]:
 PcdFromModule.Phase = "PEI"
 if PcdFromModule not in self._DynaPcdList_ and 
PcdFromModule.Type in GenC.gDynamicExPcd:
 self._DynaPcdList_.append(PcdFromModule)
@@ -2203,7 +2203,7 @@ class PlatformAutoGen(AutoGen):
 
LibraryModule.LibraryClass.append(LibraryClassObject(LibraryClassName, 
[ModuleType]))
 elif LibraryModule.LibraryClass is None \
  or len(LibraryModule.LibraryClass) == 0 \
- or (ModuleType != 'USER_DEFINED'
+ or (ModuleType != SUP_MODULE_USER_DEFINED
  and ModuleType not in 
LibraryModule.LibraryClass[0].SupModList):
 # only USER_DEFINED can link against any library 
instance despite of its SupModList
 EdkLogger.error("build", OPTION_MISSING,
@@ -3969,8 +3969,8 @@ class ModuleAutoGen(AutoGen):
 break
 

[edk2] [PATCH v2 13/27] BaseTools: replace string constants used for module types

2018-04-26 Thread Jaben Carsey
replace raw strings in the code (note: except UPT) with constants.
SUP_MODULE_BASE was 'BASE'
SUP_MODULE_SEC was 'SEC'
SUP_MODULE_PEI_CORE was 'PEI_CORE'
SUP_MODULE_PEIM was 'PEIM'
SUP_MODULE_DXE_CORE was 'DXE_CORE'
SUP_MODULE_DXE_DRIVER was 'DXE_DRIVER'
SUP_MODULE_DXE_RUNTIME_DRIVER was 'DXE_RUNTIME_DRIVER'
SUP_MODULE_DXE_SAL_DRIVER was 'DXE_SAL_DRIVER'
SUP_MODULE_DXE_SMM_DRIVER was 'DXE_SMM_DRIVER'
SUP_MODULE_UEFI_DRIVER was 'UEFI_DRIVER'
SUP_MODULE_UEFI_APPLICATION was 'UEFI_APPLICATION'
SUP_MODULE_USER_DEFINED was 'USER_DEFINED'
SUP_MODULE_SMM_CORE was 'SMM_CORE'
SUP_MODULE_MM_STANDALONE was 'MM_STANDALONE'
SUP_MODULE_MM_CORE_STANDALONE was 'MM_CORE_STANDALONE'

v2 - fix Yonghong's comments.

Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey 
---
 BaseTools/Source/Python/AutoGen/AutoGen.py   |  20 ++--
 BaseTools/Source/Python/AutoGen/BuildEngine.py   |  10 +-
 BaseTools/Source/Python/AutoGen/GenC.py  | 120 ++--
 BaseTools/Source/Python/AutoGen/GenDepex.py  |  33 +++---
 BaseTools/Source/Python/Common/DataType.py   |   2 +-
 BaseTools/Source/Python/Ecc/Check.py |   6 +-
 BaseTools/Source/Python/GenFds/CompressSection.py|   3 +-
 BaseTools/Source/Python/GenFds/DataSection.py|   5 +-
 BaseTools/Source/Python/GenFds/DepexSection.py   |  11 +-
 BaseTools/Source/Python/GenFds/EfiSection.py |  17 +--
 BaseTools/Source/Python/GenFds/FdfParser.py  |  16 +--
 BaseTools/Source/Python/GenFds/Ffs.py|  41 +++
 BaseTools/Source/Python/GenFds/FfsInfStatement.py|  30 ++---
 BaseTools/Source/Python/GenFds/FvImageSection.py |   5 +-
 BaseTools/Source/Python/GenFds/GuidSection.py|   5 +-
 BaseTools/Source/Python/GenFds/UiSection.py  |   3 +-
 BaseTools/Source/Python/GenFds/VerSection.py |   3 +-
 BaseTools/Source/Python/Workspace/InfBuildData.py|  48 
 BaseTools/Source/Python/Workspace/WorkspaceCommon.py |   2 +-
 BaseTools/Source/Python/build/BuildReport.py |  56 -
 BaseTools/Source/Python/build/build.py   |  10 +-
 21 files changed, 228 insertions(+), 218 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py 
b/BaseTools/Source/Python/AutoGen/AutoGen.py
index dc82075c5876..2811952fe1d3 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -1430,7 +1430,7 @@ class PlatformAutoGen(AutoGen):
 # used by DXE module, it should be stored in DXE PCD 
database.
 # The default Phase is DXE
 #
-if M.ModuleType in ["PEIM", "PEI_CORE"]:
+if M.ModuleType in [SUP_MODULE_PEIM, SUP_MODULE_PEI_CORE]:
 PcdFromModule.Phase = "PEI"
 if PcdFromModule not in self._DynaPcdList_:
 self._DynaPcdList_.append(PcdFromModule)
@@ -1472,7 +1472,7 @@ class PlatformAutoGen(AutoGen):
 # make sure that the "VOID*" kind of datum has 
MaxDatumSize set
 if PcdFromModule.DatumType == TAB_VOID and 
PcdFromModule.MaxDatumSize in [None, '']:
 NoDatumTypePcdList.add("%s.%s [%s]" % 
(PcdFromModule.TokenSpaceGuidCName, PcdFromModule.TokenCName, InfName))
-if M.ModuleType in ["PEIM", "PEI_CORE"]:
+if M.ModuleType in [SUP_MODULE_PEIM, SUP_MODULE_PEI_CORE]:
 PcdFromModule.Phase = "PEI"
 if PcdFromModule not in self._DynaPcdList_ and 
PcdFromModule.Type in GenC.gDynamicExPcd:
 self._DynaPcdList_.append(PcdFromModule)
@@ -2203,7 +2203,7 @@ class PlatformAutoGen(AutoGen):
 
LibraryModule.LibraryClass.append(LibraryClassObject(LibraryClassName, 
[ModuleType]))
 elif LibraryModule.LibraryClass is None \
  or len(LibraryModule.LibraryClass) == 0 \
- or (ModuleType != 'USER_DEFINED'
+ or (ModuleType != SUP_MODULE_USER_DEFINED
  and ModuleType not in 
LibraryModule.LibraryClass[0].SupModList):
 # only USER_DEFINED can link against any library 
instance despite of its SupModList
 EdkLogger.error("build", OPTION_MISSING,
@@ -3969,8 +3969,8 @@ class ModuleAutoGen(AutoGen):
 break
 
 ModuleType = self.ModuleType
-if ModuleType == 'UEFI_DRIVER' and self.DepexGenerated:
-ModuleType = 'DXE_DRIVER'
+if ModuleType == SUP_MODULE_UEFI_DRIVER and self.DepexGenerated:
+ModuleType = SUP_MODULE_DXE_DRIVER
 
 DriverType = ''
 if self.PcdIsDriver != '':
@@ -4047,11 +4047,11 @@ class