public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v1 00/27] BaseTools refactoring
@ 2018-04-20 15:51 Jaben Carsey
  2018-04-20 15:51 ` [PATCH v1 01/27] BaseTools: Misc - refactor RegEx to minimize multiple compiling Jaben Carsey
                   ` (26 more replies)
  0 siblings, 27 replies; 56+ messages in thread
From: Jaben Carsey @ 2018-04-20 15:51 UTC (permalink / raw)
  To: edk2-devel

remove unused code/variables/file
move re.compile to eliminate recompiling same expression
replace string constants in code with predefined constants
(including sets, preferred for "in" testing, and lists of string constants)
(include making new constants, sets, and lists)
switch dict to defaultdict to eliminate initialization code
dont compare using "in [None,'']" as python does that by default
use a shared Component to Module map

Jaben Carsey (27):
  BaseTools: Misc - refactor RegEx to minimize multiple compiling
  BaseTools: GenPatchPcdTable - refactor RegEx to minimize multiple
    compiling
  BaseTools: Share RegEx between files
  BaseTools: Workspace - refactor RegEx to minimize multiple compiling
  BaseTools: Autogen - replace string constants with those from DataType
  BaseTools: simplify if call
  BaseTools: Workspace - refactor GetStructurePcdInfo
  BaseTools: AutoGen - remove dictionary populated, but never accessed
  BaseTools: AutoGen - remove unused variables.
  BaseTools: Remove extra .keys()
  BaseTools: Workspace/MetaFileParser - refactor dicts
  BaseTools: remove dict from DscBuildData
  BaseTools: replace string constants used for module types
  BaseTools: Define and use a set for common list
  BaseTools: Share a dictionary instead of keeping multiples
  BaseTools: Replace EDK Component strings with predefined constant
  BaseTools: DataType - cleanup list constants
  BaseTools: Replace PCD type strings with predefined constant
  BaseTools: Replace Binary File type strings with predefined constant
  BaseTools: remove duplicate variable
  BaseTools: replace string with predefined constant
  BaseTools: remove redundant if comparison
  BaseTools: AutoGen - use dafultdict instead of dict
  BaseTools: GenFds - simplify testing for Hex number
  BaseTools: AutoGen - use defaultdict to auto initialize
  BaseTools: remove unused MigrationUtilities.py
  BaseTools: CommonClass - remove unused classes

 BaseTools/Source/Python/AutoGen/AutoGen.py                   | 153 +++---
 BaseTools/Source/Python/AutoGen/BuildEngine.py               |  10 +-
 BaseTools/Source/Python/AutoGen/GenC.py                      | 170 +++---
 BaseTools/Source/Python/AutoGen/GenDepex.py                  |  33 +-
 BaseTools/Source/Python/AutoGen/GenMake.py                   |   2 -
 BaseTools/Source/Python/AutoGen/GenPcdDb.py                  |  12 +-
 BaseTools/Source/Python/AutoGen/GenVar.py                    |   6 +-
 BaseTools/Source/Python/Common/DataType.py                   |  54 +-
 BaseTools/Source/Python/Common/Expression.py                 |   4 +-
 BaseTools/Source/Python/Common/GlobalData.py                 |   1 +
 BaseTools/Source/Python/Common/MigrationUtilities.py         | 568 --------------------
 BaseTools/Source/Python/Common/Misc.py                       |  26 +-
 BaseTools/Source/Python/CommonDataClass/CommonClass.py       | 397 +-------------
 BaseTools/Source/Python/Ecc/Check.py                         |   6 +-
 BaseTools/Source/Python/Ecc/Configuration.py                 |   2 +-
 BaseTools/Source/Python/Ecc/c.py                             |   2 +-
 BaseTools/Source/Python/GenFds/CompressSection.py            |   3 +-
 BaseTools/Source/Python/GenFds/DataSection.py                |   8 +-
 BaseTools/Source/Python/GenFds/DepexSection.py               |  17 +-
 BaseTools/Source/Python/GenFds/EfiSection.py                 |  25 +-
 BaseTools/Source/Python/GenFds/Fd.py                         |   3 +-
 BaseTools/Source/Python/GenFds/FdfParser.py                  | 121 ++---
 BaseTools/Source/Python/GenFds/Ffs.py                        |  51 +-
 BaseTools/Source/Python/GenFds/FfsInfStatement.py            |  56 +-
 BaseTools/Source/Python/GenFds/Fv.py                         |   6 +-
 BaseTools/Source/Python/GenFds/FvImageSection.py             |   5 +-
 BaseTools/Source/Python/GenFds/GenFds.py                     |  10 +-
 BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py       |  40 +-
 BaseTools/Source/Python/GenFds/GuidSection.py                |   5 +-
 BaseTools/Source/Python/GenFds/OptRomInfStatement.py         |   3 +-
 BaseTools/Source/Python/GenFds/Region.py                     |   5 +-
 BaseTools/Source/Python/GenFds/Section.py                    |  46 +-
 BaseTools/Source/Python/GenFds/UiSection.py                  |   3 +-
 BaseTools/Source/Python/GenFds/VerSection.py                 |   3 +-
 BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py |  23 +-
 BaseTools/Source/Python/Makefile                             |   1 -
 BaseTools/Source/Python/Trim/Trim.py                         |   2 +-
 BaseTools/Source/Python/Workspace/DecBuildData.py            |  22 +-
 BaseTools/Source/Python/Workspace/DscBuildData.py            |  51 +-
 BaseTools/Source/Python/Workspace/InfBuildData.py            |  74 +--
 BaseTools/Source/Python/Workspace/MetaFileParser.py          |  27 +-
 BaseTools/Source/Python/Workspace/WorkspaceCommon.py         |   2 +-
 BaseTools/Source/Python/build/BuildReport.py                 |  99 ++--
 BaseTools/Source/Python/build/build.py                       |  16 +-
 44 files changed, 583 insertions(+), 1590 deletions(-)
 delete mode 100644 BaseTools/Source/Python/Common/MigrationUtilities.py

-- 
2.16.2.windows.1



^ permalink raw reply	[flat|nested] 56+ messages in thread

* [PATCH v1 01/27] BaseTools: Misc - refactor RegEx to minimize multiple compiling
  2018-04-20 15:51 [PATCH v1 00/27] BaseTools refactoring Jaben Carsey
@ 2018-04-20 15:51 ` Jaben Carsey
  2018-04-25  8:49   ` Zhu, Yonghong
  2018-04-20 15:51 ` [PATCH v1 02/27] BaseTools: GenPatchPcdTable " Jaben Carsey
                   ` (25 subsequent siblings)
  26 siblings, 1 reply; 56+ messages in thread
From: Jaben Carsey @ 2018-04-20 15:51 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Yonghong Zhu

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>
---
 BaseTools/Source/Python/Common/Misc.py | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
index 4f2bfd63cfc3..bc7d0c2d9d00 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -84,6 +84,7 @@ def _parseForXcode(lines, efifilepath, varnames):
         if status == 1 and len(line) != 0:
             for varname in varnames:
                 if varname in line:
+                    # cannot pregenerate this RegEx since it uses varname from varnames.
                     m = re.match('^([\da-fA-FxX]+)([\s\S]*)([_]*%s)$' % varname, line)
                     if m is not None:
                         ret.append((varname, m.group(1)))
@@ -91,6 +92,8 @@ def _parseForXcode(lines, efifilepath, varnames):
 
 def _parseForGCC(lines, efifilepath, varnames):
     """ Parse map file generated by GCC linker """
+    valuePattern = re.compile('^([\w_\.]+) +([\da-fA-Fx]+) +([\da-fA-Fx]+)$')
+    pcdPattern = re.compile('^([\da-fA-Fx]+) +([\da-fA-Fx]+)')
     status = 0
     sections = []
     varoffset = []
@@ -109,7 +112,7 @@ def _parseForGCC(lines, efifilepath, varnames):
 
         # status handler
         if status == 3:
-            m = re.match('^([\w_\.]+) +([\da-fA-Fx]+) +([\da-fA-Fx]+)$', line)
+            m = valuePattern.match(line)
             if m is not None:
                 sections.append(m.groups(0))
             for varname in varnames:
@@ -122,7 +125,7 @@ def _parseForGCC(lines, efifilepath, varnames):
                     else:
                         Str = line[len(".data.%s" % varname):]
                     if Str:
-                        m = re.match('^([\da-fA-Fx]+) +([\da-fA-Fx]+)', Str.strip())
+                        m = pcdPattern.match(Str.strip())
                         if m is not None:
                             varoffset.append((varname, int(m.groups(0)[0], 16) , int(sections[-1][1], 16), sections[-1][0]))
 
@@ -152,16 +155,18 @@ def _parseGeneral(lines, efifilepath, varnames):
     varoffset = []
     secRe = re.compile('^([\da-fA-F]+):([\da-fA-F]+) +([\da-fA-F]+)[Hh]? +([.\w\$]+) +(\w+)', re.UNICODE)
     symRe = re.compile('^([\da-fA-F]+):([\da-fA-F]+) +([\.:\\\\\w\?@\$]+) +([\da-fA-F]+)', re.UNICODE)
+    startRe = re.compile("^Start[' ']+Length[' ']+Name[' ']+Class")
+    addressRe = re.compile("^Address[' ']+Publics by Value[' ']+Rva\+Base")
 
     for line in lines:
         line = line.strip()
-        if re.match("^Start[' ']+Length[' ']+Name[' ']+Class", line):
+        if startRe.match(line):
             status = 1
             continue
-        if re.match("^Address[' ']+Publics by Value[' ']+Rva\+Base", line):
+        if addressRe.match(line):
             status = 2
             continue
-        if re.match("^entry point at", line):
+        if line.startswith("entry point at"):
             status = 3
             continue        
         if status == 1 and len(line) != 0:
@@ -177,6 +182,7 @@ def _parseGeneral(lines, efifilepath, varnames):
                 sec_no     = int(sec_no,     16)
                 sym_offset = int(sym_offset, 16)
                 vir_addr   = int(vir_addr,   16)
+                # cannot pregenerate this RegEx since it uses varname from varnames.
                 m2 = re.match('^[_]*(%s)' % varname, sym_name)
                 if m2 is not None:
                     # fond a binary pcd entry in map file
-- 
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH v1 02/27] BaseTools: GenPatchPcdTable - refactor RegEx to minimize multiple compiling
  2018-04-20 15:51 [PATCH v1 00/27] BaseTools refactoring Jaben Carsey
  2018-04-20 15:51 ` [PATCH v1 01/27] BaseTools: Misc - refactor RegEx to minimize multiple compiling Jaben Carsey
@ 2018-04-20 15:51 ` Jaben Carsey
  2018-04-25  8:50   ` Zhu, Yonghong
  2018-04-20 15:51 ` [PATCH v1 03/27] BaseTools: Share RegEx between files Jaben Carsey
                   ` (24 subsequent siblings)
  26 siblings, 1 reply; 56+ messages in thread
From: Jaben Carsey @ 2018-04-20 15:51 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Yonghong Zhu

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>
---
 BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py | 24 ++++++++++++--------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py b/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py
index dc2ceaf775d8..59748763a553 100644
--- a/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py
+++ b/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py
@@ -63,6 +63,7 @@ def parsePcdInfoFromMapFile(mapfilepath, efifilepath):
     return _parseGeneral(lines, efifilepath)
 
 def _parseForXcode(lines, efifilepath):
+    valuePattern = re.compile('^([\da-fA-FxX]+)([\s\S]*)([_]*_gPcd_BinaryPatch_([\w]+))')
     status = 0
     pcds = []
     for line in lines:
@@ -72,13 +73,16 @@ def _parseForXcode(lines, efifilepath):
             continue
         if status == 1 and len(line) != 0:
             if '_gPcd_BinaryPatch_' in line:
-                m = re.match('^([\da-fA-FxX]+)([\s\S]*)([_]*_gPcd_BinaryPatch_([\w]+))', line)
+                m = valuePattern.match(line)
                 if m is not None:
                     pcds.append((m.groups(0)[3], int(m.groups(0)[0], 16)))
     return pcds
 
 def _parseForGCC(lines, efifilepath):
     """ Parse map file generated by GCC linker """
+    valuePattern = re.compile('^([\w_\.]+) +([\da-fA-Fx]+) +([\da-fA-Fx]+)$')
+    dataPattern = re.compile('^.data._gPcd_BinaryPatch_([\w_\d]+)$')
+    pcdPattern = re.compile('^([\da-fA-Fx]+) +([\da-fA-Fx]+)')
     status = 0
     imageBase = -1
     sections = []
@@ -98,15 +102,15 @@ def _parseForGCC(lines, efifilepath):
 
         # status handler
         if status == 3:
-            m = re.match('^([\w_\.]+) +([\da-fA-Fx]+) +([\da-fA-Fx]+)$', line)
+            m = valuePattern.match(line)
             if m is not None:
                 sections.append(m.groups(0))
         if status == 3:
-            m = re.match('^.data._gPcd_BinaryPatch_([\w_\d]+)$', line)
+            m = dataPattern.match(line)
             if m is not None:
                 if lines[index + 1]:
                     PcdName = m.groups(0)[0]
-                    m = re.match('^([\da-fA-Fx]+) +([\da-fA-Fx]+)', lines[index + 1].strip())
+                    m = pcdPattern.match(lines[index + 1].strip())
                     if m is not None:
                         bpcds.append((PcdName, int(m.groups(0)[0], 16) , int(sections[-1][1], 16), sections[-1][0]))
                 
@@ -137,17 +141,19 @@ def _parseGeneral(lines, efifilepath):
     status = 0    #0 - beginning of file; 1 - PE section definition; 2 - symbol table
     secs = []    # key = section name
     bPcds = []
-
+    startPattern = re.compile("^Start[' ']+Length[' ']+Name[' ']+Class")
+    addressPattern = re.compile("^Address[' ']+Publics by Value[' ']+Rva\+Base")
+    symPattern = re.compile('^[_]+gPcd_BinaryPatch_([\w]+)')
 
     for line in lines:
         line = line.strip()
-        if re.match("^Start[' ']+Length[' ']+Name[' ']+Class", line):
+        if startPattern.match(line):
             status = 1
             continue
-        if re.match("^Address[' ']+Publics by Value[' ']+Rva\+Base", line):
+        if addressPattern.match(line):
             status = 2
             continue
-        if re.match("^entry point at", line):
+        if line.startswith("entry point at"):
             status = 3
             continue
         if status == 1 and len(line) != 0:
@@ -162,7 +168,7 @@ def _parseGeneral(lines, efifilepath):
             sec_no = int(sec_no, 16)
             sym_offset = int(sym_offset, 16)
             vir_addr = int(vir_addr, 16)
-            m2 = re.match('^[_]+gPcd_BinaryPatch_([\w]+)', sym_name)
+            m2 = symPattern.match(sym_name)
             if m2 is not None:
                 # fond a binary pcd entry in map file
                 for sec in secs:
-- 
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH v1 03/27] BaseTools: Share RegEx between files
  2018-04-20 15:51 [PATCH v1 00/27] BaseTools refactoring Jaben Carsey
  2018-04-20 15:51 ` [PATCH v1 01/27] BaseTools: Misc - refactor RegEx to minimize multiple compiling Jaben Carsey
  2018-04-20 15:51 ` [PATCH v1 02/27] BaseTools: GenPatchPcdTable " Jaben Carsey
@ 2018-04-20 15:51 ` Jaben Carsey
  2018-04-25  8:51   ` Zhu, Yonghong
  2018-04-20 15:51 ` [PATCH v1 04/27] BaseTools: Workspace - refactor RegEx to minimize multiple compiling Jaben Carsey
                   ` (23 subsequent siblings)
  26 siblings, 1 reply; 56+ messages in thread
From: Jaben Carsey @ 2018-04-20 15:51 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Yonghong Zhu

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>
---
 BaseTools/Source/Python/Common/Misc.py                       | 22 +++++++++++---------
 BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py | 15 +++++--------
 2 files changed, 17 insertions(+), 20 deletions(-)

diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
index bc7d0c2d9d00..4a6a29c7ae80 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -42,6 +42,13 @@ import subprocess
 ## Regular expression used to find out place holders in string template
 gPlaceholderPattern = re.compile("\$\{([^$()\s]+)\}", re.MULTILINE | re.UNICODE)
 
+## regular expressions for map file processing
+startPatternGeneral = re.compile("^Start[' ']+Length[' ']+Name[' ']+Class")
+addressPatternGeneral = re.compile("^Address[' ']+Publics by Value[' ']+Rva\+Base")
+valuePatternGcc = re.compile('^([\w_\.]+) +([\da-fA-Fx]+) +([\da-fA-Fx]+)$')
+pcdPatternGcc = re.compile('^([\da-fA-Fx]+) +([\da-fA-Fx]+)')
+secReGeneral = re.compile('^([\da-fA-F]+):([\da-fA-F]+) +([\da-fA-F]+)[Hh]? +([.\w\$]+) +(\w+)', re.UNICODE)
+
 ## Dictionary used to store file time stamp for quick re-access
 gFileTimeStampCache = {}    # {file path : file time stamp}
 
@@ -92,8 +99,6 @@ def _parseForXcode(lines, efifilepath, varnames):
 
 def _parseForGCC(lines, efifilepath, varnames):
     """ Parse map file generated by GCC linker """
-    valuePattern = re.compile('^([\w_\.]+) +([\da-fA-Fx]+) +([\da-fA-Fx]+)$')
-    pcdPattern = re.compile('^([\da-fA-Fx]+) +([\da-fA-Fx]+)')
     status = 0
     sections = []
     varoffset = []
@@ -112,7 +117,7 @@ def _parseForGCC(lines, efifilepath, varnames):
 
         # status handler
         if status == 3:
-            m = valuePattern.match(line)
+            m = valuePatternGcc.match(line)
             if m is not None:
                 sections.append(m.groups(0))
             for varname in varnames:
@@ -125,7 +130,7 @@ def _parseForGCC(lines, efifilepath, varnames):
                     else:
                         Str = line[len(".data.%s" % varname):]
                     if Str:
-                        m = pcdPattern.match(Str.strip())
+                        m = pcdPatternGcc.match(Str.strip())
                         if m is not None:
                             varoffset.append((varname, int(m.groups(0)[0], 16) , int(sections[-1][1], 16), sections[-1][0]))
 
@@ -153,24 +158,21 @@ def _parseGeneral(lines, efifilepath, varnames):
     status = 0    #0 - beginning of file; 1 - PE section definition; 2 - symbol table
     secs  = []    # key = section name
     varoffset = []
-    secRe = re.compile('^([\da-fA-F]+):([\da-fA-F]+) +([\da-fA-F]+)[Hh]? +([.\w\$]+) +(\w+)', re.UNICODE)
     symRe = re.compile('^([\da-fA-F]+):([\da-fA-F]+) +([\.:\\\\\w\?@\$]+) +([\da-fA-F]+)', re.UNICODE)
-    startRe = re.compile("^Start[' ']+Length[' ']+Name[' ']+Class")
-    addressRe = re.compile("^Address[' ']+Publics by Value[' ']+Rva\+Base")
 
     for line in lines:
         line = line.strip()
-        if startRe.match(line):
+        if startPatternGeneral.match(line):
             status = 1
             continue
-        if addressRe.match(line):
+        if addressPatternGeneral.match(line):
             status = 2
             continue
         if line.startswith("entry point at"):
             status = 3
             continue        
         if status == 1 and len(line) != 0:
-            m =  secRe.match(line)
+            m =  secReGeneral.match(line)
             assert m is not None, "Fail to parse the section in map file , line is %s" % line
             sec_no, sec_start, sec_length, sec_name, sec_class = m.groups(0)
             secs.append([int(sec_no, 16), int(sec_start, 16), int(sec_length, 16), sec_name, sec_class])
diff --git a/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py b/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py
index 59748763a553..2a039480a00a 100644
--- a/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py
+++ b/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py
@@ -24,7 +24,7 @@ import array
 
 from Common.BuildToolError import *
 import Common.EdkLogger as EdkLogger
-from Common.Misc import PeImageClass
+from Common.Misc import PeImageClass, startPatternGeneral, addressPatternGeneral, valuePatternGcc, pcdPatternGcc, secReGeneral
 from Common.BuildVersion import gBUILD_VERSION
 from Common.LongFilePathSupport import OpenLongFilePath as open
 
@@ -36,7 +36,6 @@ __copyright__ = "Copyright (c) 2008 - 2010, Intel Corporation. All rights reserv
 #======================================  Internal Libraries ========================================
 
 #============================================== Code ===============================================
-secRe = re.compile('^([\da-fA-F]+):([\da-fA-F]+) +([\da-fA-F]+)[Hh]? +([.\w\$]+) +(\w+)', re.UNICODE)
 symRe = re.compile('^([\da-fA-F]+):([\da-fA-F]+) +([\.\-:\\\\\w\?@\$<>]+) +([\da-fA-F]+)', re.UNICODE)
 
 def parsePcdInfoFromMapFile(mapfilepath, efifilepath):
@@ -80,9 +79,7 @@ def _parseForXcode(lines, efifilepath):
 
 def _parseForGCC(lines, efifilepath):
     """ Parse map file generated by GCC linker """
-    valuePattern = re.compile('^([\w_\.]+) +([\da-fA-Fx]+) +([\da-fA-Fx]+)$')
     dataPattern = re.compile('^.data._gPcd_BinaryPatch_([\w_\d]+)$')
-    pcdPattern = re.compile('^([\da-fA-Fx]+) +([\da-fA-Fx]+)')
     status = 0
     imageBase = -1
     sections = []
@@ -102,7 +99,7 @@ def _parseForGCC(lines, efifilepath):
 
         # status handler
         if status == 3:
-            m = valuePattern.match(line)
+            m = valuePatternGcc.match(line)
             if m is not None:
                 sections.append(m.groups(0))
         if status == 3:
@@ -110,7 +107,7 @@ def _parseForGCC(lines, efifilepath):
             if m is not None:
                 if lines[index + 1]:
                     PcdName = m.groups(0)[0]
-                    m = pcdPattern.match(lines[index + 1].strip())
+                    m = pcdPatternGcc.match(lines[index + 1].strip())
                     if m is not None:
                         bpcds.append((PcdName, int(m.groups(0)[0], 16) , int(sections[-1][1], 16), sections[-1][0]))
                 
@@ -141,16 +138,14 @@ def _parseGeneral(lines, efifilepath):
     status = 0    #0 - beginning of file; 1 - PE section definition; 2 - symbol table
     secs = []    # key = section name
     bPcds = []
-    startPattern = re.compile("^Start[' ']+Length[' ']+Name[' ']+Class")
-    addressPattern = re.compile("^Address[' ']+Publics by Value[' ']+Rva\+Base")
     symPattern = re.compile('^[_]+gPcd_BinaryPatch_([\w]+)')
 
     for line in lines:
         line = line.strip()
-        if startPattern.match(line):
+        if startPatternGeneral.match(line):
             status = 1
             continue
-        if addressPattern.match(line):
+        if addressPatternGeneral.match(line):
             status = 2
             continue
         if line.startswith("entry point at"):
-- 
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH v1 04/27] BaseTools: Workspace - refactor RegEx to minimize multiple compiling
  2018-04-20 15:51 [PATCH v1 00/27] BaseTools refactoring Jaben Carsey
                   ` (2 preceding siblings ...)
  2018-04-20 15:51 ` [PATCH v1 03/27] BaseTools: Share RegEx between files Jaben Carsey
@ 2018-04-20 15:51 ` Jaben Carsey
  2018-04-25  8:50   ` Zhu, Yonghong
  2018-04-20 15:51 ` [PATCH v1 05/27] BaseTools: Autogen - replace string constants with those from DataType Jaben Carsey
                   ` (22 subsequent siblings)
  26 siblings, 1 reply; 56+ messages in thread
From: Jaben Carsey @ 2018-04-20 15:51 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Yonghong Zhu

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>
---
 BaseTools/Source/Python/Workspace/DscBuildData.py   | 4 +++-
 BaseTools/Source/Python/Workspace/MetaFileParser.py | 8 ++++++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py
index d6b8b761d607..be3f7b6881e8 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -41,6 +41,8 @@ from Common.Misc import SaveFileOnChange
 from Workspace.BuildClassObject import PlatformBuildClassObject, StructurePcd, PcdClassObject, ModuleBuildClassObject
 from collections import OrderedDict
 
+variablePattern = re.compile(r'[\t\s]*0[xX][a-fA-F0-9]+$')
+
 #
 # Treat CHAR16 as a synonym for UINT16.  CHAR16 support is required for VFR C structs
 #
@@ -2421,7 +2423,7 @@ class DscBuildData(PlatformBuildClassObject):
             if VariableOffset.isdigit():
                 if int(VariableOffset, 10) > 0xFFFF:
                     ExceedMax = True
-            elif re.match(r'[\t\s]*0[xX][a-fA-F0-9]+$', VariableOffset):
+            elif variablePattern.match(VariableOffset):
                 if int(VariableOffset, 16) > 0xFFFF:
                     ExceedMax = True
             # For Offset written in "A.B"
diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py
index 322ed3844966..550359f9abb2 100644
--- a/BaseTools/Source/Python/Workspace/MetaFileParser.py
+++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py
@@ -35,6 +35,10 @@ from Common.LongFilePathSupport import OpenLongFilePath as open
 from MetaFileTable import MetaFileStorage
 from MetaFileCommentParser import CheckInfComment
 
+## RegEx for finding file versions
+hexVersionPattern = re.compile(r'0[xX][\da-f-A-F]{5,8}')
+decVersionPattern = re.compile(r'\d+\.\d+')
+
 ## A decorator used to parse macro definition
 def ParseMacro(Parser):
     def MacroParser(self):
@@ -366,9 +370,9 @@ class MetaFileParser(object):
                 EdkLogger.error("Parser", FORMAT_INVALID, "%s not defined" % (Macro), ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1)
         # Sometimes, we need to make differences between EDK and EDK2 modules 
         if Name == 'INF_VERSION':
-            if re.match(r'0[xX][\da-f-A-F]{5,8}', Value):
+            if hexVersionPattern.match(Value):
                 self._Version = int(Value, 0)   
-            elif re.match(r'\d+\.\d+', Value):
+            elif decVersionPattern.match(Value):
                 ValueList = Value.split('.')
                 Major = '%04o' % int(ValueList[0], 0)
                 Minor = '%04o' % int(ValueList[1], 0)
-- 
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH v1 05/27] BaseTools: Autogen - replace string constants with those from DataType
  2018-04-20 15:51 [PATCH v1 00/27] BaseTools refactoring Jaben Carsey
                   ` (3 preceding siblings ...)
  2018-04-20 15:51 ` [PATCH v1 04/27] BaseTools: Workspace - refactor RegEx to minimize multiple compiling Jaben Carsey
@ 2018-04-20 15:51 ` Jaben Carsey
  2018-04-25  8:50   ` Zhu, Yonghong
  2018-04-20 15:51 ` [PATCH v1 06/27] BaseTools: simplify if call Jaben Carsey
                   ` (21 subsequent siblings)
  26 siblings, 1 reply; 56+ messages in thread
From: Jaben Carsey @ 2018-04-20 15:51 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Yonghong Zhu

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>
---
 BaseTools/Source/Python/AutoGen/AutoGen.py | 68 ++++++++++----------
 1 file changed, 34 insertions(+), 34 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 6152225943cf..3a2976181ac1 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -259,7 +259,7 @@ class WorkspaceAutoGen(AutoGen):
         self.BuildDatabase  = MetaFileDb
         self.MetaFile       = ActivePlatform
         self.WorkspaceDir   = WorkspaceDir
-        self.Platform       = self.BuildDatabase[self.MetaFile, TAB_COMMON, Target, Toolchain]
+        self.Platform       = self.BuildDatabase[self.MetaFile, TAB_ARCH_COMMON, Target, Toolchain]
         GlobalData.gActivePlatform = self.Platform
         self.BuildTarget    = Target
         self.ToolChain      = Toolchain
@@ -405,8 +405,8 @@ class WorkspaceAutoGen(AutoGen):
             Platform = self.BuildDatabase[self.MetaFile, Arch, Target, Toolchain]
             PlatformPcds = Platform.Pcds
             self._GuidDict = Platform._GuidDict
-            SourcePcdDict = {'DynamicEx':set(), 'PatchableInModule':set(),'Dynamic':set(),'FixedAtBuild':set()}
-            BinaryPcdDict = {'DynamicEx':set(), 'PatchableInModule':set()}
+            SourcePcdDict = {TAB_PCDS_DYNAMIC_EX:set(), TAB_PCDS_PATCHABLE_IN_MODULE:set(),TAB_PCDS_DYNAMIC:set(),TAB_PCDS_FIXED_AT_BUILD:set()}
+            BinaryPcdDict = {TAB_PCDS_DYNAMIC_EX:set(), TAB_PCDS_PATCHABLE_IN_MODULE:set()}
             SourcePcdDict_Keys = SourcePcdDict.keys()
             BinaryPcdDict_Keys = BinaryPcdDict.keys()
 
@@ -430,23 +430,23 @@ class WorkspaceAutoGen(AutoGen):
                                     if PcdInPlatform.Type not in [None, '']:
                                         BuildData.Pcds[key].Type = PcdInPlatform.Type
 
-                        if 'DynamicEx' in BuildData.Pcds[key].Type:
+                        if TAB_PCDS_DYNAMIC_EX in BuildData.Pcds[key].Type:
                             if BuildData.IsBinaryModule:
-                                BinaryPcdDict['DynamicEx'].add((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))
+                                BinaryPcdDict[TAB_PCDS_DYNAMIC_EX].add((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))
                             else:
-                                SourcePcdDict['DynamicEx'].add((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))
+                                SourcePcdDict[TAB_PCDS_DYNAMIC_EX].add((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))
 
-                        elif 'PatchableInModule' in BuildData.Pcds[key].Type:
+                        elif TAB_PCDS_PATCHABLE_IN_MODULE in BuildData.Pcds[key].Type:
                             if BuildData.MetaFile.Ext == '.inf':
                                 if BuildData.IsBinaryModule:
-                                    BinaryPcdDict['PatchableInModule'].add((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))
+                                    BinaryPcdDict[TAB_PCDS_PATCHABLE_IN_MODULE].add((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))
                                 else:
-                                    SourcePcdDict['PatchableInModule'].add((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))
+                                    SourcePcdDict[TAB_PCDS_PATCHABLE_IN_MODULE].add((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))
 
-                        elif 'Dynamic' in BuildData.Pcds[key].Type:
-                            SourcePcdDict['Dynamic'].add((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))
-                        elif 'FixedAtBuild' in BuildData.Pcds[key].Type:
-                            SourcePcdDict['FixedAtBuild'].add((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))
+                        elif TAB_PCDS_DYNAMIC in BuildData.Pcds[key].Type:
+                            SourcePcdDict[TAB_PCDS_DYNAMIC].add((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))
+                        elif TAB_PCDS_FIXED_AT_BUILD in BuildData.Pcds[key].Type:
+                            SourcePcdDict[TAB_PCDS_FIXED_AT_BUILD].add((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))
                 else:
                     pass
             #
@@ -788,7 +788,7 @@ class WorkspaceAutoGen(AutoGen):
                             # Here we just need to get FILE_GUID from INF file, use 'COMMON' as ARCH attribute. and use 
                             # BuildObject from one of AutoGenObjectList is enough.
                             #
-                            InfObj = self.AutoGenObjectList[0].BuildDatabase.WorkspaceDb.BuildObject[PathClassObj, TAB_COMMON, self.BuildTarget, self.ToolChain]
+                            InfObj = self.AutoGenObjectList[0].BuildDatabase.WorkspaceDb.BuildObject[PathClassObj, TAB_ARCH_COMMON, self.BuildTarget, self.ToolChain]
                             if InfObj.Guid.upper() not in _GuidDict:
                                 _GuidDict[InfObj.Guid.upper()] = FfsFile
                             else:
@@ -869,9 +869,9 @@ class WorkspaceAutoGen(AutoGen):
 
     def _CheckPcdDefineAndType(self):
         PcdTypeList = [
-            "FixedAtBuild", "PatchableInModule", "FeatureFlag",
-            "Dynamic", #"DynamicHii", "DynamicVpd",
-            "DynamicEx", # "DynamicExHii", "DynamicExVpd"
+            TAB_PCDS_FIXED_AT_BUILD, TAB_PCDS_PATCHABLE_IN_MODULE, TAB_PCDS_FEATURE_FLAG,
+            TAB_PCDS_DYNAMIC, #"DynamicHii", "DynamicVpd",
+            TAB_PCDS_DYNAMIC_EX, # "DynamicExHii", "DynamicExVpd"
         ]
 
         # This dict store PCDs which are not used by any modules with specified arches
@@ -886,10 +886,10 @@ class WorkspaceAutoGen(AutoGen):
                     continue
 
                 # Try to remove Hii and Vpd suffix
-                if PcdType.startswith("DynamicEx"):
-                    PcdType = "DynamicEx"
-                elif PcdType.startswith("Dynamic"):
-                    PcdType = "Dynamic"
+                if PcdType.startswith(TAB_PCDS_DYNAMIC_EX):
+                    PcdType = TAB_PCDS_DYNAMIC_EX
+                elif PcdType.startswith(TAB_PCDS_DYNAMIC):
+                    PcdType = TAB_PCDS_DYNAMIC
 
                 for Package in Pa.PackageList:
                     # Key of DEC's Pcds dictionary is PcdCName, TokenSpaceGuid, PcdType
@@ -1286,7 +1286,7 @@ class PlatformAutoGen(AutoGen):
                     continue
                 else:
                     DscPcd = self.NonDynamicPcdDict[(Pcd.TokenCName,Pcd.TokenSpaceGuidCName)]
-                    if DscPcd.Type != "FixedAtBuild":
+                    if DscPcd.Type != TAB_PCDS_FIXED_AT_BUILD:
                         continue
                 if key in ShareFixedAtBuildPcdsSameValue and ShareFixedAtBuildPcdsSameValue[key]:                    
                     LibAuto.ConstPcd[key] = FixedAtBuildPcds[key]
@@ -2066,28 +2066,28 @@ class PlatformAutoGen(AutoGen):
             #
             for Pcd in self.DynamicPcdList:
                 if Pcd.Phase == "PEI":
-                    if Pcd.Type in ["Dynamic", "DynamicDefault", "DynamicVpd", "DynamicHii"]:
+                    if Pcd.Type in [TAB_PCDS_DYNAMIC, "DynamicDefault", "DynamicVpd", "DynamicHii"]:
                         EdkLogger.debug(EdkLogger.DEBUG_5, "%s %s (%s) -> %d" % (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Pcd.Phase, TokenNumber))
                         self._PcdTokenNumber[Pcd.TokenCName, Pcd.TokenSpaceGuidCName] = TokenNumber
                         TokenNumber += 1
 
             for Pcd in self.DynamicPcdList:
                 if Pcd.Phase == "PEI":
-                    if Pcd.Type in ["DynamicEx", "DynamicExDefault", "DynamicExVpd", "DynamicExHii"]:
+                    if Pcd.Type in [TAB_PCDS_DYNAMIC_EX, "DynamicExDefault", "DynamicExVpd", "DynamicExHii"]:
                         EdkLogger.debug(EdkLogger.DEBUG_5, "%s %s (%s) -> %d" % (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Pcd.Phase, TokenNumber))
                         self._PcdTokenNumber[Pcd.TokenCName, Pcd.TokenSpaceGuidCName] = TokenNumber
                         TokenNumber += 1
 
             for Pcd in self.DynamicPcdList:
                 if Pcd.Phase == "DXE":
-                    if Pcd.Type in ["Dynamic", "DynamicDefault", "DynamicVpd", "DynamicHii"]:
+                    if Pcd.Type in [TAB_PCDS_DYNAMIC, "DynamicDefault", "DynamicVpd", "DynamicHii"]:
                         EdkLogger.debug(EdkLogger.DEBUG_5, "%s %s (%s) -> %d" % (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Pcd.Phase, TokenNumber))
                         self._PcdTokenNumber[Pcd.TokenCName, Pcd.TokenSpaceGuidCName] = TokenNumber
                         TokenNumber += 1
 
             for Pcd in self.DynamicPcdList:
                 if Pcd.Phase == "DXE":
-                    if Pcd.Type in ["DynamicEx", "DynamicExDefault", "DynamicExVpd", "DynamicExHii"]:
+                    if Pcd.Type in [TAB_PCDS_DYNAMIC_EX, "DynamicExDefault", "DynamicExVpd", "DynamicExHii"]:
                         EdkLogger.debug(EdkLogger.DEBUG_5, "%s %s (%s) -> %d" % (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Pcd.Phase, TokenNumber))
                         self._PcdTokenNumber[Pcd.TokenCName, Pcd.TokenSpaceGuidCName] = TokenNumber
                         TokenNumber += 1
@@ -2331,7 +2331,7 @@ class PlatformAutoGen(AutoGen):
                 ToPcd.Type = FromPcd.Type
             elif (ToPcd.Type not in [None, '']) and (FromPcd.Type not in [None, ''])\
                 and (ToPcd.Type != FromPcd.Type) and (ToPcd.Type in FromPcd.Type):
-                if ToPcd.Type.strip() == "DynamicEx":
+                if ToPcd.Type.strip() == TAB_PCDS_DYNAMIC_EX:
                     ToPcd.Type = FromPcd.Type
             elif ToPcd.Type not in [None, ''] and FromPcd.Type not in [None, ''] \
                 and ToPcd.Type != FromPcd.Type:
@@ -2881,7 +2881,7 @@ class ModuleAutoGen(AutoGen):
         if self._FixedAtBuildPcds:
             return self._FixedAtBuildPcds
         for Pcd in self.ModulePcdList:
-            if Pcd.Type != "FixedAtBuild":
+            if Pcd.Type != TAB_PCDS_FIXED_AT_BUILD:
                 continue
             if Pcd not in self._FixedAtBuildPcds:
                 self._FixedAtBuildPcds.append(Pcd)
@@ -3418,7 +3418,7 @@ class ModuleAutoGen(AutoGen):
         if self._BinaryFileList is None:
             self._BinaryFileList = []
             for F in self.Module.Binaries:
-                if F.Target not in [TAB_COMMON, '*'] and F.Target != self.BuildTarget:
+                if F.Target not in [TAB_ARCH_COMMON, '*'] and F.Target != self.BuildTarget:
                     continue
                 self._BinaryFileList.append(F)
                 self._ApplyBuildRule(F, F.Type)
@@ -3931,12 +3931,12 @@ class ModuleAutoGen(AutoGen):
         for Pcd in self.ModulePcdList + self.LibraryPcdList:
             if Pcd.Type == TAB_PCDS_PATCHABLE_IN_MODULE:
                 PatchablePcds += [Pcd]
-                PcdCheckList.append((Pcd.TokenCName, Pcd.TokenSpaceGuidCName, 'PatchableInModule'))
+                PcdCheckList.append((Pcd.TokenCName, Pcd.TokenSpaceGuidCName, TAB_PCDS_PATCHABLE_IN_MODULE))
             elif Pcd.Type in GenC.gDynamicExPcd:
                 if Pcd not in Pcds:
                     Pcds += [Pcd]
-                    PcdCheckList.append((Pcd.TokenCName, Pcd.TokenSpaceGuidCName, 'DynamicEx'))
-                    PcdCheckList.append((Pcd.TokenCName, Pcd.TokenSpaceGuidCName, 'Dynamic'))
+                    PcdCheckList.append((Pcd.TokenCName, Pcd.TokenSpaceGuidCName, TAB_PCDS_DYNAMIC_EX))
+                    PcdCheckList.append((Pcd.TokenCName, Pcd.TokenSpaceGuidCName, TAB_PCDS_DYNAMIC))
                     PcdTokenSpaceList.append(Pcd.TokenSpaceGuidCName)
         GuidList = OrderedDict()
         GuidList.update(self.GuidList)
@@ -3964,8 +3964,8 @@ class ModuleAutoGen(AutoGen):
             if Pkg in Packages:
                 continue
             for VfrPcd in VfrPcds:
-                if ((VfrPcd.TokenCName, VfrPcd.TokenSpaceGuidCName, 'DynamicEx') in Pkg.Pcds or
-                    (VfrPcd.TokenCName, VfrPcd.TokenSpaceGuidCName, 'Dynamic') in Pkg.Pcds):
+                if ((VfrPcd.TokenCName, VfrPcd.TokenSpaceGuidCName, TAB_PCDS_DYNAMIC_EX) in Pkg.Pcds or
+                    (VfrPcd.TokenCName, VfrPcd.TokenSpaceGuidCName, TAB_PCDS_DYNAMIC) in Pkg.Pcds):
                     Packages += [Pkg]
                     break
 
-- 
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH v1 06/27] BaseTools: simplify if call
  2018-04-20 15:51 [PATCH v1 00/27] BaseTools refactoring Jaben Carsey
                   ` (4 preceding siblings ...)
  2018-04-20 15:51 ` [PATCH v1 05/27] BaseTools: Autogen - replace string constants with those from DataType Jaben Carsey
@ 2018-04-20 15:51 ` Jaben Carsey
  2018-04-25  8:50   ` Zhu, Yonghong
  2018-04-20 15:51 ` [PATCH v1 07/27] BaseTools: Workspace - refactor GetStructurePcdInfo Jaben Carsey
                   ` (20 subsequent siblings)
  26 siblings, 1 reply; 56+ messages in thread
From: Jaben Carsey @ 2018-04-20 15:51 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Yonghong Zhu

the variable is a string type since we just used .strip() on it.

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>
---
 BaseTools/Source/Python/Common/Expression.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Source/Python/Common/Expression.py
index 9a3415ccaabe..99929938fb5a 100644
--- a/BaseTools/Source/Python/Common/Expression.py
+++ b/BaseTools/Source/Python/Common/Expression.py
@@ -815,7 +815,7 @@ class ValueExpressionEx(ValueExpression):
         except BadExpression, Value:
             if self.PcdType in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN']:
                 PcdValue = PcdValue.strip()
-                if type(PcdValue) == type('') and PcdValue.startswith('{') and PcdValue.endswith('}'):
+                if PcdValue.startswith('{') and PcdValue.endswith('}'):
                     PcdValue = SplitPcdValueString(PcdValue[1:-1])
                 if type(PcdValue) == type([]):
                     TmpValue = 0
-- 
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH v1 07/27] BaseTools: Workspace - refactor GetStructurePcdInfo
  2018-04-20 15:51 [PATCH v1 00/27] BaseTools refactoring Jaben Carsey
                   ` (5 preceding siblings ...)
  2018-04-20 15:51 ` [PATCH v1 06/27] BaseTools: simplify if call Jaben Carsey
@ 2018-04-20 15:51 ` Jaben Carsey
  2018-04-25  8:50   ` Zhu, Yonghong
  2018-04-20 15:51 ` [PATCH v1 08/27] BaseTools: AutoGen - remove dictionary populated, but never accessed Jaben Carsey
                   ` (19 subsequent siblings)
  26 siblings, 1 reply; 56+ messages in thread
From: Jaben Carsey @ 2018-04-20 15:51 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Yonghong Zhu

the function doesn't use self and can be static
defaultdict replaces dict and removes the dict initialization code

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>
---
 BaseTools/Source/Python/Workspace/DscBuildData.py | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py
index be3f7b6881e8..904c52d9576a 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -39,7 +39,7 @@ import Common.GlobalData as GlobalData
 import subprocess
 from Common.Misc import SaveFileOnChange
 from Workspace.BuildClassObject import PlatformBuildClassObject, StructurePcd, PcdClassObject, ModuleBuildClassObject
-from collections import OrderedDict
+from collections import OrderedDict,defaultdict
 
 variablePattern = re.compile(r'[\t\s]*0[xX][a-fA-F0-9]+$')
 
@@ -1187,11 +1187,10 @@ class DscBuildData(PlatformBuildClassObject):
                             options[Key] += ' ' + Option
         return self._ModuleTypeOptions[Edk, ModuleType]
 
-    def GetStructurePcdInfo(self, PcdSet):
-        structure_pcd_data = {}
+    @staticmethod
+    def GetStructurePcdInfo(PcdSet):
+        structure_pcd_data = defaultdict(list)
         for item in PcdSet:
-            if (item[0],item[1]) not in structure_pcd_data:
-                structure_pcd_data[(item[0],item[1])] = []
             structure_pcd_data[(item[0],item[1])].append(item)
 
         return structure_pcd_data
@@ -1298,7 +1297,7 @@ class DscBuildData(PlatformBuildClassObject):
                 S_PcdSet.append([ TokenSpaceGuid.split(".")[0],TokenSpaceGuid.split(".")[1], PcdCName,SkuName, default_store,Dummy5, AnalyzePcdExpression(Setting)[0]])
 
         # handle pcd value override
-        StrPcdSet = self.GetStructurePcdInfo(S_PcdSet)
+        StrPcdSet = DscBuildData.GetStructurePcdInfo(S_PcdSet)
         S_pcd_set = OrderedDict()
         for str_pcd in StrPcdSet:
             str_pcd_obj = Pcds.get((str_pcd[1], str_pcd[0]), None)
-- 
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH v1 08/27] BaseTools: AutoGen - remove dictionary populated, but never accessed
  2018-04-20 15:51 [PATCH v1 00/27] BaseTools refactoring Jaben Carsey
                   ` (6 preceding siblings ...)
  2018-04-20 15:51 ` [PATCH v1 07/27] BaseTools: Workspace - refactor GetStructurePcdInfo Jaben Carsey
@ 2018-04-20 15:51 ` Jaben Carsey
  2018-04-25  8:50   ` Zhu, Yonghong
  2018-04-20 15:51 ` [PATCH v1 09/27] BaseTools: AutoGen - remove unused variables Jaben Carsey
                   ` (18 subsequent siblings)
  26 siblings, 1 reply; 56+ messages in thread
From: Jaben Carsey @ 2018-04-20 15:51 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Yonghong Zhu

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>
---
 BaseTools/Source/Python/AutoGen/GenPcdDb.py | 2 --
 1 file changed, 2 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
index 5937558e7038..4f4a8d856842 100644
--- a/BaseTools/Source/Python/AutoGen/GenPcdDb.py
+++ b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
@@ -980,7 +980,6 @@ def CreatePcdDatabaseCode (Info, AutoGenC, AutoGenH):
     Changed = SaveFileOnChange(DbFileName, DbFile.getvalue(), True)
 def CreatePcdDataBase(PcdDBData):
     delta = {}
-    basedata = {}
     for skuname,skuid in PcdDBData:
         if len(PcdDBData[(skuname,skuid)][1]) != len(PcdDBData[(TAB_DEFAULT,"0")][1]):
             EdkLogger.ERROR("The size of each sku in one pcd are not same")
@@ -988,7 +987,6 @@ def CreatePcdDataBase(PcdDBData):
         if skuname == TAB_DEFAULT:
             continue
         delta[(skuname,skuid)] = [(index,data,hex(data)) for index,data in enumerate(PcdDBData[(skuname,skuid)][1]) if PcdDBData[(skuname,skuid)][1][index] != PcdDBData[(TAB_DEFAULT,"0")][1][index]]
-        basedata[(skuname,skuid)] = [(index,PcdDBData[(TAB_DEFAULT,"0")][1][index],hex(PcdDBData[(TAB_DEFAULT,"0")][1][index])) for index,data in enumerate(PcdDBData[(skuname,skuid)][1]) if PcdDBData[(skuname,skuid)][1][index] != PcdDBData[(TAB_DEFAULT,"0")][1][index]]
     databasebuff = PcdDBData[(TAB_DEFAULT,"0")][0]
 
     for skuname,skuid in delta:
-- 
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH v1 09/27] BaseTools: AutoGen - remove unused variables.
  2018-04-20 15:51 [PATCH v1 00/27] BaseTools refactoring Jaben Carsey
                   ` (7 preceding siblings ...)
  2018-04-20 15:51 ` [PATCH v1 08/27] BaseTools: AutoGen - remove dictionary populated, but never accessed Jaben Carsey
@ 2018-04-20 15:51 ` Jaben Carsey
  2018-04-25  8:52   ` Zhu, Yonghong
  2018-04-20 15:51 ` [PATCH v1 10/27] BaseTools: Remove extra .keys() Jaben Carsey
                   ` (17 subsequent siblings)
  26 siblings, 1 reply; 56+ messages in thread
From: Jaben Carsey @ 2018-04-20 15:51 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Yonghong Zhu

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>
---
 BaseTools/Source/Python/AutoGen/GenMake.py | 2 --
 1 file changed, 2 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/Python/AutoGen/GenMake.py
index 1bb5163e73e0..a37350742240 100644
--- a/BaseTools/Source/Python/AutoGen/GenMake.py
+++ b/BaseTools/Source/Python/AutoGen/GenMake.py
@@ -427,8 +427,6 @@ cleanlib:
         self.ResultFileList = []
         self.IntermediateDirectoryList = ["$(DEBUG_DIR)", "$(OUTPUT_DIR)"]
 
-        self.SourceFileDatabase = {}        # {file type : file path}
-        self.DestFileDatabase = {}          # {file type : file path}
         self.FileBuildTargetList = []       # [(src, target string)]
         self.BuildTargetList = []           # [target string]
         self.PendingBuildTargetList = []    # [FileBuildRule objects]
-- 
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH v1 10/27] BaseTools: Remove extra .keys()
  2018-04-20 15:51 [PATCH v1 00/27] BaseTools refactoring Jaben Carsey
                   ` (8 preceding siblings ...)
  2018-04-20 15:51 ` [PATCH v1 09/27] BaseTools: AutoGen - remove unused variables Jaben Carsey
@ 2018-04-20 15:51 ` Jaben Carsey
  2018-04-25  8:51   ` Zhu, Yonghong
  2018-04-20 15:51 ` [PATCH v1 11/27] BaseTools: Workspace/MetaFileParser - refactor dicts Jaben Carsey
                   ` (16 subsequent siblings)
  26 siblings, 1 reply; 56+ messages in thread
From: Jaben Carsey @ 2018-04-20 15:51 UTC (permalink / raw)
  To: edk2-devel; +Cc: Yonghong Zhu, Liming Gao

Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
---
 BaseTools/Source/Python/GenFds/Fv.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Source/Python/GenFds/Fv.py b/BaseTools/Source/Python/GenFds/Fv.py
index 5228e155267f..71bcd4c72170 100644
--- a/BaseTools/Source/Python/GenFds/Fv.py
+++ b/BaseTools/Source/Python/GenFds/Fv.py
@@ -316,7 +316,7 @@ class FV (FvClassObject):
                                           ' %s' %ErasePloarity    + \
                                           T_CHAR_LF)
         if not (self.FvAttributeDict is None):
-            for FvAttribute in self.FvAttributeDict:
+            for FvAttribute in self.FvAttributeDict.keys() :
                 if FvAttribute == "FvUsedSizeEnable":
                     if self.FvAttributeDict[FvAttribute].upper() in ('TRUE', '1') :
                         self.UsedSizeEnable = True
-- 
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH v1 11/27] BaseTools: Workspace/MetaFileParser - refactor dicts
  2018-04-20 15:51 [PATCH v1 00/27] BaseTools refactoring Jaben Carsey
                   ` (9 preceding siblings ...)
  2018-04-20 15:51 ` [PATCH v1 10/27] BaseTools: Remove extra .keys() Jaben Carsey
@ 2018-04-20 15:51 ` Jaben Carsey
  2018-04-20 15:51 ` [PATCH v1 12/27] BaseTools: remove dict from DscBuildData Jaben Carsey
                   ` (15 subsequent siblings)
  26 siblings, 0 replies; 56+ messages in thread
From: Jaben Carsey @ 2018-04-20 15:51 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Yonghong Zhu

make defaultdict to avoid initialize inner items
to empty the dict, call clear instead of making a new object

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>
---
 BaseTools/Source/Python/Workspace/MetaFileParser.py | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py
index 550359f9abb2..99f6fcd0dc30 100644
--- a/BaseTools/Source/Python/Workspace/MetaFileParser.py
+++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py
@@ -31,7 +31,7 @@ from Common.Misc import GuidStructureStringToGuidString, CheckPcdDatum, PathClas
 from Common.Expression import *
 from CommonDataClass.Exceptions import *
 from Common.LongFilePathSupport import OpenLongFilePath as open
-
+from collections import defaultdict
 from MetaFileTable import MetaFileStorage
 from MetaFileCommentParser import CheckInfComment
 
@@ -163,7 +163,7 @@ class MetaFileParser(object):
         self._FileDir = self.MetaFile.Dir
         self._Defines = {}
         self._FileLocalMacros = {}
-        self._SectionsMacroDict = {}
+        self._SectionsMacroDict = defaultdict(dict)
 
         # for recursive parsing
         self._Owner = [Owner]
@@ -421,17 +421,16 @@ class MetaFileParser(object):
     def _ConstructSectionMacroDict(self, Name, Value):
         ScopeKey = [(Scope[0], Scope[1],Scope[2]) for Scope in self._Scope]
         ScopeKey = tuple(ScopeKey)
-        SectionDictKey = self._SectionType, ScopeKey
         #
         # DecParser SectionType is a list, will contain more than one item only in Pcd Section
         # As Pcd section macro usage is not alllowed, so here it is safe
         #
         if type(self) == DecParser:
             SectionDictKey = self._SectionType[0], ScopeKey
-        if SectionDictKey not in self._SectionsMacroDict:
-            self._SectionsMacroDict[SectionDictKey] = {}
-        SectionLocalMacros = self._SectionsMacroDict[SectionDictKey]
-        SectionLocalMacros[Name] = Value
+        else:
+            SectionDictKey = self._SectionType, ScopeKey
+
+        self._SectionsMacroDict[SectionDictKey][Name] = Value
 
     ## Get section Macros that are applicable to current line, which may come from other sections 
     ## that share the same name while scope is wider
@@ -936,7 +935,7 @@ class DscParser(MetaFileParser):
                 self._SubsectionType = MODEL_UNKNOWN
                 self._SubsectionName = ''
                 self._Owner[-1] = -1
-                OwnerId = {}
+                OwnerId.clear()
                 continue
             # subsection header
             elif Line[0] == TAB_OPTION_START and Line[-1] == TAB_OPTION_END:
-- 
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH v1 12/27] BaseTools: remove dict from DscBuildData
  2018-04-20 15:51 [PATCH v1 00/27] BaseTools refactoring Jaben Carsey
                   ` (10 preceding siblings ...)
  2018-04-20 15:51 ` [PATCH v1 11/27] BaseTools: Workspace/MetaFileParser - refactor dicts Jaben Carsey
@ 2018-04-20 15:51 ` Jaben Carsey
  2018-04-25  8:50   ` Zhu, Yonghong
  2018-04-20 15:51 ` [PATCH v1 13/27] BaseTools: replace string constants used for module types Jaben Carsey
                   ` (14 subsequent siblings)
  26 siblings, 1 reply; 56+ messages in thread
From: Jaben Carsey @ 2018-04-20 15:51 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Yonghong Zhu

the dict is not needed as BaseTools can check the set

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>
---
 BaseTools/Source/Python/Workspace/DscBuildData.py | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py
index 904c52d9576a..eb435cece480 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -1953,13 +1953,11 @@ class DscBuildData(PlatformBuildClassObject):
         InitByteValue = ""
         CApp = PcdMainCHeader
 
-        Includes = {}
         IncludeFiles = set()
         for PcdName in StructuredPcds:
             Pcd = StructuredPcds[PcdName]
             for IncludeFile in Pcd.StructuredPcdIncludeFile:
-                if IncludeFile not in Includes:
-                    Includes[IncludeFile] = True
+                if IncludeFile not in IncludeFiles:
                     IncludeFiles.add(IncludeFile)
                     CApp = CApp + '#include <%s>\n' % (IncludeFile)
         CApp = CApp + '\n'
-- 
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH v1 13/27] BaseTools: replace string constants used for module types
  2018-04-20 15:51 [PATCH v1 00/27] BaseTools refactoring Jaben Carsey
                   ` (11 preceding siblings ...)
  2018-04-20 15:51 ` [PATCH v1 12/27] BaseTools: remove dict from DscBuildData Jaben Carsey
@ 2018-04-20 15:51 ` Jaben Carsey
  2018-04-25  5:57   ` Zhu, Yonghong
  2018-04-20 15:51 ` [PATCH v1 14/27] BaseTools: Define and use a set for common list Jaben Carsey
                   ` (13 subsequent siblings)
  26 siblings, 1 reply; 56+ messages in thread
From: Jaben Carsey @ 2018-04-20 15:51 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Yonghong Zhu

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'

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>
---
 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                 |   4 +-
 BaseTools/Source/Python/GenFds/CompressSection.py    |   3 +-
 BaseTools/Source/Python/GenFds/DataSection.py        |   2 +-
 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, 225 insertions(+), 216 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 3a2976181ac1..9c3bf864e360 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -1431,7 +1431,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)
@@ -1473,7 +1473,7 @@ class PlatformAutoGen(AutoGen):
                     # make sure that the "VOID*" kind of datum has MaxDatumSize set
                     if PcdFromModule.DatumType == "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)
@@ -2204,7 +2204,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,
@@ -3970,8 +3970,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 != '':
@@ -4048,11 +4048,11 @@ class ModuleAutoGen(AutoGen):
                 AsBuiltInfDict['binary_item'] += ['BIN|' + File]
         if self.DepexGenerated:
             self.OutputFile.add(self.Name + '.depex')
-            if self.ModuleType in ['PEIM']:
+            if self.ModuleType in [SUP_MODULE_PEIM]:
                 AsBuiltInfDict['binary_item'] += ['PEI_DEPEX|' + self.Name + '.depex']
-            if self.ModuleType in ['DXE_DRIVER', 'DXE_RUNTIME_DRIVER', 'DXE_SAL_DRIVER', 'UEFI_DRIVER']:
+            if self.ModuleType in [SUP_MODULE_DXE_DRIVER, SUP_MODULE_DXE_RUNTIME_DRIVER, SUP_MODULE_DXE_SAL_DRIVER, SUP_MODULE_UEFI_DRIVER]:
                 AsBuiltInfDict['binary_item'] += ['DXE_DEPEX|' + self.Name + '.depex']
-            if self.ModuleType in ['DXE_SMM_DRIVER']:
+            if self.ModuleType in [SUP_MODULE_DXE_SMM_DRIVER]:
                 AsBuiltInfDict['binary_item'] += ['SMM_DEPEX|' + self.Name + '.depex']
 
         Bin = self._GenOffsetBin()
@@ -4378,8 +4378,8 @@ class ModuleAutoGen(AutoGen):
             return
 
         for ModuleType in self.DepexList:
-            # Ignore empty [depex] section or [depex] section for "USER_DEFINED" module
-            if len(self.DepexList[ModuleType]) == 0 or ModuleType == "USER_DEFINED":
+            # Ignore empty [depex] section or [depex] section for SUP_MODULE_USER_DEFINED module
+            if len(self.DepexList[ModuleType]) == 0 or ModuleType == SUP_MODULE_USER_DEFINED:
                 continue
 
             Dpx = GenDepex.DependencyExpression(self.DepexList[ModuleType], ModuleType, True)
diff --git a/BaseTools/Source/Python/AutoGen/BuildEngine.py b/BaseTools/Source/Python/AutoGen/BuildEngine.py
index bbd1a4d5b257..a4f39b0b2925 100644
--- a/BaseTools/Source/Python/AutoGen/BuildEngine.py
+++ b/BaseTools/Source/Python/AutoGen/BuildEngine.py
@@ -612,11 +612,11 @@ if __name__ == '__main__':
     EdkLogger.Initialize()
     if len(sys.argv) > 1:
         Br = BuildRule(sys.argv[1])
-        print str(Br[".c", "DXE_DRIVER", "IA32", "MSFT"][1])
+        print str(Br[".c", SUP_MODULE_DXE_DRIVER, "IA32", "MSFT"][1])
         print
-        print str(Br[".c", "DXE_DRIVER", "IA32", "INTEL"][1])
+        print str(Br[".c", SUP_MODULE_DXE_DRIVER, "IA32", "INTEL"][1])
         print
-        print str(Br[".c", "DXE_DRIVER", "IA32", "GCC"][1])
+        print str(Br[".c", SUP_MODULE_DXE_DRIVER, "IA32", "GCC"][1])
         print
         print str(Br[".ac", "ACPI_TABLE", "IA32", "MSFT"][1])
         print
@@ -624,7 +624,7 @@ if __name__ == '__main__':
         print
         print str(Br[".ac", "ACPI_TABLE", "IA32", "MSFT"][1])
         print
-        print str(Br[".s", "SEC", "IPF", "COMMON"][1])
+        print str(Br[".s", SUP_MODULE_SEC, "IPF", "COMMON"][1])
         print
-        print str(Br[".s", "SEC"][1])
+        print str(Br[".s", SUP_MODULE_SEC][1])
 
diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py
index 6706629722fc..7bc352274e66 100644
--- a/BaseTools/Source/Python/AutoGen/GenC.py
+++ b/BaseTools/Source/Python/AutoGen/GenC.py
@@ -651,7 +651,7 @@ ${END}
 ]
 
 gLibraryStructorPrototype = {
-'BASE'  : TemplateString("""${BEGIN}
+SUP_MODULE_BASE  : TemplateString("""${BEGIN}
 RETURN_STATUS
 EFIAPI
 ${Function} (
@@ -688,7 +688,7 @@ ${Function} (
 }
 
 gLibraryStructorCall = {
-'BASE'  : TemplateString("""${BEGIN}
+SUP_MODULE_BASE  : TemplateString("""${BEGIN}
   Status = ${Function} ();
   ASSERT_EFI_ERROR (Status);${END}
 """),
@@ -711,7 +711,7 @@ gLibraryStructorCall = {
 
 ## Library Constructor and Destructor Templates
 gLibraryString = {
-'BASE'  :   TemplateString("""
+SUP_MODULE_BASE  :   TemplateString("""
 ${BEGIN}${FunctionPrototype}${END}
 
 VOID
@@ -774,21 +774,21 @@ ${FunctionCall}${END}
 gBasicHeaderFile = "Base.h"
 
 gModuleTypeHeaderFile = {
-    "BASE"              :   [gBasicHeaderFile],
-    "SEC"               :   ["PiPei.h", "Library/DebugLib.h"],
-    "PEI_CORE"          :   ["PiPei.h", "Library/DebugLib.h", "Library/PeiCoreEntryPoint.h"],
-    "PEIM"              :   ["PiPei.h", "Library/DebugLib.h", "Library/PeimEntryPoint.h"],
-    "DXE_CORE"          :   ["PiDxe.h", "Library/DebugLib.h", "Library/DxeCoreEntryPoint.h"],
-    "DXE_DRIVER"        :   ["PiDxe.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiDriverEntryPoint.h"],
-    "DXE_SMM_DRIVER"    :   ["PiDxe.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiDriverEntryPoint.h"],
-    "DXE_RUNTIME_DRIVER":   ["PiDxe.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiDriverEntryPoint.h"],
-    "DXE_SAL_DRIVER"    :   ["PiDxe.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiDriverEntryPoint.h"],
-    "UEFI_DRIVER"       :   ["Uefi.h",  "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiDriverEntryPoint.h"],
-    "UEFI_APPLICATION"  :   ["Uefi.h",  "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiApplicationEntryPoint.h"],
-    "SMM_CORE"          :   ["PiDxe.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiDriverEntryPoint.h"],
-    "MM_STANDALONE"     :   ["PiSmm.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/SmmDriverStandaloneEntryPoint.h"],
-    "MM_CORE_STANDALONE" :  ["PiSmm.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/SmmCoreStandaloneEntryPoint.h"],
-    "USER_DEFINED"      :   [gBasicHeaderFile]
+    SUP_MODULE_BASE              :   [gBasicHeaderFile],
+    SUP_MODULE_SEC               :   ["PiPei.h", "Library/DebugLib.h"],
+    SUP_MODULE_PEI_CORE          :   ["PiPei.h", "Library/DebugLib.h", "Library/PeiCoreEntryPoint.h"],
+    SUP_MODULE_PEIM              :   ["PiPei.h", "Library/DebugLib.h", "Library/PeimEntryPoint.h"],
+    SUP_MODULE_DXE_CORE          :   ["PiDxe.h", "Library/DebugLib.h", "Library/DxeCoreEntryPoint.h"],
+    SUP_MODULE_DXE_DRIVER        :   ["PiDxe.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiDriverEntryPoint.h"],
+    SUP_MODULE_DXE_SMM_DRIVER    :   ["PiDxe.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiDriverEntryPoint.h"],
+    SUP_MODULE_DXE_RUNTIME_DRIVER:   ["PiDxe.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiDriverEntryPoint.h"],
+    SUP_MODULE_DXE_SAL_DRIVER    :   ["PiDxe.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiDriverEntryPoint.h"],
+    SUP_MODULE_UEFI_DRIVER       :   ["Uefi.h",  "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiDriverEntryPoint.h"],
+    SUP_MODULE_UEFI_APPLICATION  :   ["Uefi.h",  "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiApplicationEntryPoint.h"],
+    SUP_MODULE_SMM_CORE          :   ["PiDxe.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiDriverEntryPoint.h"],
+    SUP_MODULE_MM_STANDALONE     :   ["PiSmm.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/SmmDriverStandaloneEntryPoint.h"],
+    SUP_MODULE_MM_CORE_STANDALONE :  ["PiSmm.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/SmmCoreStandaloneEntryPoint.h"],
+    SUP_MODULE_USER_DEFINED      :   [gBasicHeaderFile]
 }
 
 ## Autogen internal worker macro to define DynamicEx PCD name includes both the TokenSpaceGuidName 
@@ -1408,17 +1408,17 @@ def CreateLibraryConstructorCode(Info, AutoGenC, AutoGenH):
         if len(Lib.ConstructorList) <= 0:
             continue
         Dict = {'Function':Lib.ConstructorList}
-        if Lib.ModuleType in ['BASE', 'SEC']:
-            ConstructorPrototypeString.Append(gLibraryStructorPrototype['BASE'].Replace(Dict))
-            ConstructorCallingString.Append(gLibraryStructorCall['BASE'].Replace(Dict))
-        elif Lib.ModuleType in ['PEI_CORE','PEIM']:
+        if Lib.ModuleType in [SUP_MODULE_BASE, SUP_MODULE_SEC]:
+            ConstructorPrototypeString.Append(gLibraryStructorPrototype[SUP_MODULE_BASE].Replace(Dict))
+            ConstructorCallingString.Append(gLibraryStructorCall[SUP_MODULE_BASE].Replace(Dict))
+        elif Lib.ModuleType in [SUP_MODULE_PEI_CORE,SUP_MODULE_PEIM]:
             ConstructorPrototypeString.Append(gLibraryStructorPrototype['PEI'].Replace(Dict))
             ConstructorCallingString.Append(gLibraryStructorCall['PEI'].Replace(Dict))
-        elif Lib.ModuleType in ['DXE_CORE','DXE_DRIVER','DXE_SMM_DRIVER','DXE_RUNTIME_DRIVER',
-                                'DXE_SAL_DRIVER','UEFI_DRIVER','UEFI_APPLICATION','SMM_CORE']:
+        elif Lib.ModuleType in [SUP_MODULE_DXE_CORE,SUP_MODULE_DXE_DRIVER,SUP_MODULE_DXE_SMM_DRIVER,SUP_MODULE_DXE_RUNTIME_DRIVER,
+                                SUP_MODULE_DXE_SAL_DRIVER,SUP_MODULE_UEFI_DRIVER,SUP_MODULE_UEFI_APPLICATION,SUP_MODULE_SMM_CORE]:
             ConstructorPrototypeString.Append(gLibraryStructorPrototype['DXE'].Replace(Dict))
             ConstructorCallingString.Append(gLibraryStructorCall['DXE'].Replace(Dict))
-        elif Lib.ModuleType in ['MM_STANDALONE','MM_CORE_STANDALONE']:
+        elif Lib.ModuleType in [SUP_MODULE_MM_STANDALONE,SUP_MODULE_MM_CORE_STANDALONE]:
             ConstructorPrototypeString.Append(gLibraryStructorPrototype['MM'].Replace(Dict))
             ConstructorCallingString.Append(gLibraryStructorCall['MM'].Replace(Dict))
 
@@ -1439,14 +1439,14 @@ def CreateLibraryConstructorCode(Info, AutoGenC, AutoGenH):
     if Info.IsLibrary:
         AutoGenH.Append("${BEGIN}${FunctionPrototype}${END}", Dict)
     else:
-        if Info.ModuleType in ['BASE', 'SEC']:
-            AutoGenC.Append(gLibraryString['BASE'].Replace(Dict))
-        elif Info.ModuleType in ['PEI_CORE','PEIM']:
+        if Info.ModuleType in [SUP_MODULE_BASE, SUP_MODULE_SEC]:
+            AutoGenC.Append(gLibraryString[SUP_MODULE_BASE].Replace(Dict))
+        elif Info.ModuleType in [SUP_MODULE_PEI_CORE,SUP_MODULE_PEIM]:
             AutoGenC.Append(gLibraryString['PEI'].Replace(Dict))
-        elif Info.ModuleType in ['DXE_CORE','DXE_DRIVER','DXE_SMM_DRIVER','DXE_RUNTIME_DRIVER',
-                                 'DXE_SAL_DRIVER','UEFI_DRIVER','UEFI_APPLICATION','SMM_CORE']:
+        elif Info.ModuleType in [SUP_MODULE_DXE_CORE,SUP_MODULE_DXE_DRIVER,SUP_MODULE_DXE_SMM_DRIVER,SUP_MODULE_DXE_RUNTIME_DRIVER,
+                                 SUP_MODULE_DXE_SAL_DRIVER,SUP_MODULE_UEFI_DRIVER,SUP_MODULE_UEFI_APPLICATION,SUP_MODULE_SMM_CORE]:
             AutoGenC.Append(gLibraryString['DXE'].Replace(Dict))
-        elif Info.ModuleType in ['MM_STANDALONE','MM_CORE_STANDALONE']:
+        elif Info.ModuleType in [SUP_MODULE_MM_STANDALONE,SUP_MODULE_MM_CORE_STANDALONE]:
             AutoGenC.Append(gLibraryString['MM'].Replace(Dict))
 
 ## Create code for library destructor
@@ -1470,17 +1470,17 @@ def CreateLibraryDestructorCode(Info, AutoGenC, AutoGenH):
         if len(Lib.DestructorList) <= 0:
             continue
         Dict = {'Function':Lib.DestructorList}
-        if Lib.ModuleType in ['BASE', 'SEC']:
-            DestructorPrototypeString.Append(gLibraryStructorPrototype['BASE'].Replace(Dict))
-            DestructorCallingString.Append(gLibraryStructorCall['BASE'].Replace(Dict))
-        elif Lib.ModuleType in ['PEI_CORE','PEIM']:
+        if Lib.ModuleType in [SUP_MODULE_BASE, SUP_MODULE_SEC]:
+            DestructorPrototypeString.Append(gLibraryStructorPrototype[SUP_MODULE_BASE].Replace(Dict))
+            DestructorCallingString.Append(gLibraryStructorCall[SUP_MODULE_BASE].Replace(Dict))
+        elif Lib.ModuleType in [SUP_MODULE_PEI_CORE,SUP_MODULE_PEIM]:
             DestructorPrototypeString.Append(gLibraryStructorPrototype['PEI'].Replace(Dict))
             DestructorCallingString.Append(gLibraryStructorCall['PEI'].Replace(Dict))
-        elif Lib.ModuleType in ['DXE_CORE','DXE_DRIVER','DXE_SMM_DRIVER','DXE_RUNTIME_DRIVER',
-                                'DXE_SAL_DRIVER','UEFI_DRIVER','UEFI_APPLICATION', 'SMM_CORE']:
+        elif Lib.ModuleType in [SUP_MODULE_DXE_CORE,SUP_MODULE_DXE_DRIVER,SUP_MODULE_DXE_SMM_DRIVER,SUP_MODULE_DXE_RUNTIME_DRIVER,
+                                SUP_MODULE_DXE_SAL_DRIVER,SUP_MODULE_UEFI_DRIVER,SUP_MODULE_UEFI_APPLICATION, SUP_MODULE_SMM_CORE]:
             DestructorPrototypeString.Append(gLibraryStructorPrototype['DXE'].Replace(Dict))
             DestructorCallingString.Append(gLibraryStructorCall['DXE'].Replace(Dict))
-        elif Lib.ModuleType in ['MM_STANDALONE','MM_CORE_STANDALONE']:
+        elif Lib.ModuleType in [SUP_MODULE_MM_STANDALONE,SUP_MODULE_MM_CORE_STANDALONE]:
             DestructorPrototypeString.Append(gLibraryStructorPrototype['MM'].Replace(Dict))
             DestructorCallingString.Append(gLibraryStructorCall['MM'].Replace(Dict))
 
@@ -1501,14 +1501,14 @@ def CreateLibraryDestructorCode(Info, AutoGenC, AutoGenH):
     if Info.IsLibrary:
         AutoGenH.Append("${BEGIN}${FunctionPrototype}${END}", Dict)
     else:
-        if Info.ModuleType in ['BASE', 'SEC']:
-            AutoGenC.Append(gLibraryString['BASE'].Replace(Dict))
-        elif Info.ModuleType in ['PEI_CORE','PEIM']:
+        if Info.ModuleType in [SUP_MODULE_BASE, SUP_MODULE_SEC]:
+            AutoGenC.Append(gLibraryString[SUP_MODULE_BASE].Replace(Dict))
+        elif Info.ModuleType in [SUP_MODULE_PEI_CORE,SUP_MODULE_PEIM]:
             AutoGenC.Append(gLibraryString['PEI'].Replace(Dict))
-        elif Info.ModuleType in ['DXE_CORE','DXE_DRIVER','DXE_SMM_DRIVER','DXE_RUNTIME_DRIVER',
-                                 'DXE_SAL_DRIVER','UEFI_DRIVER','UEFI_APPLICATION','SMM_CORE']:
+        elif Info.ModuleType in [SUP_MODULE_DXE_CORE,SUP_MODULE_DXE_DRIVER,SUP_MODULE_DXE_SMM_DRIVER,SUP_MODULE_DXE_RUNTIME_DRIVER,
+                                 SUP_MODULE_DXE_SAL_DRIVER,SUP_MODULE_UEFI_DRIVER,SUP_MODULE_UEFI_APPLICATION,SUP_MODULE_SMM_CORE]:
             AutoGenC.Append(gLibraryString['DXE'].Replace(Dict))
-        elif Info.ModuleType in ['MM_STANDALONE','MM_CORE_STANDALONE']:
+        elif Info.ModuleType in [SUP_MODULE_MM_STANDALONE,SUP_MODULE_MM_CORE_STANDALONE]:
             AutoGenC.Append(gLibraryString['MM'].Replace(Dict))
 
 
@@ -1519,7 +1519,7 @@ def CreateLibraryDestructorCode(Info, AutoGenC, AutoGenH):
 #   @param      AutoGenH    The TemplateString object for header file
 #
 def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH):
-    if Info.IsLibrary or Info.ModuleType in ['USER_DEFINED', 'SEC']:
+    if Info.IsLibrary or Info.ModuleType in [SUP_MODULE_USER_DEFINED, SUP_MODULE_SEC]:
         return
     #
     # Module Entry Points
@@ -1539,7 +1539,7 @@ def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH):
         'UefiSpecVersion':   UefiSpecVersion + 'U'
     }
 
-    if Info.ModuleType in ['PEI_CORE', 'DXE_CORE', 'SMM_CORE', 'MM_CORE_STANDALONE']:
+    if Info.ModuleType in [SUP_MODULE_PEI_CORE, SUP_MODULE_DXE_CORE, SUP_MODULE_SMM_CORE, SUP_MODULE_MM_CORE_STANDALONE]:
         if Info.SourceFileList:
           if NumEntryPoints != 1:
               EdkLogger.error(
@@ -1549,43 +1549,43 @@ def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH):
                   File=str(Info),
                   ExtraData= ", ".join(Info.Module.ModuleEntryPointList)
                   )
-    if Info.ModuleType == 'PEI_CORE':
+    if Info.ModuleType == SUP_MODULE_PEI_CORE:
         AutoGenC.Append(gPeiCoreEntryPointString.Replace(Dict))
         AutoGenH.Append(gPeiCoreEntryPointPrototype.Replace(Dict))
-    elif Info.ModuleType == 'DXE_CORE':
+    elif Info.ModuleType == SUP_MODULE_DXE_CORE:
         AutoGenC.Append(gDxeCoreEntryPointString.Replace(Dict))
         AutoGenH.Append(gDxeCoreEntryPointPrototype.Replace(Dict))
-    elif Info.ModuleType == 'SMM_CORE':
+    elif Info.ModuleType == SUP_MODULE_SMM_CORE:
         AutoGenC.Append(gSmmCoreEntryPointString.Replace(Dict))
         AutoGenH.Append(gSmmCoreEntryPointPrototype.Replace(Dict))
-    elif Info.ModuleType == 'MM_CORE_STANDALONE':
+    elif Info.ModuleType == SUP_MODULE_MM_CORE_STANDALONE:
         AutoGenC.Append(gMmCoreStandaloneEntryPointString.Replace(Dict))
         AutoGenH.Append(gMmCoreStandaloneEntryPointPrototype.Replace(Dict))
-    elif Info.ModuleType == 'PEIM':
+    elif Info.ModuleType == SUP_MODULE_PEIM:
         if NumEntryPoints < 2:
             AutoGenC.Append(gPeimEntryPointString[NumEntryPoints].Replace(Dict))
         else:
             AutoGenC.Append(gPeimEntryPointString[2].Replace(Dict))
         AutoGenH.Append(gPeimEntryPointPrototype.Replace(Dict))
-    elif Info.ModuleType in ['DXE_RUNTIME_DRIVER','DXE_DRIVER','DXE_SAL_DRIVER','UEFI_DRIVER']:
+    elif Info.ModuleType in [SUP_MODULE_DXE_RUNTIME_DRIVER,SUP_MODULE_DXE_DRIVER,SUP_MODULE_DXE_SAL_DRIVER,SUP_MODULE_UEFI_DRIVER]:
         if NumEntryPoints < 2:
             AutoGenC.Append(gUefiDriverEntryPointString[NumEntryPoints].Replace(Dict))
         else:
             AutoGenC.Append(gUefiDriverEntryPointString[2].Replace(Dict))
         AutoGenH.Append(gUefiDriverEntryPointPrototype.Replace(Dict))
-    elif Info.ModuleType == 'DXE_SMM_DRIVER':
+    elif Info.ModuleType == SUP_MODULE_DXE_SMM_DRIVER:
         if NumEntryPoints == 0:
             AutoGenC.Append(gDxeSmmEntryPointString[0].Replace(Dict))
         else:
             AutoGenC.Append(gDxeSmmEntryPointString[1].Replace(Dict))
         AutoGenH.Append(gDxeSmmEntryPointPrototype.Replace(Dict))
-    elif Info.ModuleType == 'MM_STANDALONE':
+    elif Info.ModuleType == SUP_MODULE_MM_STANDALONE:
         if NumEntryPoints < 2:
             AutoGenC.Append(gMmStandaloneEntryPointString[NumEntryPoints].Replace(Dict))
         else:
             AutoGenC.Append(gMmStandaloneEntryPointString[2].Replace(Dict))
         AutoGenH.Append(gMmStandaloneEntryPointPrototype.Replace(Dict))
-    elif Info.ModuleType == 'UEFI_APPLICATION':
+    elif Info.ModuleType == SUP_MODULE_UEFI_APPLICATION:
         if NumEntryPoints < 2:
             AutoGenC.Append(gUefiApplicationEntryPointString[NumEntryPoints].Replace(Dict))
         else:
@@ -1599,7 +1599,7 @@ def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH):
 #   @param      AutoGenH    The TemplateString object for header file
 #
 def CreateModuleUnloadImageCode(Info, AutoGenC, AutoGenH):
-    if Info.IsLibrary or Info.ModuleType in ['USER_DEFINED', 'SEC']:
+    if Info.IsLibrary or Info.ModuleType in [SUP_MODULE_USER_DEFINED, SUP_MODULE_SEC]:
         return
     #
     # Unload Image Handlers
@@ -1619,7 +1619,7 @@ def CreateModuleUnloadImageCode(Info, AutoGenC, AutoGenH):
 #   @param      AutoGenH    The TemplateString object for header file
 #
 def CreateGuidDefinitionCode(Info, AutoGenC, AutoGenH):
-    if Info.ModuleType in ["USER_DEFINED", "BASE"]:
+    if Info.ModuleType in [SUP_MODULE_USER_DEFINED, SUP_MODULE_BASE]:
         GuidType = "GUID"
     else:
         GuidType = "EFI_GUID"
@@ -1643,7 +1643,7 @@ def CreateGuidDefinitionCode(Info, AutoGenC, AutoGenH):
 #   @param      AutoGenH    The TemplateString object for header file
 #
 def CreateProtocolDefinitionCode(Info, AutoGenC, AutoGenH):
-    if Info.ModuleType in ["USER_DEFINED", "BASE"]:
+    if Info.ModuleType in [SUP_MODULE_USER_DEFINED, SUP_MODULE_BASE]:
         GuidType = "GUID"
     else:
         GuidType = "EFI_GUID"
@@ -1667,7 +1667,7 @@ def CreateProtocolDefinitionCode(Info, AutoGenC, AutoGenH):
 #   @param      AutoGenH    The TemplateString object for header file
 #
 def CreatePpiDefinitionCode(Info, AutoGenC, AutoGenH):
-    if Info.ModuleType in ["USER_DEFINED", "BASE"]:
+    if Info.ModuleType in [SUP_MODULE_USER_DEFINED, SUP_MODULE_BASE]:
         GuidType = "GUID"
     else:
         GuidType = "EFI_GUID"
@@ -1704,7 +1704,7 @@ def CreatePcdCode(Info, AutoGenC, AutoGenH):
     # Add extern declarations to AutoGen.h if one or more Token Space GUIDs were found
     if TokenSpaceList:
         AutoGenH.Append("\n// Definition of PCD Token Space GUIDs used in this module\n\n")
-        if Info.ModuleType in ["USER_DEFINED", "BASE"]:
+        if Info.ModuleType in [SUP_MODULE_USER_DEFINED, SUP_MODULE_BASE]:
             GuidType = "GUID"
         else:
             GuidType = "EFI_GUID"              
diff --git a/BaseTools/Source/Python/AutoGen/GenDepex.py b/BaseTools/Source/Python/AutoGen/GenDepex.py
index 9acea8f6bfed..100f1250b31f 100644
--- a/BaseTools/Source/Python/AutoGen/GenDepex.py
+++ b/BaseTools/Source/Python/AutoGen/GenDepex.py
@@ -24,26 +24,27 @@ from Common.Misc import SaveFileOnChange
 from Common.Misc import GuidStructureStringToGuidString
 from Common import EdkLogger as EdkLogger
 from Common.BuildVersion import gBUILD_VERSION
+from Common.DataType import *
 
 ## Regular expression for matching "DEPENDENCY_START ... DEPENDENCY_END"
 gStartClosePattern = re.compile(".*DEPENDENCY_START(.+)DEPENDENCY_END.*", re.S)
 
 ## Mapping between module type and EFI phase
 gType2Phase = {
-    "BASE"              :   None,
-    "SEC"               :   "PEI",
-    "PEI_CORE"          :   "PEI",
-    "PEIM"              :   "PEI",
-    "DXE_CORE"          :   "DXE",
-    "DXE_DRIVER"        :   "DXE",
-    "DXE_SMM_DRIVER"    :   "DXE",
-    "DXE_RUNTIME_DRIVER":   "DXE",
-    "DXE_SAL_DRIVER"    :   "DXE",
-    "UEFI_DRIVER"       :   "DXE",
-    "UEFI_APPLICATION"  :   "DXE",
-    "SMM_CORE"          :   "DXE",
-    "MM_STANDALONE"     :   "MM",
-    "MM_CORE_STANDALONE" :  "MM",
+    SUP_MODULE_BASE              :   None,
+    SUP_MODULE_SEC               :   "PEI",
+    SUP_MODULE_PEI_CORE          :   "PEI",
+    SUP_MODULE_PEIM              :   "PEI",
+    SUP_MODULE_DXE_CORE          :   "DXE",
+    SUP_MODULE_DXE_DRIVER        :   "DXE",
+    SUP_MODULE_DXE_SMM_DRIVER    :   "DXE",
+    SUP_MODULE_DXE_RUNTIME_DRIVER:   "DXE",
+    SUP_MODULE_DXE_SAL_DRIVER    :   "DXE",
+    SUP_MODULE_UEFI_DRIVER       :   "DXE",
+    SUP_MODULE_UEFI_APPLICATION  :   "DXE",
+    SUP_MODULE_SMM_CORE          :   "DXE",
+    SUP_MODULE_MM_STANDALONE     :   "MM",
+    SUP_MODULE_MM_CORE_STANDALONE :  "MM",
 }
 
 ## Convert dependency expression string into EFI internal representation
@@ -299,12 +300,12 @@ class DependencyExpression:
             NewOperand.append(Token)
 
         # don't generate depex if only TRUE operand left
-        if self.ModuleType == 'PEIM' and len(NewOperand) == 1 and NewOperand[0] == 'TRUE':
+        if self.ModuleType == SUP_MODULE_PEIM and len(NewOperand) == 1 and NewOperand[0] == 'TRUE':
             self.PostfixNotation = []
             return
 
         # don't generate depex if all operands are architecture protocols
-        if self.ModuleType in ['UEFI_DRIVER', 'DXE_DRIVER', 'DXE_RUNTIME_DRIVER', 'DXE_SAL_DRIVER', 'DXE_SMM_DRIVER', 'MM_STANDALONE'] and \
+        if self.ModuleType in [SUP_MODULE_UEFI_DRIVER, SUP_MODULE_DXE_DRIVER, SUP_MODULE_DXE_RUNTIME_DRIVER, SUP_MODULE_DXE_SAL_DRIVER, SUP_MODULE_DXE_SMM_DRIVER, SUP_MODULE_MM_STANDALONE] and \
            Op == 'AND' and \
            self.ArchProtocols == set([GuidStructureStringToGuidString(Guid) for Guid in AllOperand]):
             self.PostfixNotation = []
diff --git a/BaseTools/Source/Python/Common/DataType.py b/BaseTools/Source/Python/Common/DataType.py
index 1e632f3abdbf..0bd55494df66 100644
--- a/BaseTools/Source/Python/Common/DataType.py
+++ b/BaseTools/Source/Python/Common/DataType.py
@@ -80,7 +80,7 @@ SUP_MODULE_LIST_STRING = TAB_VALUE_SPLIT.join(SUP_MODULE_LIST)
 
 EDK_COMPONENT_TYPE_LIBRARY = 'LIBRARY'
 EDK_COMPONENT_TYPE_SECUARITY_CORE = 'SECUARITY_CORE'
-EDK_COMPONENT_TYPE_PEI_CORE = 'PEI_CORE'
+EDK_COMPONENT_TYPE_PEI_CORE = SUP_MODULE_PEI_CORE
 EDK_COMPONENT_TYPE_COMBINED_PEIM_DRIVER = 'COMBINED_PEIM_DRIVER'
 EDK_COMPONENT_TYPE_PIC_PEIM = 'PIC_PEIM'
 EDK_COMPONENT_TYPE_RELOCATABLE_PEIM = 'RELOCATABLE_PEIM'
diff --git a/BaseTools/Source/Python/Ecc/Check.py b/BaseTools/Source/Python/Ecc/Check.py
index 27783e617b92..c0e8006dcc51 100644
--- a/BaseTools/Source/Python/Ecc/Check.py
+++ b/BaseTools/Source/Python/Ecc/Check.py
@@ -744,7 +744,7 @@ class Check(object):
                         if Item not in LibraryClasses[List[0]]:
                             LibraryClasses[List[0]].append(Item)
 
-                if Record[2] != 'BASE' and Record[2] not in SupModType:
+                if Record[2] != SUP_MODULE_BASE and Record[2] not in SupModType:
                     EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_LIBRARY_INSTANCE_2, OtherMsg="The Library Class '%s' does not specify its supported module types" % (List[0]), BelongsToTable='Inf', BelongsToItem=Record[0])
 
             SqlCommand = """select A.ID, A.Value1, B.Value3 from Inf as A left join Inf as B
@@ -763,7 +763,7 @@ class Check(object):
 
             for Record in RecordSet:
                 if Record[1] in LibraryClasses:
-                    if Record[2] not in LibraryClasses[Record[1]] and 'BASE' not in RecordDict[Record[1]]:
+                    if Record[2] not in LibraryClasses[Record[1]] and SUP_MODULE_BASE not in RecordDict[Record[1]]:
                         if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_LIBRARY_INSTANCE_1, Record[1]):
                             EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_LIBRARY_INSTANCE_1, OtherMsg="The type of Library Class [%s] defined in Inf file does not match the type of the module" % (Record[1]), BelongsToTable='Inf', BelongsToItem=Record[0])
                 else:
diff --git a/BaseTools/Source/Python/GenFds/CompressSection.py b/BaseTools/Source/Python/GenFds/CompressSection.py
index 08ab48669f45..4ae14f27b3e1 100644
--- a/BaseTools/Source/Python/GenFds/CompressSection.py
+++ b/BaseTools/Source/Python/GenFds/CompressSection.py
@@ -21,6 +21,7 @@ import subprocess
 import Common.LongFilePathOs as os
 from GenFdsGlobalVariable import GenFdsGlobalVariable
 from CommonDataClass.FdfClass import CompressSectionClassObject
+from Common.DataType import *
 
 ## generate compress section
 #
@@ -82,7 +83,7 @@ class CompressSection (CompressSectionClassObject) :
         OutputFile = OutputPath + \
                      os.sep     + \
                      ModuleName + \
-                     'SEC'      + \
+                     SUP_MODULE_SEC      + \
                      SecNum     + \
                      Ffs.SectionSuffix['COMPRESS']
         OutputFile = os.path.normpath(OutputFile)
diff --git a/BaseTools/Source/Python/GenFds/DataSection.py b/BaseTools/Source/Python/GenFds/DataSection.py
index 40e345eee77e..3c435c2fcc65 100644
--- a/BaseTools/Source/Python/GenFds/DataSection.py
+++ b/BaseTools/Source/Python/GenFds/DataSection.py
@@ -119,7 +119,7 @@ class DataSection (DataSectionClassObject):
                 )
             self.SectFileName = TeFile
 
-        OutputFile = os.path.join (OutputPath, ModuleName + 'SEC' + SecNum + Ffs.SectionSuffix.get(self.SecType))
+        OutputFile = os.path.join (OutputPath, ModuleName + SUP_MODULE_SEC + SecNum + Ffs.SectionSuffix.get(self.SecType))
         OutputFile = os.path.normpath(OutputFile)
         GenFdsGlobalVariable.GenerateSection(OutputFile, [self.SectFileName], Section.Section.SectionType.get(self.SecType), IsMakefile = IsMakefile)
         FileList = [OutputFile]
diff --git a/BaseTools/Source/Python/GenFds/DepexSection.py b/BaseTools/Source/Python/GenFds/DepexSection.py
index 4ed1aa779292..d04160e890f1 100644
--- a/BaseTools/Source/Python/GenFds/DepexSection.py
+++ b/BaseTools/Source/Python/GenFds/DepexSection.py
@@ -25,6 +25,7 @@ from AutoGen.GenDepex import DependencyExpression
 from Common import EdkLogger
 from Common.BuildToolError import *
 from Common.Misc import PathClass
+from Common.DataType import *
 
 ## generate data section
 #
@@ -94,24 +95,24 @@ class DepexSection (DepexSectionClassObject):
             self.ExpressionProcessed = True
 
         if self.DepexType == 'PEI_DEPEX_EXP':
-            ModuleType = 'PEIM'
+            ModuleType = SUP_MODULE_PEIM
             SecType    = 'PEI_DEPEX'
         elif self.DepexType == 'DXE_DEPEX_EXP':
-            ModuleType = 'DXE_DRIVER'
+            ModuleType = SUP_MODULE_DXE_DRIVER
             SecType    = 'DXE_DEPEX'
         elif self.DepexType == 'SMM_DEPEX_EXP':
-            ModuleType = 'DXE_SMM_DRIVER'
+            ModuleType = SUP_MODULE_DXE_SMM_DRIVER
             SecType    = 'SMM_DEPEX'
         else:
             EdkLogger.error("GenFds", FORMAT_INVALID,
                             "Depex type %s is not valid for module %s" % (self.DepexType, ModuleName))
 
-        InputFile = os.path.join (OutputPath, ModuleName + 'SEC' + SecNum + '.depex')
+        InputFile = os.path.join (OutputPath, ModuleName + SUP_MODULE_SEC + SecNum + '.depex')
         InputFile = os.path.normpath(InputFile)
         Depex = DependencyExpression(self.Expression, ModuleType)
         Depex.Generate(InputFile)
 
-        OutputFile = os.path.join (OutputPath, ModuleName + 'SEC' + SecNum + '.dpx')
+        OutputFile = os.path.join (OutputPath, ModuleName + SUP_MODULE_SEC + SecNum + '.dpx')
         OutputFile = os.path.normpath(OutputFile)
 
         GenFdsGlobalVariable.GenerateSection(OutputFile, [InputFile], Section.Section.SectionType.get (SecType), IsMakefile=IsMakefile)
diff --git a/BaseTools/Source/Python/GenFds/EfiSection.py b/BaseTools/Source/Python/GenFds/EfiSection.py
index 5bb1ae6f664c..1be23b4bf7fd 100644
--- a/BaseTools/Source/Python/GenFds/EfiSection.py
+++ b/BaseTools/Source/Python/GenFds/EfiSection.py
@@ -27,6 +27,7 @@ from Common.BuildToolError import *
 from Common.Misc import PeImageClass
 from Common.LongFilePathSupport import OpenLongFilePath as open
 from Common.LongFilePathSupport import CopyLongFilePath
+from Common.DataType import *
 
 ## generate rule section
 #
@@ -66,7 +67,7 @@ class EfiSection (EfiSectionClassObject):
             StringData = FfsInf.__ExtendMacro__(self.StringData)
             ModuleNameStr = FfsInf.__ExtendMacro__('$(MODULE_NAME)')
             NoStrip = True
-            if FfsInf.ModuleType in ('SEC', 'PEI_CORE', 'PEIM') and SectionType in ('TE', 'PE32'):
+            if FfsInf.ModuleType in (SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM) and SectionType in ('TE', 'PE32'):
                 if FfsInf.KeepReloc is not None:
                     NoStrip = FfsInf.KeepReloc
                 elif FfsInf.KeepRelocFromRule is not None:
@@ -122,7 +123,7 @@ class EfiSection (EfiSectionClassObject):
                     BuildNumTuple = tuple()
 
                 Num = SecNum
-                OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + str(Num) + Ffs.SectionSuffix.get(SectionType))
+                OutputFile = os.path.join( OutputPath, ModuleName + SUP_MODULE_SEC + str(Num) + Ffs.SectionSuffix.get(SectionType))
                 GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_VERSION',
                                                     #Ui=StringData,
                                                     Ver=BuildNum,
@@ -133,7 +134,7 @@ class EfiSection (EfiSectionClassObject):
                 for File in FileList:
                     Index = Index + 1
                     Num = '%s.%d' %(SecNum , Index)
-                    OutputFile = os.path.join(OutputPath, ModuleName + 'SEC' + Num + Ffs.SectionSuffix.get(SectionType))
+                    OutputFile = os.path.join(OutputPath, ModuleName + SUP_MODULE_SEC + Num + Ffs.SectionSuffix.get(SectionType))
                     f = open(File, 'r')
                     VerString = f.read()
                     f.close()
@@ -162,7 +163,7 @@ class EfiSection (EfiSectionClassObject):
                     else:
                         EdkLogger.error("GenFds", GENFDS_ERROR, "File: %s miss Version Section value" %InfFileName)
                 Num = SecNum
-                OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + str(Num) + Ffs.SectionSuffix.get(SectionType))
+                OutputFile = os.path.join( OutputPath, ModuleName + SUP_MODULE_SEC + str(Num) + Ffs.SectionSuffix.get(SectionType))
                 GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_VERSION',
                                                     #Ui=VerString,
                                                     Ver=BuildNum,
@@ -183,7 +184,7 @@ class EfiSection (EfiSectionClassObject):
                 Num = SecNum
                 if IsMakefile and StringData == ModuleNameStr:
                     StringData = "$(MODULE_NAME)"
-                OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + str(Num) + Ffs.SectionSuffix.get(SectionType))
+                OutputFile = os.path.join( OutputPath, ModuleName + SUP_MODULE_SEC + str(Num) + Ffs.SectionSuffix.get(SectionType))
                 GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_USER_INTERFACE',
                                                      Ui=StringData, IsMakefile=IsMakefile)
                 OutputFileList.append(OutputFile)
@@ -192,7 +193,7 @@ class EfiSection (EfiSectionClassObject):
                 for File in FileList:
                     Index = Index + 1
                     Num = '%s.%d' %(SecNum , Index)
-                    OutputFile = os.path.join(OutputPath, ModuleName + 'SEC' + Num + Ffs.SectionSuffix.get(SectionType))
+                    OutputFile = os.path.join(OutputPath, ModuleName + SUP_MODULE_SEC + Num + Ffs.SectionSuffix.get(SectionType))
                     f = open(File, 'r')
                     UiString = f.read()
                     f.close()
@@ -216,7 +217,7 @@ class EfiSection (EfiSectionClassObject):
                 Num = SecNum
                 if IsMakefile and StringData == ModuleNameStr:
                     StringData = "$(MODULE_NAME)"
-                OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + str(Num) + Ffs.SectionSuffix.get(SectionType))
+                OutputFile = os.path.join( OutputPath, ModuleName + SUP_MODULE_SEC + str(Num) + Ffs.SectionSuffix.get(SectionType))
                 GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_USER_INTERFACE',
                                                      Ui=StringData, IsMakefile=IsMakefile)
                 OutputFileList.append(OutputFile)
@@ -237,7 +238,7 @@ class EfiSection (EfiSectionClassObject):
                     """ Copy Map file to FFS output path """
                     Index = Index + 1
                     Num = '%s.%d' %(SecNum , Index)
-                    OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + Num + Ffs.SectionSuffix.get(SectionType))
+                    OutputFile = os.path.join( OutputPath, ModuleName + SUP_MODULE_SEC + Num + Ffs.SectionSuffix.get(SectionType))
                     File = GenFdsGlobalVariable.MacroExtend(File, Dict)
                     
                     #Get PE Section alignment when align is set to AUTO
diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py
index a106253527c4..4ec114a81883 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -2633,7 +2633,7 @@ class FdfParser:
     #
     @staticmethod
     def __FileCouldHaveRelocFlag (FileType):
-        if FileType in ('SEC', 'PEI_CORE', 'PEIM', 'PEI_DXE_COMBO'):
+        if FileType in (SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM, 'PEI_DXE_COMBO'):
             return True
         else:
             return False
@@ -3633,12 +3633,12 @@ class FdfParser:
 
         if not self.__GetNextWord():
             raise Warning("expected Module type", self.FileName, self.CurrentLineNumber)
-        if self.__Token.upper() not in ("SEC", "PEI_CORE", "PEIM", "DXE_CORE", \
-                             "DXE_DRIVER", "DXE_SAL_DRIVER", \
-                             "DXE_SMM_DRIVER", "DXE_RUNTIME_DRIVER", \
-                             "UEFI_DRIVER", "UEFI_APPLICATION", "USER_DEFINED", "DEFAULT", "BASE", \
+        if self.__Token.upper() not in (SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM, SUP_MODULE_DXE_CORE, \
+                             SUP_MODULE_DXE_DRIVER, SUP_MODULE_DXE_SAL_DRIVER, \
+                             SUP_MODULE_DXE_SMM_DRIVER, SUP_MODULE_DXE_RUNTIME_DRIVER, \
+                             SUP_MODULE_UEFI_DRIVER, SUP_MODULE_UEFI_APPLICATION, SUP_MODULE_USER_DEFINED, "DEFAULT", SUP_MODULE_BASE, \
                              "SECURITY_CORE", "COMBINED_PEIM_DRIVER", "PIC_PEIM", "RELOCATABLE_PEIM", \
-                                        "PE32_PEIM", "BS_DRIVER", "RT_DRIVER", "SAL_RT_DRIVER", "APPLICATION", "ACPITABLE", "SMM_CORE", "MM_STANDALONE", "MM_CORE_STANDALONE"):
+                                        "PE32_PEIM", "BS_DRIVER", "RT_DRIVER", "SAL_RT_DRIVER", "APPLICATION", "ACPITABLE", SUP_MODULE_SMM_CORE, SUP_MODULE_MM_STANDALONE, SUP_MODULE_MM_CORE_STANDALONE):
             raise Warning("Unknown Module type '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
         return self.__Token
 
@@ -3680,8 +3680,8 @@ class FdfParser:
             raise Warning("expected FFS type", self.FileName, self.CurrentLineNumber)
 
         Type = self.__Token.strip().upper()
-        if Type not in ("RAW", "FREEFORM", "SEC", "PEI_CORE", "PEIM",\
-                             "PEI_DXE_COMBO", "DRIVER", "DXE_CORE", "APPLICATION", "FV_IMAGE", "SMM", "SMM_CORE", "MM_STANDALONE", "MM_CORE_STANDALONE"):
+        if Type not in ("RAW", "FREEFORM", SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM,\
+                             "PEI_DXE_COMBO", "DRIVER", SUP_MODULE_DXE_CORE, "APPLICATION", "FV_IMAGE", "SMM", SUP_MODULE_SMM_CORE, SUP_MODULE_MM_STANDALONE, SUP_MODULE_MM_CORE_STANDALONE):
             raise Warning("Unknown FV type '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
 
         if not self.__IsToken("="):
diff --git a/BaseTools/Source/Python/GenFds/Ffs.py b/BaseTools/Source/Python/GenFds/Ffs.py
index a4178121118b..fc760ae8beda 100644
--- a/BaseTools/Source/Python/GenFds/Ffs.py
+++ b/BaseTools/Source/Python/GenFds/Ffs.py
@@ -16,6 +16,7 @@
 # Import Modules
 #
 from CommonDataClass.FdfClass import FDClassObject
+from Common.DataType import *
 
 ## generate FFS
 #
@@ -24,27 +25,27 @@ class Ffs(FDClassObject):
     
     # mapping between MODULE type in FDF (from INF) and file type for GenFfs
     ModuleTypeToFileType = {
-        'SEC'               : 'EFI_FV_FILETYPE_SECURITY_CORE',
-        'PEI_CORE'          : 'EFI_FV_FILETYPE_PEI_CORE',
-        'PEIM'              : 'EFI_FV_FILETYPE_PEIM',
-        'DXE_CORE'          : 'EFI_FV_FILETYPE_DXE_CORE',
-        'DXE_DRIVER'        : 'EFI_FV_FILETYPE_DRIVER',
-        'DXE_SAL_DRIVER'    : 'EFI_FV_FILETYPE_DRIVER',
-        'DXE_SMM_DRIVER'    : 'EFI_FV_FILETYPE_DRIVER',
-        'DXE_RUNTIME_DRIVER': 'EFI_FV_FILETYPE_DRIVER',
-        'UEFI_DRIVER'       : 'EFI_FV_FILETYPE_DRIVER',
-        'UEFI_APPLICATION'  : 'EFI_FV_FILETYPE_APPLICATION',
-        'SMM_CORE'          : 'EFI_FV_FILETYPE_SMM_CORE',
-        'MM_STANDALONE'     : 'EFI_FV_FILETYPE_MM_STANDALONE',
-        'MM_CORE_STANDALONE' : 'EFI_FV_FILETYPE_MM_CORE_STANDALONE'
+        SUP_MODULE_SEC               : 'EFI_FV_FILETYPE_SECURITY_CORE',
+        SUP_MODULE_PEI_CORE          : 'EFI_FV_FILETYPE_PEI_CORE',
+        SUP_MODULE_PEIM              : 'EFI_FV_FILETYPE_PEIM',
+        SUP_MODULE_DXE_CORE          : 'EFI_FV_FILETYPE_DXE_CORE',
+        SUP_MODULE_DXE_DRIVER        : 'EFI_FV_FILETYPE_DRIVER',
+        SUP_MODULE_DXE_SAL_DRIVER    : 'EFI_FV_FILETYPE_DRIVER',
+        SUP_MODULE_DXE_SMM_DRIVER    : 'EFI_FV_FILETYPE_DRIVER',
+        SUP_MODULE_DXE_RUNTIME_DRIVER: 'EFI_FV_FILETYPE_DRIVER',
+        SUP_MODULE_UEFI_DRIVER       : 'EFI_FV_FILETYPE_DRIVER',
+        SUP_MODULE_UEFI_APPLICATION  : 'EFI_FV_FILETYPE_APPLICATION',
+        SUP_MODULE_SMM_CORE          : 'EFI_FV_FILETYPE_SMM_CORE',
+        SUP_MODULE_MM_STANDALONE     : 'EFI_FV_FILETYPE_MM_STANDALONE',
+        SUP_MODULE_MM_CORE_STANDALONE : 'EFI_FV_FILETYPE_MM_CORE_STANDALONE'
     }
     
     # mapping between FILE type in FDF and file type for GenFfs
     FdfFvFileTypeToFileType = {
-        'SEC'               : 'EFI_FV_FILETYPE_SECURITY_CORE',
-        'PEI_CORE'          : 'EFI_FV_FILETYPE_PEI_CORE',
-        'PEIM'              : 'EFI_FV_FILETYPE_PEIM',
-        'DXE_CORE'          : 'EFI_FV_FILETYPE_DXE_CORE',
+        SUP_MODULE_SEC               : 'EFI_FV_FILETYPE_SECURITY_CORE',
+        SUP_MODULE_PEI_CORE          : 'EFI_FV_FILETYPE_PEI_CORE',
+        SUP_MODULE_PEIM              : 'EFI_FV_FILETYPE_PEIM',
+        SUP_MODULE_DXE_CORE          : 'EFI_FV_FILETYPE_DXE_CORE',
         'FREEFORM'          : 'EFI_FV_FILETYPE_FREEFORM',
         'DRIVER'            : 'EFI_FV_FILETYPE_DRIVER',
         'APPLICATION'       : 'EFI_FV_FILETYPE_APPLICATION',
@@ -52,9 +53,9 @@ class Ffs(FDClassObject):
         'RAW'               : 'EFI_FV_FILETYPE_RAW',
         'PEI_DXE_COMBO'     : 'EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER',
         'SMM'               : 'EFI_FV_FILETYPE_SMM',
-        'SMM_CORE'          : 'EFI_FV_FILETYPE_SMM_CORE',
-        'MM_STANDALONE'     : 'EFI_FV_FILETYPE_MM_STANDALONE',
-        'MM_CORE_STANDALONE' : 'EFI_FV_FILETYPE_MM_CORE_STANDALONE'
+        SUP_MODULE_SMM_CORE          : 'EFI_FV_FILETYPE_SMM_CORE',
+        SUP_MODULE_MM_STANDALONE     : 'EFI_FV_FILETYPE_MM_STANDALONE',
+        SUP_MODULE_MM_CORE_STANDALONE : 'EFI_FV_FILETYPE_MM_CORE_STANDALONE'
     }
     
     # mapping between section type in FDF and file suffix
diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
index 37624f3fa9d4..d31d03d43a18 100644
--- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py
+++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
@@ -88,7 +88,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
                 self.FinalTargetSuffixMap.setdefault(os.path.splitext(File)[1], []).append(File)
 
             # Check if current INF module has DEPEX
-            if '.depex' not in self.FinalTargetSuffixMap and self.InfModule.ModuleType != "USER_DEFINED" \
+            if '.depex' not in self.FinalTargetSuffixMap and self.InfModule.ModuleType != SUP_MODULE_USER_DEFINED \
                 and not self.InfModule.DxsFile and not self.InfModule.LibraryClass:
                 ModuleType = self.InfModule.ModuleType
                 PlatformDataBase = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, self.CurrentArch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
@@ -224,10 +224,10 @@ class FfsInfStatement(FfsInfStatementClassObject):
         if len(self.SourceFileList) != 0 and not self.InDsc:
             EdkLogger.warn("GenFds", GENFDS_ERROR, "Module %s NOT found in DSC file; Is it really a binary module?" % (self.InfFileName))
 
-        if self.ModuleType == 'SMM_CORE' and int(self.PiSpecVersion, 16) < 0x0001000A:
+        if self.ModuleType == SUP_MODULE_SMM_CORE and int(self.PiSpecVersion, 16) < 0x0001000A:
             EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "SMM_CORE module type can't be used in the module with PI_SPECIFICATION_VERSION less than 0x0001000A", File=self.InfFileName)      
 
-        if self.ModuleType == 'MM_CORE_STANDALONE' and int(self.PiSpecVersion, 16) < 0x00010032:
+        if self.ModuleType == SUP_MODULE_MM_CORE_STANDALONE and int(self.PiSpecVersion, 16) < 0x00010032:
             EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "MM_CORE_STANDALONE module type can't be used in the module with PI_SPECIFICATION_VERSION less than 0x00010032", File=self.InfFileName)
 
         if Inf._Defs is not None and len(Inf._Defs) > 0:
@@ -381,7 +381,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
         #
         # Only patch file if FileType is PE32 or ModuleType is USER_DEFINED
         #  
-        if FileType != 'PE32' and self.ModuleType != "USER_DEFINED":
+        if FileType != 'PE32' and self.ModuleType != SUP_MODULE_USER_DEFINED:
             return EfiFile
 
         #
@@ -488,14 +488,14 @@ class FfsInfStatement(FfsInfStatementClassObject):
         #
         # Convert Fv File Type for PI1.1 SMM driver.
         #
-        if self.ModuleType == 'DXE_SMM_DRIVER' and int(self.PiSpecVersion, 16) >= 0x0001000A:
+        if self.ModuleType == SUP_MODULE_DXE_SMM_DRIVER and int(self.PiSpecVersion, 16) >= 0x0001000A:
             if Rule.FvFileType == 'DRIVER':
                 Rule.FvFileType = 'SMM'
         #
         # Framework SMM Driver has no SMM FV file type
         #
-        if self.ModuleType == 'DXE_SMM_DRIVER' and int(self.PiSpecVersion, 16) < 0x0001000A:
-            if Rule.FvFileType == 'SMM' or Rule.FvFileType == 'SMM_CORE':
+        if self.ModuleType == SUP_MODULE_DXE_SMM_DRIVER and int(self.PiSpecVersion, 16) < 0x0001000A:
+            if Rule.FvFileType == 'SMM' or Rule.FvFileType == SUP_MODULE_SMM_CORE:
                 EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "Framework SMM module doesn't support SMM or SMM_CORE FV file type", File=self.InfFileName)
         #
         # For the rule only has simpleFile
@@ -738,17 +738,17 @@ class FfsInfStatement(FfsInfStatementClassObject):
         #
         # Convert Fv Section Type for PI1.1 SMM driver.
         #
-        if self.ModuleType == 'DXE_SMM_DRIVER' and int(self.PiSpecVersion, 16) >= 0x0001000A:
+        if self.ModuleType == SUP_MODULE_DXE_SMM_DRIVER and int(self.PiSpecVersion, 16) >= 0x0001000A:
             if SectionType == 'DXE_DEPEX':
                 SectionType = 'SMM_DEPEX'
         #
         # Framework SMM Driver has no SMM_DEPEX section type
         #
-        if self.ModuleType == 'DXE_SMM_DRIVER' and int(self.PiSpecVersion, 16) < 0x0001000A:
+        if self.ModuleType == SUP_MODULE_DXE_SMM_DRIVER and int(self.PiSpecVersion, 16) < 0x0001000A:
             if SectionType == 'SMM_DEPEX':
                 EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "Framework SMM module doesn't support SMM_DEPEX section type", File=self.InfFileName)
         NoStrip = True
-        if self.ModuleType in ('SEC', 'PEI_CORE', 'PEIM'):
+        if self.ModuleType in (SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM):
             if self.KeepReloc is not None:
                 NoStrip = self.KeepReloc
             elif Rule.KeepReloc is not None:
@@ -761,7 +761,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
 
                 SecNum = '%d' %Index
                 GenSecOutputFile= self.__ExtendMacro__(Rule.NameGuid) + \
-                              Ffs.Ffs.SectionSuffix[SectionType] + 'SEC' + SecNum
+                              Ffs.Ffs.SectionSuffix[SectionType] + SUP_MODULE_SEC + SecNum
                 Index = Index + 1
                 OutputFile = os.path.join(self.OutputPath, GenSecOutputFile)
                 File = GenFdsGlobalVariable.MacroExtend(File, Dict, self.CurrentArch)
@@ -804,7 +804,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
         else:
             SecNum = '%d' %Index
             GenSecOutputFile= self.__ExtendMacro__(Rule.NameGuid) + \
-                              Ffs.Ffs.SectionSuffix[SectionType] + 'SEC' + SecNum
+                              Ffs.Ffs.SectionSuffix[SectionType] + SUP_MODULE_SEC + SecNum
             OutputFile = os.path.join(self.OutputPath, GenSecOutputFile)
             GenSecInputFile = GenFdsGlobalVariable.MacroExtend(GenSecInputFile, Dict, self.CurrentArch)
 
@@ -902,7 +902,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
     #   @retval string       File name of the generated section file
     #
     def __GenComplexFileSection__(self, Rule, FvChildAddr, FvParentAddr, IsMakefile = False):
-        if self.ModuleType in ('SEC', 'PEI_CORE', 'PEIM'):
+        if self.ModuleType in (SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM):
             if Rule.KeepReloc is not None:
                 self.KeepRelocFromRule = Rule.KeepReloc
         SectFiles = []
@@ -941,13 +941,13 @@ class FfsInfStatement(FfsInfStatementClassObject):
             #
             # Convert Fv Section Type for PI1.1 SMM driver.
             #
-            if self.ModuleType == 'DXE_SMM_DRIVER' and int(self.PiSpecVersion, 16) >= 0x0001000A:
+            if self.ModuleType == SUP_MODULE_DXE_SMM_DRIVER and int(self.PiSpecVersion, 16) >= 0x0001000A:
                 if Sect.SectionType == 'DXE_DEPEX':
                     Sect.SectionType = 'SMM_DEPEX'
             #
             # Framework SMM Driver has no SMM_DEPEX section type
             #
-            if self.ModuleType == 'DXE_SMM_DRIVER' and int(self.PiSpecVersion, 16) < 0x0001000A:
+            if self.ModuleType == SUP_MODULE_DXE_SMM_DRIVER and int(self.PiSpecVersion, 16) < 0x0001000A:
                 if Sect.SectionType == 'SMM_DEPEX':
                     EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "Framework SMM module doesn't support SMM_DEPEX section type", File=self.InfFileName)
             #
diff --git a/BaseTools/Source/Python/GenFds/FvImageSection.py b/BaseTools/Source/Python/GenFds/FvImageSection.py
index 5026a3ffca2f..eb84b44bbec4 100644
--- a/BaseTools/Source/Python/GenFds/FvImageSection.py
+++ b/BaseTools/Source/Python/GenFds/FvImageSection.py
@@ -24,6 +24,7 @@ import Common.LongFilePathOs as os
 from CommonDataClass.FdfClass import FvImageSectionClassObject
 from Common import EdkLogger
 from Common.BuildToolError import *
+from Common.DataType import *
 
 ## generate FV image section
 #
@@ -74,7 +75,7 @@ class FvImageSection(FvImageSectionClassObject):
                 if FvAlignmentValue > MaxFvAlignment:
                     MaxFvAlignment = FvAlignmentValue
 
-                OutputFile = os.path.join(OutputPath, ModuleName + 'SEC' + Num + Ffs.SectionSuffix.get("FV_IMAGE"))
+                OutputFile = os.path.join(OutputPath, ModuleName + SUP_MODULE_SEC + Num + Ffs.SectionSuffix.get("FV_IMAGE"))
                 GenFdsGlobalVariable.GenerateSection(OutputFile, [FvFileName], 'EFI_SECTION_FIRMWARE_VOLUME_IMAGE', IsMakefile=IsMakefile)
                 OutputFileList.append(OutputFile)
 
@@ -138,7 +139,7 @@ class FvImageSection(FvImageSectionClassObject):
             #
             # Prepare the parameter of GenSection
             #
-            OutputFile = os.path.join(OutputPath, ModuleName + 'SEC' + SecNum + Ffs.SectionSuffix.get("FV_IMAGE"))
+            OutputFile = os.path.join(OutputPath, ModuleName + SUP_MODULE_SEC + SecNum + Ffs.SectionSuffix.get("FV_IMAGE"))
             GenFdsGlobalVariable.GenerateSection(OutputFile, [FvFileName], 'EFI_SECTION_FIRMWARE_VOLUME_IMAGE', IsMakefile=IsMakefile)
             OutputFileList.append(OutputFile)
 
diff --git a/BaseTools/Source/Python/GenFds/GuidSection.py b/BaseTools/Source/Python/GenFds/GuidSection.py
index 08665a3d4d49..1105689e0d79 100644
--- a/BaseTools/Source/Python/GenFds/GuidSection.py
+++ b/BaseTools/Source/Python/GenFds/GuidSection.py
@@ -28,6 +28,7 @@ from Common.BuildToolError import *
 from FvImageSection import FvImageSection
 from Common.LongFilePathSupport import OpenLongFilePath as open
 from GenFds import FindExtendTool
+from Common.DataType import *
 
 ## generate GUIDed section
 #
@@ -121,7 +122,7 @@ class GuidSection(GuidSectionClassObject) :
         OutputFile = OutputPath + \
                      os.sep + \
                      ModuleName + \
-                     'SEC' + \
+                     SUP_MODULE_SEC + \
                      SecNum + \
                      Ffs.SectionSuffix['GUIDED']
         OutputFile = os.path.normpath(OutputFile)
@@ -156,7 +157,7 @@ class GuidSection(GuidSectionClassObject) :
             TempFile = OutputPath + \
                        os.sep + \
                        ModuleName + \
-                       'SEC' + \
+                       SUP_MODULE_SEC + \
                        SecNum + \
                        '.tmp'
             TempFile = os.path.normpath(TempFile)
diff --git a/BaseTools/Source/Python/GenFds/UiSection.py b/BaseTools/Source/Python/GenFds/UiSection.py
index 6340520602ee..084f761e1285 100644
--- a/BaseTools/Source/Python/GenFds/UiSection.py
+++ b/BaseTools/Source/Python/GenFds/UiSection.py
@@ -22,6 +22,7 @@ import Common.LongFilePathOs as os
 from GenFdsGlobalVariable import GenFdsGlobalVariable
 from CommonDataClass.FdfClass import UiSectionClassObject
 from Common.LongFilePathSupport import OpenLongFilePath as open
+from Common.DataType import SUP_MODULE_SEC
 
 ## generate UI section
 #
@@ -57,7 +58,7 @@ class UiSection (UiSectionClassObject):
             self.StringData = FfsInf.__ExtendMacro__(self.StringData)
             self.FileName = FfsInf.__ExtendMacro__(self.FileName)
 
-        OutputFile = os.path.join(OutputPath, ModuleName + 'SEC' + SecNum + Ffs.SectionSuffix.get('UI'))
+        OutputFile = os.path.join(OutputPath, ModuleName + SUP_MODULE_SEC + SecNum + Ffs.SectionSuffix.get('UI'))
 
         if self.StringData is not None :
             NameString = self.StringData
diff --git a/BaseTools/Source/Python/GenFds/VerSection.py b/BaseTools/Source/Python/GenFds/VerSection.py
index 11e974b9936e..456a430079bb 100644
--- a/BaseTools/Source/Python/GenFds/VerSection.py
+++ b/BaseTools/Source/Python/GenFds/VerSection.py
@@ -22,6 +22,7 @@ import subprocess
 from GenFdsGlobalVariable import GenFdsGlobalVariable
 from CommonDataClass.FdfClass import VerSectionClassObject
 from Common.LongFilePathSupport import OpenLongFilePath as open
+from Common.DataType import SUP_MODULE_SEC
 
 ## generate version section
 #
@@ -59,7 +60,7 @@ class VerSection (VerSectionClassObject):
             self.FileName = FfsInf.__ExtendMacro__(self.FileName)
 
         OutputFile = os.path.join(OutputPath,
-                                  ModuleName + 'SEC' + SecNum + Ffs.SectionSuffix.get('VERSION'))
+                                  ModuleName + SUP_MODULE_SEC + SecNum + Ffs.SectionSuffix.get('VERSION'))
         OutputFile = os.path.normpath(OutputFile)
 
         # Get String Data
diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py b/BaseTools/Source/Python/Workspace/InfBuildData.py
index a725a2a2a772..f2d36d0ee0d4 100644
--- a/BaseTools/Source/Python/Workspace/InfBuildData.py
+++ b/BaseTools/Source/Python/Workspace/InfBuildData.py
@@ -68,22 +68,22 @@ class InfBuildData(ModuleBuildClassObject):
 
     # dict used to convert Component type to Module type
     _MODULE_TYPE_ = {
-        "LIBRARY"               :   "BASE",
-        "SECURITY_CORE"         :   "SEC",
-        "PEI_CORE"              :   "PEI_CORE",
-        "COMBINED_PEIM_DRIVER"  :   "PEIM",
-        "PIC_PEIM"              :   "PEIM",
-        "RELOCATABLE_PEIM"      :   "PEIM",
-        "PE32_PEIM"             :   "PEIM",
-        "BS_DRIVER"             :   "DXE_DRIVER",
-        "RT_DRIVER"             :   "DXE_RUNTIME_DRIVER",
-        "SAL_RT_DRIVER"         :   "DXE_SAL_DRIVER",
-        "DXE_SMM_DRIVER"        :   "DXE_SMM_DRIVER",
-    #    "SMM_DRIVER"            :   "DXE_SMM_DRIVER",
-    #    "BS_DRIVER"             :   "DXE_SMM_DRIVER",
-    #    "BS_DRIVER"             :   "UEFI_DRIVER",
-        "APPLICATION"           :   "UEFI_APPLICATION",
-        "LOGO"                  :   "BASE",
+        "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
@@ -461,9 +461,9 @@ class InfBuildData(ModuleBuildClassObject):
             if self._Header_ is None:
                 self._GetHeaderInfo()
             if self._ModuleType is None:
-                self._ModuleType = 'BASE'
+                self._ModuleType = SUP_MODULE_BASE
             if self._ModuleType not in SUP_MODULE_LIST:
-                self._ModuleType = "USER_DEFINED"
+                self._ModuleType = SUP_MODULE_USER_DEFINED
         return self._ModuleType
 
     ## Retrieve COMPONENT_TYPE
@@ -472,7 +472,7 @@ class InfBuildData(ModuleBuildClassObject):
             if self._Header_ is None:
                 self._GetHeaderInfo()
             if self._ComponentType is None:
-                self._ComponentType = 'USER_DEFINED'
+                self._ComponentType = SUP_MODULE_USER_DEFINED
         return self._ComponentType
 
     ## Retrieve "BUILD_TYPE"
@@ -481,7 +481,7 @@ class InfBuildData(ModuleBuildClassObject):
             if self._Header_ is None:
                 self._GetHeaderInfo()
             if not self._BuildType:
-                self._BuildType = "BASE"
+                self._BuildType = SUP_MODULE_BASE
         return self._BuildType
 
     ## Retrieve file guid
@@ -899,14 +899,14 @@ class InfBuildData(ModuleBuildClassObject):
 
             # PEIM and DXE drivers must have a valid [Depex] section
             if len(self.LibraryClass) == 0 and len(RecordList) == 0:
-                if self.ModuleType == 'DXE_DRIVER' or self.ModuleType == 'PEIM' or self.ModuleType == 'DXE_SMM_DRIVER' or \
-                    self.ModuleType == 'DXE_SAL_DRIVER' or self.ModuleType == 'DXE_RUNTIME_DRIVER':
+                if self.ModuleType == SUP_MODULE_DXE_DRIVER or self.ModuleType == SUP_MODULE_PEIM or self.ModuleType == SUP_MODULE_DXE_SMM_DRIVER or \
+                    self.ModuleType == SUP_MODULE_DXE_SAL_DRIVER or self.ModuleType == SUP_MODULE_DXE_RUNTIME_DRIVER:
                     EdkLogger.error('build', RESOURCE_NOT_AVAILABLE, "No [Depex] section or no valid expression in [Depex] section for [%s] module" \
                                     % self.ModuleType, File=self.MetaFile)
 
-            if len(RecordList) != 0 and self.ModuleType == 'USER_DEFINED':
+            if len(RecordList) != 0 and self.ModuleType == SUP_MODULE_USER_DEFINED:
                 for Record in RecordList:
-                    if Record[4] not in ['PEIM', 'DXE_DRIVER', 'DXE_SMM_DRIVER']:
+                    if Record[4] not in [SUP_MODULE_PEIM, SUP_MODULE_DXE_DRIVER, SUP_MODULE_DXE_SMM_DRIVER]:
                         EdkLogger.error('build', FORMAT_INVALID,
                                         "'%s' module must specify the type of [Depex] section" % self.ModuleType,
                                         File=self.MetaFile)
diff --git a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py
index 736ef6253453..573100081815 100644
--- a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py
+++ b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py
@@ -134,7 +134,7 @@ def _GetModuleLibraryInstances(Module, Platform, BuildDatabase, Arch, Target, To
                     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
                     return []
diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Source/Python/build/BuildReport.py
index 635c311f1a48..2dfd78cb9538 100644
--- a/BaseTools/Source/Python/build/BuildReport.py
+++ b/BaseTools/Source/Python/build/BuildReport.py
@@ -48,18 +48,18 @@ import collections
 from Common.Expression import *
 
 gComponentType2ModuleType = {
-    "LIBRARY"               :   "BASE",
-    "SECURITY_CORE"         :   "SEC",
-    "PEI_CORE"              :   "PEI_CORE",
-    "COMBINED_PEIM_DRIVER"  :   "PEIM",
-    "PIC_PEIM"              :   "PEIM",
-    "RELOCATABLE_PEIM"      :   "PEIM",
-    "PE32_PEIM"             :   "PEIM",
-    "BS_DRIVER"             :   "DXE_DRIVER",
-    "RT_DRIVER"             :   "DXE_RUNTIME_DRIVER",
-    "SAL_RT_DRIVER"         :   "DXE_SAL_DRIVER",
-    "APPLICATION"           :   "UEFI_APPLICATION",
-    "LOGO"                  :   "BASE",
+    "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
@@ -122,20 +122,20 @@ gPcdTypeMap = {
 
 ## The look up table to map module type to driver type
 gDriverTypeMap = {
-  'SEC'               : '0x3 (SECURITY_CORE)',
-  'PEI_CORE'          : '0x4 (PEI_CORE)',
-  'PEIM'              : '0x6 (PEIM)',
-  'DXE_CORE'          : '0x5 (DXE_CORE)',
-  'DXE_DRIVER'        : '0x7 (DRIVER)',
-  'DXE_SAL_DRIVER'    : '0x7 (DRIVER)',
-  'DXE_SMM_DRIVER'    : '0x7 (DRIVER)',
-  'DXE_RUNTIME_DRIVER': '0x7 (DRIVER)',
-  'UEFI_DRIVER'       : '0x7 (DRIVER)',
-  'UEFI_APPLICATION'  : '0x9 (APPLICATION)',
-  'SMM_CORE'          : '0xD (SMM_CORE)',
+  SUP_MODULE_SEC               : '0x3 (SECURITY_CORE)',
+  SUP_MODULE_PEI_CORE          : '0x4 (PEI_CORE)',
+  SUP_MODULE_PEIM              : '0x6 (PEIM)',
+  SUP_MODULE_DXE_CORE          : '0x5 (DXE_CORE)',
+  SUP_MODULE_DXE_DRIVER        : '0x7 (DRIVER)',
+  SUP_MODULE_DXE_SAL_DRIVER    : '0x7 (DRIVER)',
+  SUP_MODULE_DXE_SMM_DRIVER    : '0x7 (DRIVER)',
+  SUP_MODULE_DXE_RUNTIME_DRIVER: '0x7 (DRIVER)',
+  SUP_MODULE_UEFI_DRIVER       : '0x7 (DRIVER)',
+  SUP_MODULE_UEFI_APPLICATION  : '0x9 (APPLICATION)',
+  SUP_MODULE_SMM_CORE          : '0xD (SMM_CORE)',
   'SMM_DRIVER'        : '0xA (SMM)', # Extension of module type to support PI 1.1 SMM drivers
-  'MM_STANDALONE'     : '0xE (MM_STANDALONE)',
-  'MM_CORE_STANDALONE' : '0xF (MM_CORE_STANDALONE)'
+  SUP_MODULE_MM_STANDALONE     : '0xE (MM_STANDALONE)',
+  SUP_MODULE_MM_CORE_STANDALONE : '0xF (MM_CORE_STANDALONE)'
   }
 
 ## The look up table of the supported opcode in the dependency expression binaries
@@ -424,7 +424,7 @@ class DepexReport(object):
         if not ModuleType:
             ModuleType = gComponentType2ModuleType.get(M.ComponentType, "")
 
-        if ModuleType in ["SEC", "PEI_CORE", "DXE_CORE", "SMM_CORE", "MM_CORE_STANDALONE", "UEFI_APPLICATION"]:
+        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
       
         for Source in M.SourceFileList:
@@ -591,7 +591,7 @@ class ModuleReport(object):
             #
             # If a module complies to PI 1.1, promote Module type to "SMM_DRIVER"
             #
-            if ModuleType == "DXE_SMM_DRIVER":
+            if ModuleType == SUP_MODULE_DXE_SMM_DRIVER:
                 PiSpec = M.Module.Specification.get("PI_SPECIFICATION_VERSION", "0x00010000")
                 if int(PiSpec, 0) >= 0x0001000A:
                     ModuleType = "SMM_DRIVER"
@@ -1382,7 +1382,7 @@ class PredictionReport(object):
                 # their source code to find PPI/Protocol produce or consume
                 # information.
                 #
-                if Module.ModuleType == "BASE":
+                if Module.ModuleType == SUP_MODULE_BASE:
                     continue
                 #
                 # Add module referenced source files
diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/build/build.py
index 36bb1fecf7e5..81d59dd3eedf 100644
--- a/BaseTools/Source/Python/build/build.py
+++ b/BaseTools/Source/Python/build/build.py
@@ -1587,22 +1587,22 @@ class Build():
                     if not ImageClass.IsValid:
                         EdkLogger.error("build", FILE_PARSE_FAILURE, ExtraData=ImageClass.ErrorInfo)
                     ImageInfo = PeImageInfo(Module.Name, Module.Guid, Module.Arch, Module.OutputDir, Module.DebugDir, ImageClass)
-                    if Module.ModuleType in ['PEI_CORE', 'PEIM', 'COMBINED_PEIM_DRIVER', 'PIC_PEIM', 'RELOCATABLE_PEIM', 'DXE_CORE']:
+                    if Module.ModuleType in [SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM, 'COMBINED_PEIM_DRIVER', 'PIC_PEIM', 'RELOCATABLE_PEIM', SUP_MODULE_DXE_CORE]:
                         PeiModuleList[Module.MetaFile] = ImageInfo
                         PeiSize += ImageInfo.Image.Size
-                    elif Module.ModuleType in ['BS_DRIVER', 'DXE_DRIVER', 'UEFI_DRIVER']:
+                    elif Module.ModuleType in ['BS_DRIVER', SUP_MODULE_DXE_DRIVER, SUP_MODULE_UEFI_DRIVER]:
                         BtModuleList[Module.MetaFile] = ImageInfo
                         BtSize += ImageInfo.Image.Size
-                    elif Module.ModuleType in ['DXE_RUNTIME_DRIVER', 'RT_DRIVER', 'DXE_SAL_DRIVER', 'SAL_RT_DRIVER']:
+                    elif Module.ModuleType in [SUP_MODULE_DXE_RUNTIME_DRIVER, 'RT_DRIVER', SUP_MODULE_DXE_SAL_DRIVER, 'SAL_RT_DRIVER']:
                         RtModuleList[Module.MetaFile] = ImageInfo
                         #IPF runtime driver needs to be at 2 page alignment.
                         if IsIpfPlatform and ImageInfo.Image.Size % 0x2000 != 0:
                             ImageInfo.Image.Size = (ImageInfo.Image.Size / 0x2000 + 1) * 0x2000
                         RtSize += ImageInfo.Image.Size
-                    elif Module.ModuleType in ['SMM_CORE', 'DXE_SMM_DRIVER', 'MM_STANDALONE', 'MM_CORE_STANDALONE']:
+                    elif Module.ModuleType in [SUP_MODULE_SMM_CORE, SUP_MODULE_DXE_SMM_DRIVER, SUP_MODULE_MM_STANDALONE, SUP_MODULE_MM_CORE_STANDALONE]:
                         SmmModuleList[Module.MetaFile] = ImageInfo
                         SmmSize += ImageInfo.Image.Size
-                        if Module.ModuleType == 'DXE_SMM_DRIVER':
+                        if Module.ModuleType == SUP_MODULE_DXE_SMM_DRIVER:
                             PiSpecVersion = Module.Module.Specification.get('PI_SPECIFICATION_VERSION', '0x00000000')
                             # for PI specification < PI1.1, DXE_SMM_DRIVER also runs as BOOT time driver.
                             if int(PiSpecVersion, 16) < 0x0001000A:
-- 
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH v1 14/27] BaseTools: Define and use a set for common list
  2018-04-20 15:51 [PATCH v1 00/27] BaseTools refactoring Jaben Carsey
                   ` (12 preceding siblings ...)
  2018-04-20 15:51 ` [PATCH v1 13/27] BaseTools: replace string constants used for module types Jaben Carsey
@ 2018-04-20 15:51 ` Jaben Carsey
  2018-05-02  6:48   ` Zhu, Yonghong
  2018-04-20 15:51 ` [PATCH v1 15/27] BaseTools: Share a dictionary instead of keeping multiples Jaben Carsey
                   ` (12 subsequent siblings)
  26 siblings, 1 reply; 56+ messages in thread
From: Jaben Carsey @ 2018-04-20 15:51 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Yonghong Zhu

share a set for both PEI module types

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>
---
 BaseTools/Source/Python/AutoGen/AutoGen.py | 4 ++--
 BaseTools/Source/Python/AutoGen/GenC.py    | 8 ++++----
 BaseTools/Source/Python/Common/DataType.py | 1 +
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 9c3bf864e360..60088c87a03b 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -1431,7 +1431,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 [SUP_MODULE_PEIM, SUP_MODULE_PEI_CORE]:
+                    if M.ModuleType in SUP_MODULE_SET_PEI:
                         PcdFromModule.Phase = "PEI"
                     if PcdFromModule not in self._DynaPcdList_:
                         self._DynaPcdList_.append(PcdFromModule)
@@ -1473,7 +1473,7 @@ class PlatformAutoGen(AutoGen):
                     # make sure that the "VOID*" kind of datum has MaxDatumSize set
                     if PcdFromModule.DatumType == "VOID*" and PcdFromModule.MaxDatumSize in [None, '']:
                         NoDatumTypePcdList.add("%s.%s [%s]" % (PcdFromModule.TokenSpaceGuidCName, PcdFromModule.TokenCName, InfName))
-                    if M.ModuleType in [SUP_MODULE_PEIM, SUP_MODULE_PEI_CORE]:
+                    if M.ModuleType in SUP_MODULE_SET_PEI:
                         PcdFromModule.Phase = "PEI"
                     if PcdFromModule not in self._DynaPcdList_ and PcdFromModule.Type in GenC.gDynamicExPcd:
                         self._DynaPcdList_.append(PcdFromModule)
diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py
index 7bc352274e66..57ff699a968a 100644
--- a/BaseTools/Source/Python/AutoGen/GenC.py
+++ b/BaseTools/Source/Python/AutoGen/GenC.py
@@ -1411,7 +1411,7 @@ def CreateLibraryConstructorCode(Info, AutoGenC, AutoGenH):
         if Lib.ModuleType in [SUP_MODULE_BASE, SUP_MODULE_SEC]:
             ConstructorPrototypeString.Append(gLibraryStructorPrototype[SUP_MODULE_BASE].Replace(Dict))
             ConstructorCallingString.Append(gLibraryStructorCall[SUP_MODULE_BASE].Replace(Dict))
-        elif Lib.ModuleType in [SUP_MODULE_PEI_CORE,SUP_MODULE_PEIM]:
+        elif Lib.ModuleType in SUP_MODULE_SET_PEI:
             ConstructorPrototypeString.Append(gLibraryStructorPrototype['PEI'].Replace(Dict))
             ConstructorCallingString.Append(gLibraryStructorCall['PEI'].Replace(Dict))
         elif Lib.ModuleType in [SUP_MODULE_DXE_CORE,SUP_MODULE_DXE_DRIVER,SUP_MODULE_DXE_SMM_DRIVER,SUP_MODULE_DXE_RUNTIME_DRIVER,
@@ -1441,7 +1441,7 @@ def CreateLibraryConstructorCode(Info, AutoGenC, AutoGenH):
     else:
         if Info.ModuleType in [SUP_MODULE_BASE, SUP_MODULE_SEC]:
             AutoGenC.Append(gLibraryString[SUP_MODULE_BASE].Replace(Dict))
-        elif Info.ModuleType in [SUP_MODULE_PEI_CORE,SUP_MODULE_PEIM]:
+        elif Info.ModuleType in SUP_MODULE_SET_PEI:
             AutoGenC.Append(gLibraryString['PEI'].Replace(Dict))
         elif Info.ModuleType in [SUP_MODULE_DXE_CORE,SUP_MODULE_DXE_DRIVER,SUP_MODULE_DXE_SMM_DRIVER,SUP_MODULE_DXE_RUNTIME_DRIVER,
                                  SUP_MODULE_DXE_SAL_DRIVER,SUP_MODULE_UEFI_DRIVER,SUP_MODULE_UEFI_APPLICATION,SUP_MODULE_SMM_CORE]:
@@ -1473,7 +1473,7 @@ def CreateLibraryDestructorCode(Info, AutoGenC, AutoGenH):
         if Lib.ModuleType in [SUP_MODULE_BASE, SUP_MODULE_SEC]:
             DestructorPrototypeString.Append(gLibraryStructorPrototype[SUP_MODULE_BASE].Replace(Dict))
             DestructorCallingString.Append(gLibraryStructorCall[SUP_MODULE_BASE].Replace(Dict))
-        elif Lib.ModuleType in [SUP_MODULE_PEI_CORE,SUP_MODULE_PEIM]:
+        elif Lib.ModuleType in SUP_MODULE_SET_PEI:
             DestructorPrototypeString.Append(gLibraryStructorPrototype['PEI'].Replace(Dict))
             DestructorCallingString.Append(gLibraryStructorCall['PEI'].Replace(Dict))
         elif Lib.ModuleType in [SUP_MODULE_DXE_CORE,SUP_MODULE_DXE_DRIVER,SUP_MODULE_DXE_SMM_DRIVER,SUP_MODULE_DXE_RUNTIME_DRIVER,
@@ -1503,7 +1503,7 @@ def CreateLibraryDestructorCode(Info, AutoGenC, AutoGenH):
     else:
         if Info.ModuleType in [SUP_MODULE_BASE, SUP_MODULE_SEC]:
             AutoGenC.Append(gLibraryString[SUP_MODULE_BASE].Replace(Dict))
-        elif Info.ModuleType in [SUP_MODULE_PEI_CORE,SUP_MODULE_PEIM]:
+        elif Info.ModuleType in SUP_MODULE_SET_PEI:
             AutoGenC.Append(gLibraryString['PEI'].Replace(Dict))
         elif Info.ModuleType in [SUP_MODULE_DXE_CORE,SUP_MODULE_DXE_DRIVER,SUP_MODULE_DXE_SMM_DRIVER,SUP_MODULE_DXE_RUNTIME_DRIVER,
                                  SUP_MODULE_DXE_SAL_DRIVER,SUP_MODULE_UEFI_DRIVER,SUP_MODULE_UEFI_APPLICATION,SUP_MODULE_SMM_CORE]:
diff --git a/BaseTools/Source/Python/Common/DataType.py b/BaseTools/Source/Python/Common/DataType.py
index 0bd55494df66..06e8defcf927 100644
--- a/BaseTools/Source/Python/Common/DataType.py
+++ b/BaseTools/Source/Python/Common/DataType.py
@@ -77,6 +77,7 @@ SUP_MODULE_LIST = [SUP_MODULE_BASE, SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MOD
                    SUP_MODULE_DXE_RUNTIME_DRIVER, SUP_MODULE_DXE_SAL_DRIVER, SUP_MODULE_DXE_SMM_DRIVER, SUP_MODULE_UEFI_DRIVER, \
                    SUP_MODULE_UEFI_APPLICATION, SUP_MODULE_USER_DEFINED, SUP_MODULE_SMM_CORE, SUP_MODULE_MM_STANDALONE, SUP_MODULE_MM_CORE_STANDALONE]
 SUP_MODULE_LIST_STRING = TAB_VALUE_SPLIT.join(SUP_MODULE_LIST)
+SUP_MODULE_SET_PEI = {SUP_MODULE_PEIM, SUP_MODULE_PEI_CORE}
 
 EDK_COMPONENT_TYPE_LIBRARY = 'LIBRARY'
 EDK_COMPONENT_TYPE_SECUARITY_CORE = 'SECUARITY_CORE'
-- 
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH v1 15/27] BaseTools: Share a dictionary instead of keeping multiples
  2018-04-20 15:51 [PATCH v1 00/27] BaseTools refactoring Jaben Carsey
                   ` (13 preceding siblings ...)
  2018-04-20 15:51 ` [PATCH v1 14/27] BaseTools: Define and use a set for common list Jaben Carsey
@ 2018-04-20 15:51 ` Jaben Carsey
  2018-04-20 15:51 ` [PATCH v1 16/27] BaseTools: Replace EDK Component strings with predefined constant Jaben Carsey
                   ` (11 subsequent siblings)
  26 siblings, 0 replies; 56+ messages in thread
From: Jaben Carsey @ 2018-04-20 15:51 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Yonghong Zhu

Move a dictionary to a shared location and use from there

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>
---
 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



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH v1 16/27] BaseTools: Replace EDK Component strings with predefined constant
  2018-04-20 15:51 [PATCH v1 00/27] BaseTools refactoring Jaben Carsey
                   ` (14 preceding siblings ...)
  2018-04-20 15:51 ` [PATCH v1 15/27] BaseTools: Share a dictionary instead of keeping multiples Jaben Carsey
@ 2018-04-20 15:51 ` Jaben Carsey
  2018-04-24  7:42   ` Zhu, Yonghong
  2018-04-20 15:51 ` [PATCH v1 17/27] BaseTools: DataType - cleanup list constants Jaben Carsey
                   ` (10 subsequent siblings)
  26 siblings, 1 reply; 56+ messages in thread
From: Jaben Carsey @ 2018-04-20 15:51 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Yonghong Zhu

EDK_COMPONENT_TYPE_LIBRARY was 'LIBRARY'
EDK_COMPONENT_TYPE_SECURITY_CORE was 'SECURITY_CORE'
EDK_COMPONENT_TYPE_COMBINED_PEIM_DRIVER was 'COMBINED_PEIM_DRIVER'
EDK_COMPONENT_TYPE_PIC_PEIM was 'PIC_PEIM'
EDK_COMPONENT_TYPE_RELOCATABLE_PEIM was 'RELOCATABLE_PEIM'
EDK_COMPONENT_TYPE_BS_DRIVER was 'BS_DRIVER'
EDK_COMPONENT_TYPE_RT_DRIVER was 'RT_DRIVER'
EDK_COMPONENT_TYPE_SAL_RT_DRIVER was 'SAL_RT_DRIVER'
EDK_COMPONENT_TYPE_APPLICATION was 'APPLICATION'

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>
---
 BaseTools/Source/Python/Common/DataType.py        | 28 ++++++++++----------
 BaseTools/Source/Python/GenFds/FdfParser.py       |  6 ++---
 BaseTools/Source/Python/GenFds/Ffs.py             |  2 +-
 BaseTools/Source/Python/Workspace/InfBuildData.py |  2 +-
 BaseTools/Source/Python/build/BuildReport.py      |  6 ++---
 BaseTools/Source/Python/build/build.py            |  8 +++---
 6 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/BaseTools/Source/Python/Common/DataType.py b/BaseTools/Source/Python/Common/DataType.py
index ab9acb417331..74ed711abc52 100644
--- a/BaseTools/Source/Python/Common/DataType.py
+++ b/BaseTools/Source/Python/Common/DataType.py
@@ -80,7 +80,7 @@ SUP_MODULE_LIST_STRING = TAB_VALUE_SPLIT.join(SUP_MODULE_LIST)
 SUP_MODULE_SET_PEI = {SUP_MODULE_PEIM, SUP_MODULE_PEI_CORE}
 
 EDK_COMPONENT_TYPE_LIBRARY = 'LIBRARY'
-EDK_COMPONENT_TYPE_SECUARITY_CORE = 'SECUARITY_CORE'
+EDK_COMPONENT_TYPE_SECURITY_CORE = 'SECURITY_CORE'
 EDK_COMPONENT_TYPE_PEI_CORE = SUP_MODULE_PEI_CORE
 EDK_COMPONENT_TYPE_COMBINED_PEIM_DRIVER = 'COMBINED_PEIM_DRIVER'
 EDK_COMPONENT_TYPE_PIC_PEIM = 'PIC_PEIM'
@@ -93,18 +93,18 @@ 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,
+    EDK_COMPONENT_TYPE_LIBRARY               :   SUP_MODULE_BASE,
+    EDK_COMPONENT_TYPE_SECURITY_CORE         :   SUP_MODULE_SEC,
+    EDK_COMPONENT_TYPE_PEI_CORE              :   SUP_MODULE_PEI_CORE,
+    EDK_COMPONENT_TYPE_COMBINED_PEIM_DRIVER  :   SUP_MODULE_PEIM,
+    EDK_COMPONENT_TYPE_PIC_PEIM              :   SUP_MODULE_PEIM,
+    EDK_COMPONENT_TYPE_RELOCATABLE_PEIM      :   SUP_MODULE_PEIM,
+    "PE32_PEIM"                              :   SUP_MODULE_PEIM,
+    EDK_COMPONENT_TYPE_BS_DRIVER             :   SUP_MODULE_DXE_DRIVER,
+    EDK_COMPONENT_TYPE_RT_DRIVER             :   SUP_MODULE_DXE_RUNTIME_DRIVER,
+    EDK_COMPONENT_TYPE_SAL_RT_DRIVER         :   SUP_MODULE_DXE_SAL_DRIVER,
+    EDK_COMPONENT_TYPE_APPLICATION           :   SUP_MODULE_UEFI_APPLICATION,
+    "LOGO"                                   :   SUP_MODULE_BASE,
 }
 
 BINARY_FILE_TYPE_FW = 'FW'
@@ -125,7 +125,7 @@ BINARY_FILE_TYPE_UI = 'UI'
 BINARY_FILE_TYPE_BIN = 'BIN'
 BINARY_FILE_TYPE_FV = 'FV'
 
-PLATFORM_COMPONENT_TYPE_LIBRARY = 'LIBRARY'
+PLATFORM_COMPONENT_TYPE_LIBRARY = EDK_COMPONENT_TYPE_LIBRARY
 PLATFORM_COMPONENT_TYPE_LIBRARY_CLASS = 'LIBRARY_CLASS'
 PLATFORM_COMPONENT_TYPE_MODULE = 'MODULE'
 
diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py
index 4ec114a81883..e117a3717d42 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -3637,8 +3637,8 @@ class FdfParser:
                              SUP_MODULE_DXE_DRIVER, SUP_MODULE_DXE_SAL_DRIVER, \
                              SUP_MODULE_DXE_SMM_DRIVER, SUP_MODULE_DXE_RUNTIME_DRIVER, \
                              SUP_MODULE_UEFI_DRIVER, SUP_MODULE_UEFI_APPLICATION, SUP_MODULE_USER_DEFINED, "DEFAULT", SUP_MODULE_BASE, \
-                             "SECURITY_CORE", "COMBINED_PEIM_DRIVER", "PIC_PEIM", "RELOCATABLE_PEIM", \
-                                        "PE32_PEIM", "BS_DRIVER", "RT_DRIVER", "SAL_RT_DRIVER", "APPLICATION", "ACPITABLE", SUP_MODULE_SMM_CORE, SUP_MODULE_MM_STANDALONE, SUP_MODULE_MM_CORE_STANDALONE):
+                             EDK_COMPONENT_TYPE_SECURITY_CORE, EDK_COMPONENT_TYPE_COMBINED_PEIM_DRIVER, EDK_COMPONENT_TYPE_PIC_PEIM, EDK_COMPONENT_TYPE_RELOCATABLE_PEIM, \
+                                        "PE32_PEIM", EDK_COMPONENT_TYPE_BS_DRIVER, EDK_COMPONENT_TYPE_RT_DRIVER, EDK_COMPONENT_TYPE_SAL_RT_DRIVER, EDK_COMPONENT_TYPE_APPLICATION, "ACPITABLE", SUP_MODULE_SMM_CORE, SUP_MODULE_MM_STANDALONE, SUP_MODULE_MM_CORE_STANDALONE):
             raise Warning("Unknown Module type '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
         return self.__Token
 
@@ -3681,7 +3681,7 @@ class FdfParser:
 
         Type = self.__Token.strip().upper()
         if Type not in ("RAW", "FREEFORM", SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM,\
-                             "PEI_DXE_COMBO", "DRIVER", SUP_MODULE_DXE_CORE, "APPLICATION", "FV_IMAGE", "SMM", SUP_MODULE_SMM_CORE, SUP_MODULE_MM_STANDALONE, SUP_MODULE_MM_CORE_STANDALONE):
+                             "PEI_DXE_COMBO", "DRIVER", SUP_MODULE_DXE_CORE, EDK_COMPONENT_TYPE_APPLICATION, "FV_IMAGE", "SMM", SUP_MODULE_SMM_CORE, SUP_MODULE_MM_STANDALONE, SUP_MODULE_MM_CORE_STANDALONE):
             raise Warning("Unknown FV type '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
 
         if not self.__IsToken("="):
diff --git a/BaseTools/Source/Python/GenFds/Ffs.py b/BaseTools/Source/Python/GenFds/Ffs.py
index fc760ae8beda..f15d2330ce58 100644
--- a/BaseTools/Source/Python/GenFds/Ffs.py
+++ b/BaseTools/Source/Python/GenFds/Ffs.py
@@ -48,7 +48,7 @@ class Ffs(FDClassObject):
         SUP_MODULE_DXE_CORE          : 'EFI_FV_FILETYPE_DXE_CORE',
         'FREEFORM'          : 'EFI_FV_FILETYPE_FREEFORM',
         'DRIVER'            : 'EFI_FV_FILETYPE_DRIVER',
-        'APPLICATION'       : 'EFI_FV_FILETYPE_APPLICATION',
+        EDK_COMPONENT_TYPE_APPLICATION       : 'EFI_FV_FILETYPE_APPLICATION',
         'FV_IMAGE'          : 'EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE',
         'RAW'               : 'EFI_FV_FILETYPE_RAW',
         'PEI_DXE_COMBO'     : 'EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER',
diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py b/BaseTools/Source/Python/Workspace/InfBuildData.py
index d64a281a98f7..27ef163eb40c 100644
--- a/BaseTools/Source/Python/Workspace/InfBuildData.py
+++ b/BaseTools/Source/Python/Workspace/InfBuildData.py
@@ -344,7 +344,7 @@ class InfBuildData(ModuleBuildClassObject):
             self._BuildType = self._ComponentType.upper()
             if self._ComponentType in COMPONENT_TO_MODULE_MAP_DICT:
                 self._ModuleType = COMPONENT_TO_MODULE_MAP_DICT[self._ComponentType]
-            if self._ComponentType == 'LIBRARY':
+            if self._ComponentType == EDK_COMPONENT_TYPE_LIBRARY:
                 self._LibraryClass = [LibraryClassObject(self._BaseName, SUP_MODULE_LIST)]
             # make use some [nmake] section macros
             Macros = self._Macros
diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Source/Python/build/BuildReport.py
index 5846c2870d2e..02e01a1fa2ab 100644
--- a/BaseTools/Source/Python/build/BuildReport.py
+++ b/BaseTools/Source/Python/build/BuildReport.py
@@ -599,7 +599,7 @@ class ModuleReport(object):
                 self.ModulePcdSet.setdefault((Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Pcd.Type), (Pcd.InfDefaultValue, Pcd.DefaultValue))
 
         self.LibraryReport = None
-        if "LIBRARY" in ReportType:
+        if EDK_COMPONENT_TYPE_LIBRARY in ReportType:
             self.LibraryReport = LibraryReport(M)
 
         self.DepexReport = None
@@ -702,7 +702,7 @@ class ModuleReport(object):
         if "PCD" in ReportType:
             GlobalPcdReport.GenerateReport(File, self.ModulePcdSet)
 
-        if "LIBRARY" in ReportType:
+        if EDK_COMPONENT_TYPE_LIBRARY in ReportType:
             self.LibraryReport.GenerateReport(File)
 
         if "DEPEX" in ReportType:
@@ -2097,7 +2097,7 @@ class BuildReport(object):
                     if ReportTypeItem not in self.ReportType:
                         self.ReportType.append(ReportTypeItem)
             else:
-                self.ReportType = ["PCD", "LIBRARY", "BUILD_FLAGS", "DEPEX", "HASH", "FLASH", "FIXED_ADDRESS"]
+                self.ReportType = ["PCD", EDK_COMPONENT_TYPE_LIBRARY, "BUILD_FLAGS", "DEPEX", "HASH", "FLASH", "FIXED_ADDRESS"]
     ##
     # Adds platform report to the list
     #
diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/build/build.py
index 81d59dd3eedf..29ad0c7228c7 100644
--- a/BaseTools/Source/Python/build/build.py
+++ b/BaseTools/Source/Python/build/build.py
@@ -1587,13 +1587,13 @@ class Build():
                     if not ImageClass.IsValid:
                         EdkLogger.error("build", FILE_PARSE_FAILURE, ExtraData=ImageClass.ErrorInfo)
                     ImageInfo = PeImageInfo(Module.Name, Module.Guid, Module.Arch, Module.OutputDir, Module.DebugDir, ImageClass)
-                    if Module.ModuleType in [SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM, 'COMBINED_PEIM_DRIVER', 'PIC_PEIM', 'RELOCATABLE_PEIM', SUP_MODULE_DXE_CORE]:
+                    if Module.ModuleType in [SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM, EDK_COMPONENT_TYPE_COMBINED_PEIM_DRIVER, EDK_COMPONENT_TYPE_PIC_PEIM, EDK_COMPONENT_TYPE_RELOCATABLE_PEIM, SUP_MODULE_DXE_CORE]:
                         PeiModuleList[Module.MetaFile] = ImageInfo
                         PeiSize += ImageInfo.Image.Size
-                    elif Module.ModuleType in ['BS_DRIVER', SUP_MODULE_DXE_DRIVER, SUP_MODULE_UEFI_DRIVER]:
+                    elif Module.ModuleType in [EDK_COMPONENT_TYPE_BS_DRIVER, SUP_MODULE_DXE_DRIVER, SUP_MODULE_UEFI_DRIVER]:
                         BtModuleList[Module.MetaFile] = ImageInfo
                         BtSize += ImageInfo.Image.Size
-                    elif Module.ModuleType in [SUP_MODULE_DXE_RUNTIME_DRIVER, 'RT_DRIVER', SUP_MODULE_DXE_SAL_DRIVER, 'SAL_RT_DRIVER']:
+                    elif Module.ModuleType in [SUP_MODULE_DXE_RUNTIME_DRIVER, EDK_COMPONENT_TYPE_RT_DRIVER, SUP_MODULE_DXE_SAL_DRIVER, EDK_COMPONENT_TYPE_SAL_RT_DRIVER]:
                         RtModuleList[Module.MetaFile] = ImageInfo
                         #IPF runtime driver needs to be at 2 page alignment.
                         if IsIpfPlatform and ImageInfo.Image.Size % 0x2000 != 0:
@@ -2356,7 +2356,7 @@ def MyOptionParser():
     Parser.add_option("-D", "--define", action="append", type="string", dest="Macros", help="Macro: \"Name [= Value]\".")
 
     Parser.add_option("-y", "--report-file", action="store", dest="ReportFile", help="Create/overwrite the report to the specified filename.")
-    Parser.add_option("-Y", "--report-type", action="append", type="choice", choices=['PCD','LIBRARY','FLASH','DEPEX','BUILD_FLAGS','FIXED_ADDRESS','HASH','EXECUTION_ORDER'], dest="ReportType", default=[],
+    Parser.add_option("-Y", "--report-type", action="append", type="choice", choices=['PCD',EDK_COMPONENT_TYPE_LIBRARY,'FLASH','DEPEX','BUILD_FLAGS','FIXED_ADDRESS','HASH','EXECUTION_ORDER'], dest="ReportType", default=[],
         help="Flags that control the type of build report to generate.  Must be one of: [PCD, LIBRARY, FLASH, DEPEX, BUILD_FLAGS, FIXED_ADDRESS, HASH, EXECUTION_ORDER].  "\
              "To specify more than one flag, repeat this option on the command line and the default flag set is [PCD, LIBRARY, FLASH, DEPEX, HASH, BUILD_FLAGS, FIXED_ADDRESS]")
     Parser.add_option("-F", "--flag", action="store", type="string", dest="Flag",
-- 
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH v1 17/27] BaseTools: DataType - cleanup list constants
  2018-04-20 15:51 [PATCH v1 00/27] BaseTools refactoring Jaben Carsey
                   ` (15 preceding siblings ...)
  2018-04-20 15:51 ` [PATCH v1 16/27] BaseTools: Replace EDK Component strings with predefined constant Jaben Carsey
@ 2018-04-20 15:51 ` Jaben Carsey
  2018-05-04 11:14   ` Laszlo Ersek
  2018-04-20 15:51 ` [PATCH v1 18/27] BaseTools: Replace PCD type strings with predefined constant Jaben Carsey
                   ` (9 subsequent siblings)
  26 siblings, 1 reply; 56+ messages in thread
From: Jaben Carsey @ 2018-04-20 15:51 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Yonghong Zhu

remove unused ones
convert lists used for membership testing to sets
use shared ones not local ones

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>
---
 BaseTools/Source/Python/AutoGen/AutoGen.py           | 32 ++++++++---------
 BaseTools/Source/Python/AutoGen/GenC.py              | 36 ++++++++------------
 BaseTools/Source/Python/AutoGen/GenPcdDb.py          |  4 +--
 BaseTools/Source/Python/Common/DataType.py           | 29 ++++++----------
 BaseTools/Source/Python/Ecc/Configuration.py         |  2 +-
 BaseTools/Source/Python/Ecc/c.py                     |  2 +-
 BaseTools/Source/Python/GenFds/FdfParser.py          |  2 +-
 BaseTools/Source/Python/GenFds/Ffs.py                | 20 +----------
 BaseTools/Source/Python/GenFds/OptRomInfStatement.py |  1 -
 BaseTools/Source/Python/Workspace/InfBuildData.py    |  2 +-
 BaseTools/Source/Python/Workspace/MetaFileParser.py  |  4 +--
 BaseTools/Source/Python/build/build.py               |  4 +--
 12 files changed, 53 insertions(+), 85 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 60088c87a03b..2f60c17439c0 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -508,8 +508,8 @@ class WorkspaceAutoGen(AutoGen):
                         if (BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName) == SinglePcd:
                             for item in GlobalData.MixedPcd[SinglePcd]:
                                 Pcd_Type = item[0].split('_')[-1]
-                                if (Pcd_Type == BuildData.Pcds[key].Type) or (Pcd_Type == TAB_PCDS_DYNAMIC_EX and BuildData.Pcds[key].Type in GenC.gDynamicExPcd) or \
-                                   (Pcd_Type == TAB_PCDS_DYNAMIC and BuildData.Pcds[key].Type in GenC.gDynamicPcd):
+                                if (Pcd_Type == BuildData.Pcds[key].Type) or (Pcd_Type == TAB_PCDS_DYNAMIC_EX and BuildData.Pcds[key].Type in PCD_DYNAMIC_EX_TYPE_SET) or \
+                                   (Pcd_Type == TAB_PCDS_DYNAMIC and BuildData.Pcds[key].Type in PCD_DYNAMIC_TYPE_SET):
                                     Value = BuildData.Pcds[key]
                                     Value.TokenCName = BuildData.Pcds[key].TokenCName + '_' + Pcd_Type
                                     if len(key) == 2:
@@ -1363,8 +1363,8 @@ class PlatformAutoGen(AutoGen):
                 if (self.Platform.Pcds[key].TokenCName, self.Platform.Pcds[key].TokenSpaceGuidCName) == SinglePcd:
                     for item in GlobalData.MixedPcd[SinglePcd]:
                         Pcd_Type = item[0].split('_')[-1]
-                        if (Pcd_Type == self.Platform.Pcds[key].Type) or (Pcd_Type == TAB_PCDS_DYNAMIC_EX and self.Platform.Pcds[key].Type in GenC.gDynamicExPcd) or \
-                           (Pcd_Type == TAB_PCDS_DYNAMIC and self.Platform.Pcds[key].Type in GenC.gDynamicPcd):
+                        if (Pcd_Type == self.Platform.Pcds[key].Type) or (Pcd_Type == TAB_PCDS_DYNAMIC_EX and self.Platform.Pcds[key].Type in PCD_DYNAMIC_EX_TYPE_SET) or \
+                           (Pcd_Type == TAB_PCDS_DYNAMIC and self.Platform.Pcds[key].Type in PCD_DYNAMIC_TYPE_SET):
                             Value = self.Platform.Pcds[key]
                             Value.TokenCName = self.Platform.Pcds[key].TokenCName + '_' + Pcd_Type
                             if len(key) == 2:
@@ -1404,7 +1404,7 @@ class PlatformAutoGen(AutoGen):
                 # Check the PCD from DSC or not 
                 PcdFromModule.IsFromDsc = (PcdFromModule.TokenCName, PcdFromModule.TokenSpaceGuidCName) in self.Platform.Pcds
 
-                if PcdFromModule.Type in GenC.gDynamicPcd or PcdFromModule.Type in GenC.gDynamicExPcd:
+                if PcdFromModule.Type in PCD_DYNAMIC_TYPE_SET or PcdFromModule.Type in PCD_DYNAMIC_EX_TYPE_SET:
                     if F.Path not in FdfModuleList:
                         # If one of the Source built modules listed in the DSC is not listed 
                         # in FDF modules, and the INF lists a PCD can only use the PcdsDynamic 
@@ -1414,7 +1414,7 @@ class PlatformAutoGen(AutoGen):
                         # be included in a flash image in order to be functional. These Dynamic 
                         # PCD will not be added into the Database unless it is used by other 
                         # modules that are included in the FDF file.
-                        if PcdFromModule.Type in GenC.gDynamicPcd and \
+                        if PcdFromModule.Type in PCD_DYNAMIC_TYPE_SET and \
                             PcdFromModule.IsFromBinaryInf == False:
                             # Print warning message to let the developer make a determine.
                             continue
@@ -1423,7 +1423,7 @@ class PlatformAutoGen(AutoGen):
                         # access method (it is only listed in the DEC file that declares the 
                         # PCD as PcdsDynamicEx), then DO NOT break the build; DO NOT add the 
                         # PCD to the Platform's PCD Database.
-                        if PcdFromModule.Type in GenC.gDynamicExPcd:
+                        if PcdFromModule.Type in PCD_DYNAMIC_EX_TYPE_SET:
                             continue
                     #
                     # If a dynamic PCD used by a PEM module/PEI module & DXE module,
@@ -1465,7 +1465,7 @@ class PlatformAutoGen(AutoGen):
                     PcdFromModule.IsFromBinaryInf = True
                     PcdFromModule.IsFromDsc = False
                     # Only allow the DynamicEx and Patchable PCD in AsBuild INF
-                    if PcdFromModule.Type not in GenC.gDynamicExPcd and PcdFromModule.Type not in TAB_PCDS_PATCHABLE_IN_MODULE:
+                    if PcdFromModule.Type not in PCD_DYNAMIC_EX_TYPE_SET and PcdFromModule.Type not in TAB_PCDS_PATCHABLE_IN_MODULE:
                         EdkLogger.error("build", AUTOGEN_ERROR, "PCD setting error",
                                         File=self.MetaFile,
                                         ExtraData="\n\tExisted %s PCD %s in:\n\t\t%s\n"
@@ -1475,11 +1475,11 @@ class PlatformAutoGen(AutoGen):
                         NoDatumTypePcdList.add("%s.%s [%s]" % (PcdFromModule.TokenSpaceGuidCName, PcdFromModule.TokenCName, InfName))
                     if M.ModuleType in SUP_MODULE_SET_PEI:
                         PcdFromModule.Phase = "PEI"
-                    if PcdFromModule not in self._DynaPcdList_ and PcdFromModule.Type in GenC.gDynamicExPcd:
+                    if PcdFromModule not in self._DynaPcdList_ and PcdFromModule.Type in PCD_DYNAMIC_EX_TYPE_SET:
                         self._DynaPcdList_.append(PcdFromModule)
                     elif PcdFromModule not in self._NonDynaPcdList_ and PcdFromModule.Type in TAB_PCDS_PATCHABLE_IN_MODULE:
                         self._NonDynaPcdList_.append(PcdFromModule)
-                    if PcdFromModule in self._DynaPcdList_ and PcdFromModule.Phase == 'PEI' and PcdFromModule.Type in GenC.gDynamicExPcd:
+                    if PcdFromModule in self._DynaPcdList_ and PcdFromModule.Phase == 'PEI' and PcdFromModule.Type in PCD_DYNAMIC_EX_TYPE_SET:
                         # Overwrite the phase of any the same PCD existing, if Phase is PEI.
                         # It is to solve the case that a dynamic PCD used by a PEM module/PEI 
                         # module & DXE module at a same time.
@@ -2066,28 +2066,28 @@ class PlatformAutoGen(AutoGen):
             #
             for Pcd in self.DynamicPcdList:
                 if Pcd.Phase == "PEI":
-                    if Pcd.Type in [TAB_PCDS_DYNAMIC, "DynamicDefault", "DynamicVpd", "DynamicHii"]:
+                    if Pcd.Type in PCD_DYNAMIC_TYPE_SET:
                         EdkLogger.debug(EdkLogger.DEBUG_5, "%s %s (%s) -> %d" % (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Pcd.Phase, TokenNumber))
                         self._PcdTokenNumber[Pcd.TokenCName, Pcd.TokenSpaceGuidCName] = TokenNumber
                         TokenNumber += 1
 
             for Pcd in self.DynamicPcdList:
                 if Pcd.Phase == "PEI":
-                    if Pcd.Type in [TAB_PCDS_DYNAMIC_EX, "DynamicExDefault", "DynamicExVpd", "DynamicExHii"]:
+                    if Pcd.Type in PCD_DYNAMIC_EX_TYPE_SET:
                         EdkLogger.debug(EdkLogger.DEBUG_5, "%s %s (%s) -> %d" % (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Pcd.Phase, TokenNumber))
                         self._PcdTokenNumber[Pcd.TokenCName, Pcd.TokenSpaceGuidCName] = TokenNumber
                         TokenNumber += 1
 
             for Pcd in self.DynamicPcdList:
                 if Pcd.Phase == "DXE":
-                    if Pcd.Type in [TAB_PCDS_DYNAMIC, "DynamicDefault", "DynamicVpd", "DynamicHii"]:
+                    if Pcd.Type in PCD_DYNAMIC_TYPE_SET:
                         EdkLogger.debug(EdkLogger.DEBUG_5, "%s %s (%s) -> %d" % (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Pcd.Phase, TokenNumber))
                         self._PcdTokenNumber[Pcd.TokenCName, Pcd.TokenSpaceGuidCName] = TokenNumber
                         TokenNumber += 1
 
             for Pcd in self.DynamicPcdList:
                 if Pcd.Phase == "DXE":
-                    if Pcd.Type in [TAB_PCDS_DYNAMIC_EX, "DynamicExDefault", "DynamicExVpd", "DynamicExHii"]:
+                    if Pcd.Type in PCD_DYNAMIC_EX_TYPE_SET:
                         EdkLogger.debug(EdkLogger.DEBUG_5, "%s %s (%s) -> %d" % (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Pcd.Phase, TokenNumber))
                         self._PcdTokenNumber[Pcd.TokenCName, Pcd.TokenSpaceGuidCName] = TokenNumber
                         TokenNumber += 1
@@ -2383,7 +2383,7 @@ class PlatformAutoGen(AutoGen):
                 ToPcd.MaxDatumSize = str(len(Value) - 1)
 
         # apply default SKU for dynamic PCDS if specified one is not available
-        if (ToPcd.Type in PCD_DYNAMIC_TYPE_LIST or ToPcd.Type in PCD_DYNAMIC_EX_TYPE_LIST) \
+        if (ToPcd.Type in PCD_DYNAMIC_TYPE_SET or ToPcd.Type in PCD_DYNAMIC_EX_TYPE_SET) \
             and ToPcd.SkuInfoList in [None, {}, '']:
             if self.Platform.SkuName in self.Platform.SkuIds:
                 SkuName = self.Platform.SkuName
@@ -3932,7 +3932,7 @@ class ModuleAutoGen(AutoGen):
             if Pcd.Type == TAB_PCDS_PATCHABLE_IN_MODULE:
                 PatchablePcds += [Pcd]
                 PcdCheckList.append((Pcd.TokenCName, Pcd.TokenSpaceGuidCName, TAB_PCDS_PATCHABLE_IN_MODULE))
-            elif Pcd.Type in GenC.gDynamicExPcd:
+            elif Pcd.Type in PCD_DYNAMIC_EX_TYPE_SET:
                 if Pcd not in Pcds:
                     Pcds += [Pcd]
                     PcdCheckList.append((Pcd.TokenCName, Pcd.TokenSpaceGuidCName, TAB_PCDS_DYNAMIC_EX))
diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py
index 57ff699a968a..86b21de31eee 100644
--- a/BaseTools/Source/Python/AutoGen/GenC.py
+++ b/BaseTools/Source/Python/AutoGen/GenC.py
@@ -43,12 +43,6 @@ gItemTypeStringDatabase  = {
 
 _NumericDataTypesList = ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN']
 
-## Dynamic PCD types
-gDynamicPcd = [TAB_PCDS_DYNAMIC, TAB_PCDS_DYNAMIC_DEFAULT, TAB_PCDS_DYNAMIC_VPD, TAB_PCDS_DYNAMIC_HII]
-
-## Dynamic-ex PCD types
-gDynamicExPcd = [TAB_PCDS_DYNAMIC_EX, TAB_PCDS_DYNAMIC_EX_DEFAULT, TAB_PCDS_DYNAMIC_EX_VPD, TAB_PCDS_DYNAMIC_EX_HII]
-
 ## Datum size
 gDatumSizeStringDatabase = {'UINT8':'8','UINT16':'16','UINT32':'32','UINT64':'64','BOOLEAN':'BOOLEAN','VOID*':'8'}
 gDatumSizeStringDatabaseH = {'UINT8':'8','UINT16':'16','UINT32':'32','UINT64':'64','BOOLEAN':'BOOL','VOID*':'PTR'}
@@ -804,7 +798,7 @@ def DynExPcdTokenNumberMapping(Info, AutoGenH):
     # Even it is the Library, the PCD is saved in the ModulePcdList
     PcdList = Info.ModulePcdList
     for Pcd in PcdList:
-        if Pcd.Type in gDynamicExPcd:
+        if Pcd.Type in PCD_DYNAMIC_EX_TYPE_SET:
             ExTokenCNameList.append(Pcd.TokenCName)
             PcdExList.append(Pcd)
     if len(ExTokenCNameList) == 0:
@@ -850,7 +844,7 @@ def DynExPcdTokenNumberMapping(Info, AutoGenH):
                 if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName) in GlobalData.MixedPcd[PcdItem]:
                     RealTokenCName = PcdItem[0]
                     break
-            if Pcd.Type in gDynamicExPcd and Pcd.TokenCName == TokenCName:
+            if Pcd.Type in PCD_DYNAMIC_EX_TYPE_SET and Pcd.TokenCName == TokenCName:
                 Index = Index + 1
                 if Index == 1:
                     AutoGenH.Append('\n#define __PCD_%s_VAL_CMP(GuidPtr)  (' % (RealTokenCName))
@@ -923,7 +917,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
     if Pcd.PcdValueFromComm:
         Pcd.DefaultValue = Pcd.PcdValueFromComm
     
-    if Pcd.Type in gDynamicExPcd:
+    if Pcd.Type in PCD_DYNAMIC_EX_TYPE_SET:
         TokenNumber = int(Pcd.TokenValue, 0)
         # Add TokenSpaceGuidValue value to PcdTokenName to discriminate the DynamicEx PCDs with 
         # different Guids but same TokenCName
@@ -939,7 +933,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
             # will not be added into the Database unless it is used by other modules that are 
             # included in the FDF file. 
             # In this case, just assign an invalid token number to make it pass build.
-            if Pcd.Type in PCD_DYNAMIC_TYPE_LIST:
+            if Pcd.Type in PCD_DYNAMIC_TYPE_SET:
                 TokenNumber = 0
             else:
                 EdkLogger.error("build", AUTOGEN_ERROR,
@@ -962,14 +956,14 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
     SetModeStatusName = '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[Pcd.DatumType] + '_S_' + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH['VOID*'] + '_S_' + TokenCName
     GetModeSizeName = '_PCD_GET_MODE_SIZE' + '_' + TokenCName
     
-    if Pcd.Type in gDynamicExPcd:
+    if Pcd.Type in PCD_DYNAMIC_EX_TYPE_SET:
         if Info.IsLibrary:
             PcdList = Info.LibraryPcdList
         else:
             PcdList = Info.ModulePcdList
         PcdExCNameTest = 0
         for PcdModule in PcdList:
-            if PcdModule.Type in gDynamicExPcd and Pcd.TokenCName == PcdModule.TokenCName:
+            if PcdModule.Type in PCD_DYNAMIC_EX_TYPE_SET and Pcd.TokenCName == PcdModule.TokenCName:
                 PcdExCNameTest += 1
             # get out early once we found > 1...
             if PcdExCNameTest > 1:
@@ -998,10 +992,10 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
             else:
                 AutoGenH.Append('#define %s(Value)  LibPcdSetEx%s(&%s, %s, (Value))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
                 AutoGenH.Append('#define %s(Value)  LibPcdSetEx%sS(&%s, %s, (Value))\n' % (SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
-    elif Pcd.Type in gDynamicPcd:
+    elif Pcd.Type in PCD_DYNAMIC_TYPE_SET:
         PcdCNameTest = 0
         for PcdModule in Info.LibraryPcdList + Info.ModulePcdList:
-            if PcdModule.Type in gDynamicPcd and Pcd.TokenCName == PcdModule.TokenCName:
+            if PcdModule.Type in PCD_DYNAMIC_TYPE_SET and Pcd.TokenCName == PcdModule.TokenCName:
                 PcdCNameTest += 1
             # get out early once we found > 1...
             if PcdCNameTest > 1:
@@ -1227,7 +1221,7 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd):
     #
     # Write PCDs
     #
-    if Pcd.Type in gDynamicExPcd:
+    if Pcd.Type in PCD_DYNAMIC_EX_TYPE_SET:
         TokenNumber = int(Pcd.TokenValue, 0)
     else:
         if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName) not in PcdTokenNumber:
@@ -1239,7 +1233,7 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd):
             # will not be added into the Database unless it is used by other modules that are 
             # included in the FDF file. 
             # In this case, just assign an invalid token number to make it pass build.
-            if Pcd.Type in PCD_DYNAMIC_TYPE_LIST:
+            if Pcd.Type in PCD_DYNAMIC_TYPE_SET:
                 TokenNumber = 0
             else:
                 EdkLogger.error("build", AUTOGEN_ERROR,
@@ -1268,7 +1262,7 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd):
             Type = '(VOID *)'
         Array = '[]'
     PcdItemType = Pcd.Type
-    if PcdItemType in gDynamicExPcd:
+    if PcdItemType in PCD_DYNAMIC_EX_TYPE_SET:
         PcdExTokenName = '_PCD_TOKEN_' + TokenSpaceGuidCName + '_' + TokenCName
         AutoGenH.Append('\n#define %s  %dU\n' % (PcdExTokenName, TokenNumber))
         
@@ -1278,7 +1272,7 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd):
             PcdList = Info.ModulePcdList
         PcdExCNameTest = 0
         for PcdModule in PcdList:
-            if PcdModule.Type in gDynamicExPcd and Pcd.TokenCName == PcdModule.TokenCName:
+            if PcdModule.Type in PCD_DYNAMIC_EX_TYPE_SET and Pcd.TokenCName == PcdModule.TokenCName:
                 PcdExCNameTest += 1
             # get out early once we found > 1...
             if PcdExCNameTest > 1:
@@ -1309,13 +1303,13 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd):
                 AutoGenH.Append('#define %s(Value)  LibPcdSetEx%sS(&%s, %s, (Value))\n' % (SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
     else:
         AutoGenH.Append('#define _PCD_TOKEN_%s  %dU\n' % (TokenCName, TokenNumber))
-    if PcdItemType in gDynamicPcd:
+    if PcdItemType in PCD_DYNAMIC_TYPE_SET:
         PcdList = []
         PcdCNameList = []
         PcdList.extend(Info.LibraryPcdList)
         PcdList.extend(Info.ModulePcdList)
         for PcdModule in PcdList:
-            if PcdModule.Type in gDynamicPcd:
+            if PcdModule.Type in PCD_DYNAMIC_TYPE_SET:
                 PcdCNameList.append(PcdModule.TokenCName)
         if PcdCNameList.count(Pcd.TokenCName) > 1:
             EdkLogger.error("build", AUTOGEN_ERROR, "More than one Dynamic Pcds [%s] are different Guids but same CName.They need to be changed to DynamicEx type to avoid the confliction.\n" % (TokenCName), ExtraData="[%s]" % str(Info.MetaFile.Path))
@@ -1695,7 +1689,7 @@ def CreatePcdCode(Info, AutoGenC, AutoGenH):
     # Collect Token Space GUIDs used by DynamicEc PCDs
     TokenSpaceList = []
     for Pcd in Info.ModulePcdList:
-        if Pcd.Type in gDynamicExPcd and Pcd.TokenSpaceGuidCName not in TokenSpaceList:
+        if Pcd.Type in PCD_DYNAMIC_EX_TYPE_SET and Pcd.TokenSpaceGuidCName not in TokenSpaceList:
             TokenSpaceList += [Pcd.TokenSpaceGuidCName]
             
     SkuMgr = Info.Workspace.Platform.SkuIdMgr
diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
index 4f4a8d856842..afd690bc5b1b 100644
--- a/BaseTools/Source/Python/AutoGen/GenPcdDb.py
+++ b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
@@ -1200,7 +1200,7 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase):
         #
         TokenSpaceGuidStructure = Pcd.TokenSpaceGuidValue
         TokenSpaceGuid = GuidStructureStringToGuidValueName(TokenSpaceGuidStructure)
-        if Pcd.Type in gDynamicExPcd:
+        if Pcd.Type in PCD_DYNAMIC_EX_TYPE_SET:
             if TokenSpaceGuid not in GuidList:
                 GuidList += [TokenSpaceGuid]
                 Dict['GUID_STRUCTURE'].append(TokenSpaceGuidStructure)
@@ -1568,7 +1568,7 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase):
             Dict['VARDEF_HEADER'][GeneratedTokenNumber] = ''
        
         
-        if Pcd.Type in gDynamicExPcd:
+        if Pcd.Type in PCD_DYNAMIC_EX_TYPE_SET:
             
             if Phase == 'DXE':
                 GeneratedTokenNumber += NumberOfPeiLocalTokens
diff --git a/BaseTools/Source/Python/Common/DataType.py b/BaseTools/Source/Python/Common/DataType.py
index 74ed711abc52..13e9c96dd51b 100644
--- a/BaseTools/Source/Python/Common/DataType.py
+++ b/BaseTools/Source/Python/Common/DataType.py
@@ -54,8 +54,7 @@ TAB_ARCH_ARM = 'ARM'
 TAB_ARCH_EBC = 'EBC'
 TAB_ARCH_AARCH64 = 'AARCH64'
 
-ARCH_LIST = [TAB_ARCH_IA32, TAB_ARCH_X64, TAB_ARCH_IPF, TAB_ARCH_ARM, TAB_ARCH_EBC, TAB_ARCH_AARCH64]
-ARCH_LIST_FULL = [TAB_ARCH_COMMON] + ARCH_LIST
+ARCH_SET_FULL = {TAB_ARCH_IA32, TAB_ARCH_X64, TAB_ARCH_IPF, TAB_ARCH_ARM, TAB_ARCH_EBC, TAB_ARCH_AARCH64, TAB_ARCH_COMMON}
 
 SUP_MODULE_BASE = 'BASE'
 SUP_MODULE_SEC = 'SEC'
@@ -216,11 +215,8 @@ TAB_PCDS_DYNAMIC_DEFAULT = 'DynamicDefault'
 TAB_PCDS_DYNAMIC_VPD = 'DynamicVpd'
 TAB_PCDS_DYNAMIC_HII = 'DynamicHii'
 
-PCD_DYNAMIC_TYPE_LIST = [TAB_PCDS_DYNAMIC, TAB_PCDS_DYNAMIC_DEFAULT, TAB_PCDS_DYNAMIC_VPD, TAB_PCDS_DYNAMIC_HII]
-PCD_DYNAMIC_EX_TYPE_LIST = [TAB_PCDS_DYNAMIC_EX, TAB_PCDS_DYNAMIC_EX_DEFAULT, TAB_PCDS_DYNAMIC_EX_VPD, TAB_PCDS_DYNAMIC_EX_HII]
-
-## Dynamic-ex PCD types
-gDynamicExPcd = [TAB_PCDS_DYNAMIC_EX, TAB_PCDS_DYNAMIC_EX_DEFAULT, TAB_PCDS_DYNAMIC_EX_VPD, TAB_PCDS_DYNAMIC_EX_HII]
+PCD_DYNAMIC_TYPE_SET = {TAB_PCDS_DYNAMIC, TAB_PCDS_DYNAMIC_DEFAULT, TAB_PCDS_DYNAMIC_VPD, TAB_PCDS_DYNAMIC_HII}
+PCD_DYNAMIC_EX_TYPE_SET = {TAB_PCDS_DYNAMIC_EX, TAB_PCDS_DYNAMIC_EX_DEFAULT, TAB_PCDS_DYNAMIC_EX_VPD, TAB_PCDS_DYNAMIC_EX_HII}
 
 TAB_PCDS_FIXED_AT_BUILD_NULL = TAB_PCDS + TAB_PCDS_FIXED_AT_BUILD
 TAB_PCDS_FIXED_AT_BUILD_COMMON = TAB_PCDS + TAB_PCDS_FIXED_AT_BUILD + TAB_SPLIT + TAB_ARCH_COMMON
@@ -273,9 +269,6 @@ TAB_PCDS_DYNAMIC_ARM = TAB_PCDS + TAB_PCDS_DYNAMIC + TAB_SPLIT + TAB_ARCH_ARM
 TAB_PCDS_DYNAMIC_EBC = TAB_PCDS + TAB_PCDS_DYNAMIC + TAB_SPLIT + TAB_ARCH_EBC
 TAB_PCDS_DYNAMIC_AARCH64 = TAB_PCDS + TAB_PCDS_DYNAMIC + TAB_SPLIT + TAB_ARCH_AARCH64
 
-TAB_PCD_DYNAMIC_TYPE_LIST = [TAB_PCDS_DYNAMIC_DEFAULT_NULL, TAB_PCDS_DYNAMIC_VPD_NULL, TAB_PCDS_DYNAMIC_HII_NULL]
-TAB_PCD_DYNAMIC_EX_TYPE_LIST = [TAB_PCDS_DYNAMIC_EX_DEFAULT_NULL, TAB_PCDS_DYNAMIC_EX_VPD_NULL, TAB_PCDS_DYNAMIC_EX_HII_NULL]
-
 TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_PEI_PAGE_SIZE = 'PcdLoadFixAddressPeiCodePageNumber'
 TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_PEI_PAGE_SIZE_DATA_TYPE = 'UINT32'
 TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_DXE_PAGE_SIZE = 'PcdLoadFixAddressBootTimeCodePageNumber'
@@ -284,10 +277,10 @@ TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_RUNTIME_PAGE_SIZE = 'PcdLoadFixAddressRuntim
 TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_RUNTIME_PAGE_SIZE_DATA_TYPE = 'UINT32'
 TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_SMM_PAGE_SIZE = 'PcdLoadFixAddressSmmCodePageNumber'
 TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_SMM_PAGE_SIZE_DATA_TYPE = 'UINT32'
-TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_LIST = [TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_PEI_PAGE_SIZE, \
+TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_SET =  {TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_PEI_PAGE_SIZE, \
                                             TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_DXE_PAGE_SIZE, \
                                             TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_RUNTIME_PAGE_SIZE, \
-                                            TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_SMM_PAGE_SIZE]
+                                            TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_SMM_PAGE_SIZE}
 
 ## The mapping dictionary from datum type to its maximum number.
 MAX_VAL_TYPE = {"BOOLEAN":0x01, TAB_UINT8:0xFF, TAB_UINT16:0xFFFF, TAB_UINT32:0xFFFFFFFF, TAB_UINT64:0xFFFFFFFFFFFFFFFF}
@@ -485,10 +478,10 @@ TAB_UNKNOWN = 'UNKNOWN'
 DATABASE_PATH = ":memory:" #"BuildDatabase.db"
 
 # used by ECC
-MODIFIER_LIST = ['IN', 'OUT', 'OPTIONAL', 'UNALIGNED', 'EFI_RUNTIMESERVICE', 'EFI_BOOTSERVICE', 'EFIAPI']
+MODIFIER_SET = {'IN', 'OUT', 'OPTIONAL', 'UNALIGNED', 'EFI_RUNTIMESERVICE', 'EFI_BOOTSERVICE', 'EFIAPI'}
 
 # Dependency Expression
-DEPEX_SUPPORTED_OPCODE = ["BEFORE", "AFTER", "PUSH", "AND", "OR", "NOT", "END", "SOR", "TRUE", "FALSE", '(', ')']
+DEPEX_SUPPORTED_OPCODE_SET = {"BEFORE", "AFTER", "PUSH", "AND", "OR", "NOT", "END", "SOR", "TRUE", "FALSE", '(', ')'}
 
 TAB_STATIC_LIBRARY = "STATIC-LIBRARY-FILE"
 TAB_DYNAMIC_LIBRARY = "DYNAMIC-LIBRARY-FILE"
@@ -520,10 +513,10 @@ PCDS_DYNAMICEX_DEFAULT = "PcdsDynamicExDefault"
 PCDS_DYNAMICEX_VPD = "PcdsDynamicExVpd"
 PCDS_DYNAMICEX_HII = "PcdsDynamicExHii"
 
-SECTIONS_HAVE_ITEM_PCD = [PCDS_DYNAMIC_DEFAULT.upper(),PCDS_DYNAMIC_VPD.upper(),PCDS_DYNAMIC_HII.upper(), \
-                          PCDS_DYNAMICEX_DEFAULT.upper(),PCDS_DYNAMICEX_VPD.upper(),PCDS_DYNAMICEX_HII.upper()]
+SECTIONS_HAVE_ITEM_PCD_SET = {PCDS_DYNAMIC_DEFAULT.upper(),PCDS_DYNAMIC_VPD.upper(),PCDS_DYNAMIC_HII.upper(), \
+                              PCDS_DYNAMICEX_DEFAULT.upper(),PCDS_DYNAMICEX_VPD.upper(),PCDS_DYNAMICEX_HII.upper()}
 # Section allowed to have items after arch
-SECTIONS_HAVE_ITEM_AFTER_ARCH = [TAB_LIBRARY_CLASSES.upper(), TAB_DEPEX.upper(), TAB_USER_EXTENSIONS.upper(),
+SECTIONS_HAVE_ITEM_AFTER_ARCH_SET = {TAB_LIBRARY_CLASSES.upper(), TAB_DEPEX.upper(), TAB_USER_EXTENSIONS.upper(),
                                  PCDS_DYNAMIC_DEFAULT.upper(),
                                  PCDS_DYNAMIC_VPD.upper(),
                                  PCDS_DYNAMIC_HII.upper(),
@@ -531,4 +524,4 @@ SECTIONS_HAVE_ITEM_AFTER_ARCH = [TAB_LIBRARY_CLASSES.upper(), TAB_DEPEX.upper(),
                                  PCDS_DYNAMICEX_VPD.upper(),
                                  PCDS_DYNAMICEX_HII.upper(),
                                  TAB_BUILD_OPTIONS.upper(),
-                                 TAB_INCLUDES.upper()]
+                                 TAB_INCLUDES.upper()}
diff --git a/BaseTools/Source/Python/Ecc/Configuration.py b/BaseTools/Source/Python/Ecc/Configuration.py
index b523858e1b1f..b5b583be8c4a 100644
--- a/BaseTools/Source/Python/Ecc/Configuration.py
+++ b/BaseTools/Source/Python/Ecc/Configuration.py
@@ -53,7 +53,7 @@ class Configuration(object):
 
         # List customized Modifer here, split with ','
         # Defaultly use the definition in class DataType
-        self.ModifierList = MODIFIER_LIST
+        self.ModifierSet = MODIFIER_SET
 
         ## General Checking
         self.GeneralCheckAll = 0
diff --git a/BaseTools/Source/Python/Ecc/c.py b/BaseTools/Source/Python/Ecc/c.py
index 175e2d2e0439..93ee1990ba28 100644
--- a/BaseTools/Source/Python/Ecc/c.py
+++ b/BaseTools/Source/Python/Ecc/c.py
@@ -830,7 +830,7 @@ def GetDataTypeFromModifier(ModifierStr):
     MList = ModifierStr.split()
     ReturnType = ''
     for M in MList:
-        if M in EccGlobalData.gConfig.ModifierList:
+        if M in EccGlobalData.gConfig.ModifierSet:
             continue
         # remove array sufix
         if M.startswith('[') or M.endswith(']'):
diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py
index e117a3717d42..23c04123af1b 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -3587,7 +3587,7 @@ class FdfParser:
             raise Warning("expected '.'", self.FileName, self.CurrentLineNumber)
 
         Arch = self.__SkippedChars.rstrip(".")
-        if Arch.upper() not in ARCH_LIST_FULL:
+        if Arch.upper() not in ARCH_SET_FULL:
             raise Warning("Unknown Arch '%s'" % Arch, self.FileName, self.CurrentLineNumber)
 
         ModuleType = self.__GetModuleType()
diff --git a/BaseTools/Source/Python/GenFds/Ffs.py b/BaseTools/Source/Python/GenFds/Ffs.py
index f15d2330ce58..f6a7f4b007f9 100644
--- a/BaseTools/Source/Python/GenFds/Ffs.py
+++ b/BaseTools/Source/Python/GenFds/Ffs.py
@@ -1,7 +1,7 @@
 ## @file
 # process FFS generation
 #
-#  Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
+#  Copyright (c) 2007-2018, Intel Corporation. All rights reserved.<BR>
 #
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD License
@@ -22,24 +22,6 @@ from Common.DataType import *
 #
 #
 class Ffs(FDClassObject):
-    
-    # mapping between MODULE type in FDF (from INF) and file type for GenFfs
-    ModuleTypeToFileType = {
-        SUP_MODULE_SEC               : 'EFI_FV_FILETYPE_SECURITY_CORE',
-        SUP_MODULE_PEI_CORE          : 'EFI_FV_FILETYPE_PEI_CORE',
-        SUP_MODULE_PEIM              : 'EFI_FV_FILETYPE_PEIM',
-        SUP_MODULE_DXE_CORE          : 'EFI_FV_FILETYPE_DXE_CORE',
-        SUP_MODULE_DXE_DRIVER        : 'EFI_FV_FILETYPE_DRIVER',
-        SUP_MODULE_DXE_SAL_DRIVER    : 'EFI_FV_FILETYPE_DRIVER',
-        SUP_MODULE_DXE_SMM_DRIVER    : 'EFI_FV_FILETYPE_DRIVER',
-        SUP_MODULE_DXE_RUNTIME_DRIVER: 'EFI_FV_FILETYPE_DRIVER',
-        SUP_MODULE_UEFI_DRIVER       : 'EFI_FV_FILETYPE_DRIVER',
-        SUP_MODULE_UEFI_APPLICATION  : 'EFI_FV_FILETYPE_APPLICATION',
-        SUP_MODULE_SMM_CORE          : 'EFI_FV_FILETYPE_SMM_CORE',
-        SUP_MODULE_MM_STANDALONE     : 'EFI_FV_FILETYPE_MM_STANDALONE',
-        SUP_MODULE_MM_CORE_STANDALONE : 'EFI_FV_FILETYPE_MM_CORE_STANDALONE'
-    }
-    
     # mapping between FILE type in FDF and file type for GenFfs
     FdfFvFileTypeToFileType = {
         SUP_MODULE_SEC               : 'EFI_FV_FILETYPE_SECURITY_CORE',
diff --git a/BaseTools/Source/Python/GenFds/OptRomInfStatement.py b/BaseTools/Source/Python/GenFds/OptRomInfStatement.py
index 62d731fb9cca..8f8761b20589 100644
--- a/BaseTools/Source/Python/GenFds/OptRomInfStatement.py
+++ b/BaseTools/Source/Python/GenFds/OptRomInfStatement.py
@@ -93,7 +93,6 @@ class OptRomInfStatement (FfsInfStatement):
         #
         Rule = self.__GetRule__()
         GenFdsGlobalVariable.VerboseLogger( "Packing binaries from inf file : %s" %self.InfFileName)
-        #FileType = Ffs.Ffs.ModuleTypeToFileType[Rule.ModuleType]
         #
         # For the rule only has simpleFile
         #
diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py b/BaseTools/Source/Python/Workspace/InfBuildData.py
index 27ef163eb40c..94f142e8e617 100644
--- a/BaseTools/Source/Python/Workspace/InfBuildData.py
+++ b/BaseTools/Source/Python/Workspace/InfBuildData.py
@@ -901,7 +901,7 @@ class InfBuildData(ModuleBuildClassObject):
                     Depex[Arch, ModuleType] = []
                 DepexList = Depex[Arch, ModuleType]
                 for Token in TokenList:
-                    if Token in DEPEX_SUPPORTED_OPCODE:
+                    if Token in DEPEX_SUPPORTED_OPCODE_SET:
                         DepexList.append(Token)
                     elif Token.endswith(".inf"):  # module file name
                         ModuleFile = os.path.normpath(Token)
diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py
index 99f6fcd0dc30..f0c8012f5eef 100644
--- a/BaseTools/Source/Python/Workspace/MetaFileParser.py
+++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py
@@ -310,7 +310,7 @@ class MetaFileParser(object):
             if self._SectionName in self.DataType:
                 self._SectionType = self.DataType[self._SectionName]
                 # Check if the section name is valid
-                if self._SectionName not in SECTIONS_HAVE_ITEM_AFTER_ARCH and len(ItemList) > 3:
+                if self._SectionName not in SECTIONS_HAVE_ITEM_AFTER_ARCH_SET and len(ItemList) > 3:
                     EdkLogger.error("Parser", FORMAT_UNKNOWN_ERROR, "%s is not a valid section name" % Item,
                                     self.MetaFile, self._LineIndex + 1, self._CurrentLine)
             elif self._Version >= 0x00010005:
@@ -328,7 +328,7 @@ class MetaFileParser(object):
 
             # S2 may be Platform or ModuleType
             if len(ItemList) > 2:
-                if self._SectionName.upper() in SECTIONS_HAVE_ITEM_PCD:
+                if self._SectionName.upper() in SECTIONS_HAVE_ITEM_PCD_SET:
                     S2 = ItemList[2]
                 else:
                     S2 = ItemList[2].upper()
diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/build/build.py
index 29ad0c7228c7..be56aecb79ef 100644
--- a/BaseTools/Source/Python/build/build.py
+++ b/BaseTools/Source/Python/build/build.py
@@ -1616,12 +1616,12 @@ class Build():
             if OutputImageFile != '':
                 ModuleIsPatch = False
                 for Pcd in Module.ModulePcdList:
-                    if Pcd.Type == TAB_PCDS_PATCHABLE_IN_MODULE and Pcd.TokenCName in TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_LIST:
+                    if Pcd.Type == TAB_PCDS_PATCHABLE_IN_MODULE and Pcd.TokenCName in TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_SET:
                         ModuleIsPatch = True
                         break
                 if not ModuleIsPatch:
                     for Pcd in Module.LibraryPcdList:
-                        if Pcd.Type == TAB_PCDS_PATCHABLE_IN_MODULE and Pcd.TokenCName in TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_LIST:
+                        if Pcd.Type == TAB_PCDS_PATCHABLE_IN_MODULE and Pcd.TokenCName in TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_SET:
                             ModuleIsPatch = True
                             break
 
-- 
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH v1 18/27] BaseTools: Replace PCD type strings with predefined constant
  2018-04-20 15:51 [PATCH v1 00/27] BaseTools refactoring Jaben Carsey
                   ` (16 preceding siblings ...)
  2018-04-20 15:51 ` [PATCH v1 17/27] BaseTools: DataType - cleanup list constants Jaben Carsey
@ 2018-04-20 15:51 ` Jaben Carsey
  2018-04-25  6:00   ` Zhu, Yonghong
  2018-04-20 15:51 ` [PATCH v1 19/27] BaseTools: Replace Binary File " Jaben Carsey
                   ` (8 subsequent siblings)
  26 siblings, 1 reply; 56+ messages in thread
From: Jaben Carsey @ 2018-04-20 15:51 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Yonghong Zhu

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>
---
 BaseTools/Source/Python/AutoGen/AutoGen.py             |  4 +--
 BaseTools/Source/Python/AutoGen/GenC.py                |  4 +--
 BaseTools/Source/Python/AutoGen/GenPcdDb.py            |  2 +-
 BaseTools/Source/Python/Common/DataType.py             |  3 ++
 BaseTools/Source/Python/Common/MigrationUtilities.py   |  2 +-
 BaseTools/Source/Python/GenFds/FfsInfStatement.py      |  2 +-
 BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py |  4 +--
 BaseTools/Source/Python/Workspace/DecBuildData.py      | 22 +++++++-------
 BaseTools/Source/Python/Workspace/DscBuildData.py      | 22 +++++++-------
 BaseTools/Source/Python/Workspace/InfBuildData.py      | 26 ++++++++---------
 BaseTools/Source/Python/build/BuildReport.py           | 30 ++++++++++----------
 11 files changed, 62 insertions(+), 59 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 2f60c17439c0..9b2164ed8216 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -870,8 +870,8 @@ class WorkspaceAutoGen(AutoGen):
     def _CheckPcdDefineAndType(self):
         PcdTypeList = [
             TAB_PCDS_FIXED_AT_BUILD, TAB_PCDS_PATCHABLE_IN_MODULE, TAB_PCDS_FEATURE_FLAG,
-            TAB_PCDS_DYNAMIC, #"DynamicHii", "DynamicVpd",
-            TAB_PCDS_DYNAMIC_EX, # "DynamicExHii", "DynamicExVpd"
+            TAB_PCDS_DYNAMIC, #TAB_PCDS_DYNAMIC_HII, TAB_PCDS_DYNAMIC_VPD,
+            TAB_PCDS_DYNAMIC_EX, # TAB_PCDS_DYNAMIC_EX_HII, TAB_PCDS_DYNAMIC_EX_VPD
         ]
 
         # This dict store PCDs which are not used by any modules with specified arches
diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py
index 86b21de31eee..6b2ee87b2211 100644
--- a/BaseTools/Source/Python/AutoGen/GenC.py
+++ b/BaseTools/Source/Python/AutoGen/GenC.py
@@ -28,8 +28,8 @@ from IdfClassObject import *
 
 ## PCD type string
 gItemTypeStringDatabase  = {
-    TAB_PCDS_FEATURE_FLAG       :   'FixedAtBuild',
-    TAB_PCDS_FIXED_AT_BUILD     :   'FixedAtBuild',
+    TAB_PCDS_FEATURE_FLAG       :   TAB_PCDS_FIXED_AT_BUILD,
+    TAB_PCDS_FIXED_AT_BUILD     :   TAB_PCDS_FIXED_AT_BUILD,
     TAB_PCDS_PATCHABLE_IN_MODULE:   'BinaryPatch',
     TAB_PCDS_DYNAMIC            :   '',
     TAB_PCDS_DYNAMIC_DEFAULT    :   '',
diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
index afd690bc5b1b..9374ca4820ef 100644
--- a/BaseTools/Source/Python/AutoGen/GenPcdDb.py
+++ b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
@@ -1217,7 +1217,7 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase):
         Pcd.InitString = 'UNINIT'
 
         if Pcd.DatumType == 'VOID*':
-            if Pcd.Type not in ["DynamicVpd", "DynamicExVpd"]:
+            if Pcd.Type not in [TAB_PCDS_DYNAMIC_VPD, TAB_PCDS_DYNAMIC_EX_VPD]:
                 Pcd.TokenTypeList = ['PCD_TYPE_STRING']
             else:
                 Pcd.TokenTypeList = []
diff --git a/BaseTools/Source/Python/Common/DataType.py b/BaseTools/Source/Python/Common/DataType.py
index 13e9c96dd51b..40a162adf33c 100644
--- a/BaseTools/Source/Python/Common/DataType.py
+++ b/BaseTools/Source/Python/Common/DataType.py
@@ -218,6 +218,9 @@ TAB_PCDS_DYNAMIC_HII = 'DynamicHii'
 PCD_DYNAMIC_TYPE_SET = {TAB_PCDS_DYNAMIC, TAB_PCDS_DYNAMIC_DEFAULT, TAB_PCDS_DYNAMIC_VPD, TAB_PCDS_DYNAMIC_HII}
 PCD_DYNAMIC_EX_TYPE_SET = {TAB_PCDS_DYNAMIC_EX, TAB_PCDS_DYNAMIC_EX_DEFAULT, TAB_PCDS_DYNAMIC_EX_VPD, TAB_PCDS_DYNAMIC_EX_HII}
 
+# leave as a list for order
+PCD_TYPE_LIST = [TAB_PCDS_FIXED_AT_BUILD, TAB_PCDS_PATCHABLE_IN_MODULE, TAB_PCDS_FEATURE_FLAG, TAB_PCDS_DYNAMIC, TAB_PCDS_DYNAMIC_EX]
+
 TAB_PCDS_FIXED_AT_BUILD_NULL = TAB_PCDS + TAB_PCDS_FIXED_AT_BUILD
 TAB_PCDS_FIXED_AT_BUILD_COMMON = TAB_PCDS + TAB_PCDS_FIXED_AT_BUILD + TAB_SPLIT + TAB_ARCH_COMMON
 TAB_PCDS_FIXED_AT_BUILD_IA32 = TAB_PCDS + TAB_PCDS_FIXED_AT_BUILD + TAB_SPLIT + TAB_ARCH_IA32
diff --git a/BaseTools/Source/Python/Common/MigrationUtilities.py b/BaseTools/Source/Python/Common/MigrationUtilities.py
index e9f1cabcb794..0c93c72a60f6 100644
--- a/BaseTools/Source/Python/Common/MigrationUtilities.py
+++ b/BaseTools/Source/Python/Common/MigrationUtilities.py
@@ -34,7 +34,7 @@ def SetCommon(Common, XmlCommon):
     XmlTag = "Usage"
     Common.Usage = XmlAttribute(XmlCommon, XmlTag).split()
 
-    XmlTag = "FeatureFlag"
+    XmlTag = TAB_PCDS_FEATURE_FLAG
     Common.FeatureFlag = XmlAttribute(XmlCommon, XmlTag)
     
     XmlTag = "SupArchList"
diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
index d31d03d43a18..8893fcbda1fc 100644
--- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py
+++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
@@ -249,7 +249,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
             Pcd = InfPcds[PcdKey]
             if not hasattr(Pcd, 'Offset'):
                 continue
-            if Pcd.Type != 'PatchableInModule':
+            if Pcd.Type != TAB_PCDS_PATCHABLE_IN_MODULE:
                 continue
             # Override Patchable PCD value by the value from DSC
             PatchPcd = None
diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
index 6a3873940ec0..e692e4e98504 100644
--- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
+++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
@@ -809,7 +809,7 @@ class GenFdsGlobalVariable:
             for Key in PcdDict:
                 PcdObj = PcdDict[Key]
                 if (PcdObj.TokenCName == TokenCName) and (PcdObj.TokenSpaceGuidCName == TokenSpace):
-                    if PcdObj.Type != 'FixedAtBuild':
+                    if PcdObj.Type != TAB_PCDS_FIXED_AT_BUILD:
                         EdkLogger.error("GenFds", GENFDS_ERROR, "%s is not FixedAtBuild type." % PcdPattern)
                     if PcdObj.DatumType != 'VOID*':
                         EdkLogger.error("GenFds", GENFDS_ERROR, "%s is not VOID* datum type." % PcdPattern)
@@ -825,7 +825,7 @@ class GenFdsGlobalVariable:
                 for Key in PcdDict:
                     PcdObj = PcdDict[Key]
                     if (PcdObj.TokenCName == TokenCName) and (PcdObj.TokenSpaceGuidCName == TokenSpace):
-                        if PcdObj.Type != 'FixedAtBuild':
+                        if PcdObj.Type != TAB_PCDS_FIXED_AT_BUILD:
                             EdkLogger.error("GenFds", GENFDS_ERROR, "%s is not FixedAtBuild type." % PcdPattern)
                         if PcdObj.DatumType != 'VOID*':
                             EdkLogger.error("GenFds", GENFDS_ERROR, "%s is not VOID* datum type." % PcdPattern)
diff --git a/BaseTools/Source/Python/Workspace/DecBuildData.py b/BaseTools/Source/Python/Workspace/DecBuildData.py
index 31870e078cec..1fbd095f743c 100644
--- a/BaseTools/Source/Python/Workspace/DecBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DecBuildData.py
@@ -27,17 +27,17 @@ from Workspace.BuildClassObject import PackageBuildClassObject, StructurePcd, Pc
 class DecBuildData(PackageBuildClassObject):
     # dict used to convert PCD type in database to string used by build tool
     _PCD_TYPE_STRING_ = {
-        MODEL_PCD_FIXED_AT_BUILD        :   "FixedAtBuild",
-        MODEL_PCD_PATCHABLE_IN_MODULE   :   "PatchableInModule",
-        MODEL_PCD_FEATURE_FLAG          :   "FeatureFlag",
-        MODEL_PCD_DYNAMIC               :   "Dynamic",
-        MODEL_PCD_DYNAMIC_DEFAULT       :   "Dynamic",
-        MODEL_PCD_DYNAMIC_HII           :   "DynamicHii",
-        MODEL_PCD_DYNAMIC_VPD           :   "DynamicVpd",
-        MODEL_PCD_DYNAMIC_EX            :   "DynamicEx",
-        MODEL_PCD_DYNAMIC_EX_DEFAULT    :   "DynamicEx",
-        MODEL_PCD_DYNAMIC_EX_HII        :   "DynamicExHii",
-        MODEL_PCD_DYNAMIC_EX_VPD        :   "DynamicExVpd",
+        MODEL_PCD_FIXED_AT_BUILD        :   TAB_PCDS_FIXED_AT_BUILD,
+        MODEL_PCD_PATCHABLE_IN_MODULE   :   TAB_PCDS_PATCHABLE_IN_MODULE,
+        MODEL_PCD_FEATURE_FLAG          :   TAB_PCDS_FEATURE_FLAG,
+        MODEL_PCD_DYNAMIC               :   TAB_PCDS_DYNAMIC,
+        MODEL_PCD_DYNAMIC_DEFAULT       :   TAB_PCDS_DYNAMIC,
+        MODEL_PCD_DYNAMIC_HII           :   TAB_PCDS_DYNAMIC_HII,
+        MODEL_PCD_DYNAMIC_VPD           :   TAB_PCDS_DYNAMIC_VPD,
+        MODEL_PCD_DYNAMIC_EX            :   TAB_PCDS_DYNAMIC_EX,
+        MODEL_PCD_DYNAMIC_EX_DEFAULT    :   TAB_PCDS_DYNAMIC_EX,
+        MODEL_PCD_DYNAMIC_EX_HII        :   TAB_PCDS_DYNAMIC_EX_HII,
+        MODEL_PCD_DYNAMIC_EX_VPD        :   TAB_PCDS_DYNAMIC_EX_VPD,
     }
 
     # dict used to convert part of [Defines] to members of DecBuildData directly
diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py
index eb435cece480..373441521723 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -164,17 +164,17 @@ def GetDependencyList(FileStack,SearchPathList):
 class DscBuildData(PlatformBuildClassObject):
     # dict used to convert PCD type in database to string used by build tool
     _PCD_TYPE_STRING_ = {
-        MODEL_PCD_FIXED_AT_BUILD        :   "FixedAtBuild",
-        MODEL_PCD_PATCHABLE_IN_MODULE   :   "PatchableInModule",
-        MODEL_PCD_FEATURE_FLAG          :   "FeatureFlag",
-        MODEL_PCD_DYNAMIC               :   "Dynamic",
-        MODEL_PCD_DYNAMIC_DEFAULT       :   "Dynamic",
-        MODEL_PCD_DYNAMIC_HII           :   "DynamicHii",
-        MODEL_PCD_DYNAMIC_VPD           :   "DynamicVpd",
-        MODEL_PCD_DYNAMIC_EX            :   "DynamicEx",
-        MODEL_PCD_DYNAMIC_EX_DEFAULT    :   "DynamicEx",
-        MODEL_PCD_DYNAMIC_EX_HII        :   "DynamicExHii",
-        MODEL_PCD_DYNAMIC_EX_VPD        :   "DynamicExVpd",
+        MODEL_PCD_FIXED_AT_BUILD        :   TAB_PCDS_FIXED_AT_BUILD,
+        MODEL_PCD_PATCHABLE_IN_MODULE   :   TAB_PCDS_PATCHABLE_IN_MODULE,
+        MODEL_PCD_FEATURE_FLAG          :   TAB_PCDS_FEATURE_FLAG,
+        MODEL_PCD_DYNAMIC               :   TAB_PCDS_DYNAMIC,
+        MODEL_PCD_DYNAMIC_DEFAULT       :   TAB_PCDS_DYNAMIC,
+        MODEL_PCD_DYNAMIC_HII           :   TAB_PCDS_DYNAMIC_HII,
+        MODEL_PCD_DYNAMIC_VPD           :   TAB_PCDS_DYNAMIC_VPD,
+        MODEL_PCD_DYNAMIC_EX            :   TAB_PCDS_DYNAMIC_EX,
+        MODEL_PCD_DYNAMIC_EX_DEFAULT    :   TAB_PCDS_DYNAMIC_EX,
+        MODEL_PCD_DYNAMIC_EX_HII        :   TAB_PCDS_DYNAMIC_EX_HII,
+        MODEL_PCD_DYNAMIC_EX_VPD        :   TAB_PCDS_DYNAMIC_EX_VPD,
     }
 
     # dict used to convert part of [Defines] to members of DscBuildData directly
diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py b/BaseTools/Source/Python/Workspace/InfBuildData.py
index 94f142e8e617..157f7a2d2de8 100644
--- a/BaseTools/Source/Python/Workspace/InfBuildData.py
+++ b/BaseTools/Source/Python/Workspace/InfBuildData.py
@@ -28,17 +28,17 @@ from Workspace.BuildClassObject import ModuleBuildClassObject, LibraryClassObjec
 class InfBuildData(ModuleBuildClassObject):
     # dict used to convert PCD type in database to string used by build tool
     _PCD_TYPE_STRING_ = {
-        MODEL_PCD_FIXED_AT_BUILD        :   "FixedAtBuild",
-        MODEL_PCD_PATCHABLE_IN_MODULE   :   "PatchableInModule",
-        MODEL_PCD_FEATURE_FLAG          :   "FeatureFlag",
-        MODEL_PCD_DYNAMIC               :   "Dynamic",
-        MODEL_PCD_DYNAMIC_DEFAULT       :   "Dynamic",
-        MODEL_PCD_DYNAMIC_HII           :   "DynamicHii",
-        MODEL_PCD_DYNAMIC_VPD           :   "DynamicVpd",
-        MODEL_PCD_DYNAMIC_EX            :   "DynamicEx",
-        MODEL_PCD_DYNAMIC_EX_DEFAULT    :   "DynamicEx",
-        MODEL_PCD_DYNAMIC_EX_HII        :   "DynamicExHii",
-        MODEL_PCD_DYNAMIC_EX_VPD        :   "DynamicExVpd",
+        MODEL_PCD_FIXED_AT_BUILD        :   TAB_PCDS_FIXED_AT_BUILD,
+        MODEL_PCD_PATCHABLE_IN_MODULE   :   TAB_PCDS_PATCHABLE_IN_MODULE,
+        MODEL_PCD_FEATURE_FLAG          :   TAB_PCDS_FEATURE_FLAG,
+        MODEL_PCD_DYNAMIC               :   TAB_PCDS_DYNAMIC,
+        MODEL_PCD_DYNAMIC_DEFAULT       :   TAB_PCDS_DYNAMIC,
+        MODEL_PCD_DYNAMIC_HII           :   TAB_PCDS_DYNAMIC_HII,
+        MODEL_PCD_DYNAMIC_VPD           :   TAB_PCDS_DYNAMIC_VPD,
+        MODEL_PCD_DYNAMIC_EX            :   TAB_PCDS_DYNAMIC_EX,
+        MODEL_PCD_DYNAMIC_EX_DEFAULT    :   TAB_PCDS_DYNAMIC_EX,
+        MODEL_PCD_DYNAMIC_EX_HII        :   TAB_PCDS_DYNAMIC_EX_HII,
+        MODEL_PCD_DYNAMIC_EX_VPD        :   TAB_PCDS_DYNAMIC_EX_VPD,
     }
 
     # dict used to convert part of [Defines] to members of InfBuildData directly
@@ -1026,13 +1026,13 @@ class InfBuildData(ModuleBuildClassObject):
                 # if platform doesn't give its type, use 'lowest' one in the
                 # following order, if any
                 #
-                #   "FixedAtBuild", "PatchableInModule", "FeatureFlag", "Dynamic", "DynamicEx"
+                #   TAB_PCDS_FIXED_AT_BUILD, TAB_PCDS_PATCHABLE_IN_MODULE, TAB_PCDS_FEATURE_FLAG, TAB_PCDS_DYNAMIC, TAB_PCDS_DYNAMIC_EX
                 #
                 _GuidDict.update(Package.Guids)
                 PcdType = self._PCD_TYPE_STRING_[Type]
                 if Type == MODEL_PCD_DYNAMIC:
                     Pcd.Pending = True
-                    for T in ["FixedAtBuild", "PatchableInModule", "FeatureFlag", "Dynamic", "DynamicEx"]:
+                    for T in PCD_TYPE_LIST:
                         if (PcdRealName, TokenSpaceGuid) in GlobalData.MixedPcd:
                             for item in GlobalData.MixedPcd[(PcdRealName, TokenSpaceGuid)]:
                                 if str(item[0]).endswith(T) and (item[0], item[1], T) in Package.Pcds:
diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Source/Python/build/BuildReport.py
index 02e01a1fa2ab..c8948b5cfbd9 100644
--- a/BaseTools/Source/Python/build/BuildReport.py
+++ b/BaseTools/Source/Python/build/BuildReport.py
@@ -94,15 +94,15 @@ gSubSectionSep = "-" * gLineMaxLength
 
 ## The look up table to map PCD type to pair of report display type and DEC type
 gPcdTypeMap = {
-  'FixedAtBuild'     : ('FIXED',  'FixedAtBuild'),
-  'PatchableInModule': ('PATCH',  'PatchableInModule'),
-  'FeatureFlag'      : ('FLAG',   'FeatureFlag'),
-  'Dynamic'          : ('DYN',    'Dynamic'),
-  'DynamicHii'       : ('DYNHII', 'Dynamic'),
-  'DynamicVpd'       : ('DYNVPD', 'Dynamic'),
-  'DynamicEx'        : ('DEX',    'DynamicEx'),
-  'DynamicExHii'     : ('DEXHII', 'DynamicEx'),
-  'DynamicExVpd'     : ('DEXVPD', 'DynamicEx'),
+  TAB_PCDS_FIXED_AT_BUILD     : ('FIXED',  TAB_PCDS_FIXED_AT_BUILD),
+  TAB_PCDS_PATCHABLE_IN_MODULE: ('PATCH',  TAB_PCDS_PATCHABLE_IN_MODULE),
+  TAB_PCDS_FEATURE_FLAG       : ('FLAG',   TAB_PCDS_FEATURE_FLAG),
+  TAB_PCDS_DYNAMIC            : ('DYN',    TAB_PCDS_DYNAMIC),
+  TAB_PCDS_DYNAMIC_HII        : ('DYNHII', TAB_PCDS_DYNAMIC),
+  TAB_PCDS_DYNAMIC_VPD        : ('DYNVPD', TAB_PCDS_DYNAMIC),
+  TAB_PCDS_DYNAMIC_EX         : ('DEX',    TAB_PCDS_DYNAMIC_EX),
+  TAB_PCDS_DYNAMIC_EX_HII     : ('DEXHII', TAB_PCDS_DYNAMIC_EX),
+  TAB_PCDS_DYNAMIC_EX_VPD     : ('DEXVPD', TAB_PCDS_DYNAMIC_EX),
   }
 
 ## The look up table to map module type to driver type
@@ -784,7 +784,7 @@ class PcdReport(object):
                 Pcd = Pa.Platform.Pcds[item]
                 if not Pcd.Type:
                     # check the Pcd in FDF file, whether it is used in module first
-                    for T in ["FixedAtBuild", "PatchableInModule", "FeatureFlag", "Dynamic", "DynamicEx"]:
+                    for T in PCD_TYPE_LIST:
                         PcdList = self.AllPcds.setdefault(Pcd.TokenSpaceGuidCName, {}).setdefault(T, [])
                         if Pcd in PcdList:
                             Pcd.Type = T
@@ -792,7 +792,7 @@ class PcdReport(object):
                 if not Pcd.Type:
                     PcdTypeFlag = False
                     for package in Pa.PackageList:
-                        for T in ["FixedAtBuild", "PatchableInModule", "FeatureFlag", "Dynamic", "DynamicEx"]:
+                        for T in PCD_TYPE_LIST:
                             if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, T) in package.Pcds:
                                 Pcd.Type = T
                                 PcdTypeFlag = True
@@ -804,10 +804,10 @@ class PcdReport(object):
                 if not Pcd.DatumType:
                     PcdType = Pcd.Type
                     # Try to remove Hii and Vpd suffix
-                    if PcdType.startswith("DynamicEx"):
-                        PcdType = "DynamicEx"
-                    elif PcdType.startswith("Dynamic"):
-                        PcdType = "Dynamic"
+                    if PcdType.startswith(TAB_PCDS_DYNAMIC_EX):
+                        PcdType = TAB_PCDS_DYNAMIC_EX
+                    elif PcdType.startswith(TAB_PCDS_DYNAMIC):
+                        PcdType = TAB_PCDS_DYNAMIC
                     for package in Pa.PackageList:
                         if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, PcdType) in package.Pcds:
                             Pcd.DatumType = package.Pcds[(Pcd.TokenCName, Pcd.TokenSpaceGuidCName, PcdType)].DatumType
-- 
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH v1 19/27] BaseTools: Replace Binary File type strings with predefined constant
  2018-04-20 15:51 [PATCH v1 00/27] BaseTools refactoring Jaben Carsey
                   ` (17 preceding siblings ...)
  2018-04-20 15:51 ` [PATCH v1 18/27] BaseTools: Replace PCD type strings with predefined constant Jaben Carsey
@ 2018-04-20 15:51 ` Jaben Carsey
  2018-04-24  7:38   ` Zhu, Yonghong
  2018-04-20 15:51 ` [PATCH v1 20/27] BaseTools: remove duplicate variable Jaben Carsey
                   ` (7 subsequent siblings)
  26 siblings, 1 reply; 56+ messages in thread
From: Jaben Carsey @ 2018-04-20 15:51 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Yonghong Zhu

BINARY_FILE_TYPE_FW was 'FW'
BINARY_FILE_TYPE_GUID was 'GUID'
BINARY_FILE_TYPE_PREEFORM was 'PREEFORM'
BINARY_FILE_TYPE_UEFI_APP was 'UEFI_APP'
BINARY_FILE_TYPE_UNI_UI was 'UNI_UI'
BINARY_FILE_TYPE_UNI_VER was 'UNI_VER'
BINARY_FILE_TYPE_LIB was 'LIB'
BINARY_FILE_TYPE_PE32 was 'PE32'
BINARY_FILE_TYPE_PIC was 'PIC'
BINARY_FILE_TYPE_PEI_DEPEX was 'PEI_DEPEX'
BINARY_FILE_TYPE_DXE_DEPEX was 'DXE_DEPEX'
BINARY_FILE_TYPE_SMM_DEPEX was 'SMM_DEPEX'
BINARY_FILE_TYPE_TE was 'TE'
BINARY_FILE_TYPE_VER was 'VER'
BINARY_FILE_TYPE_UI was 'UI'
BINARY_FILE_TYPE_BIN was 'BIN'
BINARY_FILE_TYPE_FV was 'FV'

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>
---
 BaseTools/Source/Python/AutoGen/AutoGen.py             | 12 +--
 BaseTools/Source/Python/AutoGen/GenC.py                |  8 +-
 BaseTools/Source/Python/AutoGen/GenPcdDb.py            |  4 +-
 BaseTools/Source/Python/Common/Expression.py           |  2 +-
 BaseTools/Source/Python/Common/Misc.py                 |  4 +-
 BaseTools/Source/Python/GenFds/DataSection.py          |  6 +-
 BaseTools/Source/Python/GenFds/DepexSection.py         |  6 +-
 BaseTools/Source/Python/GenFds/EfiSection.py           | 10 +--
 BaseTools/Source/Python/GenFds/Fd.py                   |  3 +-
 BaseTools/Source/Python/GenFds/FdfParser.py            | 92 ++++++++++----------
 BaseTools/Source/Python/GenFds/Ffs.py                  | 14 +--
 BaseTools/Source/Python/GenFds/FfsInfStatement.py      | 22 ++---
 BaseTools/Source/Python/GenFds/Fv.py                   |  4 +-
 BaseTools/Source/Python/GenFds/GenFds.py               | 10 +--
 BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py |  4 +-
 BaseTools/Source/Python/GenFds/OptRomInfStatement.py   |  2 +-
 BaseTools/Source/Python/GenFds/Region.py               |  5 +-
 BaseTools/Source/Python/GenFds/Section.py              | 46 +++++-----
 BaseTools/Source/Python/GenFds/UiSection.py            |  2 +-
 BaseTools/Source/Python/Trim/Trim.py                   |  2 +-
 BaseTools/Source/Python/Workspace/DscBuildData.py      |  2 +-
 BaseTools/Source/Python/Workspace/InfBuildData.py      |  2 +-
 BaseTools/Source/Python/build/BuildReport.py           | 12 +--
 23 files changed, 138 insertions(+), 136 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 9b2164ed8216..534fbe79fad9 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -923,7 +923,7 @@ class WorkspaceAutoGen(AutoGen):
     ## Return the directory to store FV files
     def _GetFvDir(self):
         if self._FvDir is None:
-            self._FvDir = path.join(self.BuildDir, 'FV')
+            self._FvDir = path.join(self.BuildDir, BINARY_FILE_TYPE_FV)
         return self._FvDir
 
     ## Return the directory to store all intermediate and final files built
@@ -1326,7 +1326,7 @@ class PlatformAutoGen(AutoGen):
 
     def UpdateNVStoreMaxSize(self,OrgVpdFile):
         if self.VariableInfo:
-            VpdMapFilePath = os.path.join(self.BuildDir, "FV", "%s.map" % self.Platform.VpdToolGuid)
+            VpdMapFilePath = os.path.join(self.BuildDir, BINARY_FILE_TYPE_FV, "%s.map" % self.Platform.VpdToolGuid)
             PcdNvStoreDfBuffer = [item for item in self._DynamicPcdList if item.TokenCName == "PcdNvStoreDefaultValueBuffer" and item.TokenSpaceGuidCName == "gEfiMdeModulePkgTokenSpaceGuid"]
 
             if PcdNvStoreDfBuffer:
@@ -1719,7 +1719,7 @@ class PlatformAutoGen(AutoGen):
 
                 # Process VPD map file generated by third party BPDG tool
                 if NeedProcessVpdMapFile:
-                    VpdMapFilePath = os.path.join(self.BuildDir, "FV", "%s.map" % self.Platform.VpdToolGuid)
+                    VpdMapFilePath = os.path.join(self.BuildDir, BINARY_FILE_TYPE_FV, "%s.map" % self.Platform.VpdToolGuid)
                     if os.path.exists(VpdMapFilePath):
                         VpdFile.Read(VpdMapFilePath)
 
@@ -1770,7 +1770,7 @@ class PlatformAutoGen(AutoGen):
         self.AllPcdList = self._NonDynamicPcdList + self._DynamicPcdList
 
     def FixVpdOffset(self,VpdFile ):
-        FvPath = os.path.join(self.BuildDir, "FV")
+        FvPath = os.path.join(self.BuildDir, BINARY_FILE_TYPE_FV)
         if not os.path.exists(FvPath):
             try:
                 os.makedirs(FvPath)
@@ -1783,7 +1783,7 @@ class PlatformAutoGen(AutoGen):
             # retrieve BPDG tool's path from tool_def.txt according to VPD_TOOL_GUID defined in DSC file.
             BPDGToolName = None
             for ToolDef in self.ToolDefinition.values():
-                if ToolDef.has_key("GUID") and ToolDef["GUID"] == self.Platform.VpdToolGuid:
+                if ToolDef.has_key(BINARY_FILE_TYPE_GUID) and ToolDef[BINARY_FILE_TYPE_GUID] == self.Platform.VpdToolGuid:
                     if not ToolDef.has_key("PATH"):
                         EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE, "PATH attribute was not provided for BPDG guid tool %s in tools_def.txt" % self.Platform.VpdToolGuid)
                     BPDGToolName = ToolDef["PATH"]
@@ -3032,7 +3032,7 @@ class ModuleAutoGen(AutoGen):
     def _GetFfsOutputDir(self):
         if self._FfsOutputDir is None:
             if GlobalData.gFdfParser is not None:
-                self._FfsOutputDir = path.join(self.PlatformInfo.BuildDir, "FV", "Ffs", self.Guid + self.Name)
+                self._FfsOutputDir = path.join(self.PlatformInfo.BuildDir, BINARY_FILE_TYPE_FV, "Ffs", self.Guid + self.Name)
             else:
                 self._FfsOutputDir = ''
         return self._FfsOutputDir
diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py
index 6b2ee87b2211..ca54ac107e5d 100644
--- a/BaseTools/Source/Python/AutoGen/GenC.py
+++ b/BaseTools/Source/Python/AutoGen/GenC.py
@@ -1614,7 +1614,7 @@ def CreateModuleUnloadImageCode(Info, AutoGenC, AutoGenH):
 #
 def CreateGuidDefinitionCode(Info, AutoGenC, AutoGenH):
     if Info.ModuleType in [SUP_MODULE_USER_DEFINED, SUP_MODULE_BASE]:
-        GuidType = "GUID"
+        GuidType = BINARY_FILE_TYPE_GUID
     else:
         GuidType = "EFI_GUID"
 
@@ -1638,7 +1638,7 @@ def CreateGuidDefinitionCode(Info, AutoGenC, AutoGenH):
 #
 def CreateProtocolDefinitionCode(Info, AutoGenC, AutoGenH):
     if Info.ModuleType in [SUP_MODULE_USER_DEFINED, SUP_MODULE_BASE]:
-        GuidType = "GUID"
+        GuidType = BINARY_FILE_TYPE_GUID
     else:
         GuidType = "EFI_GUID"
 
@@ -1662,7 +1662,7 @@ def CreateProtocolDefinitionCode(Info, AutoGenC, AutoGenH):
 #
 def CreatePpiDefinitionCode(Info, AutoGenC, AutoGenH):
     if Info.ModuleType in [SUP_MODULE_USER_DEFINED, SUP_MODULE_BASE]:
-        GuidType = "GUID"
+        GuidType = BINARY_FILE_TYPE_GUID
     else:
         GuidType = "EFI_GUID"
 
@@ -1699,7 +1699,7 @@ def CreatePcdCode(Info, AutoGenC, AutoGenH):
     if TokenSpaceList:
         AutoGenH.Append("\n// Definition of PCD Token Space GUIDs used in this module\n\n")
         if Info.ModuleType in [SUP_MODULE_USER_DEFINED, SUP_MODULE_BASE]:
-            GuidType = "GUID"
+            GuidType = BINARY_FILE_TYPE_GUID
         else:
             GuidType = "EFI_GUID"              
         for Item in TokenSpaceList:
diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
index 9374ca4820ef..63228795c001 100644
--- a/BaseTools/Source/Python/AutoGen/GenPcdDb.py
+++ b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
@@ -972,7 +972,7 @@ def CreatePcdDatabaseCode (Info, AutoGenC, AutoGenH):
         AutoGenC.Append(AdditionalAutoGenC.String)
 
     if Info.IsBinaryModule:
-        DbFileName = os.path.join(Info.PlatformInfo.BuildDir, "FV", Phase + "PcdDataBase.raw")
+        DbFileName = os.path.join(Info.PlatformInfo.BuildDir, BINARY_FILE_TYPE_FV, Phase + "PcdDataBase.raw")
     else:
         DbFileName = os.path.join(Info.OutputDir, Phase + "PcdDataBase.raw")
     DbFile = StringIO()
@@ -1054,7 +1054,7 @@ def NewCreatePcdDatabasePhaseSpecificAutoGen(Platform,Phase):
             PcdDriverAutoGenData[(skuname,skuid)] = (AdditionalAutoGenH, AdditionalAutoGenC)
             VarCheckTableData[(skuname,skuid)] = VarCheckTab
         if Platform.Platform.VarCheckFlag:
-            dest = os.path.join(Platform.BuildDir, 'FV')
+            dest = os.path.join(Platform.BuildDir, BINARY_FILE_TYPE_FV)
             VarCheckTable = CreateVarCheckBin(VarCheckTableData)
             VarCheckTable.dump(dest, Phase)
         AdditionalAutoGenH, AdditionalAutoGenC =  CreateAutoGen(PcdDriverAutoGenData)
diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Source/Python/Common/Expression.py
index 99929938fb5a..4b7d65583dc8 100644
--- a/BaseTools/Source/Python/Common/Expression.py
+++ b/BaseTools/Source/Python/Common/Expression.py
@@ -950,7 +950,7 @@ class ValueExpressionEx(ValueExpression):
                             Size = 0
                             ValueStr = ''
                             TokenSpaceGuidName = ''
-                            if Item.startswith('GUID') and Item.endswith(')'):
+                            if Item.startswith(BINARY_FILE_TYPE_GUID) and Item.endswith(')'):
                                 try:
                                     TokenSpaceGuidName = re.search('GUID\((\w+)\)', Item).group(1)
                                 except:
diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
index 4a6a29c7ae80..61617ed589b3 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -1219,7 +1219,7 @@ class tdict:
 
 def IsFieldValueAnArray (Value):
     Value = Value.strip()
-    if Value.startswith('GUID') and Value.endswith(')'):
+    if Value.startswith(BINARY_FILE_TYPE_GUID) and Value.endswith(')'):
         return True
     if Value.startswith('L"') and Value.endswith('"')  and len(list(Value[2:-1])) > 1:
         return True
@@ -1316,7 +1316,7 @@ def ParseFieldValue (Value):
         if Size > 8:
             raise BadExpression('Value (%s) Size larger than %d' % (Value, Size))
         return Value, 8
-    if Value.startswith('GUID') and Value.endswith(')'):
+    if Value.startswith(BINARY_FILE_TYPE_GUID) and Value.endswith(')'):
         Value = Value.split('(', 1)[1][:-1].strip()
         if Value[0] == '{' and Value[-1] == '}':
             TmpValue = GuidStructureStringToGuidString(Value)
diff --git a/BaseTools/Source/Python/GenFds/DataSection.py b/BaseTools/Source/Python/GenFds/DataSection.py
index 3c435c2fcc65..c066d4383549 100644
--- a/BaseTools/Source/Python/GenFds/DataSection.py
+++ b/BaseTools/Source/Python/GenFds/DataSection.py
@@ -81,7 +81,7 @@ class DataSection (DataSectionClassObject):
                         CopyLongFilePath(MapFile, CopyMapFile)
 
         #Get PE Section alignment when align is set to AUTO
-        if self.Alignment == 'Auto' and self.SecType in ('TE', 'PE32'):
+        if self.Alignment == 'Auto' and self.SecType in (BINARY_FILE_TYPE_TE, BINARY_FILE_TYPE_PE32):
             ImageObj = PeImageClass (Filename)
             if ImageObj.SectionAlignment < 0x400:
                 self.Alignment = str (ImageObj.SectionAlignment)
@@ -91,7 +91,7 @@ class DataSection (DataSectionClassObject):
                 self.Alignment = str (ImageObj.SectionAlignment / 0x100000) + 'M'
 
         NoStrip = True
-        if self.SecType in ('TE', 'PE32'):
+        if self.SecType in (BINARY_FILE_TYPE_TE, BINARY_FILE_TYPE_PE32):
             if self.KeepReloc is not None:
                 NoStrip = self.KeepReloc
 
@@ -109,7 +109,7 @@ class DataSection (DataSectionClassObject):
                 )
             self.SectFileName = StrippedFile
 
-        if self.SecType == 'TE':
+        if self.SecType == BINARY_FILE_TYPE_TE:
             TeFile = os.path.join( OutputPath, ModuleName + 'Te.raw')
             GenFdsGlobalVariable.GenerateFirmwareImage(
                     TeFile,
diff --git a/BaseTools/Source/Python/GenFds/DepexSection.py b/BaseTools/Source/Python/GenFds/DepexSection.py
index d04160e890f1..f42162d5a27e 100644
--- a/BaseTools/Source/Python/GenFds/DepexSection.py
+++ b/BaseTools/Source/Python/GenFds/DepexSection.py
@@ -96,13 +96,13 @@ class DepexSection (DepexSectionClassObject):
 
         if self.DepexType == 'PEI_DEPEX_EXP':
             ModuleType = SUP_MODULE_PEIM
-            SecType    = 'PEI_DEPEX'
+            SecType    = BINARY_FILE_TYPE_PEI_DEPEX
         elif self.DepexType == 'DXE_DEPEX_EXP':
             ModuleType = SUP_MODULE_DXE_DRIVER
-            SecType    = 'DXE_DEPEX'
+            SecType    = BINARY_FILE_TYPE_DXE_DEPEX
         elif self.DepexType == 'SMM_DEPEX_EXP':
             ModuleType = SUP_MODULE_DXE_SMM_DRIVER
-            SecType    = 'SMM_DEPEX'
+            SecType    = BINARY_FILE_TYPE_SMM_DEPEX
         else:
             EdkLogger.error("GenFds", FORMAT_INVALID,
                             "Depex type %s is not valid for module %s" % (self.DepexType, ModuleName))
diff --git a/BaseTools/Source/Python/GenFds/EfiSection.py b/BaseTools/Source/Python/GenFds/EfiSection.py
index 1be23b4bf7fd..5405d0a8da13 100644
--- a/BaseTools/Source/Python/GenFds/EfiSection.py
+++ b/BaseTools/Source/Python/GenFds/EfiSection.py
@@ -67,7 +67,7 @@ class EfiSection (EfiSectionClassObject):
             StringData = FfsInf.__ExtendMacro__(self.StringData)
             ModuleNameStr = FfsInf.__ExtendMacro__('$(MODULE_NAME)')
             NoStrip = True
-            if FfsInf.ModuleType in (SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM) and SectionType in ('TE', 'PE32'):
+            if FfsInf.ModuleType in (SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM) and SectionType in (BINARY_FILE_TYPE_TE, BINARY_FILE_TYPE_PE32):
                 if FfsInf.KeepReloc is not None:
                     NoStrip = FfsInf.KeepReloc
                 elif FfsInf.KeepRelocFromRule is not None:
@@ -171,9 +171,9 @@ class EfiSection (EfiSectionClassObject):
                 OutputFileList.append(OutputFile)
 
         #
-        # If Section Type is 'UI'
+        # If Section Type is BINARY_FILE_TYPE_UI
         #
-        elif SectionType == 'UI':
+        elif SectionType == BINARY_FILE_TYPE_UI:
 
             InfOverrideUiString = False
             if FfsInf.Ui is not None:
@@ -242,7 +242,7 @@ class EfiSection (EfiSectionClassObject):
                     File = GenFdsGlobalVariable.MacroExtend(File, Dict)
                     
                     #Get PE Section alignment when align is set to AUTO
-                    if self.Alignment == 'Auto' and (SectionType == 'PE32' or SectionType == 'TE'):
+                    if self.Alignment == 'Auto' and (SectionType == BINARY_FILE_TYPE_PE32 or SectionType == BINARY_FILE_TYPE_TE):
                         ImageObj = PeImageClass (File)
                         if ImageObj.SectionAlignment < 0x400:
                             Align = str (ImageObj.SectionAlignment)
@@ -287,7 +287,7 @@ class EfiSection (EfiSectionClassObject):
                     
                     """For TE Section call GenFw to generate TE image"""
 
-                    if SectionType == 'TE':
+                    if SectionType == BINARY_FILE_TYPE_TE:
                         TeFile = os.path.join( OutputPath, ModuleName + 'Te.raw')
                         GenFdsGlobalVariable.GenerateFirmwareImage(
                                 TeFile,
diff --git a/BaseTools/Source/Python/GenFds/Fd.py b/BaseTools/Source/Python/GenFds/Fd.py
index cc4124ad902e..188ca28cd7ce 100644
--- a/BaseTools/Source/Python/GenFds/Fd.py
+++ b/BaseTools/Source/Python/GenFds/Fd.py
@@ -27,6 +27,7 @@ from Common import EdkLogger
 from Common.BuildToolError import *
 from Common.Misc import SaveFileOnChange
 from GenFds import GenFds
+from Common.DataType import BINARY_FILE_TYPE_FV
 
 ## generate FD
 #
@@ -158,7 +159,7 @@ class FD(FDClassObject):
         FvAddDict ={}
         FvList = []
         for RegionObj in self.RegionList:
-            if RegionObj.RegionType == 'FV':
+            if RegionObj.RegionType == BINARY_FILE_TYPE_FV:
                 if len(RegionObj.RegionDataList) == 1:
                     RegionData = RegionObj.RegionDataList[0]
                     FvList.append(RegionData.upper())
diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py
index 23c04123af1b..b8848a25b4b2 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -1850,7 +1850,7 @@ class FdfParser:
         if not self.__GetNextWord():
             return True
 
-        if not self.__Token in ("SET", "FV", "FILE", "DATA", "CAPSULE", "INF"):
+        if not self.__Token in ("SET", BINARY_FILE_TYPE_FV, "FILE", "DATA", "CAPSULE", "INF"):
             #
             # If next token is a word which is not a valid FV type, it might be part of [PcdOffset[|PcdSize]]
             # Or it might be next region's offset described by an expression which starts with a PCD.
@@ -1881,7 +1881,7 @@ class FdfParser:
             if not self.__GetNextWord():
                 return True
 
-        elif self.__Token == "FV":
+        elif self.__Token == BINARY_FILE_TYPE_FV:
             self.__UndoToken()
             self.__GetRegionFvType( RegionObj)
 
@@ -1925,8 +1925,8 @@ class FdfParser:
     #
     def __GetRegionFvType(self, RegionObj):
 
-        if not self.__IsKeyword( "FV"):
-            raise Warning("expected Keyword 'FV'", self.FileName, self.CurrentLineNumber)
+        if not self.__IsKeyword( BINARY_FILE_TYPE_FV):
+            raise Warning("expected Keyword BINARY_FILE_TYPE_FV", self.FileName, self.CurrentLineNumber)
 
         if not self.__IsToken( "="):
             raise Warning("expected '='", self.FileName, self.CurrentLineNumber)
@@ -1934,10 +1934,10 @@ class FdfParser:
         if not self.__GetNextToken():
             raise Warning("expected FV name", self.FileName, self.CurrentLineNumber)
 
-        RegionObj.RegionType = "FV"
+        RegionObj.RegionType = BINARY_FILE_TYPE_FV
         RegionObj.RegionDataList.append((self.__Token).upper())
 
-        while self.__IsKeyword( "FV"):
+        while self.__IsKeyword( BINARY_FILE_TYPE_FV):
 
             if not self.__IsToken( "="):
                 raise Warning("expected '='", self.FileName, self.CurrentLineNumber)
@@ -2535,7 +2535,7 @@ class FdfParser:
             if self.__GetStringData():
                 FfsInfObj.Version = self.__Token
 
-        if self.__IsKeyword( "UI"):
+        if self.__IsKeyword( BINARY_FILE_TYPE_UI):
             if not self.__IsToken( "="):
                 raise Warning("expected '='", self.FileName, self.CurrentLineNumber)
             if not self.__GetNextToken():
@@ -2648,7 +2648,7 @@ class FdfParser:
     #
     @staticmethod
     def __SectionCouldHaveRelocFlag (SectionType):
-        if SectionType in ('TE', 'PE32'):
+        if SectionType in (BINARY_FILE_TYPE_TE, BINARY_FILE_TYPE_PE32):
             return True
         else:
             return False
@@ -2681,7 +2681,7 @@ class FdfParser:
         if not self.__GetNextToken():
             raise Warning("expected File name or section data", self.FileName, self.CurrentLineNumber)
 
-        if self.__Token == "FV":
+        if self.__Token == BINARY_FILE_TYPE_FV:
             if not self.__IsToken( "="):
                 raise Warning("expected '='", self.FileName, self.CurrentLineNumber)
             if not self.__GetNextToken():
@@ -2888,7 +2888,7 @@ class FdfParser:
                 VerSectionObj.FileName = self.__Token
             Obj.SectionList.append(VerSectionObj)
             
-        elif self.__IsKeyword( "UI"):
+        elif self.__IsKeyword( BINARY_FILE_TYPE_UI):
             if AlignValue == 'Auto':
                 raise Warning("Auto alignment can only be used in PE32 or TE section ", self.FileName, self.CurrentLineNumber)
             if not self.__IsToken( "="):
@@ -2972,10 +2972,10 @@ class FdfParser:
                 self.SetFileBufferPos(OldPos)
                 return False
 
-            if self.__Token not in ("COMPAT16", "PE32", "PIC", "TE", "FV_IMAGE", "RAW", "DXE_DEPEX",\
-                               "UI", "VERSION", "PEI_DEPEX", "SUBTYPE_GUID", "SMM_DEPEX"):
+            if self.__Token not in ("COMPAT16", BINARY_FILE_TYPE_PE32, BINARY_FILE_TYPE_PIC, BINARY_FILE_TYPE_TE, "FV_IMAGE", "RAW", BINARY_FILE_TYPE_DXE_DEPEX,\
+                               BINARY_FILE_TYPE_UI, "VERSION", BINARY_FILE_TYPE_PEI_DEPEX, "SUBTYPE_GUID", BINARY_FILE_TYPE_SMM_DEPEX):
                 raise Warning("Unknown section type '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
-            if AlignValue == 'Auto'and (not self.__Token == 'PE32') and (not self.__Token == 'TE'):
+            if AlignValue == 'Auto'and (not self.__Token == BINARY_FILE_TYPE_PE32) and (not self.__Token == BINARY_FILE_TYPE_TE):
                 raise Warning("Auto alignment can only be used in PE32 or TE section ", self.FileName, self.CurrentLineNumber)
 
             # DataSection
@@ -3393,7 +3393,7 @@ class FdfParser:
     #
     def __GetFvStatement(self, CapsuleObj, FMPCapsule = False):
 
-        if not self.__IsKeyword("FV"):
+        if not self.__IsKeyword(BINARY_FILE_TYPE_FV):
             return False
 
         if not self.__IsToken("="):
@@ -3541,7 +3541,7 @@ class FdfParser:
         AfileBaseName = os.path.basename(AfileName)
         
         if os.path.splitext(AfileBaseName)[1]  not in [".bin",".BIN",".Bin",".dat",".DAT",".Dat",".data",".DATA",".Data"]:
-            raise Warning('invalid binary file type, should be one of "bin","BIN","Bin","dat","DAT","Dat","data","DATA","Data"', \
+            raise Warning('invalid binary file type, should be one of "bin",BINARY_FILE_TYPE_BIN,"Bin","dat","DAT","Dat","data","DATA","Data"', \
                           self.FileName, self.CurrentLineNumber)
         
         if not os.path.isabs(AfileName):
@@ -3774,8 +3774,8 @@ class FdfParser:
 
             SectionName = self.__Token
 
-            if SectionName not in ("COMPAT16", "PE32", "PIC", "TE", "FV_IMAGE", "RAW", "DXE_DEPEX",\
-                                    "UI", "PEI_DEPEX", "VERSION", "SUBTYPE_GUID", "SMM_DEPEX"):
+            if SectionName not in ("COMPAT16", BINARY_FILE_TYPE_PE32, BINARY_FILE_TYPE_PIC, BINARY_FILE_TYPE_TE, "FV_IMAGE", "RAW", BINARY_FILE_TYPE_DXE_DEPEX,\
+                                    BINARY_FILE_TYPE_UI, BINARY_FILE_TYPE_PEI_DEPEX, "VERSION", "SUBTYPE_GUID", BINARY_FILE_TYPE_SMM_DEPEX):
                 raise Warning("Unknown leaf section name '%s'" % SectionName, self.FileName, self.CurrentLineNumber)
 
 
@@ -3790,7 +3790,7 @@ class FdfParser:
                 if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K", "128K",
                                         "256K", "512K", "1M", "2M", "4M", "8M", "16M"):
                     raise Warning("Incorrect alignment '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
-                if self.__Token == 'Auto' and (not SectionName == 'PE32') and (not SectionName == 'TE'):
+                if self.__Token == 'Auto' and (not SectionName == BINARY_FILE_TYPE_PE32) and (not SectionName == BINARY_FILE_TYPE_TE):
                     raise Warning("Auto alignment can only be used in PE32 or TE section ", self.FileName, self.CurrentLineNumber)
                 SectAlignment = self.__Token
 
@@ -3831,8 +3831,8 @@ class FdfParser:
             return False
         SectionName = self.__Token
 
-        if SectionName not in ("COMPAT16", "PE32", "PIC", "TE", "FV_IMAGE", "RAW", "DXE_DEPEX",\
-                               "UI", "VERSION", "PEI_DEPEX", "GUID", "SMM_DEPEX"):
+        if SectionName not in ("COMPAT16", BINARY_FILE_TYPE_PE32, BINARY_FILE_TYPE_PIC, BINARY_FILE_TYPE_TE, "FV_IMAGE", "RAW", BINARY_FILE_TYPE_DXE_DEPEX,\
+                               BINARY_FILE_TYPE_UI, "VERSION", BINARY_FILE_TYPE_PEI_DEPEX, BINARY_FILE_TYPE_GUID, BINARY_FILE_TYPE_SMM_DEPEX):
             self.__UndoToken()
             return False
 
@@ -3862,8 +3862,8 @@ class FdfParser:
                 FvImageSectionObj.FvName = None
 
             else:
-                if not self.__IsKeyword("FV"):
-                    raise Warning("expected 'FV'", self.FileName, self.CurrentLineNumber)
+                if not self.__IsKeyword(BINARY_FILE_TYPE_FV):
+                    raise Warning("expected BINARY_FILE_TYPE_FV", self.FileName, self.CurrentLineNumber)
                 FvImageSectionObj.FvFileType = self.__Token
 
                 if self.__GetAlignment():
@@ -3875,8 +3875,8 @@ class FdfParser:
                 if self.__IsToken('|'):
                     FvImageSectionObj.FvFileExtension = self.__GetFileExtension()
                 elif self.__GetNextToken():
-                    if self.__Token not in ("}", "COMPAT16", "PE32", "PIC", "TE", "FV_IMAGE", "RAW", "DXE_DEPEX",\
-                               "UI", "VERSION", "PEI_DEPEX", "GUID", "SMM_DEPEX"):
+                    if self.__Token not in ("}", "COMPAT16", BINARY_FILE_TYPE_PE32, BINARY_FILE_TYPE_PIC, BINARY_FILE_TYPE_TE, "FV_IMAGE", "RAW", BINARY_FILE_TYPE_DXE_DEPEX,\
+                               BINARY_FILE_TYPE_UI, "VERSION", BINARY_FILE_TYPE_PEI_DEPEX, BINARY_FILE_TYPE_GUID, BINARY_FILE_TYPE_SMM_DEPEX):
                         FvImageSectionObj.FvFileName = self.__Token
                     else:
                         self.__UndoToken()
@@ -3938,7 +3938,7 @@ class FdfParser:
             if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K", "128K",
                                     "256K", "512K", "1M", "2M", "4M", "8M", "16M"):
                 raise Warning("Incorrect alignment '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
-            if self.__Token == 'Auto' and (not SectionName == 'PE32') and (not SectionName == 'TE'):
+            if self.__Token == 'Auto' and (not SectionName == BINARY_FILE_TYPE_PE32) and (not SectionName == BINARY_FILE_TYPE_TE):
                 raise Warning("Auto alignment can only be used in PE32 or TE section ", self.FileName, self.CurrentLineNumber)
             EfiSectionObj.Alignment = self.__Token
 
@@ -3957,8 +3957,8 @@ class FdfParser:
         if self.__IsToken('|'):
             EfiSectionObj.FileExtension = self.__GetFileExtension()
         elif self.__GetNextToken():
-            if self.__Token not in ("}", "COMPAT16", "PE32", "PIC", "TE", "FV_IMAGE", "RAW", "DXE_DEPEX",\
-                       "UI", "VERSION", "PEI_DEPEX", "GUID", "SMM_DEPEX"):
+            if self.__Token not in ("}", "COMPAT16", BINARY_FILE_TYPE_PE32, BINARY_FILE_TYPE_PIC, BINARY_FILE_TYPE_TE, "FV_IMAGE", "RAW", BINARY_FILE_TYPE_DXE_DEPEX,\
+                       BINARY_FILE_TYPE_UI, "VERSION", BINARY_FILE_TYPE_PEI_DEPEX, BINARY_FILE_TYPE_GUID, BINARY_FILE_TYPE_SMM_DEPEX):
                 
                 if self.__Token.startswith('PCD'):
                     self.__UndoToken()
@@ -3992,7 +3992,7 @@ class FdfParser:
     #
     @staticmethod
     def __RuleSectionCouldBeOptional(SectionType):
-        if SectionType in ("DXE_DEPEX", "UI", "VERSION", "PEI_DEPEX", "RAW", "SMM_DEPEX"):
+        if SectionType in (BINARY_FILE_TYPE_DXE_DEPEX, BINARY_FILE_TYPE_UI, "VERSION", BINARY_FILE_TYPE_PEI_DEPEX, "RAW", BINARY_FILE_TYPE_SMM_DEPEX):
             return True
         else:
             return False
@@ -4022,7 +4022,7 @@ class FdfParser:
     #
     @staticmethod
     def __RuleSectionCouldHaveString(SectionType):
-        if SectionType in ("UI", "VERSION"):
+        if SectionType in (BINARY_FILE_TYPE_UI, "VERSION"):
             return True
         else:
             return False
@@ -4039,32 +4039,32 @@ class FdfParser:
         if SectionType == "COMPAT16":
             if FileType not in ("COMPAT16", "SEC_COMPAT16"):
                 raise Warning("Incorrect section file type '%s'" % FileType, self.FileName, self.CurrentLineNumber)
-        elif SectionType == "PE32":
-            if FileType not in ("PE32", "SEC_PE32"):
+        elif SectionType == BINARY_FILE_TYPE_PE32:
+            if FileType not in (BINARY_FILE_TYPE_PE32, "SEC_PE32"):
                 raise Warning("Incorrect section file type '%s'" % FileType, self.FileName, self.CurrentLineNumber)
-        elif SectionType == "PIC":
-            if FileType not in ("PIC", "PIC"):
+        elif SectionType == BINARY_FILE_TYPE_PIC:
+            if FileType not in (BINARY_FILE_TYPE_PIC, BINARY_FILE_TYPE_PIC):
                 raise Warning("Incorrect section file type '%s'" % FileType, self.FileName, self.CurrentLineNumber)
-        elif SectionType == "TE":
-            if FileType not in ("TE", "SEC_TE"):
+        elif SectionType == BINARY_FILE_TYPE_TE:
+            if FileType not in (BINARY_FILE_TYPE_TE, "SEC_TE"):
                 raise Warning("Incorrect section file type '%s'" % FileType, self.FileName, self.CurrentLineNumber)
         elif SectionType == "RAW":
-            if FileType not in ("BIN", "SEC_BIN", "RAW", "ASL", "ACPI"):
+            if FileType not in (BINARY_FILE_TYPE_BIN, "SEC_BIN", "RAW", "ASL", "ACPI"):
                 raise Warning("Incorrect section file type '%s'" % FileType, self.FileName, self.CurrentLineNumber)
-        elif SectionType == "DXE_DEPEX" or SectionType == "SMM_DEPEX":
-            if FileType not in ("DXE_DEPEX", "SEC_DXE_DEPEX", "SMM_DEPEX"):
+        elif SectionType == BINARY_FILE_TYPE_DXE_DEPEX or SectionType == BINARY_FILE_TYPE_SMM_DEPEX:
+            if FileType not in (BINARY_FILE_TYPE_DXE_DEPEX, "SEC_DXE_DEPEX", BINARY_FILE_TYPE_SMM_DEPEX):
                 raise Warning("Incorrect section file type '%s'" % FileType, self.FileName, self.CurrentLineNumber)
-        elif SectionType == "UI":
-            if FileType not in ("UI", "SEC_UI"):
+        elif SectionType == BINARY_FILE_TYPE_UI:
+            if FileType not in (BINARY_FILE_TYPE_UI, "SEC_UI"):
                 raise Warning("Incorrect section file type '%s'" % FileType, self.FileName, self.CurrentLineNumber)
         elif SectionType == "VERSION":
             if FileType not in ("VERSION", "SEC_VERSION"):
                 raise Warning("Incorrect section file type '%s'" % FileType, self.FileName, self.CurrentLineNumber)
-        elif SectionType == "PEI_DEPEX":
-            if FileType not in ("PEI_DEPEX", "SEC_PEI_DEPEX"):
+        elif SectionType == BINARY_FILE_TYPE_PEI_DEPEX:
+            if FileType not in (BINARY_FILE_TYPE_PEI_DEPEX, "SEC_PEI_DEPEX"):
                 raise Warning("Incorrect section file type '%s'" % FileType, self.FileName, self.CurrentLineNumber)
-        elif SectionType == "GUID":
-            if FileType not in ("PE32", "SEC_GUID"):
+        elif SectionType == BINARY_FILE_TYPE_GUID:
+            if FileType not in (BINARY_FILE_TYPE_PE32, "SEC_GUID"):
                 raise Warning("Incorrect section file type '%s'" % FileType, self.FileName, self.CurrentLineNumber)
 
     ## __GetRuleEncapsulationSection() method
@@ -4501,7 +4501,7 @@ class FdfParser:
 
         FfsFileObj = OptRomFileStatement.OptRomFileStatement()
 
-        if not self.__IsKeyword("EFI") and not self.__IsKeyword("BIN"):
+        if not self.__IsKeyword("EFI") and not self.__IsKeyword(BINARY_FILE_TYPE_BIN):
             raise Warning("expected Binary type (EFI/BIN)", self.FileName, self.CurrentLineNumber)
         FfsFileObj.FileType = self.__Token
 
@@ -4582,7 +4582,7 @@ class FdfParser:
         if FdName.upper() in self.Profile.FdDict:
             FdObj = self.Profile.FdDict[FdName.upper()]
             for elementRegion in FdObj.RegionList:
-                if elementRegion.RegionType == 'FV':
+                if elementRegion.RegionType == BINARY_FILE_TYPE_FV:
                     for elementRegionData in elementRegion.RegionDataList:
                         if elementRegionData.endswith(".fv"):
                             continue
diff --git a/BaseTools/Source/Python/GenFds/Ffs.py b/BaseTools/Source/Python/GenFds/Ffs.py
index f6a7f4b007f9..44ad01cb7354 100644
--- a/BaseTools/Source/Python/GenFds/Ffs.py
+++ b/BaseTools/Source/Python/GenFds/Ffs.py
@@ -42,12 +42,12 @@ class Ffs(FDClassObject):
     
     # mapping between section type in FDF and file suffix
     SectionSuffix = {
-        'PE32'                 : '.pe32',
-        'PIC'                  : '.pic',
-        'TE'                   : '.te',
-        'DXE_DEPEX'            : '.dpx',
+        BINARY_FILE_TYPE_PE32                 : '.pe32',
+        BINARY_FILE_TYPE_PIC                  : '.pic',
+        BINARY_FILE_TYPE_TE                   : '.te',
+        BINARY_FILE_TYPE_DXE_DEPEX            : '.dpx',
         'VERSION'              : '.ver',
-        'UI'                   : '.ui',
+        BINARY_FILE_TYPE_UI                   : '.ui',
         'COMPAT16'             : '.com16',
         'RAW'                  : '.raw',
         'FREEFORM_SUBTYPE_GUID': '.guid',
@@ -55,8 +55,8 @@ class Ffs(FDClassObject):
         'FV_IMAGE'             : 'fv.sec',
         'COMPRESS'             : '.com',
         'GUIDED'               : '.guided',
-        'PEI_DEPEX'            : '.dpx',
-        'SMM_DEPEX'            : '.dpx'
+        BINARY_FILE_TYPE_PEI_DEPEX            : '.dpx',
+        BINARY_FILE_TYPE_SMM_DEPEX            : '.dpx'
     }
     
     ## The constructor
diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
index 8893fcbda1fc..b92fa4d8033c 100644
--- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py
+++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
@@ -381,7 +381,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
         #
         # Only patch file if FileType is PE32 or ModuleType is USER_DEFINED
         #  
-        if FileType != 'PE32' and self.ModuleType != SUP_MODULE_USER_DEFINED:
+        if FileType != BINARY_FILE_TYPE_PE32 and self.ModuleType != SUP_MODULE_USER_DEFINED:
             return EfiFile
 
         #
@@ -739,13 +739,13 @@ class FfsInfStatement(FfsInfStatementClassObject):
         # Convert Fv Section Type for PI1.1 SMM driver.
         #
         if self.ModuleType == SUP_MODULE_DXE_SMM_DRIVER and int(self.PiSpecVersion, 16) >= 0x0001000A:
-            if SectionType == 'DXE_DEPEX':
-                SectionType = 'SMM_DEPEX'
+            if SectionType == BINARY_FILE_TYPE_DXE_DEPEX:
+                SectionType = BINARY_FILE_TYPE_SMM_DEPEX
         #
         # Framework SMM Driver has no SMM_DEPEX section type
         #
         if self.ModuleType == SUP_MODULE_DXE_SMM_DRIVER and int(self.PiSpecVersion, 16) < 0x0001000A:
-            if SectionType == 'SMM_DEPEX':
+            if SectionType == BINARY_FILE_TYPE_SMM_DEPEX:
                 EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "Framework SMM module doesn't support SMM_DEPEX section type", File=self.InfFileName)
         NoStrip = True
         if self.ModuleType in (SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM):
@@ -767,7 +767,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
                 File = GenFdsGlobalVariable.MacroExtend(File, Dict, self.CurrentArch)
 
                 #Get PE Section alignment when align is set to AUTO
-                if self.Alignment == 'Auto' and (SectionType == 'PE32' or SectionType == 'TE'):
+                if self.Alignment == 'Auto' and (SectionType == BINARY_FILE_TYPE_PE32 or SectionType == BINARY_FILE_TYPE_TE):
                     ImageObj = PeImageClass (File)
                     if ImageObj.SectionAlignment < 0x400:
                         self.Alignment = str (ImageObj.SectionAlignment)
@@ -790,7 +790,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
                         )
                     File = StrippedFile
 
-                if SectionType == 'TE':
+                if SectionType == BINARY_FILE_TYPE_TE:
                     TeFile = os.path.join( self.OutputPath, self.ModuleGuid + 'Te.raw')
                     GenFdsGlobalVariable.GenerateFirmwareImage(
                             TeFile,
@@ -809,7 +809,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
             GenSecInputFile = GenFdsGlobalVariable.MacroExtend(GenSecInputFile, Dict, self.CurrentArch)
 
             #Get PE Section alignment when align is set to AUTO
-            if self.Alignment == 'Auto' and (SectionType == 'PE32' or SectionType == 'TE'):
+            if self.Alignment == 'Auto' and (SectionType == BINARY_FILE_TYPE_PE32 or SectionType == BINARY_FILE_TYPE_TE):
                 ImageObj = PeImageClass (GenSecInputFile)
                 if ImageObj.SectionAlignment < 0x400:
                     self.Alignment = str (ImageObj.SectionAlignment)
@@ -833,7 +833,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
                     )
                 GenSecInputFile = StrippedFile
 
-            if SectionType == 'TE':
+            if SectionType == BINARY_FILE_TYPE_TE:
                 TeFile = os.path.join( self.OutputPath, self.ModuleGuid + 'Te.raw')
                 GenFdsGlobalVariable.GenerateFirmwareImage(
                         TeFile,
@@ -942,13 +942,13 @@ class FfsInfStatement(FfsInfStatementClassObject):
             # Convert Fv Section Type for PI1.1 SMM driver.
             #
             if self.ModuleType == SUP_MODULE_DXE_SMM_DRIVER and int(self.PiSpecVersion, 16) >= 0x0001000A:
-                if Sect.SectionType == 'DXE_DEPEX':
-                    Sect.SectionType = 'SMM_DEPEX'
+                if Sect.SectionType == BINARY_FILE_TYPE_DXE_DEPEX:
+                    Sect.SectionType = BINARY_FILE_TYPE_SMM_DEPEX
             #
             # Framework SMM Driver has no SMM_DEPEX section type
             #
             if self.ModuleType == SUP_MODULE_DXE_SMM_DRIVER and int(self.PiSpecVersion, 16) < 0x0001000A:
-                if Sect.SectionType == 'SMM_DEPEX':
+                if Sect.SectionType == BINARY_FILE_TYPE_SMM_DEPEX:
                     EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "Framework SMM module doesn't support SMM_DEPEX section type", File=self.InfFileName)
             #
             # process the inside FvImage from FvSection or GuidSection
diff --git a/BaseTools/Source/Python/GenFds/Fv.py b/BaseTools/Source/Python/GenFds/Fv.py
index 71bcd4c72170..024081734a2b 100644
--- a/BaseTools/Source/Python/GenFds/Fv.py
+++ b/BaseTools/Source/Python/GenFds/Fv.py
@@ -80,7 +80,7 @@ class FV (FvClassObject):
         if self.CapsuleName is not None:
             for FdObj in GenFdsGlobalVariable.FdfParser.Profile.FdDict.values():
                 for RegionObj in FdObj.RegionList:
-                    if RegionObj.RegionType == 'FV':
+                    if RegionObj.RegionType == BINARY_FILE_TYPE_FV:
                         for RegionData in RegionObj.RegionDataList:
                             if RegionData.endswith(".fv"):
                                 continue
@@ -236,7 +236,7 @@ class FV (FvClassObject):
 
         for FdObj in GenFdsGlobalVariable.FdfParser.Profile.FdDict.values():
             for RegionObj in FdObj.RegionList:
-                if RegionObj.RegionType != 'FV':
+                if RegionObj.RegionType != BINARY_FILE_TYPE_FV:
                     continue
                 for RegionData in RegionObj.RegionDataList:
                     #
diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Python/GenFds/GenFds.py
index 54c7d828305f..8bedd9f74411 100644
--- a/BaseTools/Source/Python/GenFds/GenFds.py
+++ b/BaseTools/Source/Python/GenFds/GenFds.py
@@ -315,7 +315,7 @@ def main():
                 for Fd in FdfParserObj.Profile.FdDict:
                     FdObj = FdfParserObj.Profile.FdDict[Fd]
                     for RegionObj in FdObj.RegionList:
-                        if RegionObj.RegionType != 'FV':
+                        if RegionObj.RegionType != BINARY_FILE_TYPE_FV:
                             continue
                         for RegionData in RegionObj.RegionDataList:
                             if FvObj.UiFvName.upper() == RegionData.upper():
@@ -405,7 +405,7 @@ def FindExtendTool(KeyStringList, CurrentArchList, NameGuid):
                   KeyList[1] + \
                   '_' + \
                   KeyList[2]
-            if Key in KeyStringList and KeyList[4] == 'GUID':
+            if Key in KeyStringList and KeyList[4] == BINARY_FILE_TYPE_GUID:
                 ToolPathKey   = Key + '_' + KeyList[3] + '_PATH'
                 ToolOptionKey = Key + '_' + KeyList[3] + '_FLAGS'
                 ToolPath = ToolDefinition.get(ToolPathKey)
@@ -447,7 +447,7 @@ def FindExtendTool(KeyStringList, CurrentArchList, NameGuid):
                 if NameGuid == BuildOption[Op]:
                     KeyList = Op.split('_')
                     Key = KeyList[0] + '_' + KeyList[1] +'_' + KeyList[2]
-                    if Key in KeyStringList and KeyList[4] == 'GUID':
+                    if Key in KeyStringList and KeyList[4] == BINARY_FILE_TYPE_GUID:
                         ToolPathKey   = Key + '_' + KeyList[3] + '_PATH'
                         ToolOptionKey = Key + '_' + KeyList[3] + '_FLAGS'
         if ToolPathKey in BuildOption:
@@ -589,7 +589,7 @@ class GenFds :
         if FdObj is None:
             for ElementFd in GenFdsGlobalVariable.FdfParser.Profile.FdDict.values():
                 for ElementRegion in ElementFd.RegionList:
-                    if ElementRegion.RegionType == 'FV':
+                    if ElementRegion.RegionType == BINARY_FILE_TYPE_FV:
                         for ElementRegionData in ElementRegion.RegionDataList:
                             if ElementRegionData is not None and ElementRegionData.upper() == FvObj.UiFvName:
                                 if FvObj.BlockSizeList != []:
@@ -601,7 +601,7 @@ class GenFds :
             return DefaultBlockSize
         else:
             for ElementRegion in FdObj.RegionList:
-                    if ElementRegion.RegionType == 'FV':
+                    if ElementRegion.RegionType == BINARY_FILE_TYPE_FV:
                         for ElementRegionData in ElementRegion.RegionDataList:
                             if ElementRegionData is not None and ElementRegionData.upper() == FvObj.UiFvName:
                                 if FvObj.BlockSizeList != []:
diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
index e692e4e98504..878b13d13c2d 100644
--- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
+++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
@@ -288,7 +288,7 @@ class GenFdsGlobalVariable:
 #        GenFdsGlobalVariable.OutputDirDict = OutputDir
         GenFdsGlobalVariable.FdfParser = FdfParser
         GenFdsGlobalVariable.WorkSpace = WorkSpace
-        GenFdsGlobalVariable.FvDir = os.path.join(GenFdsGlobalVariable.OutputDirDict[ArchList[0]], 'FV')
+        GenFdsGlobalVariable.FvDir = os.path.join(GenFdsGlobalVariable.OutputDirDict[ArchList[0]], DataType.BINARY_FILE_TYPE_FV)
         if not os.path.exists(GenFdsGlobalVariable.FvDir) :
             os.makedirs(GenFdsGlobalVariable.FvDir)
         GenFdsGlobalVariable.FfsDir = os.path.join(GenFdsGlobalVariable.FvDir, 'Ffs')
@@ -349,7 +349,7 @@ class GenFdsGlobalVariable:
             GenFdsGlobalVariable.PlatformName = WorkSpace.Db.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch,
                                                                       GlobalData.gGlobalDefines['TARGET'],
                                                                       GlobalData.gGlobalDefines['TOOLCHAIN']].PlatformName
-        GenFdsGlobalVariable.FvDir = os.path.join(GenFdsGlobalVariable.OutputDirDict[ArchList[0]], 'FV')
+        GenFdsGlobalVariable.FvDir = os.path.join(GenFdsGlobalVariable.OutputDirDict[ArchList[0]], DataType.BINARY_FILE_TYPE_FV)
         if not os.path.exists(GenFdsGlobalVariable.FvDir):
             os.makedirs(GenFdsGlobalVariable.FvDir)
         GenFdsGlobalVariable.FfsDir = os.path.join(GenFdsGlobalVariable.FvDir, 'Ffs')
diff --git a/BaseTools/Source/Python/GenFds/OptRomInfStatement.py b/BaseTools/Source/Python/GenFds/OptRomInfStatement.py
index 8f8761b20589..a865ac4436d5 100644
--- a/BaseTools/Source/Python/GenFds/OptRomInfStatement.py
+++ b/BaseTools/Source/Python/GenFds/OptRomInfStatement.py
@@ -141,7 +141,7 @@ class OptRomInfStatement (FfsInfStatement):
 
         OutputFileList = []
         for Sect in Rule.SectionList:
-            if Sect.SectionType == 'PE32':
+            if Sect.SectionType == BINARY_FILE_TYPE_PE32:
                 if Sect.FileName is not None:
                     GenSecInputFile = self.__ExtendMacro__(Sect.FileName)
                     OutputFileList.append(GenSecInputFile)
diff --git a/BaseTools/Source/Python/GenFds/Region.py b/BaseTools/Source/Python/GenFds/Region.py
index 44f122a71216..9d632b6321e2 100644
--- a/BaseTools/Source/Python/GenFds/Region.py
+++ b/BaseTools/Source/Python/GenFds/Region.py
@@ -26,6 +26,7 @@ from Common import EdkLogger
 from Common.BuildToolError import *
 from Common.LongFilePathSupport import OpenLongFilePath as open
 from Common.MultipleWorkspace import MultipleWorkspace as mws
+from Common.DataType import BINARY_FILE_TYPE_FV
 
 ## generate Region
 #
@@ -80,10 +81,10 @@ class Region(RegionClassObject):
             GenFdsGlobalVariable.InfLogger('\nGenerate Region at Offset 0x%X' % self.Offset)
             GenFdsGlobalVariable.InfLogger("   Region Size = 0x%X" % Size)
         GenFdsGlobalVariable.SharpCounter = 0
-        if Flag and (self.RegionType != 'FV'):
+        if Flag and (self.RegionType != BINARY_FILE_TYPE_FV):
             return
 
-        if self.RegionType == 'FV':
+        if self.RegionType == BINARY_FILE_TYPE_FV:
             #
             # Get Fv from FvDict
             #
diff --git a/BaseTools/Source/Python/GenFds/Section.py b/BaseTools/Source/Python/GenFds/Section.py
index 4b368b3ada9d..5895998158b6 100644
--- a/BaseTools/Source/Python/GenFds/Section.py
+++ b/BaseTools/Source/Python/GenFds/Section.py
@@ -20,7 +20,7 @@ from GenFdsGlobalVariable import GenFdsGlobalVariable
 import Common.LongFilePathOs as os, glob
 from Common import EdkLogger
 from Common.BuildToolError import *
-from Common.DataType import TAB_ARCH_COMMON
+from Common.DataType import *
 
 ## section base class
 #
@@ -29,37 +29,37 @@ class Section (SectionClassObject):
     SectionType = {
         'RAW'       : 'EFI_SECTION_RAW',
         'FREEFORM'  : 'EFI_SECTION_FREEFORM_SUBTYPE_GUID',
-        'PE32'      : 'EFI_SECTION_PE32',
-        'PIC'       : 'EFI_SECTION_PIC',
-        'TE'        : 'EFI_SECTION_TE',
+        BINARY_FILE_TYPE_PE32      : 'EFI_SECTION_PE32',
+        BINARY_FILE_TYPE_PIC       : 'EFI_SECTION_PIC',
+        BINARY_FILE_TYPE_TE        : 'EFI_SECTION_TE',
         'FV_IMAGE'  : 'EFI_SECTION_FIRMWARE_VOLUME_IMAGE',
-        'DXE_DEPEX' : 'EFI_SECTION_DXE_DEPEX',
-        'PEI_DEPEX' : 'EFI_SECTION_PEI_DEPEX',
+        BINARY_FILE_TYPE_DXE_DEPEX : 'EFI_SECTION_DXE_DEPEX',
+        BINARY_FILE_TYPE_PEI_DEPEX : 'EFI_SECTION_PEI_DEPEX',
         'GUIDED'    : 'EFI_SECTION_GUID_DEFINED',
         'COMPRESS'  : 'EFI_SECTION_COMPRESSION',
-        'UI'        : 'EFI_SECTION_USER_INTERFACE',
-        'SMM_DEPEX' : 'EFI_SECTION_SMM_DEPEX'
+        BINARY_FILE_TYPE_UI        : 'EFI_SECTION_USER_INTERFACE',
+        BINARY_FILE_TYPE_SMM_DEPEX : 'EFI_SECTION_SMM_DEPEX'
     }
 
     BinFileType = {
-        'GUID'          : '.guid',
+        BINARY_FILE_TYPE_GUID          : '.guid',
         'ACPI'          : '.acpi',
         'ASL'           : '.asl' ,
-        'UEFI_APP'      : '.app',
-        'LIB'           : '.lib',
-        'PE32'          : '.pe32',
-        'PIC'           : '.pic',
-        'PEI_DEPEX'     : '.depex',
+        BINARY_FILE_TYPE_UEFI_APP      : '.app',
+        BINARY_FILE_TYPE_LIB           : '.lib',
+        BINARY_FILE_TYPE_PE32          : '.pe32',
+        BINARY_FILE_TYPE_PIC           : '.pic',
+        BINARY_FILE_TYPE_PEI_DEPEX     : '.depex',
         'SEC_PEI_DEPEX' : '.depex',
-        'TE'            : '.te',
-        'UNI_VER'       : '.ver',
-        'VER'           : '.ver',
-        'UNI_UI'        : '.ui',
-        'UI'            : '.ui',
-        'BIN'           : '.bin',
+        BINARY_FILE_TYPE_TE            : '.te',
+        BINARY_FILE_TYPE_UNI_VER       : '.ver',
+        BINARY_FILE_TYPE_VER           : '.ver',
+        BINARY_FILE_TYPE_UNI_UI        : '.ui',
+        BINARY_FILE_TYPE_UI            : '.ui',
+        BINARY_FILE_TYPE_BIN           : '.bin',
         'RAW'           : '.raw',
         'COMPAT16'      : '.comp16',
-        'FV'            : '.fv'
+        BINARY_FILE_TYPE_FV            : '.fv'
     }
 
     SectFileType = {
@@ -128,8 +128,8 @@ class Section (SectionClassObject):
             for File in FfsInf.BinFileList:
                 if File.Arch == TAB_ARCH_COMMON or FfsInf.CurrentArch == File.Arch:
                     if File.Type == FileType or (int(FfsInf.PiSpecVersion, 16) >= 0x0001000A \
-                                                 and FileType == 'DXE_DPEX'and File.Type == 'SMM_DEPEX') \
-                                                 or (FileType == 'TE'and File.Type == 'PE32'):
+                                                 and FileType == 'DXE_DPEX' and File.Type == BINARY_FILE_TYPE_SMM_DEPEX) \
+                                                 or (FileType == BINARY_FILE_TYPE_TE and File.Type == BINARY_FILE_TYPE_PE32):
                         if '*' in FfsInf.TargetOverrideList or File.Target == '*' or File.Target in FfsInf.TargetOverrideList or FfsInf.TargetOverrideList == []:
                             FileList.append(FfsInf.PatchEfiFile(File.Path, File.Type))
                         else:
diff --git a/BaseTools/Source/Python/GenFds/UiSection.py b/BaseTools/Source/Python/GenFds/UiSection.py
index 084f761e1285..31d3edebb4ef 100644
--- a/BaseTools/Source/Python/GenFds/UiSection.py
+++ b/BaseTools/Source/Python/GenFds/UiSection.py
@@ -58,7 +58,7 @@ class UiSection (UiSectionClassObject):
             self.StringData = FfsInf.__ExtendMacro__(self.StringData)
             self.FileName = FfsInf.__ExtendMacro__(self.FileName)
 
-        OutputFile = os.path.join(OutputPath, ModuleName + SUP_MODULE_SEC + SecNum + Ffs.SectionSuffix.get('UI'))
+        OutputFile = os.path.join(OutputPath, ModuleName + SUP_MODULE_SEC + SecNum + Ffs.SectionSuffix.get(BINARY_FILE_TYPE_UI))
 
         if self.StringData is not None :
             NameString = self.StringData
diff --git a/BaseTools/Source/Python/Trim/Trim.py b/BaseTools/Source/Python/Trim/Trim.py
index 3eb7fa39209d..3afe759667ac 100644
--- a/BaseTools/Source/Python/Trim/Trim.py
+++ b/BaseTools/Source/Python/Trim/Trim.py
@@ -303,7 +303,7 @@ def TrimPreprocessedVfr(Source, Target):
             FoundTypedef = False
             TypedefEnd = Index
             # keep all "typedef struct" except to GUID, EFI_PLABEL and PAL_CALL_RETURN
-            if Line.strip("} ;\r\n") in ["GUID", "EFI_PLABEL", "PAL_CALL_RETURN"]:
+            if Line.strip("} ;\r\n") in [BINARY_FILE_TYPE_GUID, "EFI_PLABEL", "PAL_CALL_RETURN"]:
                 for i in range(TypedefStart, TypedefEnd+1):
                     Lines[i] = "\n"
 
diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py
index 373441521723..6943fab4e5c8 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -1506,7 +1506,7 @@ class DscBuildData(PlatformBuildClassObject):
         def get_length(value):
             Value = value.strip()
             if len(value) > 1:
-                if Value.startswith('GUID') and Value.endswith(')'):
+                if Value.startswith(BINARY_FILE_TYPE_GUID) and Value.endswith(')'):
                     return 16
                 if Value.startswith('L"') and Value.endswith('"'):
                     return len(Value[2:-1])
diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py b/BaseTools/Source/Python/Workspace/InfBuildData.py
index 157f7a2d2de8..cf5e1df3a523 100644
--- a/BaseTools/Source/Python/Workspace/InfBuildData.py
+++ b/BaseTools/Source/Python/Workspace/InfBuildData.py
@@ -71,7 +71,7 @@ class InfBuildData(ModuleBuildClassObject):
     # dict used to convert old tool name used in [nmake] section to new ones
     _TOOL_CODE_ = {
         "C"         :   "CC",
-        "LIB"       :   "SLINK",
+        BINARY_FILE_TYPE_LIB       :   "SLINK",
         "LINK"      :   "DLINK",
     }
 
diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Source/Python/build/BuildReport.py
index c8948b5cfbd9..f551c3ac8f91 100644
--- a/BaseTools/Source/Python/build/BuildReport.py
+++ b/BaseTools/Source/Python/build/BuildReport.py
@@ -208,7 +208,7 @@ def FindIncludeFiles(Source, IncludePathList, IncludeFiles):
             FileName = "Protocol/%(Key)s/%(Key)s.h" % {"Key" : Key}
         elif "PPI" in Type:
             FileName = "Ppi/%(Key)s/%(Key)s.h" % {"Key" : Key}
-        elif "GUID" in Type:
+        elif BINARY_FILE_TYPE_GUID in Type:
             FileName = "Guid/%(Key)s/%(Key)s.h" % {"Key" : Key}
         else:
             continue
@@ -1410,7 +1410,7 @@ class PredictionReport(object):
         if Wa.FdfProfile:
             for Fd in Wa.FdfProfile.FdDict:
                 for FdRegion in Wa.FdfProfile.FdDict[Fd].RegionList:
-                    if FdRegion.RegionType != "FV":
+                    if FdRegion.RegionType != BINARY_FILE_TYPE_FV:
                         continue
                     for FvName in FdRegion.RegionDataList:
                         if FvName in self._FvList:
@@ -1686,7 +1686,7 @@ class FdRegionReport(object):
         # If the input FdRegion is not a firmware volume,
         # we are done.
         #
-        if self.Type != "FV":
+        if self.Type != BINARY_FILE_TYPE_FV:
             return
 
         #
@@ -1780,7 +1780,7 @@ class FdRegionReport(object):
         FileWrite(File, "Type:               %s" % Type)
         FileWrite(File, "Base Address:       0x%X" % BaseAddress)
 
-        if self.Type == "FV":
+        if self.Type == BINARY_FILE_TYPE_FV:
             FvTotalSize = 0
             FvTakenSize = 0
             FvFreeSize  = 0
@@ -1843,7 +1843,7 @@ class FdRegionReport(object):
         if (len(self.FvList) > 0):
             for FvItem in self.FvList:
                 Info = self.FvInfo[FvItem]
-                self._GenerateReport(File, Info[0], "FV", Info[1], Info[2], FvItem)
+                self._GenerateReport(File, Info[0], BINARY_FILE_TYPE_FV, Info[1], Info[2], FvItem)
         else:
             self._GenerateReport(File, "FD Region", self.Type, self.BaseAddress, self.Size)
 
@@ -1869,7 +1869,7 @@ class FdReport(object):
         self.BaseAddress = Fd.BaseAddress
         self.Size = Fd.Size
         self.FdRegionList = [FdRegionReport(FdRegion, Wa) for FdRegion in Fd.RegionList]
-        self.FvPath = os.path.join(Wa.BuildDir, "FV")
+        self.FvPath = os.path.join(Wa.BuildDir, BINARY_FILE_TYPE_FV)
         self.VpdFilePath = os.path.join(self.FvPath, "%s.map" % Wa.Platform.VpdToolGuid)
         self.VPDBaseAddress = 0
         self.VPDSize = 0
-- 
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH v1 20/27] BaseTools: remove duplicate variable
  2018-04-20 15:51 [PATCH v1 00/27] BaseTools refactoring Jaben Carsey
                   ` (18 preceding siblings ...)
  2018-04-20 15:51 ` [PATCH v1 19/27] BaseTools: Replace Binary File " Jaben Carsey
@ 2018-04-20 15:51 ` Jaben Carsey
  2018-04-25  8:51   ` Zhu, Yonghong
  2018-04-20 15:51 ` [PATCH v1 21/27] BaseTools: replace string with predefined constant Jaben Carsey
                   ` (6 subsequent siblings)
  26 siblings, 1 reply; 56+ messages in thread
From: Jaben Carsey @ 2018-04-20 15:51 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Yonghong Zhu

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>
---
 BaseTools/Source/Python/Common/DataType.py | 2 --
 1 file changed, 2 deletions(-)

diff --git a/BaseTools/Source/Python/Common/DataType.py b/BaseTools/Source/Python/Common/DataType.py
index 40a162adf33c..5c8cc82fc915 100644
--- a/BaseTools/Source/Python/Common/DataType.py
+++ b/BaseTools/Source/Python/Common/DataType.py
@@ -128,8 +128,6 @@ PLATFORM_COMPONENT_TYPE_LIBRARY = EDK_COMPONENT_TYPE_LIBRARY
 PLATFORM_COMPONENT_TYPE_LIBRARY_CLASS = 'LIBRARY_CLASS'
 PLATFORM_COMPONENT_TYPE_MODULE = 'MODULE'
 
-TAB_LIBRARIES = 'Libraries'
-
 TAB_SOURCES = 'Sources'
 TAB_SOURCES_COMMON = TAB_SOURCES + TAB_SPLIT + TAB_ARCH_COMMON
 TAB_SOURCES_IA32 = TAB_SOURCES + TAB_SPLIT + TAB_ARCH_IA32
-- 
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH v1 21/27] BaseTools: replace string with predefined constant
  2018-04-20 15:51 [PATCH v1 00/27] BaseTools refactoring Jaben Carsey
                   ` (19 preceding siblings ...)
  2018-04-20 15:51 ` [PATCH v1 20/27] BaseTools: remove duplicate variable Jaben Carsey
@ 2018-04-20 15:51 ` Jaben Carsey
  2018-04-25  6:04   ` Zhu, Yonghong
  2018-04-20 15:51 ` [PATCH v1 22/27] BaseTools: remove redundant if comparison Jaben Carsey
                   ` (5 subsequent siblings)
  26 siblings, 1 reply; 56+ messages in thread
From: Jaben Carsey @ 2018-04-20 15:51 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Yonghong Zhu

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>
---
 BaseTools/Source/Python/Ecc/Check.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Source/Python/Ecc/Check.py b/BaseTools/Source/Python/Ecc/Check.py
index c0e8006dcc51..6490670b0ddb 100644
--- a/BaseTools/Source/Python/Ecc/Check.py
+++ b/BaseTools/Source/Python/Ecc/Check.py
@@ -787,7 +787,7 @@ class Check(object):
                         continue
                     SqlCommand = """select Value3 from Inf where BelongsToFile =
                                     (select ID from File where lower(FullPath) = lower('%s'))
-                                    and Value2 = '%s'""" % (LibraryIns, 'LIBRARY_CLASS')
+                                    and Value2 = '%s'""" % (LibraryIns, PLATFORM_COMPONENT_TYPE_LIBRARY_CLASS)
                     RecordSet = EccGlobalData.gDb.TblInf.Exec(SqlCommand)
                     IsFound = False
                     for Record in RecordSet:
-- 
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH v1 22/27] BaseTools: remove redundant if comparison
  2018-04-20 15:51 [PATCH v1 00/27] BaseTools refactoring Jaben Carsey
                   ` (20 preceding siblings ...)
  2018-04-20 15:51 ` [PATCH v1 21/27] BaseTools: replace string with predefined constant Jaben Carsey
@ 2018-04-20 15:51 ` Jaben Carsey
  2018-05-02  6:49   ` Zhu, Yonghong
  2018-04-20 15:51 ` [PATCH v1 23/27] BaseTools: AutoGen - use dafultdict instead of dict Jaben Carsey
                   ` (4 subsequent siblings)
  26 siblings, 1 reply; 56+ messages in thread
From: Jaben Carsey @ 2018-04-20 15:51 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Yonghong Zhu

inherently python will check string and list for None and having data

if <x> in [None, ''] and similar are superflous.

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>
---
 BaseTools/Source/Python/AutoGen/AutoGen.py             | 26 ++++++++--------
 BaseTools/Source/Python/AutoGen/GenC.py                |  2 +-
 BaseTools/Source/Python/GenFds/FfsInfStatement.py      |  4 +--
 BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py | 32 ++++++++++----------
 BaseTools/Source/Python/Workspace/DscBuildData.py      |  8 ++---
 BaseTools/Source/Python/Workspace/InfBuildData.py      |  2 +-
 6 files changed, 37 insertions(+), 37 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 534fbe79fad9..871afedcde4b 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -420,14 +420,14 @@ class WorkspaceAutoGen(AutoGen):
                         if BuildData.Pcds[key].Pending:
                             if key in Platform.Pcds:
                                 PcdInPlatform = Platform.Pcds[key]
-                                if PcdInPlatform.Type not in [None, '']:
+                                if PcdInPlatform.Type:
                                     BuildData.Pcds[key].Type = PcdInPlatform.Type
 
                             if BuildData.MetaFile in Platform.Modules:
                                 PlatformModule = Platform.Modules[str(BuildData.MetaFile)]
                                 if key in PlatformModule.Pcds:
                                     PcdInPlatform = PlatformModule.Pcds[key]
-                                    if PcdInPlatform.Type not in [None, '']:
+                                    if PcdInPlatform.Type:
                                         BuildData.Pcds[key].Type = PcdInPlatform.Type
 
                         if TAB_PCDS_DYNAMIC_EX in BuildData.Pcds[key].Type:
@@ -1394,7 +1394,7 @@ class PlatformAutoGen(AutoGen):
 
             for PcdFromModule in M.ModulePcdList + M.LibraryPcdList:
                 # make sure that the "VOID*" kind of datum has MaxDatumSize set
-                if PcdFromModule.DatumType == "VOID*" and PcdFromModule.MaxDatumSize in [None, '']:
+                if PcdFromModule.DatumType == "VOID*" and not PcdFromModule.MaxDatumSize:
                     NoDatumTypePcdList.add("%s.%s [%s]" % (PcdFromModule.TokenSpaceGuidCName, PcdFromModule.TokenCName, F))
 
                 # Check the PCD from Binary INF or Source INF
@@ -1471,7 +1471,7 @@ class PlatformAutoGen(AutoGen):
                                         ExtraData="\n\tExisted %s PCD %s in:\n\t\t%s\n"
                                         % (PcdFromModule.Type, PcdFromModule.TokenCName, InfName))
                     # make sure that the "VOID*" kind of datum has MaxDatumSize set
-                    if PcdFromModule.DatumType == "VOID*" and PcdFromModule.MaxDatumSize in [None, '']:
+                    if PcdFromModule.DatumType == "VOID*" and not PcdFromModule.MaxDatumSize:
                         NoDatumTypePcdList.add("%s.%s [%s]" % (PcdFromModule.TokenSpaceGuidCName, PcdFromModule.TokenCName, InfName))
                     if M.ModuleType in SUP_MODULE_SET_PEI:
                         PcdFromModule.Phase = "PEI"
@@ -1999,7 +1999,7 @@ class PlatformAutoGen(AutoGen):
             BuildRuleFile = None
             if TAB_TAT_DEFINES_BUILD_RULE_CONF in self.Workspace.TargetTxt.TargetTxtDictionary:
                 BuildRuleFile = self.Workspace.TargetTxt.TargetTxtDictionary[TAB_TAT_DEFINES_BUILD_RULE_CONF]
-            if BuildRuleFile in [None, '']:
+            if not BuildRuleFile:
                 BuildRuleFile = gDefaultBuildRuleFile
             self._BuildRule = BuildRule(BuildRuleFile)
             if self._BuildRule._FileVersion == "":
@@ -2327,13 +2327,13 @@ class PlatformAutoGen(AutoGen):
                 TokenCName = PcdItem[0]
                 break
         if FromPcd is not None:
-            if ToPcd.Pending and FromPcd.Type not in [None, '']:
+            if ToPcd.Pending and FromPcd.Type:
                 ToPcd.Type = FromPcd.Type
-            elif (ToPcd.Type not in [None, '']) and (FromPcd.Type not in [None, ''])\
+            elif (ToPcd.Type) and (FromPcd.Type)\
                 and (ToPcd.Type != FromPcd.Type) and (ToPcd.Type in FromPcd.Type):
                 if ToPcd.Type.strip() == TAB_PCDS_DYNAMIC_EX:
                     ToPcd.Type = FromPcd.Type
-            elif ToPcd.Type not in [None, ''] and FromPcd.Type not in [None, ''] \
+            elif ToPcd.Type and FromPcd.Type \
                 and ToPcd.Type != FromPcd.Type:
                 EdkLogger.error("build", OPTION_CONFLICT, "Mismatched PCD type",
                                 ExtraData="%s.%s is defined as [%s] in module %s, but as [%s] in platform."\
@@ -2369,11 +2369,11 @@ class PlatformAutoGen(AutoGen):
             ToPcd.validlists = FromPcd.validlists
             ToPcd.expressions = FromPcd.expressions
 
-        if FromPcd is not None and ToPcd.DatumType == "VOID*" and ToPcd.MaxDatumSize in ['', None]:
+        if FromPcd is not None and ToPcd.DatumType == "VOID*" and not ToPcd.MaxDatumSize:
             EdkLogger.debug(EdkLogger.DEBUG_9, "No MaxDatumSize specified for PCD %s.%s" \
                             % (ToPcd.TokenSpaceGuidCName, TokenCName))
             Value = ToPcd.DefaultValue
-            if Value in [None, '']:
+            if not Value:
                 ToPcd.MaxDatumSize = '1'
             elif Value[0] == 'L':
                 ToPcd.MaxDatumSize = str((len(Value) - 2) * 2)
@@ -2384,7 +2384,7 @@ class PlatformAutoGen(AutoGen):
 
         # apply default SKU for dynamic PCDS if specified one is not available
         if (ToPcd.Type in PCD_DYNAMIC_TYPE_SET or ToPcd.Type in PCD_DYNAMIC_EX_TYPE_SET) \
-            and ToPcd.SkuInfoList in [None, {}, '']:
+            and not ToPcd.SkuInfoList:
             if self.Platform.SkuName in self.Platform.SkuIds:
                 SkuName = self.Platform.SkuName
             else:
@@ -2445,10 +2445,10 @@ class PlatformAutoGen(AutoGen):
         # use PCD value to calculate the MaxDatumSize when it is not specified
         for Name, Guid in Pcds:
             Pcd = Pcds[Name, Guid]
-            if Pcd.DatumType == "VOID*" and Pcd.MaxDatumSize in ['', None]:
+            if Pcd.DatumType == "VOID*" and not Pcd.MaxDatumSize:
                 Pcd.MaxSizeUserSet = None
                 Value = Pcd.DefaultValue
-                if Value in [None, '']:
+                if not Value:
                     Pcd.MaxDatumSize = '1'
                 elif Value[0] == 'L':
                     Pcd.MaxDatumSize = str((len(Value) - 2) * 2)
diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py
index ca54ac107e5d..a020d5f5e58a 100644
--- a/BaseTools/Source/Python/AutoGen/GenC.py
+++ b/BaseTools/Source/Python/AutoGen/GenC.py
@@ -867,7 +867,7 @@ def DynExPcdTokenNumberMapping(Info, AutoGenH):
 def GetPcdSize(Pcd):
     if Pcd.DatumType not in _NumericDataTypesList:
         Value = Pcd.DefaultValue
-        if Value in [None, '']:
+        if not Value:
             return 1
         elif Value[0] == 'L':
             return (len(Value) - 2) * 2
diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
index b92fa4d8033c..a26097813bcc 100644
--- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py
+++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
@@ -297,7 +297,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
 
             # Check value, if value are equal, no need to patch
             if Pcd.DatumType == "VOID*":
-                if Pcd.InfDefaultValue == DefaultValue or DefaultValue in [None, '']:
+                if Pcd.InfDefaultValue == DefaultValue or not DefaultValue:
                     continue
                 # Get the string size from FDF or DSC
                 if DefaultValue[0] == 'L':
@@ -310,7 +310,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
                 if DscOverride:
                     Pcd.MaxDatumSize = PatchPcd.MaxDatumSize
                 # If no defined the maximum size in DSC, try to get current size from INF
-                if Pcd.MaxDatumSize in ['', None]:
+                if not Pcd.MaxDatumSize:
                     Pcd.MaxDatumSize = str(len(Pcd.InfDefaultValue.split(',')))
             else:
                 Base1 = Base2 = 10
diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
index 878b13d13c2d..3a745dc4175e 100644
--- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
+++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
@@ -102,7 +102,7 @@ class GenFdsGlobalVariable:
             TargetTxt.LoadTargetTxtFile(BuildConfigurationFile)
             if DataType.TAB_TAT_DEFINES_BUILD_RULE_CONF in TargetTxt.TargetTxtDictionary:
                 BuildRuleFile = TargetTxt.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_BUILD_RULE_CONF]
-            if BuildRuleFile in [None, '']:
+            if not BuildRuleFile:
                 BuildRuleFile = 'Conf/build_rule.txt'
             GenFdsGlobalVariable.__BuildRuleDatabase = BuildRule(BuildRuleFile)
             ToolDefinitionFile = TargetTxt.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TOOL_CHAIN_CONF]
@@ -441,15 +441,15 @@ class GenFdsGlobalVariable:
     def GenerateSection(Output, Input, Type=None, CompressionType=None, Guid=None,
                         GuidHdrLen=None, GuidAttr=[], Ui=None, Ver=None, InputAlign=None, BuildNumber=None, DummyFile=None, IsMakefile=False):
         Cmd = ["GenSec"]
-        if Type not in [None, '']:
+        if Type:
             Cmd += ["-s", Type]
-        if CompressionType not in [None, '']:
+        if CompressionType:
             Cmd += ["-c", CompressionType]
         if Guid is not None:
             Cmd += ["-g", Guid]
         if DummyFile is not None:
             Cmd += ["--dummy", DummyFile]
-        if GuidHdrLen not in [None, '']:
+        if GuidHdrLen:
             Cmd += ["-l", GuidHdrLen]
         if len(GuidAttr) != 0:
             #Add each guided attribute
@@ -461,7 +461,7 @@ class GenFdsGlobalVariable:
                 Cmd += ["--sectionalign", SecAlign]
 
         CommandFile = Output + '.txt'
-        if Ui not in [None, '']:
+        if Ui:
             #Cmd += ["-n", '"' + Ui + '"']
             if IsMakefile:
                 if Ui == "$(MODULE_NAME)":
@@ -480,7 +480,7 @@ class GenFdsGlobalVariable:
                 GenFdsGlobalVariable.SectionHeader.pack_into(SectionData, 0, Len & 0xff, (Len >> 8) & 0xff, (Len >> 16) & 0xff, 0x15)
                 SaveFileOnChange(Output, SectionData.tostring())
 
-        elif Ver not in [None, '']:
+        elif Ver:
             Cmd += ["-n", Ver]
             if BuildNumber:
                 Cmd += ["-j", BuildNumber]
@@ -529,7 +529,7 @@ class GenFdsGlobalVariable:
             Cmd += ["-x"]
         if CheckSum:
             Cmd += ["-s"]
-        if Align not in [None, '']:
+        if Align:
             if Align not in mFfsValidAlign:
                 Align = GenFdsGlobalVariable.GetAlignment (Align)
                 for index in range(0, len(mFfsValidAlign) - 1):
@@ -541,7 +541,7 @@ class GenFdsGlobalVariable:
         Cmd += ["-o", Output]
         for I in range(0, len(Input)):
             Cmd += ("-i", Input[I])
-            if SectionAlign not in [None, '', []] and SectionAlign[I] not in [None, '']:
+            if SectionAlign and SectionAlign[I]:
                 Cmd += ("-n", SectionAlign[I])
 
         CommandFile = Output + '.txt'
@@ -566,7 +566,7 @@ class GenFdsGlobalVariable:
         GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input))
 
         Cmd = ["GenFv"]
-        if BaseAddress not in [None, '']:
+        if BaseAddress:
             Cmd += ["-r", BaseAddress]
 
         if ForceRebase == False:
@@ -578,9 +578,9 @@ class GenFdsGlobalVariable:
             Cmd += ["-c"]
         if Dump:
             Cmd += ["-p"]
-        if AddressFile not in [None, '']:
+        if AddressFile:
             Cmd += ["-a", AddressFile]
-        if MapFile not in [None, '']:
+        if MapFile:
             Cmd += ["-m", MapFile]
         if FileSystemGuid:
             Cmd += ["-g", FileSystemGuid]
@@ -597,7 +597,7 @@ class GenFdsGlobalVariable:
         GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input))
 
         Cmd = ["GenVtf"]
-        if BaseAddress not in [None, ''] and FvSize not in [None, ''] \
+        if BaseAddress and FvSize \
             and len(BaseAddress) == len(FvSize):
             for I in range(0, len(BaseAddress)):
                 Cmd += ["-r", BaseAddress[I], "-s", FvSize[I]]
@@ -618,13 +618,13 @@ class GenFdsGlobalVariable:
         Cmd = ["GenFw"]
         if Type.lower() == "te":
             Cmd += ["-t"]
-        if SubType not in [None, '']:
+        if SubType:
             Cmd += ["-e", SubType]
-        if TimeStamp not in [None, '']:
+        if TimeStamp:
             Cmd += ["-s", TimeStamp]
-        if Align not in [None, '']:
+        if Align:
             Cmd += ["-a", Align]
-        if Padding not in [None, '']:
+        if Padding:
             Cmd += ["-p", Padding]
         if Zero:
             Cmd += ["-z"]
diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py
index 6943fab4e5c8..91a9928c00d2 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -641,10 +641,10 @@ class DscBuildData(PlatformBuildClassObject):
             self._SkuIds = OrderedDict()
             RecordList = self._RawData[MODEL_EFI_SKU_ID, self._Arch]
             for Record in RecordList:
-                if Record[0] in [None, '']:
+                if not Record[0]:
                     EdkLogger.error('build', FORMAT_INVALID, 'No Sku ID number',
                                     File=self.MetaFile, Line=Record[-1])
-                if Record[1] in [None, '']:
+                if not Record[1]:
                     EdkLogger.error('build', FORMAT_INVALID, 'No Sku ID name',
                                     File=self.MetaFile, Line=Record[-1])
                 if not Pattern.match(Record[0]) and not HexPattern.match(Record[0]):
@@ -669,10 +669,10 @@ class DscBuildData(PlatformBuildClassObject):
             self.DefaultStores = OrderedDict()
             RecordList = self._RawData[MODEL_EFI_DEFAULT_STORES, self._Arch]
             for Record in RecordList:
-                if Record[0] in [None, '']:
+                if not Record[0]:
                     EdkLogger.error('build', FORMAT_INVALID, 'No DefaultStores ID number',
                                     File=self.MetaFile, Line=Record[-1])
-                if Record[1] in [None, '']:
+                if not Record[1]:
                     EdkLogger.error('build', FORMAT_INVALID, 'No DefaultStores ID name',
                                     File=self.MetaFile, Line=Record[-1])
                 if not Pattern.match(Record[0]) and not HexPattern.match(Record[0]):
diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py b/BaseTools/Source/Python/Workspace/InfBuildData.py
index cf5e1df3a523..602746de32f7 100644
--- a/BaseTools/Source/Python/Workspace/InfBuildData.py
+++ b/BaseTools/Source/Python/Workspace/InfBuildData.py
@@ -1116,7 +1116,7 @@ class InfBuildData(ModuleBuildClassObject):
                     Pcd.DatumType = PcdInPackage.DatumType
                     Pcd.MaxDatumSize = PcdInPackage.MaxDatumSize
                     Pcd.InfDefaultValue = Pcd.DefaultValue
-                    if Pcd.DefaultValue in [None, '']:
+                    if not Pcd.DefaultValue:
                         Pcd.DefaultValue = PcdInPackage.DefaultValue
                     else:
                         try:
-- 
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH v1 23/27] BaseTools: AutoGen - use dafultdict instead of dict
  2018-04-20 15:51 [PATCH v1 00/27] BaseTools refactoring Jaben Carsey
                   ` (21 preceding siblings ...)
  2018-04-20 15:51 ` [PATCH v1 22/27] BaseTools: remove redundant if comparison Jaben Carsey
@ 2018-04-20 15:51 ` Jaben Carsey
  2018-04-20 15:51 ` [PATCH v1 24/27] BaseTools: GenFds - simplify testing for Hex number Jaben Carsey
                   ` (3 subsequent siblings)
  26 siblings, 0 replies; 56+ messages in thread
From: Jaben Carsey @ 2018-04-20 15:51 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Yonghong Zhu

since we manually make each entry a set(), just use defaultdict(set)

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>
---
 BaseTools/Source/Python/AutoGen/AutoGen.py | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 871afedcde4b..fbc3f1516c86 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -355,10 +355,9 @@ class WorkspaceAutoGen(AutoGen):
             # but the path (self.MetaFile.Path) is the real path
             for key in self.FdfProfile.InfDict:
                 if key == 'ArchTBD':
-                    MetaFile_cache = {}
+                    MetaFile_cache = defaultdict(set)
                     for Arch in self.ArchList:
                         Current_Platform_cache = self.BuildDatabase[self.MetaFile, Arch, Target, Toolchain]
-                        MetaFile_cache[Arch] = set()
                         for Pkey in Current_Platform_cache.Modules:
                             MetaFile_cache[Arch].add(Current_Platform_cache.Modules[Pkey].MetaFile)
                     for Inf in self.FdfProfile.InfDict[key]:
-- 
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH v1 24/27] BaseTools: GenFds - simplify testing for Hex number
  2018-04-20 15:51 [PATCH v1 00/27] BaseTools refactoring Jaben Carsey
                   ` (22 preceding siblings ...)
  2018-04-20 15:51 ` [PATCH v1 23/27] BaseTools: AutoGen - use dafultdict instead of dict Jaben Carsey
@ 2018-04-20 15:51 ` Jaben Carsey
  2018-04-25  8:51   ` Zhu, Yonghong
  2018-04-20 15:51 ` [PATCH v1 25/27] BaseTools: AutoGen - use defaultdict to auto initialize Jaben Carsey
                   ` (2 subsequent siblings)
  26 siblings, 1 reply; 56+ messages in thread
From: Jaben Carsey @ 2018-04-20 15:51 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Yonghong Zhu

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>
---
 BaseTools/Source/Python/Common/GlobalData.py | 1 +
 BaseTools/Source/Python/GenFds/FdfParser.py  | 9 +--------
 2 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/BaseTools/Source/Python/Common/GlobalData.py b/BaseTools/Source/Python/Common/GlobalData.py
index f58dc5a8dda2..e3131b86cc60 100644
--- a/BaseTools/Source/Python/Common/GlobalData.py
+++ b/BaseTools/Source/Python/Common/GlobalData.py
@@ -62,6 +62,7 @@ gGuidPatternEnd = re.compile(r'{}$'.format(_GuidPattern))
 ## Regular expressions for HEX matching
 g4HexChar = re.compile(r'{}{{4}}'.format(_HexChar))
 gHexPattern = re.compile(r'0[xX]{}+'.format(_HexChar))
+gHexPatternAll = re.compile(r'0[xX]{}+$'.format(_HexChar))
 
 ## Regular expressions for string identifier checking
 gIdentifierPattern = re.compile('^[a-zA-Z][a-zA-Z0-9_]*$', re.UNICODE)
diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py
index b8848a25b4b2..fe4f2df0e1e1 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -1183,13 +1183,6 @@ class FdfParser:
 
         self.__GetOneChar()
 
-    def __IsHex(self, HexStr):
-        if not HexStr.upper().startswith("0X"):
-            return False
-        if len(self.__Token) <= 2:
-            return False
-        return True if all(x in string.hexdigits for x in HexStr[2:]) else False
-
     ## __GetNextHexNumber() method
     #
     #   Get next HEX data before a seperator
@@ -1202,7 +1195,7 @@ class FdfParser:
     def __GetNextHexNumber(self):
         if not self.__GetNextToken():
             return False
-        if self.__IsHex(self.__Token):
+        if gHexPatternAll.match(self.__Token):
             return True
         else:
             self.__UndoToken()
-- 
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH v1 25/27] BaseTools: AutoGen - use defaultdict to auto initialize
  2018-04-20 15:51 [PATCH v1 00/27] BaseTools refactoring Jaben Carsey
                   ` (23 preceding siblings ...)
  2018-04-20 15:51 ` [PATCH v1 24/27] BaseTools: GenFds - simplify testing for Hex number Jaben Carsey
@ 2018-04-20 15:51 ` Jaben Carsey
  2018-04-25  8:52   ` Zhu, Yonghong
  2018-04-20 15:51 ` [PATCH v1 26/27] BaseTools: remove unused MigrationUtilities.py Jaben Carsey
  2018-04-20 15:51 ` [PATCH v1 27/27] BaseTools: CommonClass - remove unused classes Jaben Carsey
  26 siblings, 1 reply; 56+ messages in thread
From: Jaben Carsey @ 2018-04-20 15:51 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Yonghong Zhu

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>
---
 BaseTools/Source/Python/AutoGen/GenVar.py | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/GenVar.py b/BaseTools/Source/Python/AutoGen/GenVar.py
index 37c168a84b43..99c6ed640c00 100644
--- a/BaseTools/Source/Python/AutoGen/GenVar.py
+++ b/BaseTools/Source/Python/AutoGen/GenVar.py
@@ -128,7 +128,7 @@ class VariableMgr(object):
         return var_value
     def process_variable_data(self):
 
-        var_data = dict()
+        var_data = collections.defaultdict(collections.OrderedDict)
 
         indexedvarinfo = collections.OrderedDict()
         for item in self.VarInfo:
@@ -155,8 +155,6 @@ class VariableMgr(object):
             for item in default_data_buffer:
                 default_data_array += unpack("B",item)
 
-            if (DataType.TAB_DEFAULT,DataType.TAB_DEFAULT_STORES_DEFAULT) not in var_data:
-                var_data[(DataType.TAB_DEFAULT,DataType.TAB_DEFAULT_STORES_DEFAULT)] = collections.OrderedDict()
             var_data[(DataType.TAB_DEFAULT,DataType.TAB_DEFAULT_STORES_DEFAULT)][index] = (default_data_buffer,sku_var_info[(DataType.TAB_DEFAULT,DataType.TAB_DEFAULT_STORES_DEFAULT)])
 
             for (skuid,defaultstoragename) in indexedvarinfo.get(index):
@@ -177,8 +175,6 @@ class VariableMgr(object):
 
                 data_delta = self.calculate_delta(default_data_array, others_data_array)
 
-                if (skuid,defaultstoragename) not in var_data:
-                    var_data[(skuid,defaultstoragename)] = collections.OrderedDict()
                 var_data[(skuid,defaultstoragename)][index] = (data_delta,sku_var_info[(skuid,defaultstoragename)])
         return var_data
 
-- 
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH v1 26/27] BaseTools: remove unused MigrationUtilities.py
  2018-04-20 15:51 [PATCH v1 00/27] BaseTools refactoring Jaben Carsey
                   ` (24 preceding siblings ...)
  2018-04-20 15:51 ` [PATCH v1 25/27] BaseTools: AutoGen - use defaultdict to auto initialize Jaben Carsey
@ 2018-04-20 15:51 ` Jaben Carsey
  2018-05-02  6:49   ` Zhu, Yonghong
  2018-04-20 15:51 ` [PATCH v1 27/27] BaseTools: CommonClass - remove unused classes Jaben Carsey
  26 siblings, 1 reply; 56+ messages in thread
From: Jaben Carsey @ 2018-04-20 15:51 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Yonghong Zhu

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>
---
 BaseTools/Source/Python/Common/MigrationUtilities.py | 568 --------------------
 BaseTools/Source/Python/Makefile                     |   1 -
 2 files changed, 569 deletions(-)

diff --git a/BaseTools/Source/Python/Common/MigrationUtilities.py b/BaseTools/Source/Python/Common/MigrationUtilities.py
deleted file mode 100644
index 0c93c72a60f6..000000000000
--- a/BaseTools/Source/Python/Common/MigrationUtilities.py
+++ /dev/null
@@ -1,568 +0,0 @@
-## @file
-# Contains several utilitities shared by migration tools.
-#
-# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution.  The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-
-##
-# Import Modules
-#
-import Common.LongFilePathOs as os
-import re
-import EdkLogger
-from optparse import OptionParser
-from Common.BuildToolError import *
-from XmlRoutines import *
-from CommonDataClass.CommonClass import *
-from Common.LongFilePathSupport import OpenLongFilePath as open
-
-## Set all fields of CommonClass object.
-#
-# Set all attributes of CommonClass object from XML Dom object of XmlCommon.
-#
-# @param  Common     The destine CommonClass object.
-# @param  XmlCommon  The source XML Dom object.
-#
-def SetCommon(Common, XmlCommon):
-    XmlTag = "Usage"
-    Common.Usage = XmlAttribute(XmlCommon, XmlTag).split()
-
-    XmlTag = TAB_PCDS_FEATURE_FLAG
-    Common.FeatureFlag = XmlAttribute(XmlCommon, XmlTag)
-    
-    XmlTag = "SupArchList"
-    Common.SupArchList = XmlAttribute(XmlCommon, XmlTag).split()
-    
-    XmlTag = XmlNodeName(XmlCommon) + "/" + "HelpText"
-    Common.HelpText = XmlElement(XmlCommon, XmlTag)
-
-
-## Set some fields of CommonHeaderClass object.
-#
-# Set Name, Guid, FileName and FullPath fields of CommonHeaderClass object from
-# XML Dom object of XmlCommonHeader, NameTag and FileName.
-#
-# @param  CommonHeader       The destine CommonClass object.
-# @param  XmlCommonHeader    The source XML Dom object.
-# @param  NameTag            The name tag in XML Dom object.
-# @param  FileName           The file name of the XML file.
-#
-def SetIdentification(CommonHeader, XmlCommonHeader, NameTag, FileName):
-    XmlParentTag = XmlNodeName(XmlCommonHeader)
-    
-    XmlTag = XmlParentTag + "/" + NameTag
-    CommonHeader.Name = XmlElement(XmlCommonHeader, XmlTag)
-
-    XmlTag = XmlParentTag + "/" + "GuidValue"
-    CommonHeader.Guid = XmlElement(XmlCommonHeader, XmlTag)
-
-    XmlTag = XmlParentTag + "/" + "Version"
-    CommonHeader.Version = XmlElement(XmlCommonHeader, XmlTag)
-
-    CommonHeader.FileName = os.path.basename(FileName)
-    CommonHeader.FullPath = os.path.abspath(FileName)
-
-
-## Regular expression to match specification and value.
-mReSpecification = re.compile(r"(?P<Specification>\w+)\s+(?P<Value>\w*)")
-
-## Add specification to specification dictionary.
-#
-# Abstract specification name, value pair from Specification String and add them
-# to specification dictionary.
-#
-# @param  SpecificationDict   The destine Specification dictionary.
-# @param  SpecificationString The source Specification String from which the
-#                             specification name and value pair is abstracted.
-#
-def AddToSpecificationDict(SpecificationDict, SpecificationString):
-    """Abstract specification name, value pair from Specification String"""
-    for SpecificationMatch in mReSpecification.finditer(SpecificationString):
-        Specification = SpecificationMatch.group("Specification")
-        Value = SpecificationMatch.group("Value")
-        SpecificationDict[Specification] = Value
-
-## Set all fields of CommonHeaderClass object.
-#
-# Set all attributes of CommonHeaderClass object from XML Dom object of
-# XmlCommonHeader, NameTag and FileName.
-#
-# @param  CommonHeader       The destine CommonClass object.
-# @param  XmlCommonHeader    The source XML Dom object.
-# @param  NameTag            The name tag in XML Dom object.
-# @param  FileName           The file name of the XML file.
-#
-def SetCommonHeader(CommonHeader, XmlCommonHeader):
-    """Set all attributes of CommonHeaderClass object from XmlCommonHeader"""
-    XmlParent = XmlNodeName(XmlCommonHeader)
-    
-    XmlTag = XmlParent + "/" + "Abstract"
-    CommonHeader.Abstract = XmlElement(XmlCommonHeader, XmlTag)
-
-    XmlTag = XmlParent + "/" + "Description"
-    CommonHeader.Description = XmlElement(XmlCommonHeader, XmlTag)
-
-    XmlTag = XmlParent + "/" + "Copyright"
-    CommonHeader.Copyright = XmlElement(XmlCommonHeader, XmlTag)
-
-    XmlTag = XmlParent + "/" + "License"
-    CommonHeader.License = XmlElement(XmlCommonHeader, XmlTag)
-
-    XmlTag = XmlParent + "/" + "Specification"
-    Specification = XmlElement(XmlCommonHeader, XmlTag)
-
-    AddToSpecificationDict(CommonHeader.Specification, Specification)
-
-    XmlTag = XmlParent + "/" + "ModuleType"
-    CommonHeader.ModuleType = XmlElement(XmlCommonHeader, XmlTag)
-
-
-## Load a new Cloned Record class object.
-#
-# Read an input XML ClonedRecord DOM object and return an object of Cloned Record
-# contained in the DOM object.
-#
-# @param  XmlCloned            A child XML DOM object in a Common XML DOM.
-#
-# @retvel ClonedRecord         A new Cloned Record object created by XmlCloned.
-#
-def LoadClonedRecord(XmlCloned):
-    ClonedRecord = ClonedRecordClass()
-
-    XmlTag = "Id"
-    ClonedRecord.Id = int(XmlAttribute(XmlCloned, XmlTag))
-
-    XmlTag = "FarGuid"
-    ClonedRecord.FarGuid = XmlAttribute(XmlCloned, XmlTag)
-
-    XmlTag = "Cloned/PackageGuid"
-    ClonedRecord.PackageGuid = XmlElement(XmlCloned, XmlTag)
-    
-    XmlTag = "Cloned/PackageVersion"
-    ClonedRecord.PackageVersion = XmlElement(XmlCloned, XmlTag)
-    
-    XmlTag = "Cloned/ModuleGuid"
-    ClonedRecord.ModuleGuid = XmlElement(XmlCloned, XmlTag)
-    
-    XmlTag = "Cloned/ModuleVersion"
-    ClonedRecord.ModuleVersion = XmlElement(XmlCloned, XmlTag)
-    
-    return ClonedRecord
-
-
-## Load a new Guid/Protocol/Ppi common class object.
-#
-# Read an input XML Guid/Protocol/Ppi DOM object and return an object of
-# Guid/Protocol/Ppi contained in the DOM object.
-#
-# @param  XmlGuidProtocolPpiCommon A child XML DOM object in a Common XML DOM.
-#
-# @retvel GuidProtocolPpiCommon    A new GuidProtocolPpiCommon class object
-#                                  created by XmlGuidProtocolPpiCommon.
-#
-def LoadGuidProtocolPpiCommon(XmlGuidProtocolPpiCommon):
-    GuidProtocolPpiCommon = GuidProtocolPpiCommonClass()
-    
-    XmlTag = "Name"
-    GuidProtocolPpiCommon.Name = XmlAttribute(XmlGuidProtocolPpiCommon, XmlTag)
-
-    XmlParent = XmlNodeName(XmlGuidProtocolPpiCommon)
-    if XmlParent == "Entry":
-        XmlTag = "%s/C_Name" % XmlParent
-    elif XmlParent == "GuidCNames":
-        XmlTag = "%s/GuidCName" % XmlParent
-    else:
-        XmlTag = "%s/%sCName" % (XmlParent, XmlParent)
-        
-    GuidProtocolPpiCommon.CName = XmlElement(XmlGuidProtocolPpiCommon, XmlTag)
-    
-    XmlTag = XmlParent + "/" + "GuidValue"
-    GuidProtocolPpiCommon.Guid = XmlElement(XmlGuidProtocolPpiCommon, XmlTag)
-    
-    if XmlParent.endswith("Notify"):
-        GuidProtocolPpiCommon.Notify = True
-
-    XmlTag = "GuidTypeList"
-    GuidTypes = XmlAttribute(XmlGuidProtocolPpiCommon, XmlTag)
-    GuidProtocolPpiCommon.GuidTypeList = GuidTypes.split()
-    
-    XmlTag = "SupModuleList"
-    SupModules = XmlAttribute(XmlGuidProtocolPpiCommon, XmlTag)
-    GuidProtocolPpiCommon.SupModuleList = SupModules.split()
-
-    SetCommon(GuidProtocolPpiCommon, XmlGuidProtocolPpiCommon)
-
-    return GuidProtocolPpiCommon
-
-
-## Load a new Pcd class object.
-#
-# Read an input XML Pcd DOM object and return an object of Pcd
-# contained in the DOM object.
-#
-# @param  XmlPcd               A child XML DOM object in a Common XML DOM.
-#
-# @retvel Pcd                  A new Pcd object created by XmlPcd.
-#
-def LoadPcd(XmlPcd):
-    """Return a new PcdClass object equivalent to XmlPcd"""
-    Pcd = PcdClass()
-
-    XmlTag = "PcdEntry/C_Name"
-    Pcd.CName = XmlElement(XmlPcd, XmlTag)
-
-    XmlTag = "PcdEntry/Token"
-    Pcd.Token = XmlElement(XmlPcd, XmlTag)
-
-    XmlTag = "PcdEntry/TokenSpaceGuidCName"
-    Pcd.TokenSpaceGuidCName = XmlElement(XmlPcd, XmlTag)
-
-    XmlTag = "PcdEntry/DatumType"
-    Pcd.DatumType = XmlElement(XmlPcd, XmlTag)
-
-    XmlTag = "PcdEntry/MaxDatumSize"
-    Pcd.MaxDatumSize = XmlElement(XmlPcd, XmlTag)
-
-    XmlTag = "PcdEntry/DefaultValue"
-    Pcd.DefaultValue = XmlElement(XmlPcd, XmlTag)
-
-    XmlTag = "PcdItemType"
-    Pcd.ItemType = XmlAttribute(XmlPcd, XmlTag)
-
-    XmlTag = "PcdEntry/ValidUsage"
-    Pcd.ValidUsage = XmlElement(XmlPcd, XmlTag).split()
-
-    XmlTag = "SupModuleList"
-    Pcd.SupModuleList = XmlAttribute(XmlPcd, XmlTag).split()
-
-    SetCommon(Pcd, XmlPcd)
-
-    return Pcd
-
-
-## Load a new LibraryClass class object.
-#
-# Read an input XML LibraryClass DOM object and return an object of LibraryClass
-# contained in the DOM object.
-#
-# @param  XmlLibraryClass    A child XML DOM object in a Common XML DOM.
-#
-# @retvel LibraryClass       A new LibraryClass object created by XmlLibraryClass.
-#
-def LoadLibraryClass(XmlLibraryClass):
-    LibraryClass = LibraryClassClass()
-
-    XmlTag = "LibraryClass/Keyword"
-    LibraryClass.LibraryClass = XmlElement(XmlLibraryClass, XmlTag)
-    if LibraryClass.LibraryClass == "":
-        XmlTag = "Name"
-        LibraryClass.LibraryClass = XmlAttribute(XmlLibraryClass, XmlTag)
-    
-    XmlTag = "LibraryClass/IncludeHeader"
-    LibraryClass.IncludeHeader = XmlElement(XmlLibraryClass, XmlTag)
-    
-    XmlTag = "RecommendedInstanceVersion"
-    RecommendedInstanceVersion = XmlAttribute(XmlLibraryClass, XmlTag)
-    LibraryClass.RecommendedInstanceVersion = RecommendedInstanceVersion
-    
-    XmlTag = "RecommendedInstanceGuid"
-    RecommendedInstanceGuid = XmlAttribute(XmlLibraryClass, XmlTag)
-    LibraryClass.RecommendedInstanceGuid = RecommendedInstanceGuid
-    
-    XmlTag = "SupModuleList"
-    SupModules = XmlAttribute(XmlLibraryClass, XmlTag)
-    LibraryClass.SupModuleList = SupModules.split()
-    
-    SetCommon(LibraryClass, XmlLibraryClass)
-    
-    return LibraryClass
-
-
-## Load a new Build Option class object.
-#
-# Read an input XML BuildOption DOM object and return an object of Build Option
-# contained in the DOM object.
-#
-# @param  XmlBuildOption       A child XML DOM object in a Common XML DOM.
-#
-# @retvel BuildOption          A new Build Option object created by XmlBuildOption.
-#
-def LoadBuildOption(XmlBuildOption):
-    """Return a new BuildOptionClass object equivalent to XmlBuildOption"""
-    BuildOption = BuildOptionClass()
-    
-    BuildOption.Option = XmlElementData(XmlBuildOption)
-
-    XmlTag = "BuildTargets"
-    BuildOption.BuildTargetList = XmlAttribute(XmlBuildOption, XmlTag).split()
-    
-    XmlTag = "ToolChainFamily"
-    BuildOption.ToolChainFamily = XmlAttribute(XmlBuildOption, XmlTag)
-    
-    XmlTag = "TagName"
-    BuildOption.TagName = XmlAttribute(XmlBuildOption, XmlTag)
-    
-    XmlTag = "ToolCode"
-    BuildOption.ToolCode = XmlAttribute(XmlBuildOption, XmlTag)
-    
-    XmlTag = "SupArchList"
-    BuildOption.SupArchList = XmlAttribute(XmlBuildOption, XmlTag).split()
-    
-    return BuildOption
-
-
-## Load a new User Extensions class object.
-#
-# Read an input XML UserExtensions DOM object and return an object of User
-# Extensions contained in the DOM object.
-#
-# @param  XmlUserExtensions    A child XML DOM object in a Common XML DOM.
-#
-# @retvel UserExtensions       A new User Extensions object created by
-#                              XmlUserExtensions.
-#
-def LoadUserExtensions(XmlUserExtensions):
-    UserExtensions = UserExtensionsClass()
-    
-    XmlTag = "UserID"
-    UserExtensions.UserID = XmlAttribute(XmlUserExtensions, XmlTag)
-    
-    XmlTag = "Identifier"
-    UserExtensions.Identifier = XmlAttribute(XmlUserExtensions, XmlTag)
-    
-    UserExtensions.Content = XmlElementData(XmlUserExtensions)
-    
-    return UserExtensions
-
-
-## Store content to a text file object.
-#
-# Write some text file content to a text file object. The contents may echo
-# in screen in a verbose way.
-#
-# @param  TextFile           The text file object.
-# @param  Content            The string object to be written to a text file.
-#
-def StoreTextFile(TextFile, Content):
-    EdkLogger.verbose(Content)
-    TextFile.write(Content)
-
-
-## Add item to a section.
-#
-# Add an Item with specific CPU architecture to section dictionary.
-# The possible duplication is ensured to be removed.
-#
-# @param  Section            Section dictionary indexed by CPU architecture.
-# @param  Arch               CPU architecture: Ia32, X64, Ipf, ARM, AARCH64, Ebc or Common.
-# @param  Item               The Item to be added to section dictionary.
-#
-def AddToSection(Section, Arch, Item):
-    SectionArch = Section.get(Arch, [])
-    if Item not in SectionArch:
-        SectionArch.append(Item)
-        Section[Arch] = SectionArch
-
-
-## Get section contents.
-#
-# Return the content of section named SectionName.
-# the contents is based on Methods and ObjectLists.
-#
-# @param  SectionName        The name of the section.
-# @param  Method             A function returning a string item of an object.
-# @param  ObjectList         The list of object.
-#
-# @retval Section            The string content of a section.
-#
-def GetSection(SectionName, Method, ObjectList):
-    SupportedArches = ["common", "Ia32", "X64", "Ipf", "Ebc", "ARM", "AARCH64"]
-    SectionDict = {}
-    for Object in ObjectList:
-        Item = Method(Object)
-        if Item == "":
-            continue
-        Item = "  %s" % Item
-        Arches = Object.SupArchList
-        if len(Arches) == 0:
-            AddToSection(SectionDict, "common", Item)
-        else:
-            for Arch in SupportedArches:
-                if Arch.upper() in Arches:
-                    AddToSection(SectionDict, Arch, Item)
-
-    Section = ""
-    for Arch in SupportedArches:
-        SectionArch = "\n".join(SectionDict.get(Arch, []))
-        if SectionArch != "":
-            Section += "[%s.%s]\n%s\n" % (SectionName, Arch, SectionArch)
-            Section += "\n"
-    if Section != "":
-        Section += "\n"
-    return Section
-
-
-## Store file header to a text file.
-#
-# Write standard file header to a text file. The content includes copyright,
-# abstract, description and license extracted from CommonHeader class object.
-#
-# @param  TextFile           The text file object.
-# @param  CommonHeader       The source CommonHeader class object.
-#
-def StoreHeader(TextFile, CommonHeader):
-    CopyRight = CommonHeader.Copyright
-    Abstract = CommonHeader.Abstract
-    Description = CommonHeader.Description
-    License = CommonHeader.License
-
-    Header = "#/** @file\n#\n"
-    Header += "# " + Abstract + "\n#\n"
-    Header += "# " + Description.strip().replace("\n", "\n# ") + "\n"
-    Header += "# " + CopyRight + "\n#\n"
-    Header += "#  " + License.replace("\n", "\n# ").replace("  ", " ")
-    Header += "\n#\n#**/\n\n"
-
-    StoreTextFile(TextFile, Header)
-
-## Store file header to a text file.
-#
-# Write Defines section to a text file. DefinesTupleList determines the content.
-#
-# @param  TextFile           The text file object.
-# @param  DefinesTupleList   The list of (Tag, Value) to be added as one item.
-#
-def StoreDefinesSection(TextFile, DefinesTupleList):
-    Section = "[Defines]\n"
-    for DefineItem in DefinesTupleList:
-        Section += "  %-30s = %s\n" % DefineItem
-
-    Section += "\n\n"
-    StoreTextFile(TextFile, Section)
-
-
-## Return one User Extension section.
-#
-# Read the input UserExtentsions class object and return one section.
-#
-# @param  UserExtensions       An input UserExtensions class object.
-#
-# @retval UserExtensionSection A section representing UserExtensions object.
-#
-def GetUserExtensions(UserExtensions):
-    UserId = UserExtensions.UserID
-    Identifier = UserExtensions.Identifier
-    Content = UserExtensions.Content
-
-    return "[UserExtensions.%s.%s]\n  %s\n\n" % (UserId, Identifier, Content)
-
-## Regular expression to match an equation.
-mReEquation = re.compile(r"\s*(\S+)\s*=\s*(\S*)\s*")
-
-## Return a value tuple matching information in a text fle.
-#
-# Parse the text file and return a value tuple corresponding to an input tag
-# tuple. In case of any error, an tuple of empty strings is returned.
-#
-# @param  FileName           The file name of the text file.
-# @param  TagTuple           A tuple of tags as the key to the value.
-#
-# @param  ValueTupe          The returned tuple corresponding to the tag tuple.
-#
-def GetTextFileInfo(FileName, TagTuple):
-    ValueTuple = [""] * len(TagTuple)
-    try:
-        for Line in open(FileName):
-            Line = Line.split("#", 1)[0]
-            MatchEquation = mReEquation.match(Line)
-            if MatchEquation:
-                Tag = MatchEquation.group(1).upper()
-                Value = MatchEquation.group(2)
-                for Index in range(len(TagTuple)):
-                    if TagTuple[Index] == Tag:
-                        ValueTuple[Index] = Value
-    except:
-        EdkLogger.info("IO Error in reading file %s" % FileName)
-        
-    return ValueTuple
-
-
-## Return a value tuple matching information in an XML fle.
-#
-# Parse the XML file and return a value tuple corresponding to an input tag
-# tuple. In case of any error, an tuple of empty strings is returned.
-#
-# @param  FileName           The file name of the XML file.
-# @param  TagTuple           A tuple of tags as the key to the value.
-#
-# @param  ValueTupe          The returned tuple corresponding to the tag tuple.
-#
-def GetXmlFileInfo(FileName, TagTuple):
-    XmlDom = XmlParseFile(FileName)
-    return tuple([XmlElement(XmlDom, XmlTag) for XmlTag in TagTuple])
-
-
-## Parse migration command line options
-#
-# Use standard Python module optparse to parse command line option of this tool.
-#
-# @param  Source             The source file type.
-# @param  Destinate          The destinate file type.
-#
-# @retval Options            A optparse object containing the parsed options.
-# @retval InputFile          Path of an source file to be migrated.
-#
-def MigrationOptionParser(Source, Destinate, ToolName, VersionNumber=1.0):
-    # use clearer usage to override default usage message
-    UsageString = "%s [-a] [-v|-q] [-o <output_file>] <input_file>" % ToolName
-    Version = "%s Version %.2f" % (ToolName, VersionNumber)
-    Copyright = "Copyright (c) 2007, Intel Corporation. All rights reserved."
-    
-    Parser = OptionParser(description=Copyright, version=Version, usage=UsageString)
-    Parser.add_option("-o", "--output", dest="OutputFile", help="The name of the %s file to be created." % Destinate)
-    Parser.add_option("-a", "--auto", dest="AutoWrite", action="store_true", default=False, help="Automatically create the %s file using the name of the %s file and replacing file extension" % (Source, Destinate))
-    Parser.add_option("-q", "--quiet", action="store_true", type=None, help="Disable all messages except FATAL ERRORS.")
-    Parser.add_option("-v", "--verbose", action="store_true", type=None, help="Turn on verbose output with informational messages printed.")
-
-    Options, Args = Parser.parse_args()
-
-    # Set logging level
-    if Options.verbose:
-        EdkLogger.setLevel(EdkLogger.VERBOSE)
-    elif Options.quiet:
-        EdkLogger.setLevel(EdkLogger.QUIET)
-    else:
-        EdkLogger.setLevel(EdkLogger.INFO)
-        
-    # error check
-    if len(Args) == 0:
-        raise MigrationError(PARAMETER_MISSING, name="Input file", usage=Parser.get_usage())
-    if len(Args) > 1:
-        raise MigrationError(PARAMETER_INVALID, name="Too many input files", usage=Parser.get_usage())
-
-    InputFile = Args[0]
-    if not os.path.exists(InputFile):
-        raise MigrationError(FILE_NOT_FOUND, name=InputFile)
-
-    if Options.OutputFile:
-        if Options.AutoWrite:
-            raise MigrationError(OPTION_CONFLICT, arg1="-o", arg2="-a", usage=Parser.get_usage())
-    else:
-        if Options.AutoWrite:
-            Options.OutputFile = os.path.splitext(InputFile)[0] + "." + Destinate.lower()
-        else:
-            raise MigrationError(OPTION_MISSING, name="-o", usage=Parser.get_usage())
-
-    return Options, InputFile
-
-# This acts like the main() function for the script, unless it is 'import'ed
-# into another script.
-if __name__ == '__main__':
-    pass
diff --git a/BaseTools/Source/Python/Makefile b/BaseTools/Source/Python/Makefile
index a51207d3d831..7652d2b80901 100644
--- a/BaseTools/Source/Python/Makefile
+++ b/BaseTools/Source/Python/Makefile
@@ -45,7 +45,6 @@ COMMON_PYTHON=$(BASE_TOOLS_PATH)\Source\Python\Common\BuildToolError.py \
               $(BASE_TOOLS_PATH)\Source\Python\Common\LongFilePathOs.py \
               $(BASE_TOOLS_PATH)\Source\Python\Common\LongFilePathOsPath.py \
               $(BASE_TOOLS_PATH)\Source\Python\Common\LongFilePathSupport.py \
-              $(BASE_TOOLS_PATH)\Source\Python\Common\MigrationUtilities.py \
               $(BASE_TOOLS_PATH)\Source\Python\Common\Misc.py \
               $(BASE_TOOLS_PATH)\Source\Python\Common\Parsing.py \
               $(BASE_TOOLS_PATH)\Source\Python\Common\String.py \
-- 
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH v1 27/27] BaseTools: CommonClass - remove unused classes
  2018-04-20 15:51 [PATCH v1 00/27] BaseTools refactoring Jaben Carsey
                   ` (25 preceding siblings ...)
  2018-04-20 15:51 ` [PATCH v1 26/27] BaseTools: remove unused MigrationUtilities.py Jaben Carsey
@ 2018-04-20 15:51 ` Jaben Carsey
  2018-04-25  8:51   ` Zhu, Yonghong
  26 siblings, 1 reply; 56+ messages in thread
From: Jaben Carsey @ 2018-04-20 15:51 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Yonghong Zhu

CommonDataClass/CommonClass has only 1 used class: SkuInfoClass
remove all unused classes

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>
---
 BaseTools/Source/Python/CommonDataClass/CommonClass.py | 397 +-------------------
 1 file changed, 1 insertion(+), 396 deletions(-)

diff --git a/BaseTools/Source/Python/CommonDataClass/CommonClass.py b/BaseTools/Source/Python/CommonDataClass/CommonClass.py
index 6a8262e5e964..e29f5211d5c7 100644
--- a/BaseTools/Source/Python/CommonDataClass/CommonClass.py
+++ b/BaseTools/Source/Python/CommonDataClass/CommonClass.py
@@ -1,7 +1,7 @@
 ## @file
 # This file is used to define common items of class object
 #
-# Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
 # This program and the accompanying materials
 # are licensed and made available under the terms and conditions of the BSD License
 # which accompanies this distribution.    The full text of the license may be found at
@@ -11,240 +11,6 @@
 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 
 
-#
-# Generate help text
-#
-def GenerateHelpText(Text, Lang):
-    if Text:
-        Ht = HelpTextClass()
-        Ht.Lang = Lang
-        Ht.String = Text
-    
-        return Ht
-    
-    return None
-
-## CommonClass
-#
-# This class defined common items used in Module/Platform/Package files
-# 
-# @param object:       Inherited from object class
-# @param Usage:        Input value for Usage, default is [] 
-# @param FeatureFlag:  Input value for FeatureFalg, default is ''
-# @param SupArchList:  Input value for SupArchList, default is []
-# @param HelpText:     Input value for HelpText, default is ''
-#
-# @var Usage:          To store value for Usage, selection scope is in below list
-#                      ALWAYS_CONSUMED | SOMETIMES_CONSUMED | ALWAYS_PRODUCED | SOMETIMES_PRODUCED | TO_START | BY_START | PRIVATE
-# @var FeatureFlag:    To store value for FeatureFlag
-# @var SupArchList:    To store value for SupArchList, selection scope is in below list
-#                      EBC | IA32 | X64 | IPF | ARM | PPC | AARCH64
-# @var HelpText:       To store value for HelpText
-#
-class CommonClass(object):
-    def __init__(self, Usage = None, FeatureFlag = '', SupArchList = None, HelpText = ''):
-        self.Usage = Usage
-        if self.Usage is None:
-            self.Usage = []
-        self.FeatureFlag = FeatureFlag
-        self.SupArchList = SupArchList
-        if self.SupArchList is None:
-            self.SupArchList = []
-        self.HelpText = HelpText
-        self.HelpTextList = []
-
-## CommonHeaderClass
-#
-# This class defined common items used in Module/Platform/Package files
-# 
-# @param object:          Inherited from object class
-#
-# @var Abstract:          To store value for Abstract
-# @var Description:       To store value for Description
-# @var Copyright:         To store value for Copyright
-# @var License:           To store value for License
-# @var Specification:     To store value for Specification
-#
-class CommonHeaderClass(object):
-    def __init__(self):
-        self.Abstract = ''
-        self.Description = ''
-        self.Copyright = ''
-        self.License = ''
-        self.Specification = {}
-
-## HelpTextClass
-#
-# This class defined HelpText item used in PKG file
-# 
-# @param object:     Inherited from object class
-#
-# @var Lang:         To store value for Lang
-# @var String:       To store value for String
-#
-class HelpTextClass(object):
-    def __init__(self):
-        self.Lang = ''
-        self.String = ''
-    
-## DefineClass
-#
-# This class defined item DEFINE used in Module/Platform/Package files
-#
-# @param object:  Inherited from object class
-#
-# @var Define:    To store value for Define, it is a set structure as
-#                 { (DefineName, Arch) : DefineValue, ... }
-#
-class DefineClass(object):
-    def __init__(self):
-        self.Define = {}
-
-## ClonedRecordClass
-#
-# This class defined ClonedRecord items used in Module/Platform/Package files
-# 
-# @param object:        Inherited from object class
-#
-# @var Id:              To store value for Id
-# @var FarGuid:         To store value for FarGuid
-# @var PackageGuid:     To store value for PackageGuid
-# @var PackageVersion:  To store value for PackageVersion
-# @var ModuleGuid:      To store value for ModuleGuid
-# @var ModuleVersion:   To store value for ModuleVersion
-#
-class ClonedRecordClass(object):
-    def __init__(self):
-        self.Id = 0
-        self.FarGuid = ''
-        self.PackageGuid = ''
-        self.PackageVersion = ''
-        self.ModuleGuid = ''
-        self.ModuleVersion = ''
-
-## IdentificationClass
-#
-# This class defined Identification items used in Module/Platform/Package files
-# 
-# @param object:  Inherited from object class
-#
-# @var Name:      To store value for Name
-#                 ModuleName(Inf) / PackageName(Dec) / PlatformName(Dsc)
-# @var Guid:      To store value for Guid
-# @var Version:   To store value for Version
-# @var FileName:  To store value for FileName
-# @var FullPath:  To store value for FullPath
-#
-class IdentificationClass(object):
-    def __init__(self):
-        self.Name = ''
-        self.BaseName = ''
-        self.Guid = ''
-        self.Version = ''
-        self.FileName = ''
-        self.FullPath = ''
-        self.RelaPath = ''
-        self.PackagePath = ''
-        self.ModulePath = ''
-        self.CombinePath = ''
-
-## IncludeStatementClass
-#
-# This class defined IncludeFiles item used in Module/Platform/Package files
-# 
-# @param object:      Inherited from object class
-#
-# @var IncludeFiles:  To store value for IncludeFiles
-#                     It is a set structure as { IncludeFile : [Arch1, Arch2, ...], ... }
-#
-class IncludeStatementClass(object):
-    def __init__(self):
-        self.IncludeFiles = {}                             
-
-## GuidProtocolPpiCommonClass
-#
-# This class defined Guid, Protocol and Ppi like items used in Module/Platform/Package files
-# 
-# @param CommonClass:  Inherited from CommonClass class
-#
-# @var Name:           To store value for Name
-# @var CName:          To store value for CName
-# @var Guid:           To store value for Guid
-# @var Notify:         To store value for Notify
-# @var GuidTypeList:   To store value for GuidTypeList, selection scope is in below list
-#                      DATA_HUB_RECORD | EFI_EVENT | EFI_SYSTEM_CONFIGURATION_TABLE | EFI_VARIABLE | GUID | HII_PACKAGE_LIST | HOB | TOKEN_SPACE_GUID
-# @var SupModuleList:  To store value for SupModuleList, selection scope is in below list
-#                      BASE | SEC | PEI_CORE | PEIM | DXE_CORE | DXE_DRIVER | DXE_RUNTIME_DRIVER | DXE_SAL_DRIVER | DXE_SMM_DRIVER | UEFI_DRIVER | UEFI_APPLICATION | USER_DEFINED | SMM_CORE | MM_STANDALONE | MM_CORE_STANDALONE
-#
-class GuidProtocolPpiCommonClass(CommonClass):
-    def __init__(self):
-        self.Name = ''
-        self.CName = ''
-        self.Guid = ''
-        self.VariableName = ''
-        self.Notify = False
-        self.GuidTypeList = []
-        self.GuidTypeLists = []
-        self.SupModuleList = []                           
-        CommonClass.__init__(self)
-
-## LibraryClassClass
-#
-# This class defined Library item used in Module/Platform/Package files
-# 
-# @param CommonClass:               Inherited from CommonClass class
-# @param DefineClass:               Inherited from DefineClass class
-#
-# @var LibraryClass:                To store value for LibraryClass
-# @var IncludeHeader:               To store value for IncludeHeader
-# @var RecommendedInstanceVersion:  To store value for RecommendedInstanceVersion
-# @var RecommendedInstanceGuid:     To store value for RecommendedInstanceGuid
-# @var RecommendedInstance:         To store value for RecommendedInstance, selection scope is in below list
-#                                   DATA_HUB_RECORD | EFI_EVENT | EFI_SYSTEM_CONFIGURATION_TABLE | EFI_VARIABLE | GUID | HII_PACKAGE_LIST | HOB | TOKEN_SPACE_GUID
-# @var SupModuleList:               To store value for SupModuleList, selection scope is in below list
-#                                   BASE | SEC | PEI_CORE | PEIM | DXE_CORE | DXE_DRIVER | DXE_RUNTIME_DRIVER | DXE_SAL_DRIVER | DXE_SMM_DRIVER | UEFI_DRIVER | UEFI_APPLICATION | USER_DEFINED | SMM_CORE | MM_STANDALONE | MM_CORE_STANDALONE
-#
-class LibraryClassClass(CommonClass, DefineClass):
-    def __init__(self):
-        self.LibraryClass = ''
-        self.IncludeHeader = ''
-        self.RecommendedInstanceVersion = ''
-        self.RecommendedInstanceGuid = ''
-        self.RecommendedInstance = ''
-        self.SupModuleList = []
-        CommonClass.__init__(self)
-        DefineClass.__init__(self)
-
-## GuidClass
-#
-# This class defined Guid item used in Module/Platform/Package files
-# 
-# @param GuidProtocolPpiCommonClass:  Inherited from GuidProtocolPpiCommonClass class
-#
-class GuidClass(GuidProtocolPpiCommonClass):
-    def __init__(self):
-        GuidProtocolPpiCommonClass.__init__(self)
-
-## ProtocolClass
-#
-# This class defined Protocol item used in Module/Platform/Package files
-# 
-# @param GuidProtocolPpiCommonClass:  Inherited from GuidProtocolPpiCommonClass class
-#
-class ProtocolClass(GuidProtocolPpiCommonClass):
-    def __init__(self):
-        GuidProtocolPpiCommonClass.__init__(self)
-
-## PpiClass
-#
-# This class defined Ppi item used in Module/Platform/Package files
-# 
-# @param GuidProtocolPpiCommonClass:  Inherited from GuidProtocolPpiCommonClass class
-#
-class PpiClass(GuidProtocolPpiCommonClass):        
-    def __init__(self):
-        GuidProtocolPpiCommonClass.__init__(self)
-
 ## SkuInfoClass
 #
 # This class defined SkuInfo item used in Module/Platform/Package files
@@ -314,164 +80,3 @@ class SkuInfoClass(object):
                     'VpdOffset = ' + str(self.VpdOffset) + "," + \
                     'DefaultValue = ' + str(self.DefaultValue) + ","
         return Rtn
-## PcdErrorClass
-#
-#
-#
-class PcdErrorClass(object):
-    def __init__(self):
-        self.ValidValueList = ''
-        self.ValidValueListLang = ''
-        self.ValidValueRange = ''
-        self.Expression = ''
-        self.ErrorNumber = ''
-        self.ErrorMessage = []
-
-## PcdClass
-#
-# This class defined Pcd item used in Module/Platform/Package files
-# 
-# @param CommonClass:          Inherited from CommonClass class
-# @param CName:                Input value for CName, default is ''
-# @param Token:                Input value for Token, default is ''
-# @param TokenSpaceGuidCName:  Input value for TokenSpaceGuidCName, default is ''
-# @param DatumType:            Input value for DatumType, default is ''
-# @param MaxDatumSize:         Input value for MaxDatumSize, default is ''
-# @param DefaultValue:         Input value for DefaultValue, default is ''
-# @param ItemType:             Input value for ItemType, default is ''
-# @param ValidUsage:           Input value for ValidUsage, default is []
-# @param SkuInfoList:          Input value for SkuInfoList, default is {}
-# @param SupModuleList:        Input value for SupModuleList, default is []
-#
-# @var CName:                  To store value for CName
-# @var Token:                  To store value for Token
-# @var TokenSpaceGuidCName:    To store value for TokenSpaceGuidCName
-# @var DatumType:              To store value for DatumType, selection scope is in below list
-#                              UINT8 | UINT16 | UINT32 | UINT64 | VOID* | BOOLEAN 
-# @var MaxDatumSize:           To store value for MaxDatumSize
-# @var DefaultValue:           To store value for DefaultValue
-# @var ItemType:               To store value for ItemType, selection scope is in below list
-#                              FEATURE_FLAG | FIXED_AT_BUILD | PATCHABLE_IN_MODULE | DYNAMIC | DYNAMIC_EX
-# @var ValidUsage:             To store value for ValidUsage, selection scope is in below list
-#                              FEATURE_FLAG | FIXED_AT_BUILD | PATCHABLE_IN_MODULE | DYNAMIC | DYNAMIC_EX
-# @var SkuInfoList:            To store value for SkuInfoList
-#                              It is a set structure as { [SkuIdName] : SkuInfoClass } 
-# @var SupModuleList:          To store value for SupModuleList, selection scope is in below list
-#                              BASE | SEC | PEI_CORE | PEIM | DXE_CORE | DXE_DRIVER | DXE_RUNTIME_DRIVER | DXE_SAL_DRIVER | DXE_SMM_DRIVER | UEFI_DRIVER | UEFI_APPLICATION | USER_DEFINED | SMM_CORE | MM_STANDALONE | MM_CORE_STANDALONE
-#
-class PcdClass(CommonClass):
-    def __init__(self, CName = '', Token = '', TokenSpaceGuidCName = '', DatumType = '', MaxDatumSize = '', DefaultValue = '', ItemType = '', ValidUsage = None, SkuInfoList = None, SupModuleList = None):
-        self.CName = CName
-        self.Token = Token
-        self.TokenSpaceGuidCName = TokenSpaceGuidCName
-        self.DatumType = DatumType
-        self.MaxDatumSize = MaxDatumSize
-        self.DefaultValue = DefaultValue
-        self.ItemType = ItemType
-        self.ValidUsage = ValidUsage
-        self.PcdItemType = ''
-        self.TokenSpaceGuidValue = ''
-        self.PcdUsage = ''
-        self.PcdCName = ''
-        self.Value = ''
-        self.Offset = ''
-        if self.ValidUsage is None:
-            self.ValidUsage = []
-        self.SkuInfoList = SkuInfoList
-        if self.SkuInfoList  is None:
-            self.SkuInfoList  = {}
-        self.SupModuleList = SupModuleList
-        if self.SupModuleList is None:
-            self.SupModuleList = []
-        CommonClass.__init__(self)
-        self.PcdErrors = []
-
-## BuildOptionClass
-#
-# This class defined BuildOption item used in Module/Platform/Package files
-# 
-# @param IncludeStatementClass:  Inherited from IncludeStatementClass class
-# @param ToolChainFamily:        Input value for ToolChainFamily, default is ''
-# @param ToolChain:              Input value for ToolChain, default is ''
-# @param Option:                 Input value for Option, default is ''
-#
-# @var Statement:                To store value for Statement
-#                                It is a string in a special format as "Family:Target_TagName_Tarch_ToolCode_FLAGS = String"
-# @var ToolChainFamily:          To store value for ToolChainFamily
-# @var ToolChain:                To store value for ToolChain
-# @var Option:                   To store value for Option
-# @var BuildTarget:              To store value for BuildTarget
-# @var TagName:                  To store value for TagName
-# @var ToolCode:                 To store value for ToolCode
-# @var SupArchList:              To store value for SupArchList, selection scope is in below list
-#                                EBC | IA32 | X64 | IPF | ARM | PPC | AARCH64
-#
-class BuildOptionClass(IncludeStatementClass):
-    def __init__(self, ToolChainFamily = '', ToolChain = '', Option = ''):
-        IncludeStatementClass.__init__(self)
-        self.Statement = ''                               
-        self.ToolChainFamily = ToolChainFamily
-        self.ToolChain = ToolChain
-        self.Option = Option
-        self.BuildTarget = ''
-        self.TagName = ''
-        self.ToolCode = ''
-        self.SupArchList = []
-
-## IncludeClass
-#
-# This class defined Include item used in Module/Platform/Package files
-# 
-# @param CommonClass:  Inherited from CommonClass class
-#
-# @var FilePath:       To store value for FilePath
-# @var ModuleType:     To store value for ModuleType
-# @var Comment:        To store value for Comment
-#
-class IncludeClass(CommonClass):
-    def __init__(self):
-        self.FilePath = ''
-        self.ModuleType = ''
-        self.SupModuleList = []
-        self.Comment = ''
-        CommonClass.__init__(self)        
-
-## FileClass
-#
-#
-class FileClass(CommonClass):
-    def __init__(self):
-        self.Filename = ''
-        self.Executable = ''
-        self.Family = ''
-        self.FileType = ''
-        CommonClass.__init__(self)
-        
-
-## MiscFileClass
-#
-#
-class MiscFileClass(CommonHeaderClass):
-    def __init__(self):
-        CommonHeaderClass.__init__(self)
-        self.Name = ''
-        self.Files = []
-    
-
-## UserExtensionsClass
-#
-# This class defined UserExtensions item used in Module/Platform/Package files
-# 
-# @param object:    Inherited from object class
-#
-# @var UserID:      To store value for UserID
-# @var Identifier:  To store value for Identifier
-# @var Content:     To store value for Content
-#       
-class UserExtensionsClass(object):
-    def __init__(self):
-        self.UserID = ''
-        self.Identifier = 0
-        self.Content = ''
-        self.Defines = []
-        self.BuildOptions = []
-- 
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* Re: [PATCH v1 19/27] BaseTools: Replace Binary File type strings with predefined constant
  2018-04-20 15:51 ` [PATCH v1 19/27] BaseTools: Replace Binary File " Jaben Carsey
@ 2018-04-24  7:38   ` Zhu, Yonghong
  2018-04-24 14:12     ` Carsey, Jaben
  0 siblings, 1 reply; 56+ messages in thread
From: Zhu, Yonghong @ 2018-04-24  7:38 UTC (permalink / raw)
  To: Carsey, Jaben, edk2-devel@lists.01.org; +Cc: Gao, Liming, Zhu, Yonghong

Hi Jaben,
1.  use the BINARY_FILE_TYPE_FV to replace 'FV' in the file path may be strange. How about we still keep to use 'FV' ?
2.  how about we create another constant name for 'GUID' ?  I think some place's replacement is a little odd, eg: Value.startswith(BINARY_FILE_TYPE_GUID). Do  you have any suggestions on the naming conventions ?


Best Regards,
Zhu Yonghong


-----Original Message-----
From: Carsey, Jaben 
Sent: Friday, April 20, 2018 11:52 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming <liming.gao@intel.com>; Zhu, Yonghong <yonghong.zhu@intel.com>
Subject: [PATCH v1 19/27] BaseTools: Replace Binary File type strings with predefined constant

BINARY_FILE_TYPE_FW was 'FW'
BINARY_FILE_TYPE_GUID was 'GUID'
BINARY_FILE_TYPE_PREEFORM was 'PREEFORM'
BINARY_FILE_TYPE_UEFI_APP was 'UEFI_APP'
BINARY_FILE_TYPE_UNI_UI was 'UNI_UI'
BINARY_FILE_TYPE_UNI_VER was 'UNI_VER'
BINARY_FILE_TYPE_LIB was 'LIB'
BINARY_FILE_TYPE_PE32 was 'PE32'
BINARY_FILE_TYPE_PIC was 'PIC'
BINARY_FILE_TYPE_PEI_DEPEX was 'PEI_DEPEX'
BINARY_FILE_TYPE_DXE_DEPEX was 'DXE_DEPEX'
BINARY_FILE_TYPE_SMM_DEPEX was 'SMM_DEPEX'
BINARY_FILE_TYPE_TE was 'TE'
BINARY_FILE_TYPE_VER was 'VER'
BINARY_FILE_TYPE_UI was 'UI'
BINARY_FILE_TYPE_BIN was 'BIN'
BINARY_FILE_TYPE_FV was 'FV'

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>
---
 BaseTools/Source/Python/AutoGen/AutoGen.py             | 12 +--
 BaseTools/Source/Python/AutoGen/GenC.py                |  8 +-
 BaseTools/Source/Python/AutoGen/GenPcdDb.py            |  4 +-
 BaseTools/Source/Python/Common/Expression.py           |  2 +-
 BaseTools/Source/Python/Common/Misc.py                 |  4 +-
 BaseTools/Source/Python/GenFds/DataSection.py          |  6 +-
 BaseTools/Source/Python/GenFds/DepexSection.py         |  6 +-
 BaseTools/Source/Python/GenFds/EfiSection.py           | 10 +--
 BaseTools/Source/Python/GenFds/Fd.py                   |  3 +-
 BaseTools/Source/Python/GenFds/FdfParser.py            | 92 ++++++++++----------
 BaseTools/Source/Python/GenFds/Ffs.py                  | 14 +--
 BaseTools/Source/Python/GenFds/FfsInfStatement.py      | 22 ++---
 BaseTools/Source/Python/GenFds/Fv.py                   |  4 +-
 BaseTools/Source/Python/GenFds/GenFds.py               | 10 +--
 BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py |  4 +-
 BaseTools/Source/Python/GenFds/OptRomInfStatement.py   |  2 +-
 BaseTools/Source/Python/GenFds/Region.py               |  5 +-
 BaseTools/Source/Python/GenFds/Section.py              | 46 +++++-----
 BaseTools/Source/Python/GenFds/UiSection.py            |  2 +-
 BaseTools/Source/Python/Trim/Trim.py                   |  2 +-
 BaseTools/Source/Python/Workspace/DscBuildData.py      |  2 +-
 BaseTools/Source/Python/Workspace/InfBuildData.py      |  2 +-
 BaseTools/Source/Python/build/BuildReport.py           | 12 +--
 23 files changed, 138 insertions(+), 136 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 9b2164ed8216..534fbe79fad9 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -923,7 +923,7 @@ class WorkspaceAutoGen(AutoGen):
     ## Return the directory to store FV files
     def _GetFvDir(self):
         if self._FvDir is None:
-            self._FvDir = path.join(self.BuildDir, 'FV')
+            self._FvDir = path.join(self.BuildDir, BINARY_FILE_TYPE_FV)
         return self._FvDir
 
     ## Return the directory to store all intermediate and final files built
@@ -1326,7 +1326,7 @@ class PlatformAutoGen(AutoGen):
 
     def UpdateNVStoreMaxSize(self,OrgVpdFile):
         if self.VariableInfo:
-            VpdMapFilePath = os.path.join(self.BuildDir, "FV", "%s.map" % self.Platform.VpdToolGuid)
+            VpdMapFilePath = os.path.join(self.BuildDir, BINARY_FILE_TYPE_FV, "%s.map" % self.Platform.VpdToolGuid)
             PcdNvStoreDfBuffer = [item for item in self._DynamicPcdList if item.TokenCName == "PcdNvStoreDefaultValueBuffer" and item.TokenSpaceGuidCName == "gEfiMdeModulePkgTokenSpaceGuid"]
 
             if PcdNvStoreDfBuffer:
@@ -1719,7 +1719,7 @@ class PlatformAutoGen(AutoGen):
 
                 # Process VPD map file generated by third party BPDG tool
                 if NeedProcessVpdMapFile:
-                    VpdMapFilePath = os.path.join(self.BuildDir, "FV", "%s.map" % self.Platform.VpdToolGuid)
+                    VpdMapFilePath = os.path.join(self.BuildDir, BINARY_FILE_TYPE_FV, "%s.map" % self.Platform.VpdToolGuid)
                     if os.path.exists(VpdMapFilePath):
                         VpdFile.Read(VpdMapFilePath)
 
@@ -1770,7 +1770,7 @@ class PlatformAutoGen(AutoGen):
         self.AllPcdList = self._NonDynamicPcdList + self._DynamicPcdList
 
     def FixVpdOffset(self,VpdFile ):
-        FvPath = os.path.join(self.BuildDir, "FV")
+        FvPath = os.path.join(self.BuildDir, BINARY_FILE_TYPE_FV)
         if not os.path.exists(FvPath):
             try:
                 os.makedirs(FvPath)
@@ -1783,7 +1783,7 @@ class PlatformAutoGen(AutoGen):
             # retrieve BPDG tool's path from tool_def.txt according to VPD_TOOL_GUID defined in DSC file.
             BPDGToolName = None
             for ToolDef in self.ToolDefinition.values():
-                if ToolDef.has_key("GUID") and ToolDef["GUID"] == self.Platform.VpdToolGuid:
+                if ToolDef.has_key(BINARY_FILE_TYPE_GUID) and ToolDef[BINARY_FILE_TYPE_GUID] == self.Platform.VpdToolGuid:
                     if not ToolDef.has_key("PATH"):
                         EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE, "PATH attribute was not provided for BPDG guid tool %s in tools_def.txt" % self.Platform.VpdToolGuid)
                     BPDGToolName = ToolDef["PATH"]
@@ -3032,7 +3032,7 @@ class ModuleAutoGen(AutoGen):
     def _GetFfsOutputDir(self):
         if self._FfsOutputDir is None:
             if GlobalData.gFdfParser is not None:
-                self._FfsOutputDir = path.join(self.PlatformInfo.BuildDir, "FV", "Ffs", self.Guid + self.Name)
+                self._FfsOutputDir = path.join(self.PlatformInfo.BuildDir, BINARY_FILE_TYPE_FV, "Ffs", self.Guid + self.Name)
             else:
                 self._FfsOutputDir = ''
         return self._FfsOutputDir
diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py
index 6b2ee87b2211..ca54ac107e5d 100644
--- a/BaseTools/Source/Python/AutoGen/GenC.py
+++ b/BaseTools/Source/Python/AutoGen/GenC.py
@@ -1614,7 +1614,7 @@ def CreateModuleUnloadImageCode(Info, AutoGenC, AutoGenH):
 #
 def CreateGuidDefinitionCode(Info, AutoGenC, AutoGenH):
     if Info.ModuleType in [SUP_MODULE_USER_DEFINED, SUP_MODULE_BASE]:
-        GuidType = "GUID"
+        GuidType = BINARY_FILE_TYPE_GUID
     else:
         GuidType = "EFI_GUID"
 
@@ -1638,7 +1638,7 @@ def CreateGuidDefinitionCode(Info, AutoGenC, AutoGenH):
 #
 def CreateProtocolDefinitionCode(Info, AutoGenC, AutoGenH):
     if Info.ModuleType in [SUP_MODULE_USER_DEFINED, SUP_MODULE_BASE]:
-        GuidType = "GUID"
+        GuidType = BINARY_FILE_TYPE_GUID
     else:
         GuidType = "EFI_GUID"
 
@@ -1662,7 +1662,7 @@ def CreateProtocolDefinitionCode(Info, AutoGenC, AutoGenH):
 #
 def CreatePpiDefinitionCode(Info, AutoGenC, AutoGenH):
     if Info.ModuleType in [SUP_MODULE_USER_DEFINED, SUP_MODULE_BASE]:
-        GuidType = "GUID"
+        GuidType = BINARY_FILE_TYPE_GUID
     else:
         GuidType = "EFI_GUID"
 
@@ -1699,7 +1699,7 @@ def CreatePcdCode(Info, AutoGenC, AutoGenH):
     if TokenSpaceList:
         AutoGenH.Append("\n// Definition of PCD Token Space GUIDs used in this module\n\n")
         if Info.ModuleType in [SUP_MODULE_USER_DEFINED, SUP_MODULE_BASE]:
-            GuidType = "GUID"
+            GuidType = BINARY_FILE_TYPE_GUID
         else:
             GuidType = "EFI_GUID"              
         for Item in TokenSpaceList:
diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
index 9374ca4820ef..63228795c001 100644
--- a/BaseTools/Source/Python/AutoGen/GenPcdDb.py
+++ b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
@@ -972,7 +972,7 @@ def CreatePcdDatabaseCode (Info, AutoGenC, AutoGenH):
         AutoGenC.Append(AdditionalAutoGenC.String)
 
     if Info.IsBinaryModule:
-        DbFileName = os.path.join(Info.PlatformInfo.BuildDir, "FV", Phase + "PcdDataBase.raw")
+        DbFileName = os.path.join(Info.PlatformInfo.BuildDir, BINARY_FILE_TYPE_FV, Phase + "PcdDataBase.raw")
     else:
         DbFileName = os.path.join(Info.OutputDir, Phase + "PcdDataBase.raw")
     DbFile = StringIO()
@@ -1054,7 +1054,7 @@ def NewCreatePcdDatabasePhaseSpecificAutoGen(Platform,Phase):
             PcdDriverAutoGenData[(skuname,skuid)] = (AdditionalAutoGenH, AdditionalAutoGenC)
             VarCheckTableData[(skuname,skuid)] = VarCheckTab
         if Platform.Platform.VarCheckFlag:
-            dest = os.path.join(Platform.BuildDir, 'FV')
+            dest = os.path.join(Platform.BuildDir, BINARY_FILE_TYPE_FV)
             VarCheckTable = CreateVarCheckBin(VarCheckTableData)
             VarCheckTable.dump(dest, Phase)
         AdditionalAutoGenH, AdditionalAutoGenC =  CreateAutoGen(PcdDriverAutoGenData)
diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Source/Python/Common/Expression.py
index 99929938fb5a..4b7d65583dc8 100644
--- a/BaseTools/Source/Python/Common/Expression.py
+++ b/BaseTools/Source/Python/Common/Expression.py
@@ -950,7 +950,7 @@ class ValueExpressionEx(ValueExpression):
                             Size = 0
                             ValueStr = ''
                             TokenSpaceGuidName = ''
-                            if Item.startswith('GUID') and Item.endswith(')'):
+                            if Item.startswith(BINARY_FILE_TYPE_GUID) and Item.endswith(')'):
                                 try:
                                     TokenSpaceGuidName = re.search('GUID\((\w+)\)', Item).group(1)
                                 except:
diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
index 4a6a29c7ae80..61617ed589b3 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -1219,7 +1219,7 @@ class tdict:
 
 def IsFieldValueAnArray (Value):
     Value = Value.strip()
-    if Value.startswith('GUID') and Value.endswith(')'):
+    if Value.startswith(BINARY_FILE_TYPE_GUID) and Value.endswith(')'):
         return True
     if Value.startswith('L"') and Value.endswith('"')  and len(list(Value[2:-1])) > 1:
         return True
@@ -1316,7 +1316,7 @@ def ParseFieldValue (Value):
         if Size > 8:
             raise BadExpression('Value (%s) Size larger than %d' % (Value, Size))
         return Value, 8
-    if Value.startswith('GUID') and Value.endswith(')'):
+    if Value.startswith(BINARY_FILE_TYPE_GUID) and Value.endswith(')'):
         Value = Value.split('(', 1)[1][:-1].strip()
         if Value[0] == '{' and Value[-1] == '}':
             TmpValue = GuidStructureStringToGuidString(Value)
diff --git a/BaseTools/Source/Python/GenFds/DataSection.py b/BaseTools/Source/Python/GenFds/DataSection.py
index 3c435c2fcc65..c066d4383549 100644
--- a/BaseTools/Source/Python/GenFds/DataSection.py
+++ b/BaseTools/Source/Python/GenFds/DataSection.py
@@ -81,7 +81,7 @@ class DataSection (DataSectionClassObject):
                         CopyLongFilePath(MapFile, CopyMapFile)
 
         #Get PE Section alignment when align is set to AUTO
-        if self.Alignment == 'Auto' and self.SecType in ('TE', 'PE32'):
+        if self.Alignment == 'Auto' and self.SecType in (BINARY_FILE_TYPE_TE, BINARY_FILE_TYPE_PE32):
             ImageObj = PeImageClass (Filename)
             if ImageObj.SectionAlignment < 0x400:
                 self.Alignment = str (ImageObj.SectionAlignment)
@@ -91,7 +91,7 @@ class DataSection (DataSectionClassObject):
                 self.Alignment = str (ImageObj.SectionAlignment / 0x100000) + 'M'
 
         NoStrip = True
-        if self.SecType in ('TE', 'PE32'):
+        if self.SecType in (BINARY_FILE_TYPE_TE, BINARY_FILE_TYPE_PE32):
             if self.KeepReloc is not None:
                 NoStrip = self.KeepReloc
 
@@ -109,7 +109,7 @@ class DataSection (DataSectionClassObject):
                 )
             self.SectFileName = StrippedFile
 
-        if self.SecType == 'TE':
+        if self.SecType == BINARY_FILE_TYPE_TE:
             TeFile = os.path.join( OutputPath, ModuleName + 'Te.raw')
             GenFdsGlobalVariable.GenerateFirmwareImage(
                     TeFile,
diff --git a/BaseTools/Source/Python/GenFds/DepexSection.py b/BaseTools/Source/Python/GenFds/DepexSection.py
index d04160e890f1..f42162d5a27e 100644
--- a/BaseTools/Source/Python/GenFds/DepexSection.py
+++ b/BaseTools/Source/Python/GenFds/DepexSection.py
@@ -96,13 +96,13 @@ class DepexSection (DepexSectionClassObject):
 
         if self.DepexType == 'PEI_DEPEX_EXP':
             ModuleType = SUP_MODULE_PEIM
-            SecType    = 'PEI_DEPEX'
+            SecType    = BINARY_FILE_TYPE_PEI_DEPEX
         elif self.DepexType == 'DXE_DEPEX_EXP':
             ModuleType = SUP_MODULE_DXE_DRIVER
-            SecType    = 'DXE_DEPEX'
+            SecType    = BINARY_FILE_TYPE_DXE_DEPEX
         elif self.DepexType == 'SMM_DEPEX_EXP':
             ModuleType = SUP_MODULE_DXE_SMM_DRIVER
-            SecType    = 'SMM_DEPEX'
+            SecType    = BINARY_FILE_TYPE_SMM_DEPEX
         else:
             EdkLogger.error("GenFds", FORMAT_INVALID,
                             "Depex type %s is not valid for module %s" % (self.DepexType, ModuleName))
diff --git a/BaseTools/Source/Python/GenFds/EfiSection.py b/BaseTools/Source/Python/GenFds/EfiSection.py
index 1be23b4bf7fd..5405d0a8da13 100644
--- a/BaseTools/Source/Python/GenFds/EfiSection.py
+++ b/BaseTools/Source/Python/GenFds/EfiSection.py
@@ -67,7 +67,7 @@ class EfiSection (EfiSectionClassObject):
             StringData = FfsInf.__ExtendMacro__(self.StringData)
             ModuleNameStr = FfsInf.__ExtendMacro__('$(MODULE_NAME)')
             NoStrip = True
-            if FfsInf.ModuleType in (SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM) and SectionType in ('TE', 'PE32'):
+            if FfsInf.ModuleType in (SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM) and SectionType in (BINARY_FILE_TYPE_TE, BINARY_FILE_TYPE_PE32):
                 if FfsInf.KeepReloc is not None:
                     NoStrip = FfsInf.KeepReloc
                 elif FfsInf.KeepRelocFromRule is not None:
@@ -171,9 +171,9 @@ class EfiSection (EfiSectionClassObject):
                 OutputFileList.append(OutputFile)
 
         #
-        # If Section Type is 'UI'
+        # If Section Type is BINARY_FILE_TYPE_UI
         #
-        elif SectionType == 'UI':
+        elif SectionType == BINARY_FILE_TYPE_UI:
 
             InfOverrideUiString = False
             if FfsInf.Ui is not None:
@@ -242,7 +242,7 @@ class EfiSection (EfiSectionClassObject):
                     File = GenFdsGlobalVariable.MacroExtend(File, Dict)
                     
                     #Get PE Section alignment when align is set to AUTO
-                    if self.Alignment == 'Auto' and (SectionType == 'PE32' or SectionType == 'TE'):
+                    if self.Alignment == 'Auto' and (SectionType == BINARY_FILE_TYPE_PE32 or SectionType == BINARY_FILE_TYPE_TE):
                         ImageObj = PeImageClass (File)
                         if ImageObj.SectionAlignment < 0x400:
                             Align = str (ImageObj.SectionAlignment)
@@ -287,7 +287,7 @@ class EfiSection (EfiSectionClassObject):
                     
                     """For TE Section call GenFw to generate TE image"""
 
-                    if SectionType == 'TE':
+                    if SectionType == BINARY_FILE_TYPE_TE:
                         TeFile = os.path.join( OutputPath, ModuleName + 'Te.raw')
                         GenFdsGlobalVariable.GenerateFirmwareImage(
                                 TeFile,
diff --git a/BaseTools/Source/Python/GenFds/Fd.py b/BaseTools/Source/Python/GenFds/Fd.py
index cc4124ad902e..188ca28cd7ce 100644
--- a/BaseTools/Source/Python/GenFds/Fd.py
+++ b/BaseTools/Source/Python/GenFds/Fd.py
@@ -27,6 +27,7 @@ from Common import EdkLogger
 from Common.BuildToolError import *
 from Common.Misc import SaveFileOnChange
 from GenFds import GenFds
+from Common.DataType import BINARY_FILE_TYPE_FV
 
 ## generate FD
 #
@@ -158,7 +159,7 @@ class FD(FDClassObject):
         FvAddDict ={}
         FvList = []
         for RegionObj in self.RegionList:
-            if RegionObj.RegionType == 'FV':
+            if RegionObj.RegionType == BINARY_FILE_TYPE_FV:
                 if len(RegionObj.RegionDataList) == 1:
                     RegionData = RegionObj.RegionDataList[0]
                     FvList.append(RegionData.upper())
diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py
index 23c04123af1b..b8848a25b4b2 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -1850,7 +1850,7 @@ class FdfParser:
         if not self.__GetNextWord():
             return True
 
-        if not self.__Token in ("SET", "FV", "FILE", "DATA", "CAPSULE", "INF"):
+        if not self.__Token in ("SET", BINARY_FILE_TYPE_FV, "FILE", "DATA", "CAPSULE", "INF"):
             #
             # If next token is a word which is not a valid FV type, it might be part of [PcdOffset[|PcdSize]]
             # Or it might be next region's offset described by an expression which starts with a PCD.
@@ -1881,7 +1881,7 @@ class FdfParser:
             if not self.__GetNextWord():
                 return True
 
-        elif self.__Token == "FV":
+        elif self.__Token == BINARY_FILE_TYPE_FV:
             self.__UndoToken()
             self.__GetRegionFvType( RegionObj)
 
@@ -1925,8 +1925,8 @@ class FdfParser:
     #
     def __GetRegionFvType(self, RegionObj):
 
-        if not self.__IsKeyword( "FV"):
-            raise Warning("expected Keyword 'FV'", self.FileName, self.CurrentLineNumber)
+        if not self.__IsKeyword( BINARY_FILE_TYPE_FV):
+            raise Warning("expected Keyword BINARY_FILE_TYPE_FV", self.FileName, self.CurrentLineNumber)
 
         if not self.__IsToken( "="):
             raise Warning("expected '='", self.FileName, self.CurrentLineNumber)
@@ -1934,10 +1934,10 @@ class FdfParser:
         if not self.__GetNextToken():
             raise Warning("expected FV name", self.FileName, self.CurrentLineNumber)
 
-        RegionObj.RegionType = "FV"
+        RegionObj.RegionType = BINARY_FILE_TYPE_FV
         RegionObj.RegionDataList.append((self.__Token).upper())
 
-        while self.__IsKeyword( "FV"):
+        while self.__IsKeyword( BINARY_FILE_TYPE_FV):
 
             if not self.__IsToken( "="):
                 raise Warning("expected '='", self.FileName, self.CurrentLineNumber)
@@ -2535,7 +2535,7 @@ class FdfParser:
             if self.__GetStringData():
                 FfsInfObj.Version = self.__Token
 
-        if self.__IsKeyword( "UI"):
+        if self.__IsKeyword( BINARY_FILE_TYPE_UI):
             if not self.__IsToken( "="):
                 raise Warning("expected '='", self.FileName, self.CurrentLineNumber)
             if not self.__GetNextToken():
@@ -2648,7 +2648,7 @@ class FdfParser:
     #
     @staticmethod
     def __SectionCouldHaveRelocFlag (SectionType):
-        if SectionType in ('TE', 'PE32'):
+        if SectionType in (BINARY_FILE_TYPE_TE, BINARY_FILE_TYPE_PE32):
             return True
         else:
             return False
@@ -2681,7 +2681,7 @@ class FdfParser:
         if not self.__GetNextToken():
             raise Warning("expected File name or section data", self.FileName, self.CurrentLineNumber)
 
-        if self.__Token == "FV":
+        if self.__Token == BINARY_FILE_TYPE_FV:
             if not self.__IsToken( "="):
                 raise Warning("expected '='", self.FileName, self.CurrentLineNumber)
             if not self.__GetNextToken():
@@ -2888,7 +2888,7 @@ class FdfParser:
                 VerSectionObj.FileName = self.__Token
             Obj.SectionList.append(VerSectionObj)
             
-        elif self.__IsKeyword( "UI"):
+        elif self.__IsKeyword( BINARY_FILE_TYPE_UI):
             if AlignValue == 'Auto':
                 raise Warning("Auto alignment can only be used in PE32 or TE section ", self.FileName, self.CurrentLineNumber)
             if not self.__IsToken( "="):
@@ -2972,10 +2972,10 @@ class FdfParser:
                 self.SetFileBufferPos(OldPos)
                 return False
 
-            if self.__Token not in ("COMPAT16", "PE32", "PIC", "TE", "FV_IMAGE", "RAW", "DXE_DEPEX",\
-                               "UI", "VERSION", "PEI_DEPEX", "SUBTYPE_GUID", "SMM_DEPEX"):
+            if self.__Token not in ("COMPAT16", BINARY_FILE_TYPE_PE32, BINARY_FILE_TYPE_PIC, BINARY_FILE_TYPE_TE, "FV_IMAGE", "RAW", BINARY_FILE_TYPE_DXE_DEPEX,\
+                               BINARY_FILE_TYPE_UI, "VERSION", BINARY_FILE_TYPE_PEI_DEPEX, "SUBTYPE_GUID", BINARY_FILE_TYPE_SMM_DEPEX):
                 raise Warning("Unknown section type '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
-            if AlignValue == 'Auto'and (not self.__Token == 'PE32') and (not self.__Token == 'TE'):
+            if AlignValue == 'Auto'and (not self.__Token == BINARY_FILE_TYPE_PE32) and (not self.__Token == BINARY_FILE_TYPE_TE):
                 raise Warning("Auto alignment can only be used in PE32 or TE section ", self.FileName, self.CurrentLineNumber)
 
             # DataSection
@@ -3393,7 +3393,7 @@ class FdfParser:
     #
     def __GetFvStatement(self, CapsuleObj, FMPCapsule = False):
 
-        if not self.__IsKeyword("FV"):
+        if not self.__IsKeyword(BINARY_FILE_TYPE_FV):
             return False
 
         if not self.__IsToken("="):
@@ -3541,7 +3541,7 @@ class FdfParser:
         AfileBaseName = os.path.basename(AfileName)
         
         if os.path.splitext(AfileBaseName)[1]  not in [".bin",".BIN",".Bin",".dat",".DAT",".Dat",".data",".DATA",".Data"]:
-            raise Warning('invalid binary file type, should be one of "bin","BIN","Bin","dat","DAT","Dat","data","DATA","Data"', \
+            raise Warning('invalid binary file type, should be one of "bin",BINARY_FILE_TYPE_BIN,"Bin","dat","DAT","Dat","data","DATA","Data"', \
                           self.FileName, self.CurrentLineNumber)
         
         if not os.path.isabs(AfileName):
@@ -3774,8 +3774,8 @@ class FdfParser:
 
             SectionName = self.__Token
 
-            if SectionName not in ("COMPAT16", "PE32", "PIC", "TE", "FV_IMAGE", "RAW", "DXE_DEPEX",\
-                                    "UI", "PEI_DEPEX", "VERSION", "SUBTYPE_GUID", "SMM_DEPEX"):
+            if SectionName not in ("COMPAT16", BINARY_FILE_TYPE_PE32, BINARY_FILE_TYPE_PIC, BINARY_FILE_TYPE_TE, "FV_IMAGE", "RAW", BINARY_FILE_TYPE_DXE_DEPEX,\
+                                    BINARY_FILE_TYPE_UI, BINARY_FILE_TYPE_PEI_DEPEX, "VERSION", "SUBTYPE_GUID", BINARY_FILE_TYPE_SMM_DEPEX):
                 raise Warning("Unknown leaf section name '%s'" % SectionName, self.FileName, self.CurrentLineNumber)
 
 
@@ -3790,7 +3790,7 @@ class FdfParser:
                 if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K", "128K",
                                         "256K", "512K", "1M", "2M", "4M", "8M", "16M"):
                     raise Warning("Incorrect alignment '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
-                if self.__Token == 'Auto' and (not SectionName == 'PE32') and (not SectionName == 'TE'):
+                if self.__Token == 'Auto' and (not SectionName == BINARY_FILE_TYPE_PE32) and (not SectionName == BINARY_FILE_TYPE_TE):
                     raise Warning("Auto alignment can only be used in PE32 or TE section ", self.FileName, self.CurrentLineNumber)
                 SectAlignment = self.__Token
 
@@ -3831,8 +3831,8 @@ class FdfParser:
             return False
         SectionName = self.__Token
 
-        if SectionName not in ("COMPAT16", "PE32", "PIC", "TE", "FV_IMAGE", "RAW", "DXE_DEPEX",\
-                               "UI", "VERSION", "PEI_DEPEX", "GUID", "SMM_DEPEX"):
+        if SectionName not in ("COMPAT16", BINARY_FILE_TYPE_PE32, BINARY_FILE_TYPE_PIC, BINARY_FILE_TYPE_TE, "FV_IMAGE", "RAW", BINARY_FILE_TYPE_DXE_DEPEX,\
+                               BINARY_FILE_TYPE_UI, "VERSION", BINARY_FILE_TYPE_PEI_DEPEX, BINARY_FILE_TYPE_GUID, BINARY_FILE_TYPE_SMM_DEPEX):
             self.__UndoToken()
             return False
 
@@ -3862,8 +3862,8 @@ class FdfParser:
                 FvImageSectionObj.FvName = None
 
             else:
-                if not self.__IsKeyword("FV"):
-                    raise Warning("expected 'FV'", self.FileName, self.CurrentLineNumber)
+                if not self.__IsKeyword(BINARY_FILE_TYPE_FV):
+                    raise Warning("expected BINARY_FILE_TYPE_FV", self.FileName, self.CurrentLineNumber)
                 FvImageSectionObj.FvFileType = self.__Token
 
                 if self.__GetAlignment():
@@ -3875,8 +3875,8 @@ class FdfParser:
                 if self.__IsToken('|'):
                     FvImageSectionObj.FvFileExtension = self.__GetFileExtension()
                 elif self.__GetNextToken():
-                    if self.__Token not in ("}", "COMPAT16", "PE32", "PIC", "TE", "FV_IMAGE", "RAW", "DXE_DEPEX",\
-                               "UI", "VERSION", "PEI_DEPEX", "GUID", "SMM_DEPEX"):
+                    if self.__Token not in ("}", "COMPAT16", BINARY_FILE_TYPE_PE32, BINARY_FILE_TYPE_PIC, BINARY_FILE_TYPE_TE, "FV_IMAGE", "RAW", BINARY_FILE_TYPE_DXE_DEPEX,\
+                               BINARY_FILE_TYPE_UI, "VERSION", BINARY_FILE_TYPE_PEI_DEPEX, BINARY_FILE_TYPE_GUID, BINARY_FILE_TYPE_SMM_DEPEX):
                         FvImageSectionObj.FvFileName = self.__Token
                     else:
                         self.__UndoToken()
@@ -3938,7 +3938,7 @@ class FdfParser:
             if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K", "128K",
                                     "256K", "512K", "1M", "2M", "4M", "8M", "16M"):
                 raise Warning("Incorrect alignment '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
-            if self.__Token == 'Auto' and (not SectionName == 'PE32') and (not SectionName == 'TE'):
+            if self.__Token == 'Auto' and (not SectionName == BINARY_FILE_TYPE_PE32) and (not SectionName == BINARY_FILE_TYPE_TE):
                 raise Warning("Auto alignment can only be used in PE32 or TE section ", self.FileName, self.CurrentLineNumber)
             EfiSectionObj.Alignment = self.__Token
 
@@ -3957,8 +3957,8 @@ class FdfParser:
         if self.__IsToken('|'):
             EfiSectionObj.FileExtension = self.__GetFileExtension()
         elif self.__GetNextToken():
-            if self.__Token not in ("}", "COMPAT16", "PE32", "PIC", "TE", "FV_IMAGE", "RAW", "DXE_DEPEX",\
-                       "UI", "VERSION", "PEI_DEPEX", "GUID", "SMM_DEPEX"):
+            if self.__Token not in ("}", "COMPAT16", BINARY_FILE_TYPE_PE32, BINARY_FILE_TYPE_PIC, BINARY_FILE_TYPE_TE, "FV_IMAGE", "RAW", BINARY_FILE_TYPE_DXE_DEPEX,\
+                       BINARY_FILE_TYPE_UI, "VERSION", BINARY_FILE_TYPE_PEI_DEPEX, BINARY_FILE_TYPE_GUID, BINARY_FILE_TYPE_SMM_DEPEX):
                 
                 if self.__Token.startswith('PCD'):
                     self.__UndoToken()
@@ -3992,7 +3992,7 @@ class FdfParser:
     #
     @staticmethod
     def __RuleSectionCouldBeOptional(SectionType):
-        if SectionType in ("DXE_DEPEX", "UI", "VERSION", "PEI_DEPEX", "RAW", "SMM_DEPEX"):
+        if SectionType in (BINARY_FILE_TYPE_DXE_DEPEX, BINARY_FILE_TYPE_UI, "VERSION", BINARY_FILE_TYPE_PEI_DEPEX, "RAW", BINARY_FILE_TYPE_SMM_DEPEX):
             return True
         else:
             return False
@@ -4022,7 +4022,7 @@ class FdfParser:
     #
     @staticmethod
     def __RuleSectionCouldHaveString(SectionType):
-        if SectionType in ("UI", "VERSION"):
+        if SectionType in (BINARY_FILE_TYPE_UI, "VERSION"):
             return True
         else:
             return False
@@ -4039,32 +4039,32 @@ class FdfParser:
         if SectionType == "COMPAT16":
             if FileType not in ("COMPAT16", "SEC_COMPAT16"):
                 raise Warning("Incorrect section file type '%s'" % FileType, self.FileName, self.CurrentLineNumber)
-        elif SectionType == "PE32":
-            if FileType not in ("PE32", "SEC_PE32"):
+        elif SectionType == BINARY_FILE_TYPE_PE32:
+            if FileType not in (BINARY_FILE_TYPE_PE32, "SEC_PE32"):
                 raise Warning("Incorrect section file type '%s'" % FileType, self.FileName, self.CurrentLineNumber)
-        elif SectionType == "PIC":
-            if FileType not in ("PIC", "PIC"):
+        elif SectionType == BINARY_FILE_TYPE_PIC:
+            if FileType not in (BINARY_FILE_TYPE_PIC, BINARY_FILE_TYPE_PIC):
                 raise Warning("Incorrect section file type '%s'" % FileType, self.FileName, self.CurrentLineNumber)
-        elif SectionType == "TE":
-            if FileType not in ("TE", "SEC_TE"):
+        elif SectionType == BINARY_FILE_TYPE_TE:
+            if FileType not in (BINARY_FILE_TYPE_TE, "SEC_TE"):
                 raise Warning("Incorrect section file type '%s'" % FileType, self.FileName, self.CurrentLineNumber)
         elif SectionType == "RAW":
-            if FileType not in ("BIN", "SEC_BIN", "RAW", "ASL", "ACPI"):
+            if FileType not in (BINARY_FILE_TYPE_BIN, "SEC_BIN", "RAW", "ASL", "ACPI"):
                 raise Warning("Incorrect section file type '%s'" % FileType, self.FileName, self.CurrentLineNumber)
-        elif SectionType == "DXE_DEPEX" or SectionType == "SMM_DEPEX":
-            if FileType not in ("DXE_DEPEX", "SEC_DXE_DEPEX", "SMM_DEPEX"):
+        elif SectionType == BINARY_FILE_TYPE_DXE_DEPEX or SectionType == BINARY_FILE_TYPE_SMM_DEPEX:
+            if FileType not in (BINARY_FILE_TYPE_DXE_DEPEX, "SEC_DXE_DEPEX", BINARY_FILE_TYPE_SMM_DEPEX):
                 raise Warning("Incorrect section file type '%s'" % FileType, self.FileName, self.CurrentLineNumber)
-        elif SectionType == "UI":
-            if FileType not in ("UI", "SEC_UI"):
+        elif SectionType == BINARY_FILE_TYPE_UI:
+            if FileType not in (BINARY_FILE_TYPE_UI, "SEC_UI"):
                 raise Warning("Incorrect section file type '%s'" % FileType, self.FileName, self.CurrentLineNumber)
         elif SectionType == "VERSION":
             if FileType not in ("VERSION", "SEC_VERSION"):
                 raise Warning("Incorrect section file type '%s'" % FileType, self.FileName, self.CurrentLineNumber)
-        elif SectionType == "PEI_DEPEX":
-            if FileType not in ("PEI_DEPEX", "SEC_PEI_DEPEX"):
+        elif SectionType == BINARY_FILE_TYPE_PEI_DEPEX:
+            if FileType not in (BINARY_FILE_TYPE_PEI_DEPEX, "SEC_PEI_DEPEX"):
                 raise Warning("Incorrect section file type '%s'" % FileType, self.FileName, self.CurrentLineNumber)
-        elif SectionType == "GUID":
-            if FileType not in ("PE32", "SEC_GUID"):
+        elif SectionType == BINARY_FILE_TYPE_GUID:
+            if FileType not in (BINARY_FILE_TYPE_PE32, "SEC_GUID"):
                 raise Warning("Incorrect section file type '%s'" % FileType, self.FileName, self.CurrentLineNumber)
 
     ## __GetRuleEncapsulationSection() method
@@ -4501,7 +4501,7 @@ class FdfParser:
 
         FfsFileObj = OptRomFileStatement.OptRomFileStatement()
 
-        if not self.__IsKeyword("EFI") and not self.__IsKeyword("BIN"):
+        if not self.__IsKeyword("EFI") and not self.__IsKeyword(BINARY_FILE_TYPE_BIN):
             raise Warning("expected Binary type (EFI/BIN)", self.FileName, self.CurrentLineNumber)
         FfsFileObj.FileType = self.__Token
 
@@ -4582,7 +4582,7 @@ class FdfParser:
         if FdName.upper() in self.Profile.FdDict:
             FdObj = self.Profile.FdDict[FdName.upper()]
             for elementRegion in FdObj.RegionList:
-                if elementRegion.RegionType == 'FV':
+                if elementRegion.RegionType == BINARY_FILE_TYPE_FV:
                     for elementRegionData in elementRegion.RegionDataList:
                         if elementRegionData.endswith(".fv"):
                             continue
diff --git a/BaseTools/Source/Python/GenFds/Ffs.py b/BaseTools/Source/Python/GenFds/Ffs.py
index f6a7f4b007f9..44ad01cb7354 100644
--- a/BaseTools/Source/Python/GenFds/Ffs.py
+++ b/BaseTools/Source/Python/GenFds/Ffs.py
@@ -42,12 +42,12 @@ class Ffs(FDClassObject):
     
     # mapping between section type in FDF and file suffix
     SectionSuffix = {
-        'PE32'                 : '.pe32',
-        'PIC'                  : '.pic',
-        'TE'                   : '.te',
-        'DXE_DEPEX'            : '.dpx',
+        BINARY_FILE_TYPE_PE32                 : '.pe32',
+        BINARY_FILE_TYPE_PIC                  : '.pic',
+        BINARY_FILE_TYPE_TE                   : '.te',
+        BINARY_FILE_TYPE_DXE_DEPEX            : '.dpx',
         'VERSION'              : '.ver',
-        'UI'                   : '.ui',
+        BINARY_FILE_TYPE_UI                   : '.ui',
         'COMPAT16'             : '.com16',
         'RAW'                  : '.raw',
         'FREEFORM_SUBTYPE_GUID': '.guid',
@@ -55,8 +55,8 @@ class Ffs(FDClassObject):
         'FV_IMAGE'             : 'fv.sec',
         'COMPRESS'             : '.com',
         'GUIDED'               : '.guided',
-        'PEI_DEPEX'            : '.dpx',
-        'SMM_DEPEX'            : '.dpx'
+        BINARY_FILE_TYPE_PEI_DEPEX            : '.dpx',
+        BINARY_FILE_TYPE_SMM_DEPEX            : '.dpx'
     }
     
     ## The constructor
diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
index 8893fcbda1fc..b92fa4d8033c 100644
--- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py
+++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
@@ -381,7 +381,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
         #
         # Only patch file if FileType is PE32 or ModuleType is USER_DEFINED
         #  
-        if FileType != 'PE32' and self.ModuleType != SUP_MODULE_USER_DEFINED:
+        if FileType != BINARY_FILE_TYPE_PE32 and self.ModuleType != SUP_MODULE_USER_DEFINED:
             return EfiFile
 
         #
@@ -739,13 +739,13 @@ class FfsInfStatement(FfsInfStatementClassObject):
         # Convert Fv Section Type for PI1.1 SMM driver.
         #
         if self.ModuleType == SUP_MODULE_DXE_SMM_DRIVER and int(self.PiSpecVersion, 16) >= 0x0001000A:
-            if SectionType == 'DXE_DEPEX':
-                SectionType = 'SMM_DEPEX'
+            if SectionType == BINARY_FILE_TYPE_DXE_DEPEX:
+                SectionType = BINARY_FILE_TYPE_SMM_DEPEX
         #
         # Framework SMM Driver has no SMM_DEPEX section type
         #
         if self.ModuleType == SUP_MODULE_DXE_SMM_DRIVER and int(self.PiSpecVersion, 16) < 0x0001000A:
-            if SectionType == 'SMM_DEPEX':
+            if SectionType == BINARY_FILE_TYPE_SMM_DEPEX:
                 EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "Framework SMM module doesn't support SMM_DEPEX section type", File=self.InfFileName)
         NoStrip = True
         if self.ModuleType in (SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM):
@@ -767,7 +767,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
                 File = GenFdsGlobalVariable.MacroExtend(File, Dict, self.CurrentArch)
 
                 #Get PE Section alignment when align is set to AUTO
-                if self.Alignment == 'Auto' and (SectionType == 'PE32' or SectionType == 'TE'):
+                if self.Alignment == 'Auto' and (SectionType == BINARY_FILE_TYPE_PE32 or SectionType == BINARY_FILE_TYPE_TE):
                     ImageObj = PeImageClass (File)
                     if ImageObj.SectionAlignment < 0x400:
                         self.Alignment = str (ImageObj.SectionAlignment)
@@ -790,7 +790,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
                         )
                     File = StrippedFile
 
-                if SectionType == 'TE':
+                if SectionType == BINARY_FILE_TYPE_TE:
                     TeFile = os.path.join( self.OutputPath, self.ModuleGuid + 'Te.raw')
                     GenFdsGlobalVariable.GenerateFirmwareImage(
                             TeFile,
@@ -809,7 +809,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
             GenSecInputFile = GenFdsGlobalVariable.MacroExtend(GenSecInputFile, Dict, self.CurrentArch)
 
             #Get PE Section alignment when align is set to AUTO
-            if self.Alignment == 'Auto' and (SectionType == 'PE32' or SectionType == 'TE'):
+            if self.Alignment == 'Auto' and (SectionType == BINARY_FILE_TYPE_PE32 or SectionType == BINARY_FILE_TYPE_TE):
                 ImageObj = PeImageClass (GenSecInputFile)
                 if ImageObj.SectionAlignment < 0x400:
                     self.Alignment = str (ImageObj.SectionAlignment)
@@ -833,7 +833,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
                     )
                 GenSecInputFile = StrippedFile
 
-            if SectionType == 'TE':
+            if SectionType == BINARY_FILE_TYPE_TE:
                 TeFile = os.path.join( self.OutputPath, self.ModuleGuid + 'Te.raw')
                 GenFdsGlobalVariable.GenerateFirmwareImage(
                         TeFile,
@@ -942,13 +942,13 @@ class FfsInfStatement(FfsInfStatementClassObject):
             # Convert Fv Section Type for PI1.1 SMM driver.
             #
             if self.ModuleType == SUP_MODULE_DXE_SMM_DRIVER and int(self.PiSpecVersion, 16) >= 0x0001000A:
-                if Sect.SectionType == 'DXE_DEPEX':
-                    Sect.SectionType = 'SMM_DEPEX'
+                if Sect.SectionType == BINARY_FILE_TYPE_DXE_DEPEX:
+                    Sect.SectionType = BINARY_FILE_TYPE_SMM_DEPEX
             #
             # Framework SMM Driver has no SMM_DEPEX section type
             #
             if self.ModuleType == SUP_MODULE_DXE_SMM_DRIVER and int(self.PiSpecVersion, 16) < 0x0001000A:
-                if Sect.SectionType == 'SMM_DEPEX':
+                if Sect.SectionType == BINARY_FILE_TYPE_SMM_DEPEX:
                     EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "Framework SMM module doesn't support SMM_DEPEX section type", File=self.InfFileName)
             #
             # process the inside FvImage from FvSection or GuidSection
diff --git a/BaseTools/Source/Python/GenFds/Fv.py b/BaseTools/Source/Python/GenFds/Fv.py
index 71bcd4c72170..024081734a2b 100644
--- a/BaseTools/Source/Python/GenFds/Fv.py
+++ b/BaseTools/Source/Python/GenFds/Fv.py
@@ -80,7 +80,7 @@ class FV (FvClassObject):
         if self.CapsuleName is not None:
             for FdObj in GenFdsGlobalVariable.FdfParser.Profile.FdDict.values():
                 for RegionObj in FdObj.RegionList:
-                    if RegionObj.RegionType == 'FV':
+                    if RegionObj.RegionType == BINARY_FILE_TYPE_FV:
                         for RegionData in RegionObj.RegionDataList:
                             if RegionData.endswith(".fv"):
                                 continue
@@ -236,7 +236,7 @@ class FV (FvClassObject):
 
         for FdObj in GenFdsGlobalVariable.FdfParser.Profile.FdDict.values():
             for RegionObj in FdObj.RegionList:
-                if RegionObj.RegionType != 'FV':
+                if RegionObj.RegionType != BINARY_FILE_TYPE_FV:
                     continue
                 for RegionData in RegionObj.RegionDataList:
                     #
diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Python/GenFds/GenFds.py
index 54c7d828305f..8bedd9f74411 100644
--- a/BaseTools/Source/Python/GenFds/GenFds.py
+++ b/BaseTools/Source/Python/GenFds/GenFds.py
@@ -315,7 +315,7 @@ def main():
                 for Fd in FdfParserObj.Profile.FdDict:
                     FdObj = FdfParserObj.Profile.FdDict[Fd]
                     for RegionObj in FdObj.RegionList:
-                        if RegionObj.RegionType != 'FV':
+                        if RegionObj.RegionType != BINARY_FILE_TYPE_FV:
                             continue
                         for RegionData in RegionObj.RegionDataList:
                             if FvObj.UiFvName.upper() == RegionData.upper():
@@ -405,7 +405,7 @@ def FindExtendTool(KeyStringList, CurrentArchList, NameGuid):
                   KeyList[1] + \
                   '_' + \
                   KeyList[2]
-            if Key in KeyStringList and KeyList[4] == 'GUID':
+            if Key in KeyStringList and KeyList[4] == BINARY_FILE_TYPE_GUID:
                 ToolPathKey   = Key + '_' + KeyList[3] + '_PATH'
                 ToolOptionKey = Key + '_' + KeyList[3] + '_FLAGS'
                 ToolPath = ToolDefinition.get(ToolPathKey)
@@ -447,7 +447,7 @@ def FindExtendTool(KeyStringList, CurrentArchList, NameGuid):
                 if NameGuid == BuildOption[Op]:
                     KeyList = Op.split('_')
                     Key = KeyList[0] + '_' + KeyList[1] +'_' + KeyList[2]
-                    if Key in KeyStringList and KeyList[4] == 'GUID':
+                    if Key in KeyStringList and KeyList[4] == BINARY_FILE_TYPE_GUID:
                         ToolPathKey   = Key + '_' + KeyList[3] + '_PATH'
                         ToolOptionKey = Key + '_' + KeyList[3] + '_FLAGS'
         if ToolPathKey in BuildOption:
@@ -589,7 +589,7 @@ class GenFds :
         if FdObj is None:
             for ElementFd in GenFdsGlobalVariable.FdfParser.Profile.FdDict.values():
                 for ElementRegion in ElementFd.RegionList:
-                    if ElementRegion.RegionType == 'FV':
+                    if ElementRegion.RegionType == BINARY_FILE_TYPE_FV:
                         for ElementRegionData in ElementRegion.RegionDataList:
                             if ElementRegionData is not None and ElementRegionData.upper() == FvObj.UiFvName:
                                 if FvObj.BlockSizeList != []:
@@ -601,7 +601,7 @@ class GenFds :
             return DefaultBlockSize
         else:
             for ElementRegion in FdObj.RegionList:
-                    if ElementRegion.RegionType == 'FV':
+                    if ElementRegion.RegionType == BINARY_FILE_TYPE_FV:
                         for ElementRegionData in ElementRegion.RegionDataList:
                             if ElementRegionData is not None and ElementRegionData.upper() == FvObj.UiFvName:
                                 if FvObj.BlockSizeList != []:
diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
index e692e4e98504..878b13d13c2d 100644
--- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
+++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
@@ -288,7 +288,7 @@ class GenFdsGlobalVariable:
 #        GenFdsGlobalVariable.OutputDirDict = OutputDir
         GenFdsGlobalVariable.FdfParser = FdfParser
         GenFdsGlobalVariable.WorkSpace = WorkSpace
-        GenFdsGlobalVariable.FvDir = os.path.join(GenFdsGlobalVariable.OutputDirDict[ArchList[0]], 'FV')
+        GenFdsGlobalVariable.FvDir = os.path.join(GenFdsGlobalVariable.OutputDirDict[ArchList[0]], DataType.BINARY_FILE_TYPE_FV)
         if not os.path.exists(GenFdsGlobalVariable.FvDir) :
             os.makedirs(GenFdsGlobalVariable.FvDir)
         GenFdsGlobalVariable.FfsDir = os.path.join(GenFdsGlobalVariable.FvDir, 'Ffs')
@@ -349,7 +349,7 @@ class GenFdsGlobalVariable:
             GenFdsGlobalVariable.PlatformName = WorkSpace.Db.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch,
                                                                       GlobalData.gGlobalDefines['TARGET'],
                                                                       GlobalData.gGlobalDefines['TOOLCHAIN']].PlatformName
-        GenFdsGlobalVariable.FvDir = os.path.join(GenFdsGlobalVariable.OutputDirDict[ArchList[0]], 'FV')
+        GenFdsGlobalVariable.FvDir = os.path.join(GenFdsGlobalVariable.OutputDirDict[ArchList[0]], DataType.BINARY_FILE_TYPE_FV)
         if not os.path.exists(GenFdsGlobalVariable.FvDir):
             os.makedirs(GenFdsGlobalVariable.FvDir)
         GenFdsGlobalVariable.FfsDir = os.path.join(GenFdsGlobalVariable.FvDir, 'Ffs')
diff --git a/BaseTools/Source/Python/GenFds/OptRomInfStatement.py b/BaseTools/Source/Python/GenFds/OptRomInfStatement.py
index 8f8761b20589..a865ac4436d5 100644
--- a/BaseTools/Source/Python/GenFds/OptRomInfStatement.py
+++ b/BaseTools/Source/Python/GenFds/OptRomInfStatement.py
@@ -141,7 +141,7 @@ class OptRomInfStatement (FfsInfStatement):
 
         OutputFileList = []
         for Sect in Rule.SectionList:
-            if Sect.SectionType == 'PE32':
+            if Sect.SectionType == BINARY_FILE_TYPE_PE32:
                 if Sect.FileName is not None:
                     GenSecInputFile = self.__ExtendMacro__(Sect.FileName)
                     OutputFileList.append(GenSecInputFile)
diff --git a/BaseTools/Source/Python/GenFds/Region.py b/BaseTools/Source/Python/GenFds/Region.py
index 44f122a71216..9d632b6321e2 100644
--- a/BaseTools/Source/Python/GenFds/Region.py
+++ b/BaseTools/Source/Python/GenFds/Region.py
@@ -26,6 +26,7 @@ from Common import EdkLogger
 from Common.BuildToolError import *
 from Common.LongFilePathSupport import OpenLongFilePath as open
 from Common.MultipleWorkspace import MultipleWorkspace as mws
+from Common.DataType import BINARY_FILE_TYPE_FV
 
 ## generate Region
 #
@@ -80,10 +81,10 @@ class Region(RegionClassObject):
             GenFdsGlobalVariable.InfLogger('\nGenerate Region at Offset 0x%X' % self.Offset)
             GenFdsGlobalVariable.InfLogger("   Region Size = 0x%X" % Size)
         GenFdsGlobalVariable.SharpCounter = 0
-        if Flag and (self.RegionType != 'FV'):
+        if Flag and (self.RegionType != BINARY_FILE_TYPE_FV):
             return
 
-        if self.RegionType == 'FV':
+        if self.RegionType == BINARY_FILE_TYPE_FV:
             #
             # Get Fv from FvDict
             #
diff --git a/BaseTools/Source/Python/GenFds/Section.py b/BaseTools/Source/Python/GenFds/Section.py
index 4b368b3ada9d..5895998158b6 100644
--- a/BaseTools/Source/Python/GenFds/Section.py
+++ b/BaseTools/Source/Python/GenFds/Section.py
@@ -20,7 +20,7 @@ from GenFdsGlobalVariable import GenFdsGlobalVariable
 import Common.LongFilePathOs as os, glob
 from Common import EdkLogger
 from Common.BuildToolError import *
-from Common.DataType import TAB_ARCH_COMMON
+from Common.DataType import *
 
 ## section base class
 #
@@ -29,37 +29,37 @@ class Section (SectionClassObject):
     SectionType = {
         'RAW'       : 'EFI_SECTION_RAW',
         'FREEFORM'  : 'EFI_SECTION_FREEFORM_SUBTYPE_GUID',
-        'PE32'      : 'EFI_SECTION_PE32',
-        'PIC'       : 'EFI_SECTION_PIC',
-        'TE'        : 'EFI_SECTION_TE',
+        BINARY_FILE_TYPE_PE32      : 'EFI_SECTION_PE32',
+        BINARY_FILE_TYPE_PIC       : 'EFI_SECTION_PIC',
+        BINARY_FILE_TYPE_TE        : 'EFI_SECTION_TE',
         'FV_IMAGE'  : 'EFI_SECTION_FIRMWARE_VOLUME_IMAGE',
-        'DXE_DEPEX' : 'EFI_SECTION_DXE_DEPEX',
-        'PEI_DEPEX' : 'EFI_SECTION_PEI_DEPEX',
+        BINARY_FILE_TYPE_DXE_DEPEX : 'EFI_SECTION_DXE_DEPEX',
+        BINARY_FILE_TYPE_PEI_DEPEX : 'EFI_SECTION_PEI_DEPEX',
         'GUIDED'    : 'EFI_SECTION_GUID_DEFINED',
         'COMPRESS'  : 'EFI_SECTION_COMPRESSION',
-        'UI'        : 'EFI_SECTION_USER_INTERFACE',
-        'SMM_DEPEX' : 'EFI_SECTION_SMM_DEPEX'
+        BINARY_FILE_TYPE_UI        : 'EFI_SECTION_USER_INTERFACE',
+        BINARY_FILE_TYPE_SMM_DEPEX : 'EFI_SECTION_SMM_DEPEX'
     }
 
     BinFileType = {
-        'GUID'          : '.guid',
+        BINARY_FILE_TYPE_GUID          : '.guid',
         'ACPI'          : '.acpi',
         'ASL'           : '.asl' ,
-        'UEFI_APP'      : '.app',
-        'LIB'           : '.lib',
-        'PE32'          : '.pe32',
-        'PIC'           : '.pic',
-        'PEI_DEPEX'     : '.depex',
+        BINARY_FILE_TYPE_UEFI_APP      : '.app',
+        BINARY_FILE_TYPE_LIB           : '.lib',
+        BINARY_FILE_TYPE_PE32          : '.pe32',
+        BINARY_FILE_TYPE_PIC           : '.pic',
+        BINARY_FILE_TYPE_PEI_DEPEX     : '.depex',
         'SEC_PEI_DEPEX' : '.depex',
-        'TE'            : '.te',
-        'UNI_VER'       : '.ver',
-        'VER'           : '.ver',
-        'UNI_UI'        : '.ui',
-        'UI'            : '.ui',
-        'BIN'           : '.bin',
+        BINARY_FILE_TYPE_TE            : '.te',
+        BINARY_FILE_TYPE_UNI_VER       : '.ver',
+        BINARY_FILE_TYPE_VER           : '.ver',
+        BINARY_FILE_TYPE_UNI_UI        : '.ui',
+        BINARY_FILE_TYPE_UI            : '.ui',
+        BINARY_FILE_TYPE_BIN           : '.bin',
         'RAW'           : '.raw',
         'COMPAT16'      : '.comp16',
-        'FV'            : '.fv'
+        BINARY_FILE_TYPE_FV            : '.fv'
     }
 
     SectFileType = {
@@ -128,8 +128,8 @@ class Section (SectionClassObject):
             for File in FfsInf.BinFileList:
                 if File.Arch == TAB_ARCH_COMMON or FfsInf.CurrentArch == File.Arch:
                     if File.Type == FileType or (int(FfsInf.PiSpecVersion, 16) >= 0x0001000A \
-                                                 and FileType == 'DXE_DPEX'and File.Type == 'SMM_DEPEX') \
-                                                 or (FileType == 'TE'and File.Type == 'PE32'):
+                                                 and FileType == 'DXE_DPEX' and File.Type == BINARY_FILE_TYPE_SMM_DEPEX) \
+                                                 or (FileType == BINARY_FILE_TYPE_TE and File.Type == BINARY_FILE_TYPE_PE32):
                         if '*' in FfsInf.TargetOverrideList or File.Target == '*' or File.Target in FfsInf.TargetOverrideList or FfsInf.TargetOverrideList == []:
                             FileList.append(FfsInf.PatchEfiFile(File.Path, File.Type))
                         else:
diff --git a/BaseTools/Source/Python/GenFds/UiSection.py b/BaseTools/Source/Python/GenFds/UiSection.py
index 084f761e1285..31d3edebb4ef 100644
--- a/BaseTools/Source/Python/GenFds/UiSection.py
+++ b/BaseTools/Source/Python/GenFds/UiSection.py
@@ -58,7 +58,7 @@ class UiSection (UiSectionClassObject):
             self.StringData = FfsInf.__ExtendMacro__(self.StringData)
             self.FileName = FfsInf.__ExtendMacro__(self.FileName)
 
-        OutputFile = os.path.join(OutputPath, ModuleName + SUP_MODULE_SEC + SecNum + Ffs.SectionSuffix.get('UI'))
+        OutputFile = os.path.join(OutputPath, ModuleName + SUP_MODULE_SEC + SecNum + Ffs.SectionSuffix.get(BINARY_FILE_TYPE_UI))
 
         if self.StringData is not None :
             NameString = self.StringData
diff --git a/BaseTools/Source/Python/Trim/Trim.py b/BaseTools/Source/Python/Trim/Trim.py
index 3eb7fa39209d..3afe759667ac 100644
--- a/BaseTools/Source/Python/Trim/Trim.py
+++ b/BaseTools/Source/Python/Trim/Trim.py
@@ -303,7 +303,7 @@ def TrimPreprocessedVfr(Source, Target):
             FoundTypedef = False
             TypedefEnd = Index
             # keep all "typedef struct" except to GUID, EFI_PLABEL and PAL_CALL_RETURN
-            if Line.strip("} ;\r\n") in ["GUID", "EFI_PLABEL", "PAL_CALL_RETURN"]:
+            if Line.strip("} ;\r\n") in [BINARY_FILE_TYPE_GUID, "EFI_PLABEL", "PAL_CALL_RETURN"]:
                 for i in range(TypedefStart, TypedefEnd+1):
                     Lines[i] = "\n"
 
diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py
index 373441521723..6943fab4e5c8 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -1506,7 +1506,7 @@ class DscBuildData(PlatformBuildClassObject):
         def get_length(value):
             Value = value.strip()
             if len(value) > 1:
-                if Value.startswith('GUID') and Value.endswith(')'):
+                if Value.startswith(BINARY_FILE_TYPE_GUID) and Value.endswith(')'):
                     return 16
                 if Value.startswith('L"') and Value.endswith('"'):
                     return len(Value[2:-1])
diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py b/BaseTools/Source/Python/Workspace/InfBuildData.py
index 157f7a2d2de8..cf5e1df3a523 100644
--- a/BaseTools/Source/Python/Workspace/InfBuildData.py
+++ b/BaseTools/Source/Python/Workspace/InfBuildData.py
@@ -71,7 +71,7 @@ class InfBuildData(ModuleBuildClassObject):
     # dict used to convert old tool name used in [nmake] section to new ones
     _TOOL_CODE_ = {
         "C"         :   "CC",
-        "LIB"       :   "SLINK",
+        BINARY_FILE_TYPE_LIB       :   "SLINK",
         "LINK"      :   "DLINK",
     }
 
diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Source/Python/build/BuildReport.py
index c8948b5cfbd9..f551c3ac8f91 100644
--- a/BaseTools/Source/Python/build/BuildReport.py
+++ b/BaseTools/Source/Python/build/BuildReport.py
@@ -208,7 +208,7 @@ def FindIncludeFiles(Source, IncludePathList, IncludeFiles):
             FileName = "Protocol/%(Key)s/%(Key)s.h" % {"Key" : Key}
         elif "PPI" in Type:
             FileName = "Ppi/%(Key)s/%(Key)s.h" % {"Key" : Key}
-        elif "GUID" in Type:
+        elif BINARY_FILE_TYPE_GUID in Type:
             FileName = "Guid/%(Key)s/%(Key)s.h" % {"Key" : Key}
         else:
             continue
@@ -1410,7 +1410,7 @@ class PredictionReport(object):
         if Wa.FdfProfile:
             for Fd in Wa.FdfProfile.FdDict:
                 for FdRegion in Wa.FdfProfile.FdDict[Fd].RegionList:
-                    if FdRegion.RegionType != "FV":
+                    if FdRegion.RegionType != BINARY_FILE_TYPE_FV:
                         continue
                     for FvName in FdRegion.RegionDataList:
                         if FvName in self._FvList:
@@ -1686,7 +1686,7 @@ class FdRegionReport(object):
         # If the input FdRegion is not a firmware volume,
         # we are done.
         #
-        if self.Type != "FV":
+        if self.Type != BINARY_FILE_TYPE_FV:
             return
 
         #
@@ -1780,7 +1780,7 @@ class FdRegionReport(object):
         FileWrite(File, "Type:               %s" % Type)
         FileWrite(File, "Base Address:       0x%X" % BaseAddress)
 
-        if self.Type == "FV":
+        if self.Type == BINARY_FILE_TYPE_FV:
             FvTotalSize = 0
             FvTakenSize = 0
             FvFreeSize  = 0
@@ -1843,7 +1843,7 @@ class FdRegionReport(object):
         if (len(self.FvList) > 0):
             for FvItem in self.FvList:
                 Info = self.FvInfo[FvItem]
-                self._GenerateReport(File, Info[0], "FV", Info[1], Info[2], FvItem)
+                self._GenerateReport(File, Info[0], BINARY_FILE_TYPE_FV, Info[1], Info[2], FvItem)
         else:
             self._GenerateReport(File, "FD Region", self.Type, self.BaseAddress, self.Size)
 
@@ -1869,7 +1869,7 @@ class FdReport(object):
         self.BaseAddress = Fd.BaseAddress
         self.Size = Fd.Size
         self.FdRegionList = [FdRegionReport(FdRegion, Wa) for FdRegion in Fd.RegionList]
-        self.FvPath = os.path.join(Wa.BuildDir, "FV")
+        self.FvPath = os.path.join(Wa.BuildDir, BINARY_FILE_TYPE_FV)
         self.VpdFilePath = os.path.join(self.FvPath, "%s.map" % Wa.Platform.VpdToolGuid)
         self.VPDBaseAddress = 0
         self.VPDSize = 0
-- 
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* Re: [PATCH v1 16/27] BaseTools: Replace EDK Component strings with predefined constant
  2018-04-20 15:51 ` [PATCH v1 16/27] BaseTools: Replace EDK Component strings with predefined constant Jaben Carsey
@ 2018-04-24  7:42   ` Zhu, Yonghong
  2018-04-24 14:13     ` Carsey, Jaben
  0 siblings, 1 reply; 56+ messages in thread
From: Zhu, Yonghong @ 2018-04-24  7:42 UTC (permalink / raw)
  To: Carsey, Jaben, edk2-devel@lists.01.org; +Cc: Gao, Liming, Zhu, Yonghong

Hi Jaben,

For build.py (-Y option) and BuildReport.py, use EDK_COMPONENT_TYPE_LIBRARY to replace "LIBRARY" may be confusion.  One is component type, another is report type though they use same keyword.
If we really want to do this replacement, how about use another constant name ? besides, whether we need cover the other report type, not only the "LIBRARY" ?

Best Regards,
Zhu Yonghong


-----Original Message-----
From: Carsey, Jaben 
Sent: Friday, April 20, 2018 11:52 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming <liming.gao@intel.com>; Zhu, Yonghong <yonghong.zhu@intel.com>
Subject: [PATCH v1 16/27] BaseTools: Replace EDK Component strings with predefined constant

EDK_COMPONENT_TYPE_LIBRARY was 'LIBRARY'
EDK_COMPONENT_TYPE_SECURITY_CORE was 'SECURITY_CORE'
EDK_COMPONENT_TYPE_COMBINED_PEIM_DRIVER was 'COMBINED_PEIM_DRIVER'
EDK_COMPONENT_TYPE_PIC_PEIM was 'PIC_PEIM'
EDK_COMPONENT_TYPE_RELOCATABLE_PEIM was 'RELOCATABLE_PEIM'
EDK_COMPONENT_TYPE_BS_DRIVER was 'BS_DRIVER'
EDK_COMPONENT_TYPE_RT_DRIVER was 'RT_DRIVER'
EDK_COMPONENT_TYPE_SAL_RT_DRIVER was 'SAL_RT_DRIVER'
EDK_COMPONENT_TYPE_APPLICATION was 'APPLICATION'

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>
---
 BaseTools/Source/Python/Common/DataType.py        | 28 ++++++++++----------
 BaseTools/Source/Python/GenFds/FdfParser.py       |  6 ++---
 BaseTools/Source/Python/GenFds/Ffs.py             |  2 +-
 BaseTools/Source/Python/Workspace/InfBuildData.py |  2 +-
 BaseTools/Source/Python/build/BuildReport.py      |  6 ++---
 BaseTools/Source/Python/build/build.py            |  8 +++---
 6 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/BaseTools/Source/Python/Common/DataType.py b/BaseTools/Source/Python/Common/DataType.py
index ab9acb417331..74ed711abc52 100644
--- a/BaseTools/Source/Python/Common/DataType.py
+++ b/BaseTools/Source/Python/Common/DataType.py
@@ -80,7 +80,7 @@ SUP_MODULE_LIST_STRING = TAB_VALUE_SPLIT.join(SUP_MODULE_LIST)
 SUP_MODULE_SET_PEI = {SUP_MODULE_PEIM, SUP_MODULE_PEI_CORE}
 
 EDK_COMPONENT_TYPE_LIBRARY = 'LIBRARY'
-EDK_COMPONENT_TYPE_SECUARITY_CORE = 'SECUARITY_CORE'
+EDK_COMPONENT_TYPE_SECURITY_CORE = 'SECURITY_CORE'
 EDK_COMPONENT_TYPE_PEI_CORE = SUP_MODULE_PEI_CORE  EDK_COMPONENT_TYPE_COMBINED_PEIM_DRIVER = 'COMBINED_PEIM_DRIVER'
 EDK_COMPONENT_TYPE_PIC_PEIM = 'PIC_PEIM'
@@ -93,18 +93,18 @@ 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,
+    EDK_COMPONENT_TYPE_LIBRARY               :   SUP_MODULE_BASE,
+    EDK_COMPONENT_TYPE_SECURITY_CORE         :   SUP_MODULE_SEC,
+    EDK_COMPONENT_TYPE_PEI_CORE              :   SUP_MODULE_PEI_CORE,
+    EDK_COMPONENT_TYPE_COMBINED_PEIM_DRIVER  :   SUP_MODULE_PEIM,
+    EDK_COMPONENT_TYPE_PIC_PEIM              :   SUP_MODULE_PEIM,
+    EDK_COMPONENT_TYPE_RELOCATABLE_PEIM      :   SUP_MODULE_PEIM,
+    "PE32_PEIM"                              :   SUP_MODULE_PEIM,
+    EDK_COMPONENT_TYPE_BS_DRIVER             :   SUP_MODULE_DXE_DRIVER,
+    EDK_COMPONENT_TYPE_RT_DRIVER             :   SUP_MODULE_DXE_RUNTIME_DRIVER,
+    EDK_COMPONENT_TYPE_SAL_RT_DRIVER         :   SUP_MODULE_DXE_SAL_DRIVER,
+    EDK_COMPONENT_TYPE_APPLICATION           :   SUP_MODULE_UEFI_APPLICATION,
+    "LOGO"                                   :   SUP_MODULE_BASE,
 }
 
 BINARY_FILE_TYPE_FW = 'FW'
@@ -125,7 +125,7 @@ BINARY_FILE_TYPE_UI = 'UI'
 BINARY_FILE_TYPE_BIN = 'BIN'
 BINARY_FILE_TYPE_FV = 'FV'
 
-PLATFORM_COMPONENT_TYPE_LIBRARY = 'LIBRARY'
+PLATFORM_COMPONENT_TYPE_LIBRARY = EDK_COMPONENT_TYPE_LIBRARY
 PLATFORM_COMPONENT_TYPE_LIBRARY_CLASS = 'LIBRARY_CLASS'
 PLATFORM_COMPONENT_TYPE_MODULE = 'MODULE'
 
diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py
index 4ec114a81883..e117a3717d42 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -3637,8 +3637,8 @@ class FdfParser:
                              SUP_MODULE_DXE_DRIVER, SUP_MODULE_DXE_SAL_DRIVER, \
                              SUP_MODULE_DXE_SMM_DRIVER, SUP_MODULE_DXE_RUNTIME_DRIVER, \
                              SUP_MODULE_UEFI_DRIVER, SUP_MODULE_UEFI_APPLICATION, SUP_MODULE_USER_DEFINED, "DEFAULT", SUP_MODULE_BASE, \
-                             "SECURITY_CORE", "COMBINED_PEIM_DRIVER", "PIC_PEIM", "RELOCATABLE_PEIM", \
-                                        "PE32_PEIM", "BS_DRIVER", "RT_DRIVER", "SAL_RT_DRIVER", "APPLICATION", "ACPITABLE", SUP_MODULE_SMM_CORE, SUP_MODULE_MM_STANDALONE, SUP_MODULE_MM_CORE_STANDALONE):
+                             EDK_COMPONENT_TYPE_SECURITY_CORE, EDK_COMPONENT_TYPE_COMBINED_PEIM_DRIVER, EDK_COMPONENT_TYPE_PIC_PEIM, EDK_COMPONENT_TYPE_RELOCATABLE_PEIM, \
+                                        "PE32_PEIM", EDK_COMPONENT_TYPE_BS_DRIVER, EDK_COMPONENT_TYPE_RT_DRIVER, EDK_COMPONENT_TYPE_SAL_RT_DRIVER, EDK_COMPONENT_TYPE_APPLICATION, "ACPITABLE", SUP_MODULE_SMM_CORE, SUP_MODULE_MM_STANDALONE, SUP_MODULE_MM_CORE_STANDALONE):
             raise Warning("Unknown Module type '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
         return self.__Token
 
@@ -3681,7 +3681,7 @@ class FdfParser:
 
         Type = self.__Token.strip().upper()
         if Type not in ("RAW", "FREEFORM", SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM,\
-                             "PEI_DXE_COMBO", "DRIVER", SUP_MODULE_DXE_CORE, "APPLICATION", "FV_IMAGE", "SMM", SUP_MODULE_SMM_CORE, SUP_MODULE_MM_STANDALONE, SUP_MODULE_MM_CORE_STANDALONE):
+                             "PEI_DXE_COMBO", "DRIVER", SUP_MODULE_DXE_CORE, EDK_COMPONENT_TYPE_APPLICATION, "FV_IMAGE", "SMM", SUP_MODULE_SMM_CORE, SUP_MODULE_MM_STANDALONE, SUP_MODULE_MM_CORE_STANDALONE):
             raise Warning("Unknown FV type '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
 
         if not self.__IsToken("="):
diff --git a/BaseTools/Source/Python/GenFds/Ffs.py b/BaseTools/Source/Python/GenFds/Ffs.py
index fc760ae8beda..f15d2330ce58 100644
--- a/BaseTools/Source/Python/GenFds/Ffs.py
+++ b/BaseTools/Source/Python/GenFds/Ffs.py
@@ -48,7 +48,7 @@ class Ffs(FDClassObject):
         SUP_MODULE_DXE_CORE          : 'EFI_FV_FILETYPE_DXE_CORE',
         'FREEFORM'          : 'EFI_FV_FILETYPE_FREEFORM',
         'DRIVER'            : 'EFI_FV_FILETYPE_DRIVER',
-        'APPLICATION'       : 'EFI_FV_FILETYPE_APPLICATION',
+        EDK_COMPONENT_TYPE_APPLICATION       : 'EFI_FV_FILETYPE_APPLICATION',
         'FV_IMAGE'          : 'EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE',
         'RAW'               : 'EFI_FV_FILETYPE_RAW',
         'PEI_DXE_COMBO'     : 'EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER',
diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py b/BaseTools/Source/Python/Workspace/InfBuildData.py
index d64a281a98f7..27ef163eb40c 100644
--- a/BaseTools/Source/Python/Workspace/InfBuildData.py
+++ b/BaseTools/Source/Python/Workspace/InfBuildData.py
@@ -344,7 +344,7 @@ class InfBuildData(ModuleBuildClassObject):
             self._BuildType = self._ComponentType.upper()
             if self._ComponentType in COMPONENT_TO_MODULE_MAP_DICT:
                 self._ModuleType = COMPONENT_TO_MODULE_MAP_DICT[self._ComponentType]
-            if self._ComponentType == 'LIBRARY':
+            if self._ComponentType == EDK_COMPONENT_TYPE_LIBRARY:
                 self._LibraryClass = [LibraryClassObject(self._BaseName, SUP_MODULE_LIST)]
             # make use some [nmake] section macros
             Macros = self._Macros
diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Source/Python/build/BuildReport.py
index 5846c2870d2e..02e01a1fa2ab 100644
--- a/BaseTools/Source/Python/build/BuildReport.py
+++ b/BaseTools/Source/Python/build/BuildReport.py
@@ -599,7 +599,7 @@ class ModuleReport(object):
                 self.ModulePcdSet.setdefault((Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Pcd.Type), (Pcd.InfDefaultValue, Pcd.DefaultValue))
 
         self.LibraryReport = None
-        if "LIBRARY" in ReportType:
+        if EDK_COMPONENT_TYPE_LIBRARY in ReportType:
             self.LibraryReport = LibraryReport(M)
 
         self.DepexReport = None
@@ -702,7 +702,7 @@ class ModuleReport(object):
         if "PCD" in ReportType:
             GlobalPcdReport.GenerateReport(File, self.ModulePcdSet)
 
-        if "LIBRARY" in ReportType:
+        if EDK_COMPONENT_TYPE_LIBRARY in ReportType:
             self.LibraryReport.GenerateReport(File)
 
         if "DEPEX" in ReportType:
@@ -2097,7 +2097,7 @@ class BuildReport(object):
                     if ReportTypeItem not in self.ReportType:
                         self.ReportType.append(ReportTypeItem)
             else:
-                self.ReportType = ["PCD", "LIBRARY", "BUILD_FLAGS", "DEPEX", "HASH", "FLASH", "FIXED_ADDRESS"]
+                self.ReportType = ["PCD", EDK_COMPONENT_TYPE_LIBRARY, 
+ "BUILD_FLAGS", "DEPEX", "HASH", "FLASH", "FIXED_ADDRESS"]
     ##
     # Adds platform report to the list
     #
diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/build/build.py
index 81d59dd3eedf..29ad0c7228c7 100644
--- a/BaseTools/Source/Python/build/build.py
+++ b/BaseTools/Source/Python/build/build.py
@@ -1587,13 +1587,13 @@ class Build():
                     if not ImageClass.IsValid:
                         EdkLogger.error("build", FILE_PARSE_FAILURE, ExtraData=ImageClass.ErrorInfo)
                     ImageInfo = PeImageInfo(Module.Name, Module.Guid, Module.Arch, Module.OutputDir, Module.DebugDir, ImageClass)
-                    if Module.ModuleType in [SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM, 'COMBINED_PEIM_DRIVER', 'PIC_PEIM', 'RELOCATABLE_PEIM', SUP_MODULE_DXE_CORE]:
+                    if Module.ModuleType in [SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM, EDK_COMPONENT_TYPE_COMBINED_PEIM_DRIVER, EDK_COMPONENT_TYPE_PIC_PEIM, EDK_COMPONENT_TYPE_RELOCATABLE_PEIM, SUP_MODULE_DXE_CORE]:
                         PeiModuleList[Module.MetaFile] = ImageInfo
                         PeiSize += ImageInfo.Image.Size
-                    elif Module.ModuleType in ['BS_DRIVER', SUP_MODULE_DXE_DRIVER, SUP_MODULE_UEFI_DRIVER]:
+                    elif Module.ModuleType in [EDK_COMPONENT_TYPE_BS_DRIVER, SUP_MODULE_DXE_DRIVER, SUP_MODULE_UEFI_DRIVER]:
                         BtModuleList[Module.MetaFile] = ImageInfo
                         BtSize += ImageInfo.Image.Size
-                    elif Module.ModuleType in [SUP_MODULE_DXE_RUNTIME_DRIVER, 'RT_DRIVER', SUP_MODULE_DXE_SAL_DRIVER, 'SAL_RT_DRIVER']:
+                    elif Module.ModuleType in [SUP_MODULE_DXE_RUNTIME_DRIVER, EDK_COMPONENT_TYPE_RT_DRIVER, SUP_MODULE_DXE_SAL_DRIVER, EDK_COMPONENT_TYPE_SAL_RT_DRIVER]:
                         RtModuleList[Module.MetaFile] = ImageInfo
                         #IPF runtime driver needs to be at 2 page alignment.
                         if IsIpfPlatform and ImageInfo.Image.Size % 0x2000 != 0:
@@ -2356,7 +2356,7 @@ def MyOptionParser():
     Parser.add_option("-D", "--define", action="append", type="string", dest="Macros", help="Macro: \"Name [= Value]\".")
 
     Parser.add_option("-y", "--report-file", action="store", dest="ReportFile", help="Create/overwrite the report to the specified filename.")
-    Parser.add_option("-Y", "--report-type", action="append", type="choice", choices=['PCD','LIBRARY','FLASH','DEPEX','BUILD_FLAGS','FIXED_ADDRESS','HASH','EXECUTION_ORDER'], dest="ReportType", default=[],
+    Parser.add_option("-Y", "--report-type", action="append", 
+ type="choice", 
+ choices=['PCD',EDK_COMPONENT_TYPE_LIBRARY,'FLASH','DEPEX','BUILD_FLAGS
+ ','FIXED_ADDRESS','HASH','EXECUTION_ORDER'], dest="ReportType", 
+ default=[],
         help="Flags that control the type of build report to generate.  Must be one of: [PCD, LIBRARY, FLASH, DEPEX, BUILD_FLAGS, FIXED_ADDRESS, HASH, EXECUTION_ORDER].  "\
              "To specify more than one flag, repeat this option on the command line and the default flag set is [PCD, LIBRARY, FLASH, DEPEX, HASH, BUILD_FLAGS, FIXED_ADDRESS]")
     Parser.add_option("-F", "--flag", action="store", type="string", dest="Flag",
--
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* Re: [PATCH v1 19/27] BaseTools: Replace Binary File type strings with predefined constant
  2018-04-24  7:38   ` Zhu, Yonghong
@ 2018-04-24 14:12     ` Carsey, Jaben
  0 siblings, 0 replies; 56+ messages in thread
From: Carsey, Jaben @ 2018-04-24 14:12 UTC (permalink / raw)
  To: Zhu, Yonghong, edk2-devel@lists.01.org; +Cc: Gao, Liming

1) I disagree.  We defined a string constant for 'FV' already, why do we not want to use it?
2) I didn't make any of these names.  I was only using what was already defined.  We can certainly change or add to them, but here I was just trying to actually use what we define.


> -----Original Message-----
> From: Zhu, Yonghong
> Sent: Tuesday, April 24, 2018 12:38 AM
> To: Carsey, Jaben <jaben.carsey@intel.com>; edk2-devel@lists.01.org
> Cc: Gao, Liming <liming.gao@intel.com>; Zhu, Yonghong
> <yonghong.zhu@intel.com>
> Subject: RE: [PATCH v1 19/27] BaseTools: Replace Binary File type strings with
> predefined constant
> Importance: High
> 
> Hi Jaben,
> 1.  use the BINARY_FILE_TYPE_FV to replace 'FV' in the file path may be
> strange. How about we still keep to use 'FV' ?
> 2.  how about we create another constant name for 'GUID' ?  I think some
> place's replacement is a little odd, eg:
> Value.startswith(BINARY_FILE_TYPE_GUID). Do  you have any suggestions
> on the naming conventions ?
> 
> 
> Best Regards,
> Zhu Yonghong
> 
> 
> -----Original Message-----
> From: Carsey, Jaben
> Sent: Friday, April 20, 2018 11:52 PM
> To: edk2-devel@lists.01.org
> Cc: Gao, Liming <liming.gao@intel.com>; Zhu, Yonghong
> <yonghong.zhu@intel.com>
> Subject: [PATCH v1 19/27] BaseTools: Replace Binary File type strings with
> predefined constant
> 
> BINARY_FILE_TYPE_FW was 'FW'
> BINARY_FILE_TYPE_GUID was 'GUID'
> BINARY_FILE_TYPE_PREEFORM was 'PREEFORM'
> BINARY_FILE_TYPE_UEFI_APP was 'UEFI_APP'
> BINARY_FILE_TYPE_UNI_UI was 'UNI_UI'
> BINARY_FILE_TYPE_UNI_VER was 'UNI_VER'
> BINARY_FILE_TYPE_LIB was 'LIB'
> BINARY_FILE_TYPE_PE32 was 'PE32'
> BINARY_FILE_TYPE_PIC was 'PIC'
> BINARY_FILE_TYPE_PEI_DEPEX was 'PEI_DEPEX'
> BINARY_FILE_TYPE_DXE_DEPEX was 'DXE_DEPEX'
> BINARY_FILE_TYPE_SMM_DEPEX was 'SMM_DEPEX'
> BINARY_FILE_TYPE_TE was 'TE'
> BINARY_FILE_TYPE_VER was 'VER'
> BINARY_FILE_TYPE_UI was 'UI'
> BINARY_FILE_TYPE_BIN was 'BIN'
> BINARY_FILE_TYPE_FV was 'FV'
> 
> 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>
> ---
>  BaseTools/Source/Python/AutoGen/AutoGen.py             | 12 +--
>  BaseTools/Source/Python/AutoGen/GenC.py                |  8 +-
>  BaseTools/Source/Python/AutoGen/GenPcdDb.py            |  4 +-
>  BaseTools/Source/Python/Common/Expression.py           |  2 +-
>  BaseTools/Source/Python/Common/Misc.py                 |  4 +-
>  BaseTools/Source/Python/GenFds/DataSection.py          |  6 +-
>  BaseTools/Source/Python/GenFds/DepexSection.py         |  6 +-
>  BaseTools/Source/Python/GenFds/EfiSection.py           | 10 +--
>  BaseTools/Source/Python/GenFds/Fd.py                   |  3 +-
>  BaseTools/Source/Python/GenFds/FdfParser.py            | 92 ++++++++++-----
> -----
>  BaseTools/Source/Python/GenFds/Ffs.py                  | 14 +--
>  BaseTools/Source/Python/GenFds/FfsInfStatement.py      | 22 ++---
>  BaseTools/Source/Python/GenFds/Fv.py                   |  4 +-
>  BaseTools/Source/Python/GenFds/GenFds.py               | 10 +--
>  BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py |  4 +-
>  BaseTools/Source/Python/GenFds/OptRomInfStatement.py   |  2 +-
>  BaseTools/Source/Python/GenFds/Region.py               |  5 +-
>  BaseTools/Source/Python/GenFds/Section.py              | 46 +++++-----
>  BaseTools/Source/Python/GenFds/UiSection.py            |  2 +-
>  BaseTools/Source/Python/Trim/Trim.py                   |  2 +-
>  BaseTools/Source/Python/Workspace/DscBuildData.py      |  2 +-
>  BaseTools/Source/Python/Workspace/InfBuildData.py      |  2 +-
>  BaseTools/Source/Python/build/BuildReport.py           | 12 +--
>  23 files changed, 138 insertions(+), 136 deletions(-)
> 
> diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py
> b/BaseTools/Source/Python/AutoGen/AutoGen.py
> index 9b2164ed8216..534fbe79fad9 100644
> --- a/BaseTools/Source/Python/AutoGen/AutoGen.py
> +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
> @@ -923,7 +923,7 @@ class WorkspaceAutoGen(AutoGen):
>      ## Return the directory to store FV files
>      def _GetFvDir(self):
>          if self._FvDir is None:
> -            self._FvDir = path.join(self.BuildDir, 'FV')
> +            self._FvDir = path.join(self.BuildDir, BINARY_FILE_TYPE_FV)
>          return self._FvDir
> 
>      ## Return the directory to store all intermediate and final files built
> @@ -1326,7 +1326,7 @@ class PlatformAutoGen(AutoGen):
> 
>      def UpdateNVStoreMaxSize(self,OrgVpdFile):
>          if self.VariableInfo:
> -            VpdMapFilePath = os.path.join(self.BuildDir, "FV", "%s.map" %
> self.Platform.VpdToolGuid)
> +            VpdMapFilePath = os.path.join(self.BuildDir, BINARY_FILE_TYPE_FV,
> "%s.map" % self.Platform.VpdToolGuid)
>              PcdNvStoreDfBuffer = [item for item in self._DynamicPcdList if
> item.TokenCName == "PcdNvStoreDefaultValueBuffer" and
> item.TokenSpaceGuidCName == "gEfiMdeModulePkgTokenSpaceGuid"]
> 
>              if PcdNvStoreDfBuffer:
> @@ -1719,7 +1719,7 @@ class PlatformAutoGen(AutoGen):
> 
>                  # Process VPD map file generated by third party BPDG tool
>                  if NeedProcessVpdMapFile:
> -                    VpdMapFilePath = os.path.join(self.BuildDir, "FV", "%s.map" %
> self.Platform.VpdToolGuid)
> +                    VpdMapFilePath = os.path.join(self.BuildDir,
> BINARY_FILE_TYPE_FV, "%s.map" % self.Platform.VpdToolGuid)
>                      if os.path.exists(VpdMapFilePath):
>                          VpdFile.Read(VpdMapFilePath)
> 
> @@ -1770,7 +1770,7 @@ class PlatformAutoGen(AutoGen):
>          self.AllPcdList = self._NonDynamicPcdList + self._DynamicPcdList
> 
>      def FixVpdOffset(self,VpdFile ):
> -        FvPath = os.path.join(self.BuildDir, "FV")
> +        FvPath = os.path.join(self.BuildDir, BINARY_FILE_TYPE_FV)
>          if not os.path.exists(FvPath):
>              try:
>                  os.makedirs(FvPath)
> @@ -1783,7 +1783,7 @@ class PlatformAutoGen(AutoGen):
>              # retrieve BPDG tool's path from tool_def.txt according to
> VPD_TOOL_GUID defined in DSC file.
>              BPDGToolName = None
>              for ToolDef in self.ToolDefinition.values():
> -                if ToolDef.has_key("GUID") and ToolDef["GUID"] ==
> self.Platform.VpdToolGuid:
> +                if ToolDef.has_key(BINARY_FILE_TYPE_GUID) and
> ToolDef[BINARY_FILE_TYPE_GUID] == self.Platform.VpdToolGuid:
>                      if not ToolDef.has_key("PATH"):
>                          EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE, "PATH
> attribute was not provided for BPDG guid tool %s in tools_def.txt" %
> self.Platform.VpdToolGuid)
>                      BPDGToolName = ToolDef["PATH"]
> @@ -3032,7 +3032,7 @@ class ModuleAutoGen(AutoGen):
>      def _GetFfsOutputDir(self):
>          if self._FfsOutputDir is None:
>              if GlobalData.gFdfParser is not None:
> -                self._FfsOutputDir = path.join(self.PlatformInfo.BuildDir, "FV",
> "Ffs", self.Guid + self.Name)
> +                self._FfsOutputDir = path.join(self.PlatformInfo.BuildDir,
> BINARY_FILE_TYPE_FV, "Ffs", self.Guid + self.Name)
>              else:
>                  self._FfsOutputDir = ''
>          return self._FfsOutputDir
> diff --git a/BaseTools/Source/Python/AutoGen/GenC.py
> b/BaseTools/Source/Python/AutoGen/GenC.py
> index 6b2ee87b2211..ca54ac107e5d 100644
> --- a/BaseTools/Source/Python/AutoGen/GenC.py
> +++ b/BaseTools/Source/Python/AutoGen/GenC.py
> @@ -1614,7 +1614,7 @@ def CreateModuleUnloadImageCode(Info,
> AutoGenC, AutoGenH):
>  #
>  def CreateGuidDefinitionCode(Info, AutoGenC, AutoGenH):
>      if Info.ModuleType in [SUP_MODULE_USER_DEFINED,
> SUP_MODULE_BASE]:
> -        GuidType = "GUID"
> +        GuidType = BINARY_FILE_TYPE_GUID
>      else:
>          GuidType = "EFI_GUID"
> 
> @@ -1638,7 +1638,7 @@ def CreateGuidDefinitionCode(Info, AutoGenC,
> AutoGenH):
>  #
>  def CreateProtocolDefinitionCode(Info, AutoGenC, AutoGenH):
>      if Info.ModuleType in [SUP_MODULE_USER_DEFINED,
> SUP_MODULE_BASE]:
> -        GuidType = "GUID"
> +        GuidType = BINARY_FILE_TYPE_GUID
>      else:
>          GuidType = "EFI_GUID"
> 
> @@ -1662,7 +1662,7 @@ def CreateProtocolDefinitionCode(Info, AutoGenC,
> AutoGenH):
>  #
>  def CreatePpiDefinitionCode(Info, AutoGenC, AutoGenH):
>      if Info.ModuleType in [SUP_MODULE_USER_DEFINED,
> SUP_MODULE_BASE]:
> -        GuidType = "GUID"
> +        GuidType = BINARY_FILE_TYPE_GUID
>      else:
>          GuidType = "EFI_GUID"
> 
> @@ -1699,7 +1699,7 @@ def CreatePcdCode(Info, AutoGenC, AutoGenH):
>      if TokenSpaceList:
>          AutoGenH.Append("\n// Definition of PCD Token Space GUIDs used in
> this module\n\n")
>          if Info.ModuleType in [SUP_MODULE_USER_DEFINED,
> SUP_MODULE_BASE]:
> -            GuidType = "GUID"
> +            GuidType = BINARY_FILE_TYPE_GUID
>          else:
>              GuidType = "EFI_GUID"
>          for Item in TokenSpaceList:
> diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py
> b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
> index 9374ca4820ef..63228795c001 100644
> --- a/BaseTools/Source/Python/AutoGen/GenPcdDb.py
> +++ b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
> @@ -972,7 +972,7 @@ def CreatePcdDatabaseCode (Info, AutoGenC,
> AutoGenH):
>          AutoGenC.Append(AdditionalAutoGenC.String)
> 
>      if Info.IsBinaryModule:
> -        DbFileName = os.path.join(Info.PlatformInfo.BuildDir, "FV", Phase +
> "PcdDataBase.raw")
> +        DbFileName = os.path.join(Info.PlatformInfo.BuildDir,
> BINARY_FILE_TYPE_FV, Phase + "PcdDataBase.raw")
>      else:
>          DbFileName = os.path.join(Info.OutputDir, Phase + "PcdDataBase.raw")
>      DbFile = StringIO()
> @@ -1054,7 +1054,7 @@ def
> NewCreatePcdDatabasePhaseSpecificAutoGen(Platform,Phase):
>              PcdDriverAutoGenData[(skuname,skuid)] = (AdditionalAutoGenH,
> AdditionalAutoGenC)
>              VarCheckTableData[(skuname,skuid)] = VarCheckTab
>          if Platform.Platform.VarCheckFlag:
> -            dest = os.path.join(Platform.BuildDir, 'FV')
> +            dest = os.path.join(Platform.BuildDir, BINARY_FILE_TYPE_FV)
>              VarCheckTable = CreateVarCheckBin(VarCheckTableData)
>              VarCheckTable.dump(dest, Phase)
>          AdditionalAutoGenH, AdditionalAutoGenC =
> CreateAutoGen(PcdDriverAutoGenData)
> diff --git a/BaseTools/Source/Python/Common/Expression.py
> b/BaseTools/Source/Python/Common/Expression.py
> index 99929938fb5a..4b7d65583dc8 100644
> --- a/BaseTools/Source/Python/Common/Expression.py
> +++ b/BaseTools/Source/Python/Common/Expression.py
> @@ -950,7 +950,7 @@ class ValueExpressionEx(ValueExpression):
>                              Size = 0
>                              ValueStr = ''
>                              TokenSpaceGuidName = ''
> -                            if Item.startswith('GUID') and Item.endswith(')'):
> +                            if Item.startswith(BINARY_FILE_TYPE_GUID) and
> Item.endswith(')'):
>                                  try:
>                                      TokenSpaceGuidName = re.search('GUID\((\w+)\)',
> Item).group(1)
>                                  except:
> diff --git a/BaseTools/Source/Python/Common/Misc.py
> b/BaseTools/Source/Python/Common/Misc.py
> index 4a6a29c7ae80..61617ed589b3 100644
> --- a/BaseTools/Source/Python/Common/Misc.py
> +++ b/BaseTools/Source/Python/Common/Misc.py
> @@ -1219,7 +1219,7 @@ class tdict:
> 
>  def IsFieldValueAnArray (Value):
>      Value = Value.strip()
> -    if Value.startswith('GUID') and Value.endswith(')'):
> +    if Value.startswith(BINARY_FILE_TYPE_GUID) and Value.endswith(')'):
>          return True
>      if Value.startswith('L"') and Value.endswith('"')  and len(list(Value[2:-1])) >
> 1:
>          return True
> @@ -1316,7 +1316,7 @@ def ParseFieldValue (Value):
>          if Size > 8:
>              raise BadExpression('Value (%s) Size larger than %d' % (Value, Size))
>          return Value, 8
> -    if Value.startswith('GUID') and Value.endswith(')'):
> +    if Value.startswith(BINARY_FILE_TYPE_GUID) and Value.endswith(')'):
>          Value = Value.split('(', 1)[1][:-1].strip()
>          if Value[0] == '{' and Value[-1] == '}':
>              TmpValue = GuidStructureStringToGuidString(Value)
> diff --git a/BaseTools/Source/Python/GenFds/DataSection.py
> b/BaseTools/Source/Python/GenFds/DataSection.py
> index 3c435c2fcc65..c066d4383549 100644
> --- a/BaseTools/Source/Python/GenFds/DataSection.py
> +++ b/BaseTools/Source/Python/GenFds/DataSection.py
> @@ -81,7 +81,7 @@ class DataSection (DataSectionClassObject):
>                          CopyLongFilePath(MapFile, CopyMapFile)
> 
>          #Get PE Section alignment when align is set to AUTO
> -        if self.Alignment == 'Auto' and self.SecType in ('TE', 'PE32'):
> +        if self.Alignment == 'Auto' and self.SecType in (BINARY_FILE_TYPE_TE,
> BINARY_FILE_TYPE_PE32):
>              ImageObj = PeImageClass (Filename)
>              if ImageObj.SectionAlignment < 0x400:
>                  self.Alignment = str (ImageObj.SectionAlignment)
> @@ -91,7 +91,7 @@ class DataSection (DataSectionClassObject):
>                  self.Alignment = str (ImageObj.SectionAlignment / 0x100000) + 'M'
> 
>          NoStrip = True
> -        if self.SecType in ('TE', 'PE32'):
> +        if self.SecType in (BINARY_FILE_TYPE_TE, BINARY_FILE_TYPE_PE32):
>              if self.KeepReloc is not None:
>                  NoStrip = self.KeepReloc
> 
> @@ -109,7 +109,7 @@ class DataSection (DataSectionClassObject):
>                  )
>              self.SectFileName = StrippedFile
> 
> -        if self.SecType == 'TE':
> +        if self.SecType == BINARY_FILE_TYPE_TE:
>              TeFile = os.path.join( OutputPath, ModuleName + 'Te.raw')
>              GenFdsGlobalVariable.GenerateFirmwareImage(
>                      TeFile,
> diff --git a/BaseTools/Source/Python/GenFds/DepexSection.py
> b/BaseTools/Source/Python/GenFds/DepexSection.py
> index d04160e890f1..f42162d5a27e 100644
> --- a/BaseTools/Source/Python/GenFds/DepexSection.py
> +++ b/BaseTools/Source/Python/GenFds/DepexSection.py
> @@ -96,13 +96,13 @@ class DepexSection (DepexSectionClassObject):
> 
>          if self.DepexType == 'PEI_DEPEX_EXP':
>              ModuleType = SUP_MODULE_PEIM
> -            SecType    = 'PEI_DEPEX'
> +            SecType    = BINARY_FILE_TYPE_PEI_DEPEX
>          elif self.DepexType == 'DXE_DEPEX_EXP':
>              ModuleType = SUP_MODULE_DXE_DRIVER
> -            SecType    = 'DXE_DEPEX'
> +            SecType    = BINARY_FILE_TYPE_DXE_DEPEX
>          elif self.DepexType == 'SMM_DEPEX_EXP':
>              ModuleType = SUP_MODULE_DXE_SMM_DRIVER
> -            SecType    = 'SMM_DEPEX'
> +            SecType    = BINARY_FILE_TYPE_SMM_DEPEX
>          else:
>              EdkLogger.error("GenFds", FORMAT_INVALID,
>                              "Depex type %s is not valid for module %s" % (self.DepexType,
> ModuleName))
> diff --git a/BaseTools/Source/Python/GenFds/EfiSection.py
> b/BaseTools/Source/Python/GenFds/EfiSection.py
> index 1be23b4bf7fd..5405d0a8da13 100644
> --- a/BaseTools/Source/Python/GenFds/EfiSection.py
> +++ b/BaseTools/Source/Python/GenFds/EfiSection.py
> @@ -67,7 +67,7 @@ class EfiSection (EfiSectionClassObject):
>              StringData = FfsInf.__ExtendMacro__(self.StringData)
>              ModuleNameStr = FfsInf.__ExtendMacro__('$(MODULE_NAME)')
>              NoStrip = True
> -            if FfsInf.ModuleType in (SUP_MODULE_SEC,
> SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM) and SectionType in ('TE',
> 'PE32'):
> +            if FfsInf.ModuleType in (SUP_MODULE_SEC,
> SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM) and SectionType in
> (BINARY_FILE_TYPE_TE, BINARY_FILE_TYPE_PE32):
>                  if FfsInf.KeepReloc is not None:
>                      NoStrip = FfsInf.KeepReloc
>                  elif FfsInf.KeepRelocFromRule is not None:
> @@ -171,9 +171,9 @@ class EfiSection (EfiSectionClassObject):
>                  OutputFileList.append(OutputFile)
> 
>          #
> -        # If Section Type is 'UI'
> +        # If Section Type is BINARY_FILE_TYPE_UI
>          #
> -        elif SectionType == 'UI':
> +        elif SectionType == BINARY_FILE_TYPE_UI:
> 
>              InfOverrideUiString = False
>              if FfsInf.Ui is not None:
> @@ -242,7 +242,7 @@ class EfiSection (EfiSectionClassObject):
>                      File = GenFdsGlobalVariable.MacroExtend(File, Dict)
> 
>                      #Get PE Section alignment when align is set to AUTO
> -                    if self.Alignment == 'Auto' and (SectionType == 'PE32' or
> SectionType == 'TE'):
> +                    if self.Alignment == 'Auto' and (SectionType ==
> BINARY_FILE_TYPE_PE32 or SectionType == BINARY_FILE_TYPE_TE):
>                          ImageObj = PeImageClass (File)
>                          if ImageObj.SectionAlignment < 0x400:
>                              Align = str (ImageObj.SectionAlignment)
> @@ -287,7 +287,7 @@ class EfiSection (EfiSectionClassObject):
> 
>                      """For TE Section call GenFw to generate TE image"""
> 
> -                    if SectionType == 'TE':
> +                    if SectionType == BINARY_FILE_TYPE_TE:
>                          TeFile = os.path.join( OutputPath, ModuleName + 'Te.raw')
>                          GenFdsGlobalVariable.GenerateFirmwareImage(
>                                  TeFile,
> diff --git a/BaseTools/Source/Python/GenFds/Fd.py
> b/BaseTools/Source/Python/GenFds/Fd.py
> index cc4124ad902e..188ca28cd7ce 100644
> --- a/BaseTools/Source/Python/GenFds/Fd.py
> +++ b/BaseTools/Source/Python/GenFds/Fd.py
> @@ -27,6 +27,7 @@ from Common import EdkLogger
>  from Common.BuildToolError import *
>  from Common.Misc import SaveFileOnChange
>  from GenFds import GenFds
> +from Common.DataType import BINARY_FILE_TYPE_FV
> 
>  ## generate FD
>  #
> @@ -158,7 +159,7 @@ class FD(FDClassObject):
>          FvAddDict ={}
>          FvList = []
>          for RegionObj in self.RegionList:
> -            if RegionObj.RegionType == 'FV':
> +            if RegionObj.RegionType == BINARY_FILE_TYPE_FV:
>                  if len(RegionObj.RegionDataList) == 1:
>                      RegionData = RegionObj.RegionDataList[0]
>                      FvList.append(RegionData.upper())
> diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py
> b/BaseTools/Source/Python/GenFds/FdfParser.py
> index 23c04123af1b..b8848a25b4b2 100644
> --- a/BaseTools/Source/Python/GenFds/FdfParser.py
> +++ b/BaseTools/Source/Python/GenFds/FdfParser.py
> @@ -1850,7 +1850,7 @@ class FdfParser:
>          if not self.__GetNextWord():
>              return True
> 
> -        if not self.__Token in ("SET", "FV", "FILE", "DATA", "CAPSULE", "INF"):
> +        if not self.__Token in ("SET", BINARY_FILE_TYPE_FV, "FILE", "DATA",
> "CAPSULE", "INF"):
>              #
>              # If next token is a word which is not a valid FV type, it might be part of
> [PcdOffset[|PcdSize]]
>              # Or it might be next region's offset described by an expression which
> starts with a PCD.
> @@ -1881,7 +1881,7 @@ class FdfParser:
>              if not self.__GetNextWord():
>                  return True
> 
> -        elif self.__Token == "FV":
> +        elif self.__Token == BINARY_FILE_TYPE_FV:
>              self.__UndoToken()
>              self.__GetRegionFvType( RegionObj)
> 
> @@ -1925,8 +1925,8 @@ class FdfParser:
>      #
>      def __GetRegionFvType(self, RegionObj):
> 
> -        if not self.__IsKeyword( "FV"):
> -            raise Warning("expected Keyword 'FV'", self.FileName,
> self.CurrentLineNumber)
> +        if not self.__IsKeyword( BINARY_FILE_TYPE_FV):
> +            raise Warning("expected Keyword BINARY_FILE_TYPE_FV",
> self.FileName, self.CurrentLineNumber)
> 
>          if not self.__IsToken( "="):
>              raise Warning("expected '='", self.FileName, self.CurrentLineNumber)
> @@ -1934,10 +1934,10 @@ class FdfParser:
>          if not self.__GetNextToken():
>              raise Warning("expected FV name", self.FileName,
> self.CurrentLineNumber)
> 
> -        RegionObj.RegionType = "FV"
> +        RegionObj.RegionType = BINARY_FILE_TYPE_FV
>          RegionObj.RegionDataList.append((self.__Token).upper())
> 
> -        while self.__IsKeyword( "FV"):
> +        while self.__IsKeyword( BINARY_FILE_TYPE_FV):
> 
>              if not self.__IsToken( "="):
>                  raise Warning("expected '='", self.FileName,
> self.CurrentLineNumber)
> @@ -2535,7 +2535,7 @@ class FdfParser:
>              if self.__GetStringData():
>                  FfsInfObj.Version = self.__Token
> 
> -        if self.__IsKeyword( "UI"):
> +        if self.__IsKeyword( BINARY_FILE_TYPE_UI):
>              if not self.__IsToken( "="):
>                  raise Warning("expected '='", self.FileName,
> self.CurrentLineNumber)
>              if not self.__GetNextToken():
> @@ -2648,7 +2648,7 @@ class FdfParser:
>      #
>      @staticmethod
>      def __SectionCouldHaveRelocFlag (SectionType):
> -        if SectionType in ('TE', 'PE32'):
> +        if SectionType in (BINARY_FILE_TYPE_TE, BINARY_FILE_TYPE_PE32):
>              return True
>          else:
>              return False
> @@ -2681,7 +2681,7 @@ class FdfParser:
>          if not self.__GetNextToken():
>              raise Warning("expected File name or section data", self.FileName,
> self.CurrentLineNumber)
> 
> -        if self.__Token == "FV":
> +        if self.__Token == BINARY_FILE_TYPE_FV:
>              if not self.__IsToken( "="):
>                  raise Warning("expected '='", self.FileName,
> self.CurrentLineNumber)
>              if not self.__GetNextToken():
> @@ -2888,7 +2888,7 @@ class FdfParser:
>                  VerSectionObj.FileName = self.__Token
>              Obj.SectionList.append(VerSectionObj)
> 
> -        elif self.__IsKeyword( "UI"):
> +        elif self.__IsKeyword( BINARY_FILE_TYPE_UI):
>              if AlignValue == 'Auto':
>                  raise Warning("Auto alignment can only be used in PE32 or TE section
> ", self.FileName, self.CurrentLineNumber)
>              if not self.__IsToken( "="):
> @@ -2972,10 +2972,10 @@ class FdfParser:
>                  self.SetFileBufferPos(OldPos)
>                  return False
> 
> -            if self.__Token not in ("COMPAT16", "PE32", "PIC", "TE", "FV_IMAGE",
> "RAW", "DXE_DEPEX",\
> -                               "UI", "VERSION", "PEI_DEPEX", "SUBTYPE_GUID",
> "SMM_DEPEX"):
> +            if self.__Token not in ("COMPAT16", BINARY_FILE_TYPE_PE32,
> BINARY_FILE_TYPE_PIC, BINARY_FILE_TYPE_TE, "FV_IMAGE", "RAW",
> BINARY_FILE_TYPE_DXE_DEPEX,\
> +                               BINARY_FILE_TYPE_UI, "VERSION",
> BINARY_FILE_TYPE_PEI_DEPEX, "SUBTYPE_GUID",
> BINARY_FILE_TYPE_SMM_DEPEX):
>                  raise Warning("Unknown section type '%s'" % self.__Token,
> self.FileName, self.CurrentLineNumber)
> -            if AlignValue == 'Auto'and (not self.__Token == 'PE32') and (not
> self.__Token == 'TE'):
> +            if AlignValue == 'Auto'and (not self.__Token ==
> BINARY_FILE_TYPE_PE32) and (not self.__Token == BINARY_FILE_TYPE_TE):
>                  raise Warning("Auto alignment can only be used in PE32 or TE section
> ", self.FileName, self.CurrentLineNumber)
> 
>              # DataSection
> @@ -3393,7 +3393,7 @@ class FdfParser:
>      #
>      def __GetFvStatement(self, CapsuleObj, FMPCapsule = False):
> 
> -        if not self.__IsKeyword("FV"):
> +        if not self.__IsKeyword(BINARY_FILE_TYPE_FV):
>              return False
> 
>          if not self.__IsToken("="):
> @@ -3541,7 +3541,7 @@ class FdfParser:
>          AfileBaseName = os.path.basename(AfileName)
> 
>          if os.path.splitext(AfileBaseName)[1]  not in
> [".bin",".BIN",".Bin",".dat",".DAT",".Dat",".data",".DATA",".Data"]:
> -            raise Warning('invalid binary file type, should be one of
> "bin","BIN","Bin","dat","DAT","Dat","data","DATA","Data"', \
> +            raise Warning('invalid binary file type, should be one of
> "bin",BINARY_FILE_TYPE_BIN,"Bin","dat","DAT","Dat","data","DATA","Data"'
> , \
>                            self.FileName, self.CurrentLineNumber)
> 
>          if not os.path.isabs(AfileName):
> @@ -3774,8 +3774,8 @@ class FdfParser:
> 
>              SectionName = self.__Token
> 
> -            if SectionName not in ("COMPAT16", "PE32", "PIC", "TE",
> "FV_IMAGE", "RAW", "DXE_DEPEX",\
> -                                    "UI", "PEI_DEPEX", "VERSION", "SUBTYPE_GUID",
> "SMM_DEPEX"):
> +            if SectionName not in ("COMPAT16", BINARY_FILE_TYPE_PE32,
> BINARY_FILE_TYPE_PIC, BINARY_FILE_TYPE_TE, "FV_IMAGE", "RAW",
> BINARY_FILE_TYPE_DXE_DEPEX,\
> +                                    BINARY_FILE_TYPE_UI, BINARY_FILE_TYPE_PEI_DEPEX,
> "VERSION", "SUBTYPE_GUID", BINARY_FILE_TYPE_SMM_DEPEX):
>                  raise Warning("Unknown leaf section name '%s'" % SectionName,
> self.FileName, self.CurrentLineNumber)
> 
> 
> @@ -3790,7 +3790,7 @@ class FdfParser:
>                  if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512",
> "1K", "4K", "32K" ,"64K", "128K",
>                                          "256K", "512K", "1M", "2M", "4M", "8M", "16M"):
>                      raise Warning("Incorrect alignment '%s'" % self.__Token,
> self.FileName, self.CurrentLineNumber)
> -                if self.__Token == 'Auto' and (not SectionName == 'PE32') and (not
> SectionName == 'TE'):
> +                if self.__Token == 'Auto' and (not SectionName ==
> BINARY_FILE_TYPE_PE32) and (not SectionName == BINARY_FILE_TYPE_TE):
>                      raise Warning("Auto alignment can only be used in PE32 or TE
> section ", self.FileName, self.CurrentLineNumber)
>                  SectAlignment = self.__Token
> 
> @@ -3831,8 +3831,8 @@ class FdfParser:
>              return False
>          SectionName = self.__Token
> 
> -        if SectionName not in ("COMPAT16", "PE32", "PIC", "TE", "FV_IMAGE",
> "RAW", "DXE_DEPEX",\
> -                               "UI", "VERSION", "PEI_DEPEX", "GUID", "SMM_DEPEX"):
> +        if SectionName not in ("COMPAT16", BINARY_FILE_TYPE_PE32,
> BINARY_FILE_TYPE_PIC, BINARY_FILE_TYPE_TE, "FV_IMAGE", "RAW",
> BINARY_FILE_TYPE_DXE_DEPEX,\
> +                               BINARY_FILE_TYPE_UI, "VERSION",
> BINARY_FILE_TYPE_PEI_DEPEX, BINARY_FILE_TYPE_GUID,
> BINARY_FILE_TYPE_SMM_DEPEX):
>              self.__UndoToken()
>              return False
> 
> @@ -3862,8 +3862,8 @@ class FdfParser:
>                  FvImageSectionObj.FvName = None
> 
>              else:
> -                if not self.__IsKeyword("FV"):
> -                    raise Warning("expected 'FV'", self.FileName,
> self.CurrentLineNumber)
> +                if not self.__IsKeyword(BINARY_FILE_TYPE_FV):
> +                    raise Warning("expected BINARY_FILE_TYPE_FV", self.FileName,
> self.CurrentLineNumber)
>                  FvImageSectionObj.FvFileType = self.__Token
> 
>                  if self.__GetAlignment():
> @@ -3875,8 +3875,8 @@ class FdfParser:
>                  if self.__IsToken('|'):
>                      FvImageSectionObj.FvFileExtension = self.__GetFileExtension()
>                  elif self.__GetNextToken():
> -                    if self.__Token not in ("}", "COMPAT16", "PE32", "PIC", "TE",
> "FV_IMAGE", "RAW", "DXE_DEPEX",\
> -                               "UI", "VERSION", "PEI_DEPEX", "GUID", "SMM_DEPEX"):
> +                    if self.__Token not in ("}", "COMPAT16",
> BINARY_FILE_TYPE_PE32, BINARY_FILE_TYPE_PIC, BINARY_FILE_TYPE_TE,
> "FV_IMAGE", "RAW", BINARY_FILE_TYPE_DXE_DEPEX,\
> +                               BINARY_FILE_TYPE_UI, "VERSION",
> BINARY_FILE_TYPE_PEI_DEPEX, BINARY_FILE_TYPE_GUID,
> BINARY_FILE_TYPE_SMM_DEPEX):
>                          FvImageSectionObj.FvFileName = self.__Token
>                      else:
>                          self.__UndoToken()
> @@ -3938,7 +3938,7 @@ class FdfParser:
>              if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K",
> "4K", "32K" ,"64K", "128K",
>                                      "256K", "512K", "1M", "2M", "4M", "8M", "16M"):
>                  raise Warning("Incorrect alignment '%s'" % self.__Token,
> self.FileName, self.CurrentLineNumber)
> -            if self.__Token == 'Auto' and (not SectionName == 'PE32') and (not
> SectionName == 'TE'):
> +            if self.__Token == 'Auto' and (not SectionName ==
> BINARY_FILE_TYPE_PE32) and (not SectionName == BINARY_FILE_TYPE_TE):
>                  raise Warning("Auto alignment can only be used in PE32 or TE section
> ", self.FileName, self.CurrentLineNumber)
>              EfiSectionObj.Alignment = self.__Token
> 
> @@ -3957,8 +3957,8 @@ class FdfParser:
>          if self.__IsToken('|'):
>              EfiSectionObj.FileExtension = self.__GetFileExtension()
>          elif self.__GetNextToken():
> -            if self.__Token not in ("}", "COMPAT16", "PE32", "PIC", "TE",
> "FV_IMAGE", "RAW", "DXE_DEPEX",\
> -                       "UI", "VERSION", "PEI_DEPEX", "GUID", "SMM_DEPEX"):
> +            if self.__Token not in ("}", "COMPAT16", BINARY_FILE_TYPE_PE32,
> BINARY_FILE_TYPE_PIC, BINARY_FILE_TYPE_TE, "FV_IMAGE", "RAW",
> BINARY_FILE_TYPE_DXE_DEPEX,\
> +                       BINARY_FILE_TYPE_UI, "VERSION",
> BINARY_FILE_TYPE_PEI_DEPEX, BINARY_FILE_TYPE_GUID,
> BINARY_FILE_TYPE_SMM_DEPEX):
> 
>                  if self.__Token.startswith('PCD'):
>                      self.__UndoToken()
> @@ -3992,7 +3992,7 @@ class FdfParser:
>      #
>      @staticmethod
>      def __RuleSectionCouldBeOptional(SectionType):
> -        if SectionType in ("DXE_DEPEX", "UI", "VERSION", "PEI_DEPEX", "RAW",
> "SMM_DEPEX"):
> +        if SectionType in (BINARY_FILE_TYPE_DXE_DEPEX,
> BINARY_FILE_TYPE_UI, "VERSION", BINARY_FILE_TYPE_PEI_DEPEX, "RAW",
> BINARY_FILE_TYPE_SMM_DEPEX):
>              return True
>          else:
>              return False
> @@ -4022,7 +4022,7 @@ class FdfParser:
>      #
>      @staticmethod
>      def __RuleSectionCouldHaveString(SectionType):
> -        if SectionType in ("UI", "VERSION"):
> +        if SectionType in (BINARY_FILE_TYPE_UI, "VERSION"):
>              return True
>          else:
>              return False
> @@ -4039,32 +4039,32 @@ class FdfParser:
>          if SectionType == "COMPAT16":
>              if FileType not in ("COMPAT16", "SEC_COMPAT16"):
>                  raise Warning("Incorrect section file type '%s'" % FileType,
> self.FileName, self.CurrentLineNumber)
> -        elif SectionType == "PE32":
> -            if FileType not in ("PE32", "SEC_PE32"):
> +        elif SectionType == BINARY_FILE_TYPE_PE32:
> +            if FileType not in (BINARY_FILE_TYPE_PE32, "SEC_PE32"):
>                  raise Warning("Incorrect section file type '%s'" % FileType,
> self.FileName, self.CurrentLineNumber)
> -        elif SectionType == "PIC":
> -            if FileType not in ("PIC", "PIC"):
> +        elif SectionType == BINARY_FILE_TYPE_PIC:
> +            if FileType not in (BINARY_FILE_TYPE_PIC, BINARY_FILE_TYPE_PIC):
>                  raise Warning("Incorrect section file type '%s'" % FileType,
> self.FileName, self.CurrentLineNumber)
> -        elif SectionType == "TE":
> -            if FileType not in ("TE", "SEC_TE"):
> +        elif SectionType == BINARY_FILE_TYPE_TE:
> +            if FileType not in (BINARY_FILE_TYPE_TE, "SEC_TE"):
>                  raise Warning("Incorrect section file type '%s'" % FileType,
> self.FileName, self.CurrentLineNumber)
>          elif SectionType == "RAW":
> -            if FileType not in ("BIN", "SEC_BIN", "RAW", "ASL", "ACPI"):
> +            if FileType not in (BINARY_FILE_TYPE_BIN, "SEC_BIN", "RAW", "ASL",
> "ACPI"):
>                  raise Warning("Incorrect section file type '%s'" % FileType,
> self.FileName, self.CurrentLineNumber)
> -        elif SectionType == "DXE_DEPEX" or SectionType == "SMM_DEPEX":
> -            if FileType not in ("DXE_DEPEX", "SEC_DXE_DEPEX", "SMM_DEPEX"):
> +        elif SectionType == BINARY_FILE_TYPE_DXE_DEPEX or SectionType ==
> BINARY_FILE_TYPE_SMM_DEPEX:
> +            if FileType not in (BINARY_FILE_TYPE_DXE_DEPEX, "SEC_DXE_DEPEX",
> BINARY_FILE_TYPE_SMM_DEPEX):
>                  raise Warning("Incorrect section file type '%s'" % FileType,
> self.FileName, self.CurrentLineNumber)
> -        elif SectionType == "UI":
> -            if FileType not in ("UI", "SEC_UI"):
> +        elif SectionType == BINARY_FILE_TYPE_UI:
> +            if FileType not in (BINARY_FILE_TYPE_UI, "SEC_UI"):
>                  raise Warning("Incorrect section file type '%s'" % FileType,
> self.FileName, self.CurrentLineNumber)
>          elif SectionType == "VERSION":
>              if FileType not in ("VERSION", "SEC_VERSION"):
>                  raise Warning("Incorrect section file type '%s'" % FileType,
> self.FileName, self.CurrentLineNumber)
> -        elif SectionType == "PEI_DEPEX":
> -            if FileType not in ("PEI_DEPEX", "SEC_PEI_DEPEX"):
> +        elif SectionType == BINARY_FILE_TYPE_PEI_DEPEX:
> +            if FileType not in (BINARY_FILE_TYPE_PEI_DEPEX, "SEC_PEI_DEPEX"):
>                  raise Warning("Incorrect section file type '%s'" % FileType,
> self.FileName, self.CurrentLineNumber)
> -        elif SectionType == "GUID":
> -            if FileType not in ("PE32", "SEC_GUID"):
> +        elif SectionType == BINARY_FILE_TYPE_GUID:
> +            if FileType not in (BINARY_FILE_TYPE_PE32, "SEC_GUID"):
>                  raise Warning("Incorrect section file type '%s'" % FileType,
> self.FileName, self.CurrentLineNumber)
> 
>      ## __GetRuleEncapsulationSection() method
> @@ -4501,7 +4501,7 @@ class FdfParser:
> 
>          FfsFileObj = OptRomFileStatement.OptRomFileStatement()
> 
> -        if not self.__IsKeyword("EFI") and not self.__IsKeyword("BIN"):
> +        if not self.__IsKeyword("EFI") and not
> self.__IsKeyword(BINARY_FILE_TYPE_BIN):
>              raise Warning("expected Binary type (EFI/BIN)", self.FileName,
> self.CurrentLineNumber)
>          FfsFileObj.FileType = self.__Token
> 
> @@ -4582,7 +4582,7 @@ class FdfParser:
>          if FdName.upper() in self.Profile.FdDict:
>              FdObj = self.Profile.FdDict[FdName.upper()]
>              for elementRegion in FdObj.RegionList:
> -                if elementRegion.RegionType == 'FV':
> +                if elementRegion.RegionType == BINARY_FILE_TYPE_FV:
>                      for elementRegionData in elementRegion.RegionDataList:
>                          if elementRegionData.endswith(".fv"):
>                              continue
> diff --git a/BaseTools/Source/Python/GenFds/Ffs.py
> b/BaseTools/Source/Python/GenFds/Ffs.py
> index f6a7f4b007f9..44ad01cb7354 100644
> --- a/BaseTools/Source/Python/GenFds/Ffs.py
> +++ b/BaseTools/Source/Python/GenFds/Ffs.py
> @@ -42,12 +42,12 @@ class Ffs(FDClassObject):
> 
>      # mapping between section type in FDF and file suffix
>      SectionSuffix = {
> -        'PE32'                 : '.pe32',
> -        'PIC'                  : '.pic',
> -        'TE'                   : '.te',
> -        'DXE_DEPEX'            : '.dpx',
> +        BINARY_FILE_TYPE_PE32                 : '.pe32',
> +        BINARY_FILE_TYPE_PIC                  : '.pic',
> +        BINARY_FILE_TYPE_TE                   : '.te',
> +        BINARY_FILE_TYPE_DXE_DEPEX            : '.dpx',
>          'VERSION'              : '.ver',
> -        'UI'                   : '.ui',
> +        BINARY_FILE_TYPE_UI                   : '.ui',
>          'COMPAT16'             : '.com16',
>          'RAW'                  : '.raw',
>          'FREEFORM_SUBTYPE_GUID': '.guid',
> @@ -55,8 +55,8 @@ class Ffs(FDClassObject):
>          'FV_IMAGE'             : 'fv.sec',
>          'COMPRESS'             : '.com',
>          'GUIDED'               : '.guided',
> -        'PEI_DEPEX'            : '.dpx',
> -        'SMM_DEPEX'            : '.dpx'
> +        BINARY_FILE_TYPE_PEI_DEPEX            : '.dpx',
> +        BINARY_FILE_TYPE_SMM_DEPEX            : '.dpx'
>      }
> 
>      ## The constructor
> diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py
> b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
> index 8893fcbda1fc..b92fa4d8033c 100644
> --- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py
> +++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
> @@ -381,7 +381,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
>          #
>          # Only patch file if FileType is PE32 or ModuleType is USER_DEFINED
>          #
> -        if FileType != 'PE32' and self.ModuleType !=
> SUP_MODULE_USER_DEFINED:
> +        if FileType != BINARY_FILE_TYPE_PE32 and self.ModuleType !=
> SUP_MODULE_USER_DEFINED:
>              return EfiFile
> 
>          #
> @@ -739,13 +739,13 @@ class
> FfsInfStatement(FfsInfStatementClassObject):
>          # Convert Fv Section Type for PI1.1 SMM driver.
>          #
>          if self.ModuleType == SUP_MODULE_DXE_SMM_DRIVER and
> int(self.PiSpecVersion, 16) >= 0x0001000A:
> -            if SectionType == 'DXE_DEPEX':
> -                SectionType = 'SMM_DEPEX'
> +            if SectionType == BINARY_FILE_TYPE_DXE_DEPEX:
> +                SectionType = BINARY_FILE_TYPE_SMM_DEPEX
>          #
>          # Framework SMM Driver has no SMM_DEPEX section type
>          #
>          if self.ModuleType == SUP_MODULE_DXE_SMM_DRIVER and
> int(self.PiSpecVersion, 16) < 0x0001000A:
> -            if SectionType == 'SMM_DEPEX':
> +            if SectionType == BINARY_FILE_TYPE_SMM_DEPEX:
>                  EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED,
> "Framework SMM module doesn't support SMM_DEPEX section type",
> File=self.InfFileName)
>          NoStrip = True
>          if self.ModuleType in (SUP_MODULE_SEC, SUP_MODULE_PEI_CORE,
> SUP_MODULE_PEIM):
> @@ -767,7 +767,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
>                  File = GenFdsGlobalVariable.MacroExtend(File, Dict,
> self.CurrentArch)
> 
>                  #Get PE Section alignment when align is set to AUTO
> -                if self.Alignment == 'Auto' and (SectionType == 'PE32' or
> SectionType == 'TE'):
> +                if self.Alignment == 'Auto' and (SectionType ==
> BINARY_FILE_TYPE_PE32 or SectionType == BINARY_FILE_TYPE_TE):
>                      ImageObj = PeImageClass (File)
>                      if ImageObj.SectionAlignment < 0x400:
>                          self.Alignment = str (ImageObj.SectionAlignment)
> @@ -790,7 +790,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
>                          )
>                      File = StrippedFile
> 
> -                if SectionType == 'TE':
> +                if SectionType == BINARY_FILE_TYPE_TE:
>                      TeFile = os.path.join( self.OutputPath, self.ModuleGuid + 'Te.raw')
>                      GenFdsGlobalVariable.GenerateFirmwareImage(
>                              TeFile,
> @@ -809,7 +809,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
>              GenSecInputFile =
> GenFdsGlobalVariable.MacroExtend(GenSecInputFile, Dict,
> self.CurrentArch)
> 
>              #Get PE Section alignment when align is set to AUTO
> -            if self.Alignment == 'Auto' and (SectionType == 'PE32' or SectionType
> == 'TE'):
> +            if self.Alignment == 'Auto' and (SectionType ==
> BINARY_FILE_TYPE_PE32 or SectionType == BINARY_FILE_TYPE_TE):
>                  ImageObj = PeImageClass (GenSecInputFile)
>                  if ImageObj.SectionAlignment < 0x400:
>                      self.Alignment = str (ImageObj.SectionAlignment)
> @@ -833,7 +833,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
>                      )
>                  GenSecInputFile = StrippedFile
> 
> -            if SectionType == 'TE':
> +            if SectionType == BINARY_FILE_TYPE_TE:
>                  TeFile = os.path.join( self.OutputPath, self.ModuleGuid + 'Te.raw')
>                  GenFdsGlobalVariable.GenerateFirmwareImage(
>                          TeFile,
> @@ -942,13 +942,13 @@ class
> FfsInfStatement(FfsInfStatementClassObject):
>              # Convert Fv Section Type for PI1.1 SMM driver.
>              #
>              if self.ModuleType == SUP_MODULE_DXE_SMM_DRIVER and
> int(self.PiSpecVersion, 16) >= 0x0001000A:
> -                if Sect.SectionType == 'DXE_DEPEX':
> -                    Sect.SectionType = 'SMM_DEPEX'
> +                if Sect.SectionType == BINARY_FILE_TYPE_DXE_DEPEX:
> +                    Sect.SectionType = BINARY_FILE_TYPE_SMM_DEPEX
>              #
>              # Framework SMM Driver has no SMM_DEPEX section type
>              #
>              if self.ModuleType == SUP_MODULE_DXE_SMM_DRIVER and
> int(self.PiSpecVersion, 16) < 0x0001000A:
> -                if Sect.SectionType == 'SMM_DEPEX':
> +                if Sect.SectionType == BINARY_FILE_TYPE_SMM_DEPEX:
>                      EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED,
> "Framework SMM module doesn't support SMM_DEPEX section type",
> File=self.InfFileName)
>              #
>              # process the inside FvImage from FvSection or GuidSection
> diff --git a/BaseTools/Source/Python/GenFds/Fv.py
> b/BaseTools/Source/Python/GenFds/Fv.py
> index 71bcd4c72170..024081734a2b 100644
> --- a/BaseTools/Source/Python/GenFds/Fv.py
> +++ b/BaseTools/Source/Python/GenFds/Fv.py
> @@ -80,7 +80,7 @@ class FV (FvClassObject):
>          if self.CapsuleName is not None:
>              for FdObj in GenFdsGlobalVariable.FdfParser.Profile.FdDict.values():
>                  for RegionObj in FdObj.RegionList:
> -                    if RegionObj.RegionType == 'FV':
> +                    if RegionObj.RegionType == BINARY_FILE_TYPE_FV:
>                          for RegionData in RegionObj.RegionDataList:
>                              if RegionData.endswith(".fv"):
>                                  continue
> @@ -236,7 +236,7 @@ class FV (FvClassObject):
> 
>          for FdObj in GenFdsGlobalVariable.FdfParser.Profile.FdDict.values():
>              for RegionObj in FdObj.RegionList:
> -                if RegionObj.RegionType != 'FV':
> +                if RegionObj.RegionType != BINARY_FILE_TYPE_FV:
>                      continue
>                  for RegionData in RegionObj.RegionDataList:
>                      #
> diff --git a/BaseTools/Source/Python/GenFds/GenFds.py
> b/BaseTools/Source/Python/GenFds/GenFds.py
> index 54c7d828305f..8bedd9f74411 100644
> --- a/BaseTools/Source/Python/GenFds/GenFds.py
> +++ b/BaseTools/Source/Python/GenFds/GenFds.py
> @@ -315,7 +315,7 @@ def main():
>                  for Fd in FdfParserObj.Profile.FdDict:
>                      FdObj = FdfParserObj.Profile.FdDict[Fd]
>                      for RegionObj in FdObj.RegionList:
> -                        if RegionObj.RegionType != 'FV':
> +                        if RegionObj.RegionType != BINARY_FILE_TYPE_FV:
>                              continue
>                          for RegionData in RegionObj.RegionDataList:
>                              if FvObj.UiFvName.upper() == RegionData.upper():
> @@ -405,7 +405,7 @@ def FindExtendTool(KeyStringList, CurrentArchList,
> NameGuid):
>                    KeyList[1] + \
>                    '_' + \
>                    KeyList[2]
> -            if Key in KeyStringList and KeyList[4] == 'GUID':
> +            if Key in KeyStringList and KeyList[4] == BINARY_FILE_TYPE_GUID:
>                  ToolPathKey   = Key + '_' + KeyList[3] + '_PATH'
>                  ToolOptionKey = Key + '_' + KeyList[3] + '_FLAGS'
>                  ToolPath = ToolDefinition.get(ToolPathKey)
> @@ -447,7 +447,7 @@ def FindExtendTool(KeyStringList, CurrentArchList,
> NameGuid):
>                  if NameGuid == BuildOption[Op]:
>                      KeyList = Op.split('_')
>                      Key = KeyList[0] + '_' + KeyList[1] +'_' + KeyList[2]
> -                    if Key in KeyStringList and KeyList[4] == 'GUID':
> +                    if Key in KeyStringList and KeyList[4] == BINARY_FILE_TYPE_GUID:
>                          ToolPathKey   = Key + '_' + KeyList[3] + '_PATH'
>                          ToolOptionKey = Key + '_' + KeyList[3] + '_FLAGS'
>          if ToolPathKey in BuildOption:
> @@ -589,7 +589,7 @@ class GenFds :
>          if FdObj is None:
>              for ElementFd in
> GenFdsGlobalVariable.FdfParser.Profile.FdDict.values():
>                  for ElementRegion in ElementFd.RegionList:
> -                    if ElementRegion.RegionType == 'FV':
> +                    if ElementRegion.RegionType == BINARY_FILE_TYPE_FV:
>                          for ElementRegionData in ElementRegion.RegionDataList:
>                              if ElementRegionData is not None and
> ElementRegionData.upper() == FvObj.UiFvName:
>                                  if FvObj.BlockSizeList != []:
> @@ -601,7 +601,7 @@ class GenFds :
>              return DefaultBlockSize
>          else:
>              for ElementRegion in FdObj.RegionList:
> -                    if ElementRegion.RegionType == 'FV':
> +                    if ElementRegion.RegionType == BINARY_FILE_TYPE_FV:
>                          for ElementRegionData in ElementRegion.RegionDataList:
>                              if ElementRegionData is not None and
> ElementRegionData.upper() == FvObj.UiFvName:
>                                  if FvObj.BlockSizeList != []:
> diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
> b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
> index e692e4e98504..878b13d13c2d 100644
> --- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
> +++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
> @@ -288,7 +288,7 @@ class GenFdsGlobalVariable:
>  #        GenFdsGlobalVariable.OutputDirDict = OutputDir
>          GenFdsGlobalVariable.FdfParser = FdfParser
>          GenFdsGlobalVariable.WorkSpace = WorkSpace
> -        GenFdsGlobalVariable.FvDir =
> os.path.join(GenFdsGlobalVariable.OutputDirDict[ArchList[0]], 'FV')
> +        GenFdsGlobalVariable.FvDir =
> os.path.join(GenFdsGlobalVariable.OutputDirDict[ArchList[0]],
> DataType.BINARY_FILE_TYPE_FV)
>          if not os.path.exists(GenFdsGlobalVariable.FvDir) :
>              os.makedirs(GenFdsGlobalVariable.FvDir)
>          GenFdsGlobalVariable.FfsDir = os.path.join(GenFdsGlobalVariable.FvDir,
> 'Ffs')
> @@ -349,7 +349,7 @@ class GenFdsGlobalVariable:
>              GenFdsGlobalVariable.PlatformName =
> WorkSpace.Db.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch,
>                                                                        GlobalData.gGlobalDefines['TARGET'],
> 
> GlobalData.gGlobalDefines['TOOLCHAIN']].PlatformName
> -        GenFdsGlobalVariable.FvDir =
> os.path.join(GenFdsGlobalVariable.OutputDirDict[ArchList[0]], 'FV')
> +        GenFdsGlobalVariable.FvDir =
> os.path.join(GenFdsGlobalVariable.OutputDirDict[ArchList[0]],
> DataType.BINARY_FILE_TYPE_FV)
>          if not os.path.exists(GenFdsGlobalVariable.FvDir):
>              os.makedirs(GenFdsGlobalVariable.FvDir)
>          GenFdsGlobalVariable.FfsDir = os.path.join(GenFdsGlobalVariable.FvDir,
> 'Ffs')
> diff --git a/BaseTools/Source/Python/GenFds/OptRomInfStatement.py
> b/BaseTools/Source/Python/GenFds/OptRomInfStatement.py
> index 8f8761b20589..a865ac4436d5 100644
> --- a/BaseTools/Source/Python/GenFds/OptRomInfStatement.py
> +++ b/BaseTools/Source/Python/GenFds/OptRomInfStatement.py
> @@ -141,7 +141,7 @@ class OptRomInfStatement (FfsInfStatement):
> 
>          OutputFileList = []
>          for Sect in Rule.SectionList:
> -            if Sect.SectionType == 'PE32':
> +            if Sect.SectionType == BINARY_FILE_TYPE_PE32:
>                  if Sect.FileName is not None:
>                      GenSecInputFile = self.__ExtendMacro__(Sect.FileName)
>                      OutputFileList.append(GenSecInputFile)
> diff --git a/BaseTools/Source/Python/GenFds/Region.py
> b/BaseTools/Source/Python/GenFds/Region.py
> index 44f122a71216..9d632b6321e2 100644
> --- a/BaseTools/Source/Python/GenFds/Region.py
> +++ b/BaseTools/Source/Python/GenFds/Region.py
> @@ -26,6 +26,7 @@ from Common import EdkLogger
>  from Common.BuildToolError import *
>  from Common.LongFilePathSupport import OpenLongFilePath as open
>  from Common.MultipleWorkspace import MultipleWorkspace as mws
> +from Common.DataType import BINARY_FILE_TYPE_FV
> 
>  ## generate Region
>  #
> @@ -80,10 +81,10 @@ class Region(RegionClassObject):
>              GenFdsGlobalVariable.InfLogger('\nGenerate Region at Offset 0x%X'
> % self.Offset)
>              GenFdsGlobalVariable.InfLogger("   Region Size = 0x%X" % Size)
>          GenFdsGlobalVariable.SharpCounter = 0
> -        if Flag and (self.RegionType != 'FV'):
> +        if Flag and (self.RegionType != BINARY_FILE_TYPE_FV):
>              return
> 
> -        if self.RegionType == 'FV':
> +        if self.RegionType == BINARY_FILE_TYPE_FV:
>              #
>              # Get Fv from FvDict
>              #
> diff --git a/BaseTools/Source/Python/GenFds/Section.py
> b/BaseTools/Source/Python/GenFds/Section.py
> index 4b368b3ada9d..5895998158b6 100644
> --- a/BaseTools/Source/Python/GenFds/Section.py
> +++ b/BaseTools/Source/Python/GenFds/Section.py
> @@ -20,7 +20,7 @@ from GenFdsGlobalVariable import
> GenFdsGlobalVariable
>  import Common.LongFilePathOs as os, glob
>  from Common import EdkLogger
>  from Common.BuildToolError import *
> -from Common.DataType import TAB_ARCH_COMMON
> +from Common.DataType import *
> 
>  ## section base class
>  #
> @@ -29,37 +29,37 @@ class Section (SectionClassObject):
>      SectionType = {
>          'RAW'       : 'EFI_SECTION_RAW',
>          'FREEFORM'  : 'EFI_SECTION_FREEFORM_SUBTYPE_GUID',
> -        'PE32'      : 'EFI_SECTION_PE32',
> -        'PIC'       : 'EFI_SECTION_PIC',
> -        'TE'        : 'EFI_SECTION_TE',
> +        BINARY_FILE_TYPE_PE32      : 'EFI_SECTION_PE32',
> +        BINARY_FILE_TYPE_PIC       : 'EFI_SECTION_PIC',
> +        BINARY_FILE_TYPE_TE        : 'EFI_SECTION_TE',
>          'FV_IMAGE'  : 'EFI_SECTION_FIRMWARE_VOLUME_IMAGE',
> -        'DXE_DEPEX' : 'EFI_SECTION_DXE_DEPEX',
> -        'PEI_DEPEX' : 'EFI_SECTION_PEI_DEPEX',
> +        BINARY_FILE_TYPE_DXE_DEPEX : 'EFI_SECTION_DXE_DEPEX',
> +        BINARY_FILE_TYPE_PEI_DEPEX : 'EFI_SECTION_PEI_DEPEX',
>          'GUIDED'    : 'EFI_SECTION_GUID_DEFINED',
>          'COMPRESS'  : 'EFI_SECTION_COMPRESSION',
> -        'UI'        : 'EFI_SECTION_USER_INTERFACE',
> -        'SMM_DEPEX' : 'EFI_SECTION_SMM_DEPEX'
> +        BINARY_FILE_TYPE_UI        : 'EFI_SECTION_USER_INTERFACE',
> +        BINARY_FILE_TYPE_SMM_DEPEX : 'EFI_SECTION_SMM_DEPEX'
>      }
> 
>      BinFileType = {
> -        'GUID'          : '.guid',
> +        BINARY_FILE_TYPE_GUID          : '.guid',
>          'ACPI'          : '.acpi',
>          'ASL'           : '.asl' ,
> -        'UEFI_APP'      : '.app',
> -        'LIB'           : '.lib',
> -        'PE32'          : '.pe32',
> -        'PIC'           : '.pic',
> -        'PEI_DEPEX'     : '.depex',
> +        BINARY_FILE_TYPE_UEFI_APP      : '.app',
> +        BINARY_FILE_TYPE_LIB           : '.lib',
> +        BINARY_FILE_TYPE_PE32          : '.pe32',
> +        BINARY_FILE_TYPE_PIC           : '.pic',
> +        BINARY_FILE_TYPE_PEI_DEPEX     : '.depex',
>          'SEC_PEI_DEPEX' : '.depex',
> -        'TE'            : '.te',
> -        'UNI_VER'       : '.ver',
> -        'VER'           : '.ver',
> -        'UNI_UI'        : '.ui',
> -        'UI'            : '.ui',
> -        'BIN'           : '.bin',
> +        BINARY_FILE_TYPE_TE            : '.te',
> +        BINARY_FILE_TYPE_UNI_VER       : '.ver',
> +        BINARY_FILE_TYPE_VER           : '.ver',
> +        BINARY_FILE_TYPE_UNI_UI        : '.ui',
> +        BINARY_FILE_TYPE_UI            : '.ui',
> +        BINARY_FILE_TYPE_BIN           : '.bin',
>          'RAW'           : '.raw',
>          'COMPAT16'      : '.comp16',
> -        'FV'            : '.fv'
> +        BINARY_FILE_TYPE_FV            : '.fv'
>      }
> 
>      SectFileType = {
> @@ -128,8 +128,8 @@ class Section (SectionClassObject):
>              for File in FfsInf.BinFileList:
>                  if File.Arch == TAB_ARCH_COMMON or FfsInf.CurrentArch ==
> File.Arch:
>                      if File.Type == FileType or (int(FfsInf.PiSpecVersion, 16) >=
> 0x0001000A \
> -                                                 and FileType == 'DXE_DPEX'and File.Type ==
> 'SMM_DEPEX') \
> -                                                 or (FileType == 'TE'and File.Type == 'PE32'):
> +                                                 and FileType == 'DXE_DPEX' and File.Type ==
> BINARY_FILE_TYPE_SMM_DEPEX) \
> +                                                 or (FileType == BINARY_FILE_TYPE_TE and File.Type
> == BINARY_FILE_TYPE_PE32):
>                          if '*' in FfsInf.TargetOverrideList or File.Target == '*' or
> File.Target in FfsInf.TargetOverrideList or FfsInf.TargetOverrideList == []:
>                              FileList.append(FfsInf.PatchEfiFile(File.Path, File.Type))
>                          else:
> diff --git a/BaseTools/Source/Python/GenFds/UiSection.py
> b/BaseTools/Source/Python/GenFds/UiSection.py
> index 084f761e1285..31d3edebb4ef 100644
> --- a/BaseTools/Source/Python/GenFds/UiSection.py
> +++ b/BaseTools/Source/Python/GenFds/UiSection.py
> @@ -58,7 +58,7 @@ class UiSection (UiSectionClassObject):
>              self.StringData = FfsInf.__ExtendMacro__(self.StringData)
>              self.FileName = FfsInf.__ExtendMacro__(self.FileName)
> 
> -        OutputFile = os.path.join(OutputPath, ModuleName +
> SUP_MODULE_SEC + SecNum + Ffs.SectionSuffix.get('UI'))
> +        OutputFile = os.path.join(OutputPath, ModuleName +
> SUP_MODULE_SEC + SecNum +
> Ffs.SectionSuffix.get(BINARY_FILE_TYPE_UI))
> 
>          if self.StringData is not None :
>              NameString = self.StringData
> diff --git a/BaseTools/Source/Python/Trim/Trim.py
> b/BaseTools/Source/Python/Trim/Trim.py
> index 3eb7fa39209d..3afe759667ac 100644
> --- a/BaseTools/Source/Python/Trim/Trim.py
> +++ b/BaseTools/Source/Python/Trim/Trim.py
> @@ -303,7 +303,7 @@ def TrimPreprocessedVfr(Source, Target):
>              FoundTypedef = False
>              TypedefEnd = Index
>              # keep all "typedef struct" except to GUID, EFI_PLABEL and
> PAL_CALL_RETURN
> -            if Line.strip("} ;\r\n") in ["GUID", "EFI_PLABEL", "PAL_CALL_RETURN"]:
> +            if Line.strip("} ;\r\n") in [BINARY_FILE_TYPE_GUID, "EFI_PLABEL",
> "PAL_CALL_RETURN"]:
>                  for i in range(TypedefStart, TypedefEnd+1):
>                      Lines[i] = "\n"
> 
> diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py
> b/BaseTools/Source/Python/Workspace/DscBuildData.py
> index 373441521723..6943fab4e5c8 100644
> --- a/BaseTools/Source/Python/Workspace/DscBuildData.py
> +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
> @@ -1506,7 +1506,7 @@ class DscBuildData(PlatformBuildClassObject):
>          def get_length(value):
>              Value = value.strip()
>              if len(value) > 1:
> -                if Value.startswith('GUID') and Value.endswith(')'):
> +                if Value.startswith(BINARY_FILE_TYPE_GUID) and
> Value.endswith(')'):
>                      return 16
>                  if Value.startswith('L"') and Value.endswith('"'):
>                      return len(Value[2:-1])
> diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py
> b/BaseTools/Source/Python/Workspace/InfBuildData.py
> index 157f7a2d2de8..cf5e1df3a523 100644
> --- a/BaseTools/Source/Python/Workspace/InfBuildData.py
> +++ b/BaseTools/Source/Python/Workspace/InfBuildData.py
> @@ -71,7 +71,7 @@ class InfBuildData(ModuleBuildClassObject):
>      # dict used to convert old tool name used in [nmake] section to new ones
>      _TOOL_CODE_ = {
>          "C"         :   "CC",
> -        "LIB"       :   "SLINK",
> +        BINARY_FILE_TYPE_LIB       :   "SLINK",
>          "LINK"      :   "DLINK",
>      }
> 
> diff --git a/BaseTools/Source/Python/build/BuildReport.py
> b/BaseTools/Source/Python/build/BuildReport.py
> index c8948b5cfbd9..f551c3ac8f91 100644
> --- a/BaseTools/Source/Python/build/BuildReport.py
> +++ b/BaseTools/Source/Python/build/BuildReport.py
> @@ -208,7 +208,7 @@ def FindIncludeFiles(Source, IncludePathList,
> IncludeFiles):
>              FileName = "Protocol/%(Key)s/%(Key)s.h" % {"Key" : Key}
>          elif "PPI" in Type:
>              FileName = "Ppi/%(Key)s/%(Key)s.h" % {"Key" : Key}
> -        elif "GUID" in Type:
> +        elif BINARY_FILE_TYPE_GUID in Type:
>              FileName = "Guid/%(Key)s/%(Key)s.h" % {"Key" : Key}
>          else:
>              continue
> @@ -1410,7 +1410,7 @@ class PredictionReport(object):
>          if Wa.FdfProfile:
>              for Fd in Wa.FdfProfile.FdDict:
>                  for FdRegion in Wa.FdfProfile.FdDict[Fd].RegionList:
> -                    if FdRegion.RegionType != "FV":
> +                    if FdRegion.RegionType != BINARY_FILE_TYPE_FV:
>                          continue
>                      for FvName in FdRegion.RegionDataList:
>                          if FvName in self._FvList:
> @@ -1686,7 +1686,7 @@ class FdRegionReport(object):
>          # If the input FdRegion is not a firmware volume,
>          # we are done.
>          #
> -        if self.Type != "FV":
> +        if self.Type != BINARY_FILE_TYPE_FV:
>              return
> 
>          #
> @@ -1780,7 +1780,7 @@ class FdRegionReport(object):
>          FileWrite(File, "Type:               %s" % Type)
>          FileWrite(File, "Base Address:       0x%X" % BaseAddress)
> 
> -        if self.Type == "FV":
> +        if self.Type == BINARY_FILE_TYPE_FV:
>              FvTotalSize = 0
>              FvTakenSize = 0
>              FvFreeSize  = 0
> @@ -1843,7 +1843,7 @@ class FdRegionReport(object):
>          if (len(self.FvList) > 0):
>              for FvItem in self.FvList:
>                  Info = self.FvInfo[FvItem]
> -                self._GenerateReport(File, Info[0], "FV", Info[1], Info[2], FvItem)
> +                self._GenerateReport(File, Info[0], BINARY_FILE_TYPE_FV, Info[1],
> Info[2], FvItem)
>          else:
>              self._GenerateReport(File, "FD Region", self.Type, self.BaseAddress,
> self.Size)
> 
> @@ -1869,7 +1869,7 @@ class FdReport(object):
>          self.BaseAddress = Fd.BaseAddress
>          self.Size = Fd.Size
>          self.FdRegionList = [FdRegionReport(FdRegion, Wa) for FdRegion in
> Fd.RegionList]
> -        self.FvPath = os.path.join(Wa.BuildDir, "FV")
> +        self.FvPath = os.path.join(Wa.BuildDir, BINARY_FILE_TYPE_FV)
>          self.VpdFilePath = os.path.join(self.FvPath, "%s.map" %
> Wa.Platform.VpdToolGuid)
>          self.VPDBaseAddress = 0
>          self.VPDSize = 0
> --
> 2.16.2.windows.1



^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH v1 16/27] BaseTools: Replace EDK Component strings with predefined constant
  2018-04-24  7:42   ` Zhu, Yonghong
@ 2018-04-24 14:13     ` Carsey, Jaben
  0 siblings, 0 replies; 56+ messages in thread
From: Carsey, Jaben @ 2018-04-24 14:13 UTC (permalink / raw)
  To: Zhu, Yonghong, edk2-devel@lists.01.org; +Cc: Gao, Liming

Sure.  We could make a new constant that is defined to the same value.  Do you want to propose a name?

> -----Original Message-----
> From: Zhu, Yonghong
> Sent: Tuesday, April 24, 2018 12:42 AM
> To: Carsey, Jaben <jaben.carsey@intel.com>; edk2-devel@lists.01.org
> Cc: Gao, Liming <liming.gao@intel.com>; Zhu, Yonghong
> <yonghong.zhu@intel.com>
> Subject: RE: [PATCH v1 16/27] BaseTools: Replace EDK Component strings
> with predefined constant
> Importance: High
> 
> Hi Jaben,
> 
> For build.py (-Y option) and BuildReport.py, use
> EDK_COMPONENT_TYPE_LIBRARY to replace "LIBRARY" may be confusion.
> One is component type, another is report type though they use same
> keyword.
> If we really want to do this replacement, how about use another constant
> name ? besides, whether we need cover the other report type, not only the
> "LIBRARY" ?
> 
> Best Regards,
> Zhu Yonghong
> 
> 
> -----Original Message-----
> From: Carsey, Jaben
> Sent: Friday, April 20, 2018 11:52 PM
> To: edk2-devel@lists.01.org
> Cc: Gao, Liming <liming.gao@intel.com>; Zhu, Yonghong
> <yonghong.zhu@intel.com>
> Subject: [PATCH v1 16/27] BaseTools: Replace EDK Component strings with
> predefined constant
> 
> EDK_COMPONENT_TYPE_LIBRARY was 'LIBRARY'
> EDK_COMPONENT_TYPE_SECURITY_CORE was 'SECURITY_CORE'
> EDK_COMPONENT_TYPE_COMBINED_PEIM_DRIVER was
> 'COMBINED_PEIM_DRIVER'
> EDK_COMPONENT_TYPE_PIC_PEIM was 'PIC_PEIM'
> EDK_COMPONENT_TYPE_RELOCATABLE_PEIM was 'RELOCATABLE_PEIM'
> EDK_COMPONENT_TYPE_BS_DRIVER was 'BS_DRIVER'
> EDK_COMPONENT_TYPE_RT_DRIVER was 'RT_DRIVER'
> EDK_COMPONENT_TYPE_SAL_RT_DRIVER was 'SAL_RT_DRIVER'
> EDK_COMPONENT_TYPE_APPLICATION was 'APPLICATION'
> 
> 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>
> ---
>  BaseTools/Source/Python/Common/DataType.py        | 28 ++++++++++------
> ----
>  BaseTools/Source/Python/GenFds/FdfParser.py       |  6 ++---
>  BaseTools/Source/Python/GenFds/Ffs.py             |  2 +-
>  BaseTools/Source/Python/Workspace/InfBuildData.py |  2 +-
>  BaseTools/Source/Python/build/BuildReport.py      |  6 ++---
>  BaseTools/Source/Python/build/build.py            |  8 +++---
>  6 files changed, 26 insertions(+), 26 deletions(-)
> 
> diff --git a/BaseTools/Source/Python/Common/DataType.py
> b/BaseTools/Source/Python/Common/DataType.py
> index ab9acb417331..74ed711abc52 100644
> --- a/BaseTools/Source/Python/Common/DataType.py
> +++ b/BaseTools/Source/Python/Common/DataType.py
> @@ -80,7 +80,7 @@ SUP_MODULE_LIST_STRING =
> TAB_VALUE_SPLIT.join(SUP_MODULE_LIST)
>  SUP_MODULE_SET_PEI = {SUP_MODULE_PEIM, SUP_MODULE_PEI_CORE}
> 
>  EDK_COMPONENT_TYPE_LIBRARY = 'LIBRARY'
> -EDK_COMPONENT_TYPE_SECUARITY_CORE = 'SECUARITY_CORE'
> +EDK_COMPONENT_TYPE_SECURITY_CORE = 'SECURITY_CORE'
>  EDK_COMPONENT_TYPE_PEI_CORE = SUP_MODULE_PEI_CORE
> EDK_COMPONENT_TYPE_COMBINED_PEIM_DRIVER =
> 'COMBINED_PEIM_DRIVER'
>  EDK_COMPONENT_TYPE_PIC_PEIM = 'PIC_PEIM'
> @@ -93,18 +93,18 @@ 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,
> +    EDK_COMPONENT_TYPE_LIBRARY               :   SUP_MODULE_BASE,
> +    EDK_COMPONENT_TYPE_SECURITY_CORE         :   SUP_MODULE_SEC,
> +    EDK_COMPONENT_TYPE_PEI_CORE              :   SUP_MODULE_PEI_CORE,
> +    EDK_COMPONENT_TYPE_COMBINED_PEIM_DRIVER  :
> SUP_MODULE_PEIM,
> +    EDK_COMPONENT_TYPE_PIC_PEIM              :   SUP_MODULE_PEIM,
> +    EDK_COMPONENT_TYPE_RELOCATABLE_PEIM      :   SUP_MODULE_PEIM,
> +    "PE32_PEIM"                              :   SUP_MODULE_PEIM,
> +    EDK_COMPONENT_TYPE_BS_DRIVER             :
> SUP_MODULE_DXE_DRIVER,
> +    EDK_COMPONENT_TYPE_RT_DRIVER             :
> SUP_MODULE_DXE_RUNTIME_DRIVER,
> +    EDK_COMPONENT_TYPE_SAL_RT_DRIVER         :
> SUP_MODULE_DXE_SAL_DRIVER,
> +    EDK_COMPONENT_TYPE_APPLICATION           :
> SUP_MODULE_UEFI_APPLICATION,
> +    "LOGO"                                   :   SUP_MODULE_BASE,
>  }
> 
>  BINARY_FILE_TYPE_FW = 'FW'
> @@ -125,7 +125,7 @@ BINARY_FILE_TYPE_UI = 'UI'
>  BINARY_FILE_TYPE_BIN = 'BIN'
>  BINARY_FILE_TYPE_FV = 'FV'
> 
> -PLATFORM_COMPONENT_TYPE_LIBRARY = 'LIBRARY'
> +PLATFORM_COMPONENT_TYPE_LIBRARY =
> EDK_COMPONENT_TYPE_LIBRARY
>  PLATFORM_COMPONENT_TYPE_LIBRARY_CLASS = 'LIBRARY_CLASS'
>  PLATFORM_COMPONENT_TYPE_MODULE = 'MODULE'
> 
> diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py
> b/BaseTools/Source/Python/GenFds/FdfParser.py
> index 4ec114a81883..e117a3717d42 100644
> --- a/BaseTools/Source/Python/GenFds/FdfParser.py
> +++ b/BaseTools/Source/Python/GenFds/FdfParser.py
> @@ -3637,8 +3637,8 @@ class FdfParser:
>                               SUP_MODULE_DXE_DRIVER,
> SUP_MODULE_DXE_SAL_DRIVER, \
>                               SUP_MODULE_DXE_SMM_DRIVER,
> SUP_MODULE_DXE_RUNTIME_DRIVER, \
>                               SUP_MODULE_UEFI_DRIVER,
> SUP_MODULE_UEFI_APPLICATION, SUP_MODULE_USER_DEFINED,
> "DEFAULT", SUP_MODULE_BASE, \
> -                             "SECURITY_CORE", "COMBINED_PEIM_DRIVER", "PIC_PEIM",
> "RELOCATABLE_PEIM", \
> -                                        "PE32_PEIM", "BS_DRIVER", "RT_DRIVER",
> "SAL_RT_DRIVER", "APPLICATION", "ACPITABLE",
> SUP_MODULE_SMM_CORE, SUP_MODULE_MM_STANDALONE,
> SUP_MODULE_MM_CORE_STANDALONE):
> +                             EDK_COMPONENT_TYPE_SECURITY_CORE,
> EDK_COMPONENT_TYPE_COMBINED_PEIM_DRIVER,
> EDK_COMPONENT_TYPE_PIC_PEIM,
> EDK_COMPONENT_TYPE_RELOCATABLE_PEIM, \
> +                                        "PE32_PEIM", EDK_COMPONENT_TYPE_BS_DRIVER,
> EDK_COMPONENT_TYPE_RT_DRIVER,
> EDK_COMPONENT_TYPE_SAL_RT_DRIVER,
> EDK_COMPONENT_TYPE_APPLICATION, "ACPITABLE",
> SUP_MODULE_SMM_CORE, SUP_MODULE_MM_STANDALONE,
> SUP_MODULE_MM_CORE_STANDALONE):
>              raise Warning("Unknown Module type '%s'" % self.__Token,
> self.FileName, self.CurrentLineNumber)
>          return self.__Token
> 
> @@ -3681,7 +3681,7 @@ class FdfParser:
> 
>          Type = self.__Token.strip().upper()
>          if Type not in ("RAW", "FREEFORM", SUP_MODULE_SEC,
> SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM,\
> -                             "PEI_DXE_COMBO", "DRIVER", SUP_MODULE_DXE_CORE,
> "APPLICATION", "FV_IMAGE", "SMM", SUP_MODULE_SMM_CORE,
> SUP_MODULE_MM_STANDALONE,
> SUP_MODULE_MM_CORE_STANDALONE):
> +                             "PEI_DXE_COMBO", "DRIVER", SUP_MODULE_DXE_CORE,
> EDK_COMPONENT_TYPE_APPLICATION, "FV_IMAGE", "SMM",
> SUP_MODULE_SMM_CORE, SUP_MODULE_MM_STANDALONE,
> SUP_MODULE_MM_CORE_STANDALONE):
>              raise Warning("Unknown FV type '%s'" % self.__Token, self.FileName,
> self.CurrentLineNumber)
> 
>          if not self.__IsToken("="):
> diff --git a/BaseTools/Source/Python/GenFds/Ffs.py
> b/BaseTools/Source/Python/GenFds/Ffs.py
> index fc760ae8beda..f15d2330ce58 100644
> --- a/BaseTools/Source/Python/GenFds/Ffs.py
> +++ b/BaseTools/Source/Python/GenFds/Ffs.py
> @@ -48,7 +48,7 @@ class Ffs(FDClassObject):
>          SUP_MODULE_DXE_CORE          : 'EFI_FV_FILETYPE_DXE_CORE',
>          'FREEFORM'          : 'EFI_FV_FILETYPE_FREEFORM',
>          'DRIVER'            : 'EFI_FV_FILETYPE_DRIVER',
> -        'APPLICATION'       : 'EFI_FV_FILETYPE_APPLICATION',
> +        EDK_COMPONENT_TYPE_APPLICATION       :
> 'EFI_FV_FILETYPE_APPLICATION',
>          'FV_IMAGE'          : 'EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE',
>          'RAW'               : 'EFI_FV_FILETYPE_RAW',
>          'PEI_DXE_COMBO'     : 'EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER',
> diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py
> b/BaseTools/Source/Python/Workspace/InfBuildData.py
> index d64a281a98f7..27ef163eb40c 100644
> --- a/BaseTools/Source/Python/Workspace/InfBuildData.py
> +++ b/BaseTools/Source/Python/Workspace/InfBuildData.py
> @@ -344,7 +344,7 @@ class InfBuildData(ModuleBuildClassObject):
>              self._BuildType = self._ComponentType.upper()
>              if self._ComponentType in COMPONENT_TO_MODULE_MAP_DICT:
>                  self._ModuleType =
> COMPONENT_TO_MODULE_MAP_DICT[self._ComponentType]
> -            if self._ComponentType == 'LIBRARY':
> +            if self._ComponentType == EDK_COMPONENT_TYPE_LIBRARY:
>                  self._LibraryClass = [LibraryClassObject(self._BaseName,
> SUP_MODULE_LIST)]
>              # make use some [nmake] section macros
>              Macros = self._Macros
> diff --git a/BaseTools/Source/Python/build/BuildReport.py
> b/BaseTools/Source/Python/build/BuildReport.py
> index 5846c2870d2e..02e01a1fa2ab 100644
> --- a/BaseTools/Source/Python/build/BuildReport.py
> +++ b/BaseTools/Source/Python/build/BuildReport.py
> @@ -599,7 +599,7 @@ class ModuleReport(object):
>                  self.ModulePcdSet.setdefault((Pcd.TokenCName,
> Pcd.TokenSpaceGuidCName, Pcd.Type), (Pcd.InfDefaultValue,
> Pcd.DefaultValue))
> 
>          self.LibraryReport = None
> -        if "LIBRARY" in ReportType:
> +        if EDK_COMPONENT_TYPE_LIBRARY in ReportType:
>              self.LibraryReport = LibraryReport(M)
> 
>          self.DepexReport = None
> @@ -702,7 +702,7 @@ class ModuleReport(object):
>          if "PCD" in ReportType:
>              GlobalPcdReport.GenerateReport(File, self.ModulePcdSet)
> 
> -        if "LIBRARY" in ReportType:
> +        if EDK_COMPONENT_TYPE_LIBRARY in ReportType:
>              self.LibraryReport.GenerateReport(File)
> 
>          if "DEPEX" in ReportType:
> @@ -2097,7 +2097,7 @@ class BuildReport(object):
>                      if ReportTypeItem not in self.ReportType:
>                          self.ReportType.append(ReportTypeItem)
>              else:
> -                self.ReportType = ["PCD", "LIBRARY", "BUILD_FLAGS", "DEPEX",
> "HASH", "FLASH", "FIXED_ADDRESS"]
> +                self.ReportType = ["PCD", EDK_COMPONENT_TYPE_LIBRARY,
> + "BUILD_FLAGS", "DEPEX", "HASH", "FLASH", "FIXED_ADDRESS"]
>      ##
>      # Adds platform report to the list
>      #
> diff --git a/BaseTools/Source/Python/build/build.py
> b/BaseTools/Source/Python/build/build.py
> index 81d59dd3eedf..29ad0c7228c7 100644
> --- a/BaseTools/Source/Python/build/build.py
> +++ b/BaseTools/Source/Python/build/build.py
> @@ -1587,13 +1587,13 @@ class Build():
>                      if not ImageClass.IsValid:
>                          EdkLogger.error("build", FILE_PARSE_FAILURE,
> ExtraData=ImageClass.ErrorInfo)
>                      ImageInfo = PeImageInfo(Module.Name, Module.Guid,
> Module.Arch, Module.OutputDir, Module.DebugDir, ImageClass)
> -                    if Module.ModuleType in [SUP_MODULE_PEI_CORE,
> SUP_MODULE_PEIM, 'COMBINED_PEIM_DRIVER', 'PIC_PEIM',
> 'RELOCATABLE_PEIM', SUP_MODULE_DXE_CORE]:
> +                    if Module.ModuleType in [SUP_MODULE_PEI_CORE,
> SUP_MODULE_PEIM, EDK_COMPONENT_TYPE_COMBINED_PEIM_DRIVER,
> EDK_COMPONENT_TYPE_PIC_PEIM,
> EDK_COMPONENT_TYPE_RELOCATABLE_PEIM, SUP_MODULE_DXE_CORE]:
>                          PeiModuleList[Module.MetaFile] = ImageInfo
>                          PeiSize += ImageInfo.Image.Size
> -                    elif Module.ModuleType in ['BS_DRIVER',
> SUP_MODULE_DXE_DRIVER, SUP_MODULE_UEFI_DRIVER]:
> +                    elif Module.ModuleType in
> [EDK_COMPONENT_TYPE_BS_DRIVER, SUP_MODULE_DXE_DRIVER,
> SUP_MODULE_UEFI_DRIVER]:
>                          BtModuleList[Module.MetaFile] = ImageInfo
>                          BtSize += ImageInfo.Image.Size
> -                    elif Module.ModuleType in
> [SUP_MODULE_DXE_RUNTIME_DRIVER, 'RT_DRIVER',
> SUP_MODULE_DXE_SAL_DRIVER, 'SAL_RT_DRIVER']:
> +                    elif Module.ModuleType in
> [SUP_MODULE_DXE_RUNTIME_DRIVER,
> EDK_COMPONENT_TYPE_RT_DRIVER, SUP_MODULE_DXE_SAL_DRIVER,
> EDK_COMPONENT_TYPE_SAL_RT_DRIVER]:
>                          RtModuleList[Module.MetaFile] = ImageInfo
>                          #IPF runtime driver needs to be at 2 page alignment.
>                          if IsIpfPlatform and ImageInfo.Image.Size % 0x2000 != 0:
> @@ -2356,7 +2356,7 @@ def MyOptionParser():
>      Parser.add_option("-D", "--define", action="append", type="string",
> dest="Macros", help="Macro: \"Name [= Value]\".")
> 
>      Parser.add_option("-y", "--report-file", action="store", dest="ReportFile",
> help="Create/overwrite the report to the specified filename.")
> -    Parser.add_option("-Y", "--report-type", action="append", type="choice",
> choices=['PCD','LIBRARY','FLASH','DEPEX','BUILD_FLAGS','FIXED_ADDRESS','H
> ASH','EXECUTION_ORDER'], dest="ReportType", default=[],
> +    Parser.add_option("-Y", "--report-type", action="append",
> + type="choice",
> +
> choices=['PCD',EDK_COMPONENT_TYPE_LIBRARY,'FLASH','DEPEX','BUILD_FL
> AGS
> + ','FIXED_ADDRESS','HASH','EXECUTION_ORDER'], dest="ReportType",
> + default=[],
>          help="Flags that control the type of build report to generate.  Must be
> one of: [PCD, LIBRARY, FLASH, DEPEX, BUILD_FLAGS, FIXED_ADDRESS, HASH,
> EXECUTION_ORDER].  "\
>               "To specify more than one flag, repeat this option on the command
> line and the default flag set is [PCD, LIBRARY, FLASH, DEPEX, HASH,
> BUILD_FLAGS, FIXED_ADDRESS]")
>      Parser.add_option("-F", "--flag", action="store", type="string",
> dest="Flag",
> --
> 2.16.2.windows.1



^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH v1 13/27] BaseTools: replace string constants used for module types
  2018-04-20 15:51 ` [PATCH v1 13/27] BaseTools: replace string constants used for module types Jaben Carsey
@ 2018-04-25  5:57   ` Zhu, Yonghong
  0 siblings, 0 replies; 56+ messages in thread
From: Zhu, Yonghong @ 2018-04-25  5:57 UTC (permalink / raw)
  To: Carsey, Jaben, edk2-devel@lists.01.org; +Cc: Gao, Liming, Zhu, Yonghong

Hi Jaben,

two comments on this patch, please check it. thanks.
1. Check.py: it should use DT.SUP_MODULE_BASE
2. DataSection.py: need import DataType file, and update copyright year.

Best Regards,
Zhu Yonghong


-----Original Message-----
From: Carsey, Jaben 
Sent: Friday, April 20, 2018 11:52 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming <liming.gao@intel.com>; Zhu, Yonghong <yonghong.zhu@intel.com>
Subject: [PATCH v1 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'

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>
---
 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                 |   4 +-
 BaseTools/Source/Python/GenFds/CompressSection.py    |   3 +-
 BaseTools/Source/Python/GenFds/DataSection.py        |   2 +-
 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, 225 insertions(+), 216 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 3a2976181ac1..9c3bf864e360 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -1431,7 +1431,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)
@@ -1473,7 +1473,7 @@ class PlatformAutoGen(AutoGen):
                     # make sure that the "VOID*" kind of datum has MaxDatumSize set
                     if PcdFromModule.DatumType == "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)
@@ -2204,7 +2204,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,
@@ -3970,8 +3970,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 != '':
@@ -4048,11 +4048,11 @@ class ModuleAutoGen(AutoGen):
                 AsBuiltInfDict['binary_item'] += ['BIN|' + File]
         if self.DepexGenerated:
             self.OutputFile.add(self.Name + '.depex')
-            if self.ModuleType in ['PEIM']:
+            if self.ModuleType in [SUP_MODULE_PEIM]:
                 AsBuiltInfDict['binary_item'] += ['PEI_DEPEX|' + self.Name + '.depex']
-            if self.ModuleType in ['DXE_DRIVER', 'DXE_RUNTIME_DRIVER', 'DXE_SAL_DRIVER', 'UEFI_DRIVER']:
+            if self.ModuleType in [SUP_MODULE_DXE_DRIVER, SUP_MODULE_DXE_RUNTIME_DRIVER, SUP_MODULE_DXE_SAL_DRIVER, SUP_MODULE_UEFI_DRIVER]:
                 AsBuiltInfDict['binary_item'] += ['DXE_DEPEX|' + self.Name + '.depex']
-            if self.ModuleType in ['DXE_SMM_DRIVER']:
+            if self.ModuleType in [SUP_MODULE_DXE_SMM_DRIVER]:
                 AsBuiltInfDict['binary_item'] += ['SMM_DEPEX|' + self.Name + '.depex']
 
         Bin = self._GenOffsetBin()
@@ -4378,8 +4378,8 @@ class ModuleAutoGen(AutoGen):
             return
 
         for ModuleType in self.DepexList:
-            # Ignore empty [depex] section or [depex] section for "USER_DEFINED" module
-            if len(self.DepexList[ModuleType]) == 0 or ModuleType == "USER_DEFINED":
+            # Ignore empty [depex] section or [depex] section for SUP_MODULE_USER_DEFINED module
+            if len(self.DepexList[ModuleType]) == 0 or ModuleType == SUP_MODULE_USER_DEFINED:
                 continue
 
             Dpx = GenDepex.DependencyExpression(self.DepexList[ModuleType], ModuleType, True)
diff --git a/BaseTools/Source/Python/AutoGen/BuildEngine.py b/BaseTools/Source/Python/AutoGen/BuildEngine.py
index bbd1a4d5b257..a4f39b0b2925 100644
--- a/BaseTools/Source/Python/AutoGen/BuildEngine.py
+++ b/BaseTools/Source/Python/AutoGen/BuildEngine.py
@@ -612,11 +612,11 @@ if __name__ == '__main__':
     EdkLogger.Initialize()
     if len(sys.argv) > 1:
         Br = BuildRule(sys.argv[1])
-        print str(Br[".c", "DXE_DRIVER", "IA32", "MSFT"][1])
+        print str(Br[".c", SUP_MODULE_DXE_DRIVER, "IA32", "MSFT"][1])
         print
-        print str(Br[".c", "DXE_DRIVER", "IA32", "INTEL"][1])
+        print str(Br[".c", SUP_MODULE_DXE_DRIVER, "IA32", "INTEL"][1])
         print
-        print str(Br[".c", "DXE_DRIVER", "IA32", "GCC"][1])
+        print str(Br[".c", SUP_MODULE_DXE_DRIVER, "IA32", "GCC"][1])
         print
         print str(Br[".ac", "ACPI_TABLE", "IA32", "MSFT"][1])
         print
@@ -624,7 +624,7 @@ if __name__ == '__main__':
         print
         print str(Br[".ac", "ACPI_TABLE", "IA32", "MSFT"][1])
         print
-        print str(Br[".s", "SEC", "IPF", "COMMON"][1])
+        print str(Br[".s", SUP_MODULE_SEC, "IPF", "COMMON"][1])
         print
-        print str(Br[".s", "SEC"][1])
+        print str(Br[".s", SUP_MODULE_SEC][1])
 
diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py
index 6706629722fc..7bc352274e66 100644
--- a/BaseTools/Source/Python/AutoGen/GenC.py
+++ b/BaseTools/Source/Python/AutoGen/GenC.py
@@ -651,7 +651,7 @@ ${END}
 ]
 
 gLibraryStructorPrototype = {
-'BASE'  : TemplateString("""${BEGIN}
+SUP_MODULE_BASE  : TemplateString("""${BEGIN}
 RETURN_STATUS
 EFIAPI
 ${Function} (
@@ -688,7 +688,7 @@ ${Function} (
 }
 
 gLibraryStructorCall = {
-'BASE'  : TemplateString("""${BEGIN}
+SUP_MODULE_BASE  : TemplateString("""${BEGIN}
   Status = ${Function} ();
   ASSERT_EFI_ERROR (Status);${END}
 """),
@@ -711,7 +711,7 @@ gLibraryStructorCall = {
 
 ## Library Constructor and Destructor Templates
 gLibraryString = {
-'BASE'  :   TemplateString("""
+SUP_MODULE_BASE  :   TemplateString("""
 ${BEGIN}${FunctionPrototype}${END}
 
 VOID
@@ -774,21 +774,21 @@ ${FunctionCall}${END}
 gBasicHeaderFile = "Base.h"
 
 gModuleTypeHeaderFile = {
-    "BASE"              :   [gBasicHeaderFile],
-    "SEC"               :   ["PiPei.h", "Library/DebugLib.h"],
-    "PEI_CORE"          :   ["PiPei.h", "Library/DebugLib.h", "Library/PeiCoreEntryPoint.h"],
-    "PEIM"              :   ["PiPei.h", "Library/DebugLib.h", "Library/PeimEntryPoint.h"],
-    "DXE_CORE"          :   ["PiDxe.h", "Library/DebugLib.h", "Library/DxeCoreEntryPoint.h"],
-    "DXE_DRIVER"        :   ["PiDxe.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiDriverEntryPoint.h"],
-    "DXE_SMM_DRIVER"    :   ["PiDxe.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiDriverEntryPoint.h"],
-    "DXE_RUNTIME_DRIVER":   ["PiDxe.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiDriverEntryPoint.h"],
-    "DXE_SAL_DRIVER"    :   ["PiDxe.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiDriverEntryPoint.h"],
-    "UEFI_DRIVER"       :   ["Uefi.h",  "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiDriverEntryPoint.h"],
-    "UEFI_APPLICATION"  :   ["Uefi.h",  "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiApplicationEntryPoint.h"],
-    "SMM_CORE"          :   ["PiDxe.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiDriverEntryPoint.h"],
-    "MM_STANDALONE"     :   ["PiSmm.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/SmmDriverStandaloneEntryPoint.h"],
-    "MM_CORE_STANDALONE" :  ["PiSmm.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/SmmCoreStandaloneEntryPoint.h"],
-    "USER_DEFINED"      :   [gBasicHeaderFile]
+    SUP_MODULE_BASE              :   [gBasicHeaderFile],
+    SUP_MODULE_SEC               :   ["PiPei.h", "Library/DebugLib.h"],
+    SUP_MODULE_PEI_CORE          :   ["PiPei.h", "Library/DebugLib.h", "Library/PeiCoreEntryPoint.h"],
+    SUP_MODULE_PEIM              :   ["PiPei.h", "Library/DebugLib.h", "Library/PeimEntryPoint.h"],
+    SUP_MODULE_DXE_CORE          :   ["PiDxe.h", "Library/DebugLib.h", "Library/DxeCoreEntryPoint.h"],
+    SUP_MODULE_DXE_DRIVER        :   ["PiDxe.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiDriverEntryPoint.h"],
+    SUP_MODULE_DXE_SMM_DRIVER    :   ["PiDxe.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiDriverEntryPoint.h"],
+    SUP_MODULE_DXE_RUNTIME_DRIVER:   ["PiDxe.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiDriverEntryPoint.h"],
+    SUP_MODULE_DXE_SAL_DRIVER    :   ["PiDxe.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiDriverEntryPoint.h"],
+    SUP_MODULE_UEFI_DRIVER       :   ["Uefi.h",  "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiDriverEntryPoint.h"],
+    SUP_MODULE_UEFI_APPLICATION  :   ["Uefi.h",  "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiApplicationEntryPoint.h"],
+    SUP_MODULE_SMM_CORE          :   ["PiDxe.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiDriverEntryPoint.h"],
+    SUP_MODULE_MM_STANDALONE     :   ["PiSmm.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/SmmDriverStandaloneEntryPoint.h"],
+    SUP_MODULE_MM_CORE_STANDALONE :  ["PiSmm.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/SmmCoreStandaloneEntryPoint.h"],
+    SUP_MODULE_USER_DEFINED      :   [gBasicHeaderFile]
 }
 
 ## Autogen internal worker macro to define DynamicEx PCD name includes both the TokenSpaceGuidName 
@@ -1408,17 +1408,17 @@ def CreateLibraryConstructorCode(Info, AutoGenC, AutoGenH):
         if len(Lib.ConstructorList) <= 0:
             continue
         Dict = {'Function':Lib.ConstructorList}
-        if Lib.ModuleType in ['BASE', 'SEC']:
-            ConstructorPrototypeString.Append(gLibraryStructorPrototype['BASE'].Replace(Dict))
-            ConstructorCallingString.Append(gLibraryStructorCall['BASE'].Replace(Dict))
-        elif Lib.ModuleType in ['PEI_CORE','PEIM']:
+        if Lib.ModuleType in [SUP_MODULE_BASE, SUP_MODULE_SEC]:
+            ConstructorPrototypeString.Append(gLibraryStructorPrototype[SUP_MODULE_BASE].Replace(Dict))
+            ConstructorCallingString.Append(gLibraryStructorCall[SUP_MODULE_BASE].Replace(Dict))
+        elif Lib.ModuleType in [SUP_MODULE_PEI_CORE,SUP_MODULE_PEIM]:
             ConstructorPrototypeString.Append(gLibraryStructorPrototype['PEI'].Replace(Dict))
             ConstructorCallingString.Append(gLibraryStructorCall['PEI'].Replace(Dict))
-        elif Lib.ModuleType in ['DXE_CORE','DXE_DRIVER','DXE_SMM_DRIVER','DXE_RUNTIME_DRIVER',
-                                'DXE_SAL_DRIVER','UEFI_DRIVER','UEFI_APPLICATION','SMM_CORE']:
+        elif Lib.ModuleType in [SUP_MODULE_DXE_CORE,SUP_MODULE_DXE_DRIVER,SUP_MODULE_DXE_SMM_DRIVER,SUP_MODULE_DXE_RUNTIME_DRIVER,
+                                SUP_MODULE_DXE_SAL_DRIVER,SUP_MODULE_UEFI_DRIVER,SUP_MODULE_UEFI_APPLICATION,SUP_MODULE_SMM_CORE]:
             ConstructorPrototypeString.Append(gLibraryStructorPrototype['DXE'].Replace(Dict))
             ConstructorCallingString.Append(gLibraryStructorCall['DXE'].Replace(Dict))
-        elif Lib.ModuleType in ['MM_STANDALONE','MM_CORE_STANDALONE']:
+        elif Lib.ModuleType in [SUP_MODULE_MM_STANDALONE,SUP_MODULE_MM_CORE_STANDALONE]:
             ConstructorPrototypeString.Append(gLibraryStructorPrototype['MM'].Replace(Dict))
             ConstructorCallingString.Append(gLibraryStructorCall['MM'].Replace(Dict))
 
@@ -1439,14 +1439,14 @@ def CreateLibraryConstructorCode(Info, AutoGenC, AutoGenH):
     if Info.IsLibrary:
         AutoGenH.Append("${BEGIN}${FunctionPrototype}${END}", Dict)
     else:
-        if Info.ModuleType in ['BASE', 'SEC']:
-            AutoGenC.Append(gLibraryString['BASE'].Replace(Dict))
-        elif Info.ModuleType in ['PEI_CORE','PEIM']:
+        if Info.ModuleType in [SUP_MODULE_BASE, SUP_MODULE_SEC]:
+            AutoGenC.Append(gLibraryString[SUP_MODULE_BASE].Replace(Dict))
+        elif Info.ModuleType in [SUP_MODULE_PEI_CORE,SUP_MODULE_PEIM]:
             AutoGenC.Append(gLibraryString['PEI'].Replace(Dict))
-        elif Info.ModuleType in ['DXE_CORE','DXE_DRIVER','DXE_SMM_DRIVER','DXE_RUNTIME_DRIVER',
-                                 'DXE_SAL_DRIVER','UEFI_DRIVER','UEFI_APPLICATION','SMM_CORE']:
+        elif Info.ModuleType in [SUP_MODULE_DXE_CORE,SUP_MODULE_DXE_DRIVER,SUP_MODULE_DXE_SMM_DRIVER,SUP_MODULE_DXE_RUNTIME_DRIVER,
+                                 SUP_MODULE_DXE_SAL_DRIVER,SUP_MODULE_UEFI_DRIVER,SUP_MODULE_UEFI_APPLICATION,SUP_MODULE_SMM_CORE]:
             AutoGenC.Append(gLibraryString['DXE'].Replace(Dict))
-        elif Info.ModuleType in ['MM_STANDALONE','MM_CORE_STANDALONE']:
+        elif Info.ModuleType in [SUP_MODULE_MM_STANDALONE,SUP_MODULE_MM_CORE_STANDALONE]:
             AutoGenC.Append(gLibraryString['MM'].Replace(Dict))
 
 ## Create code for library destructor
@@ -1470,17 +1470,17 @@ def CreateLibraryDestructorCode(Info, AutoGenC, AutoGenH):
         if len(Lib.DestructorList) <= 0:
             continue
         Dict = {'Function':Lib.DestructorList}
-        if Lib.ModuleType in ['BASE', 'SEC']:
-            DestructorPrototypeString.Append(gLibraryStructorPrototype['BASE'].Replace(Dict))
-            DestructorCallingString.Append(gLibraryStructorCall['BASE'].Replace(Dict))
-        elif Lib.ModuleType in ['PEI_CORE','PEIM']:
+        if Lib.ModuleType in [SUP_MODULE_BASE, SUP_MODULE_SEC]:
+            DestructorPrototypeString.Append(gLibraryStructorPrototype[SUP_MODULE_BASE].Replace(Dict))
+            DestructorCallingString.Append(gLibraryStructorCall[SUP_MODULE_BASE].Replace(Dict))
+        elif Lib.ModuleType in [SUP_MODULE_PEI_CORE,SUP_MODULE_PEIM]:
             DestructorPrototypeString.Append(gLibraryStructorPrototype['PEI'].Replace(Dict))
             DestructorCallingString.Append(gLibraryStructorCall['PEI'].Replace(Dict))
-        elif Lib.ModuleType in ['DXE_CORE','DXE_DRIVER','DXE_SMM_DRIVER','DXE_RUNTIME_DRIVER',
-                                'DXE_SAL_DRIVER','UEFI_DRIVER','UEFI_APPLICATION', 'SMM_CORE']:
+        elif Lib.ModuleType in [SUP_MODULE_DXE_CORE,SUP_MODULE_DXE_DRIVER,SUP_MODULE_DXE_SMM_DRIVER,SUP_MODULE_DXE_RUNTIME_DRIVER,
+                                SUP_MODULE_DXE_SAL_DRIVER,SUP_MODULE_UEFI_DRIVER,SUP_MODULE_UEFI_APPLICATION, SUP_MODULE_SMM_CORE]:
             DestructorPrototypeString.Append(gLibraryStructorPrototype['DXE'].Replace(Dict))
             DestructorCallingString.Append(gLibraryStructorCall['DXE'].Replace(Dict))
-        elif Lib.ModuleType in ['MM_STANDALONE','MM_CORE_STANDALONE']:
+        elif Lib.ModuleType in [SUP_MODULE_MM_STANDALONE,SUP_MODULE_MM_CORE_STANDALONE]:
             DestructorPrototypeString.Append(gLibraryStructorPrototype['MM'].Replace(Dict))
             DestructorCallingString.Append(gLibraryStructorCall['MM'].Replace(Dict))
 
@@ -1501,14 +1501,14 @@ def CreateLibraryDestructorCode(Info, AutoGenC, AutoGenH):
     if Info.IsLibrary:
         AutoGenH.Append("${BEGIN}${FunctionPrototype}${END}", Dict)
     else:
-        if Info.ModuleType in ['BASE', 'SEC']:
-            AutoGenC.Append(gLibraryString['BASE'].Replace(Dict))
-        elif Info.ModuleType in ['PEI_CORE','PEIM']:
+        if Info.ModuleType in [SUP_MODULE_BASE, SUP_MODULE_SEC]:
+            AutoGenC.Append(gLibraryString[SUP_MODULE_BASE].Replace(Dict))
+        elif Info.ModuleType in [SUP_MODULE_PEI_CORE,SUP_MODULE_PEIM]:
             AutoGenC.Append(gLibraryString['PEI'].Replace(Dict))
-        elif Info.ModuleType in ['DXE_CORE','DXE_DRIVER','DXE_SMM_DRIVER','DXE_RUNTIME_DRIVER',
-                                 'DXE_SAL_DRIVER','UEFI_DRIVER','UEFI_APPLICATION','SMM_CORE']:
+        elif Info.ModuleType in [SUP_MODULE_DXE_CORE,SUP_MODULE_DXE_DRIVER,SUP_MODULE_DXE_SMM_DRIVER,SUP_MODULE_DXE_RUNTIME_DRIVER,
+                                 SUP_MODULE_DXE_SAL_DRIVER,SUP_MODULE_UEFI_DRIVER,SUP_MODULE_UEFI_APPLICATION,SUP_MODULE_SMM_CORE]:
             AutoGenC.Append(gLibraryString['DXE'].Replace(Dict))
-        elif Info.ModuleType in ['MM_STANDALONE','MM_CORE_STANDALONE']:
+        elif Info.ModuleType in [SUP_MODULE_MM_STANDALONE,SUP_MODULE_MM_CORE_STANDALONE]:
             AutoGenC.Append(gLibraryString['MM'].Replace(Dict))
 
 
@@ -1519,7 +1519,7 @@ def CreateLibraryDestructorCode(Info, AutoGenC, AutoGenH):
 #   @param      AutoGenH    The TemplateString object for header file
 #
 def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH):
-    if Info.IsLibrary or Info.ModuleType in ['USER_DEFINED', 'SEC']:
+    if Info.IsLibrary or Info.ModuleType in [SUP_MODULE_USER_DEFINED, SUP_MODULE_SEC]:
         return
     #
     # Module Entry Points
@@ -1539,7 +1539,7 @@ def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH):
         'UefiSpecVersion':   UefiSpecVersion + 'U'
     }
 
-    if Info.ModuleType in ['PEI_CORE', 'DXE_CORE', 'SMM_CORE', 'MM_CORE_STANDALONE']:
+    if Info.ModuleType in [SUP_MODULE_PEI_CORE, SUP_MODULE_DXE_CORE, SUP_MODULE_SMM_CORE, SUP_MODULE_MM_CORE_STANDALONE]:
         if Info.SourceFileList:
           if NumEntryPoints != 1:
               EdkLogger.error(
@@ -1549,43 +1549,43 @@ def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH):
                   File=str(Info),
                   ExtraData= ", ".join(Info.Module.ModuleEntryPointList)
                   )
-    if Info.ModuleType == 'PEI_CORE':
+    if Info.ModuleType == SUP_MODULE_PEI_CORE:
         AutoGenC.Append(gPeiCoreEntryPointString.Replace(Dict))
         AutoGenH.Append(gPeiCoreEntryPointPrototype.Replace(Dict))
-    elif Info.ModuleType == 'DXE_CORE':
+    elif Info.ModuleType == SUP_MODULE_DXE_CORE:
         AutoGenC.Append(gDxeCoreEntryPointString.Replace(Dict))
         AutoGenH.Append(gDxeCoreEntryPointPrototype.Replace(Dict))
-    elif Info.ModuleType == 'SMM_CORE':
+    elif Info.ModuleType == SUP_MODULE_SMM_CORE:
         AutoGenC.Append(gSmmCoreEntryPointString.Replace(Dict))
         AutoGenH.Append(gSmmCoreEntryPointPrototype.Replace(Dict))
-    elif Info.ModuleType == 'MM_CORE_STANDALONE':
+    elif Info.ModuleType == SUP_MODULE_MM_CORE_STANDALONE:
         AutoGenC.Append(gMmCoreStandaloneEntryPointString.Replace(Dict))
         AutoGenH.Append(gMmCoreStandaloneEntryPointPrototype.Replace(Dict))
-    elif Info.ModuleType == 'PEIM':
+    elif Info.ModuleType == SUP_MODULE_PEIM:
         if NumEntryPoints < 2:
             AutoGenC.Append(gPeimEntryPointString[NumEntryPoints].Replace(Dict))
         else:
             AutoGenC.Append(gPeimEntryPointString[2].Replace(Dict))
         AutoGenH.Append(gPeimEntryPointPrototype.Replace(Dict))
-    elif Info.ModuleType in ['DXE_RUNTIME_DRIVER','DXE_DRIVER','DXE_SAL_DRIVER','UEFI_DRIVER']:
+    elif Info.ModuleType in [SUP_MODULE_DXE_RUNTIME_DRIVER,SUP_MODULE_DXE_DRIVER,SUP_MODULE_DXE_SAL_DRIVER,SUP_MODULE_UEFI_DRIVER]:
         if NumEntryPoints < 2:
             AutoGenC.Append(gUefiDriverEntryPointString[NumEntryPoints].Replace(Dict))
         else:
             AutoGenC.Append(gUefiDriverEntryPointString[2].Replace(Dict))
         AutoGenH.Append(gUefiDriverEntryPointPrototype.Replace(Dict))
-    elif Info.ModuleType == 'DXE_SMM_DRIVER':
+    elif Info.ModuleType == SUP_MODULE_DXE_SMM_DRIVER:
         if NumEntryPoints == 0:
             AutoGenC.Append(gDxeSmmEntryPointString[0].Replace(Dict))
         else:
             AutoGenC.Append(gDxeSmmEntryPointString[1].Replace(Dict))
         AutoGenH.Append(gDxeSmmEntryPointPrototype.Replace(Dict))
-    elif Info.ModuleType == 'MM_STANDALONE':
+    elif Info.ModuleType == SUP_MODULE_MM_STANDALONE:
         if NumEntryPoints < 2:
             AutoGenC.Append(gMmStandaloneEntryPointString[NumEntryPoints].Replace(Dict))
         else:
             AutoGenC.Append(gMmStandaloneEntryPointString[2].Replace(Dict))
         AutoGenH.Append(gMmStandaloneEntryPointPrototype.Replace(Dict))
-    elif Info.ModuleType == 'UEFI_APPLICATION':
+    elif Info.ModuleType == SUP_MODULE_UEFI_APPLICATION:
         if NumEntryPoints < 2:
             AutoGenC.Append(gUefiApplicationEntryPointString[NumEntryPoints].Replace(Dict))
         else:
@@ -1599,7 +1599,7 @@ def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH):
 #   @param      AutoGenH    The TemplateString object for header file
 #
 def CreateModuleUnloadImageCode(Info, AutoGenC, AutoGenH):
-    if Info.IsLibrary or Info.ModuleType in ['USER_DEFINED', 'SEC']:
+    if Info.IsLibrary or Info.ModuleType in [SUP_MODULE_USER_DEFINED, SUP_MODULE_SEC]:
         return
     #
     # Unload Image Handlers
@@ -1619,7 +1619,7 @@ def CreateModuleUnloadImageCode(Info, AutoGenC, AutoGenH):
 #   @param      AutoGenH    The TemplateString object for header file
 #
 def CreateGuidDefinitionCode(Info, AutoGenC, AutoGenH):
-    if Info.ModuleType in ["USER_DEFINED", "BASE"]:
+    if Info.ModuleType in [SUP_MODULE_USER_DEFINED, SUP_MODULE_BASE]:
         GuidType = "GUID"
     else:
         GuidType = "EFI_GUID"
@@ -1643,7 +1643,7 @@ def CreateGuidDefinitionCode(Info, AutoGenC, AutoGenH):
 #   @param      AutoGenH    The TemplateString object for header file
 #
 def CreateProtocolDefinitionCode(Info, AutoGenC, AutoGenH):
-    if Info.ModuleType in ["USER_DEFINED", "BASE"]:
+    if Info.ModuleType in [SUP_MODULE_USER_DEFINED, SUP_MODULE_BASE]:
         GuidType = "GUID"
     else:
         GuidType = "EFI_GUID"
@@ -1667,7 +1667,7 @@ def CreateProtocolDefinitionCode(Info, AutoGenC, AutoGenH):
 #   @param      AutoGenH    The TemplateString object for header file
 #
 def CreatePpiDefinitionCode(Info, AutoGenC, AutoGenH):
-    if Info.ModuleType in ["USER_DEFINED", "BASE"]:
+    if Info.ModuleType in [SUP_MODULE_USER_DEFINED, SUP_MODULE_BASE]:
         GuidType = "GUID"
     else:
         GuidType = "EFI_GUID"
@@ -1704,7 +1704,7 @@ def CreatePcdCode(Info, AutoGenC, AutoGenH):
     # Add extern declarations to AutoGen.h if one or more Token Space GUIDs were found
     if TokenSpaceList:
         AutoGenH.Append("\n// Definition of PCD Token Space GUIDs used in this module\n\n")
-        if Info.ModuleType in ["USER_DEFINED", "BASE"]:
+        if Info.ModuleType in [SUP_MODULE_USER_DEFINED, SUP_MODULE_BASE]:
             GuidType = "GUID"
         else:
             GuidType = "EFI_GUID"              
diff --git a/BaseTools/Source/Python/AutoGen/GenDepex.py b/BaseTools/Source/Python/AutoGen/GenDepex.py
index 9acea8f6bfed..100f1250b31f 100644
--- a/BaseTools/Source/Python/AutoGen/GenDepex.py
+++ b/BaseTools/Source/Python/AutoGen/GenDepex.py
@@ -24,26 +24,27 @@ from Common.Misc import SaveFileOnChange
 from Common.Misc import GuidStructureStringToGuidString
 from Common import EdkLogger as EdkLogger
 from Common.BuildVersion import gBUILD_VERSION
+from Common.DataType import *
 
 ## Regular expression for matching "DEPENDENCY_START ... DEPENDENCY_END"
 gStartClosePattern = re.compile(".*DEPENDENCY_START(.+)DEPENDENCY_END.*", re.S)
 
 ## Mapping between module type and EFI phase
 gType2Phase = {
-    "BASE"              :   None,
-    "SEC"               :   "PEI",
-    "PEI_CORE"          :   "PEI",
-    "PEIM"              :   "PEI",
-    "DXE_CORE"          :   "DXE",
-    "DXE_DRIVER"        :   "DXE",
-    "DXE_SMM_DRIVER"    :   "DXE",
-    "DXE_RUNTIME_DRIVER":   "DXE",
-    "DXE_SAL_DRIVER"    :   "DXE",
-    "UEFI_DRIVER"       :   "DXE",
-    "UEFI_APPLICATION"  :   "DXE",
-    "SMM_CORE"          :   "DXE",
-    "MM_STANDALONE"     :   "MM",
-    "MM_CORE_STANDALONE" :  "MM",
+    SUP_MODULE_BASE              :   None,
+    SUP_MODULE_SEC               :   "PEI",
+    SUP_MODULE_PEI_CORE          :   "PEI",
+    SUP_MODULE_PEIM              :   "PEI",
+    SUP_MODULE_DXE_CORE          :   "DXE",
+    SUP_MODULE_DXE_DRIVER        :   "DXE",
+    SUP_MODULE_DXE_SMM_DRIVER    :   "DXE",
+    SUP_MODULE_DXE_RUNTIME_DRIVER:   "DXE",
+    SUP_MODULE_DXE_SAL_DRIVER    :   "DXE",
+    SUP_MODULE_UEFI_DRIVER       :   "DXE",
+    SUP_MODULE_UEFI_APPLICATION  :   "DXE",
+    SUP_MODULE_SMM_CORE          :   "DXE",
+    SUP_MODULE_MM_STANDALONE     :   "MM",
+    SUP_MODULE_MM_CORE_STANDALONE :  "MM",
 }
 
 ## Convert dependency expression string into EFI internal representation
@@ -299,12 +300,12 @@ class DependencyExpression:
             NewOperand.append(Token)
 
         # don't generate depex if only TRUE operand left
-        if self.ModuleType == 'PEIM' and len(NewOperand) == 1 and NewOperand[0] == 'TRUE':
+        if self.ModuleType == SUP_MODULE_PEIM and len(NewOperand) == 1 and NewOperand[0] == 'TRUE':
             self.PostfixNotation = []
             return
 
         # don't generate depex if all operands are architecture protocols
-        if self.ModuleType in ['UEFI_DRIVER', 'DXE_DRIVER', 'DXE_RUNTIME_DRIVER', 'DXE_SAL_DRIVER', 'DXE_SMM_DRIVER', 'MM_STANDALONE'] and \
+        if self.ModuleType in [SUP_MODULE_UEFI_DRIVER, SUP_MODULE_DXE_DRIVER, SUP_MODULE_DXE_RUNTIME_DRIVER, SUP_MODULE_DXE_SAL_DRIVER, SUP_MODULE_DXE_SMM_DRIVER, SUP_MODULE_MM_STANDALONE] and \
            Op == 'AND' and \
            self.ArchProtocols == set([GuidStructureStringToGuidString(Guid) for Guid in AllOperand]):
             self.PostfixNotation = []
diff --git a/BaseTools/Source/Python/Common/DataType.py b/BaseTools/Source/Python/Common/DataType.py
index 1e632f3abdbf..0bd55494df66 100644
--- a/BaseTools/Source/Python/Common/DataType.py
+++ b/BaseTools/Source/Python/Common/DataType.py
@@ -80,7 +80,7 @@ SUP_MODULE_LIST_STRING = TAB_VALUE_SPLIT.join(SUP_MODULE_LIST)
 
 EDK_COMPONENT_TYPE_LIBRARY = 'LIBRARY'
 EDK_COMPONENT_TYPE_SECUARITY_CORE = 'SECUARITY_CORE'
-EDK_COMPONENT_TYPE_PEI_CORE = 'PEI_CORE'
+EDK_COMPONENT_TYPE_PEI_CORE = SUP_MODULE_PEI_CORE
 EDK_COMPONENT_TYPE_COMBINED_PEIM_DRIVER = 'COMBINED_PEIM_DRIVER'
 EDK_COMPONENT_TYPE_PIC_PEIM = 'PIC_PEIM'
 EDK_COMPONENT_TYPE_RELOCATABLE_PEIM = 'RELOCATABLE_PEIM'
diff --git a/BaseTools/Source/Python/Ecc/Check.py b/BaseTools/Source/Python/Ecc/Check.py
index 27783e617b92..c0e8006dcc51 100644
--- a/BaseTools/Source/Python/Ecc/Check.py
+++ b/BaseTools/Source/Python/Ecc/Check.py
@@ -744,7 +744,7 @@ class Check(object):
                         if Item not in LibraryClasses[List[0]]:
                             LibraryClasses[List[0]].append(Item)
 
-                if Record[2] != 'BASE' and Record[2] not in SupModType:
+                if Record[2] != SUP_MODULE_BASE and Record[2] not in SupModType:
                     EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_LIBRARY_INSTANCE_2, OtherMsg="The Library Class '%s' does not specify its supported module types" % (List[0]), BelongsToTable='Inf', BelongsToItem=Record[0])
 
             SqlCommand = """select A.ID, A.Value1, B.Value3 from Inf as A left join Inf as B
@@ -763,7 +763,7 @@ class Check(object):
 
             for Record in RecordSet:
                 if Record[1] in LibraryClasses:
-                    if Record[2] not in LibraryClasses[Record[1]] and 'BASE' not in RecordDict[Record[1]]:
+                    if Record[2] not in LibraryClasses[Record[1]] and SUP_MODULE_BASE not in RecordDict[Record[1]]:
                         if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_LIBRARY_INSTANCE_1, Record[1]):
                             EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_LIBRARY_INSTANCE_1, OtherMsg="The type of Library Class [%s] defined in Inf file does not match the type of the module" % (Record[1]), BelongsToTable='Inf', BelongsToItem=Record[0])
                 else:
diff --git a/BaseTools/Source/Python/GenFds/CompressSection.py b/BaseTools/Source/Python/GenFds/CompressSection.py
index 08ab48669f45..4ae14f27b3e1 100644
--- a/BaseTools/Source/Python/GenFds/CompressSection.py
+++ b/BaseTools/Source/Python/GenFds/CompressSection.py
@@ -21,6 +21,7 @@ import subprocess
 import Common.LongFilePathOs as os
 from GenFdsGlobalVariable import GenFdsGlobalVariable
 from CommonDataClass.FdfClass import CompressSectionClassObject
+from Common.DataType import *
 
 ## generate compress section
 #
@@ -82,7 +83,7 @@ class CompressSection (CompressSectionClassObject) :
         OutputFile = OutputPath + \
                      os.sep     + \
                      ModuleName + \
-                     'SEC'      + \
+                     SUP_MODULE_SEC      + \
                      SecNum     + \
                      Ffs.SectionSuffix['COMPRESS']
         OutputFile = os.path.normpath(OutputFile)
diff --git a/BaseTools/Source/Python/GenFds/DataSection.py b/BaseTools/Source/Python/GenFds/DataSection.py
index 40e345eee77e..3c435c2fcc65 100644
--- a/BaseTools/Source/Python/GenFds/DataSection.py
+++ b/BaseTools/Source/Python/GenFds/DataSection.py
@@ -119,7 +119,7 @@ class DataSection (DataSectionClassObject):
                 )
             self.SectFileName = TeFile
 
-        OutputFile = os.path.join (OutputPath, ModuleName + 'SEC' + SecNum + Ffs.SectionSuffix.get(self.SecType))
+        OutputFile = os.path.join (OutputPath, ModuleName + SUP_MODULE_SEC + SecNum + Ffs.SectionSuffix.get(self.SecType))
         OutputFile = os.path.normpath(OutputFile)
         GenFdsGlobalVariable.GenerateSection(OutputFile, [self.SectFileName], Section.Section.SectionType.get(self.SecType), IsMakefile = IsMakefile)
         FileList = [OutputFile]
diff --git a/BaseTools/Source/Python/GenFds/DepexSection.py b/BaseTools/Source/Python/GenFds/DepexSection.py
index 4ed1aa779292..d04160e890f1 100644
--- a/BaseTools/Source/Python/GenFds/DepexSection.py
+++ b/BaseTools/Source/Python/GenFds/DepexSection.py
@@ -25,6 +25,7 @@ from AutoGen.GenDepex import DependencyExpression
 from Common import EdkLogger
 from Common.BuildToolError import *
 from Common.Misc import PathClass
+from Common.DataType import *
 
 ## generate data section
 #
@@ -94,24 +95,24 @@ class DepexSection (DepexSectionClassObject):
             self.ExpressionProcessed = True
 
         if self.DepexType == 'PEI_DEPEX_EXP':
-            ModuleType = 'PEIM'
+            ModuleType = SUP_MODULE_PEIM
             SecType    = 'PEI_DEPEX'
         elif self.DepexType == 'DXE_DEPEX_EXP':
-            ModuleType = 'DXE_DRIVER'
+            ModuleType = SUP_MODULE_DXE_DRIVER
             SecType    = 'DXE_DEPEX'
         elif self.DepexType == 'SMM_DEPEX_EXP':
-            ModuleType = 'DXE_SMM_DRIVER'
+            ModuleType = SUP_MODULE_DXE_SMM_DRIVER
             SecType    = 'SMM_DEPEX'
         else:
             EdkLogger.error("GenFds", FORMAT_INVALID,
                             "Depex type %s is not valid for module %s" % (self.DepexType, ModuleName))
 
-        InputFile = os.path.join (OutputPath, ModuleName + 'SEC' + SecNum + '.depex')
+        InputFile = os.path.join (OutputPath, ModuleName + SUP_MODULE_SEC + SecNum + '.depex')
         InputFile = os.path.normpath(InputFile)
         Depex = DependencyExpression(self.Expression, ModuleType)
         Depex.Generate(InputFile)
 
-        OutputFile = os.path.join (OutputPath, ModuleName + 'SEC' + SecNum + '.dpx')
+        OutputFile = os.path.join (OutputPath, ModuleName + SUP_MODULE_SEC + SecNum + '.dpx')
         OutputFile = os.path.normpath(OutputFile)
 
         GenFdsGlobalVariable.GenerateSection(OutputFile, [InputFile], Section.Section.SectionType.get (SecType), IsMakefile=IsMakefile)
diff --git a/BaseTools/Source/Python/GenFds/EfiSection.py b/BaseTools/Source/Python/GenFds/EfiSection.py
index 5bb1ae6f664c..1be23b4bf7fd 100644
--- a/BaseTools/Source/Python/GenFds/EfiSection.py
+++ b/BaseTools/Source/Python/GenFds/EfiSection.py
@@ -27,6 +27,7 @@ from Common.BuildToolError import *
 from Common.Misc import PeImageClass
 from Common.LongFilePathSupport import OpenLongFilePath as open
 from Common.LongFilePathSupport import CopyLongFilePath
+from Common.DataType import *
 
 ## generate rule section
 #
@@ -66,7 +67,7 @@ class EfiSection (EfiSectionClassObject):
             StringData = FfsInf.__ExtendMacro__(self.StringData)
             ModuleNameStr = FfsInf.__ExtendMacro__('$(MODULE_NAME)')
             NoStrip = True
-            if FfsInf.ModuleType in ('SEC', 'PEI_CORE', 'PEIM') and SectionType in ('TE', 'PE32'):
+            if FfsInf.ModuleType in (SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM) and SectionType in ('TE', 'PE32'):
                 if FfsInf.KeepReloc is not None:
                     NoStrip = FfsInf.KeepReloc
                 elif FfsInf.KeepRelocFromRule is not None:
@@ -122,7 +123,7 @@ class EfiSection (EfiSectionClassObject):
                     BuildNumTuple = tuple()
 
                 Num = SecNum
-                OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + str(Num) + Ffs.SectionSuffix.get(SectionType))
+                OutputFile = os.path.join( OutputPath, ModuleName + SUP_MODULE_SEC + str(Num) + Ffs.SectionSuffix.get(SectionType))
                 GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_VERSION',
                                                     #Ui=StringData,
                                                     Ver=BuildNum,
@@ -133,7 +134,7 @@ class EfiSection (EfiSectionClassObject):
                 for File in FileList:
                     Index = Index + 1
                     Num = '%s.%d' %(SecNum , Index)
-                    OutputFile = os.path.join(OutputPath, ModuleName + 'SEC' + Num + Ffs.SectionSuffix.get(SectionType))
+                    OutputFile = os.path.join(OutputPath, ModuleName + SUP_MODULE_SEC + Num + Ffs.SectionSuffix.get(SectionType))
                     f = open(File, 'r')
                     VerString = f.read()
                     f.close()
@@ -162,7 +163,7 @@ class EfiSection (EfiSectionClassObject):
                     else:
                         EdkLogger.error("GenFds", GENFDS_ERROR, "File: %s miss Version Section value" %InfFileName)
                 Num = SecNum
-                OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + str(Num) + Ffs.SectionSuffix.get(SectionType))
+                OutputFile = os.path.join( OutputPath, ModuleName + SUP_MODULE_SEC + str(Num) + Ffs.SectionSuffix.get(SectionType))
                 GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_VERSION',
                                                     #Ui=VerString,
                                                     Ver=BuildNum,
@@ -183,7 +184,7 @@ class EfiSection (EfiSectionClassObject):
                 Num = SecNum
                 if IsMakefile and StringData == ModuleNameStr:
                     StringData = "$(MODULE_NAME)"
-                OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + str(Num) + Ffs.SectionSuffix.get(SectionType))
+                OutputFile = os.path.join( OutputPath, ModuleName + SUP_MODULE_SEC + str(Num) + Ffs.SectionSuffix.get(SectionType))
                 GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_USER_INTERFACE',
                                                      Ui=StringData, IsMakefile=IsMakefile)
                 OutputFileList.append(OutputFile)
@@ -192,7 +193,7 @@ class EfiSection (EfiSectionClassObject):
                 for File in FileList:
                     Index = Index + 1
                     Num = '%s.%d' %(SecNum , Index)
-                    OutputFile = os.path.join(OutputPath, ModuleName + 'SEC' + Num + Ffs.SectionSuffix.get(SectionType))
+                    OutputFile = os.path.join(OutputPath, ModuleName + SUP_MODULE_SEC + Num + Ffs.SectionSuffix.get(SectionType))
                     f = open(File, 'r')
                     UiString = f.read()
                     f.close()
@@ -216,7 +217,7 @@ class EfiSection (EfiSectionClassObject):
                 Num = SecNum
                 if IsMakefile and StringData == ModuleNameStr:
                     StringData = "$(MODULE_NAME)"
-                OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + str(Num) + Ffs.SectionSuffix.get(SectionType))
+                OutputFile = os.path.join( OutputPath, ModuleName + SUP_MODULE_SEC + str(Num) + Ffs.SectionSuffix.get(SectionType))
                 GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_USER_INTERFACE',
                                                      Ui=StringData, IsMakefile=IsMakefile)
                 OutputFileList.append(OutputFile)
@@ -237,7 +238,7 @@ class EfiSection (EfiSectionClassObject):
                     """ Copy Map file to FFS output path """
                     Index = Index + 1
                     Num = '%s.%d' %(SecNum , Index)
-                    OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + Num + Ffs.SectionSuffix.get(SectionType))
+                    OutputFile = os.path.join( OutputPath, ModuleName + SUP_MODULE_SEC + Num + Ffs.SectionSuffix.get(SectionType))
                     File = GenFdsGlobalVariable.MacroExtend(File, Dict)
                     
                     #Get PE Section alignment when align is set to AUTO
diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py
index a106253527c4..4ec114a81883 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -2633,7 +2633,7 @@ class FdfParser:
     #
     @staticmethod
     def __FileCouldHaveRelocFlag (FileType):
-        if FileType in ('SEC', 'PEI_CORE', 'PEIM', 'PEI_DXE_COMBO'):
+        if FileType in (SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM, 'PEI_DXE_COMBO'):
             return True
         else:
             return False
@@ -3633,12 +3633,12 @@ class FdfParser:
 
         if not self.__GetNextWord():
             raise Warning("expected Module type", self.FileName, self.CurrentLineNumber)
-        if self.__Token.upper() not in ("SEC", "PEI_CORE", "PEIM", "DXE_CORE", \
-                             "DXE_DRIVER", "DXE_SAL_DRIVER", \
-                             "DXE_SMM_DRIVER", "DXE_RUNTIME_DRIVER", \
-                             "UEFI_DRIVER", "UEFI_APPLICATION", "USER_DEFINED", "DEFAULT", "BASE", \
+        if self.__Token.upper() not in (SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM, SUP_MODULE_DXE_CORE, \
+                             SUP_MODULE_DXE_DRIVER, SUP_MODULE_DXE_SAL_DRIVER, \
+                             SUP_MODULE_DXE_SMM_DRIVER, SUP_MODULE_DXE_RUNTIME_DRIVER, \
+                             SUP_MODULE_UEFI_DRIVER, SUP_MODULE_UEFI_APPLICATION, SUP_MODULE_USER_DEFINED, "DEFAULT", SUP_MODULE_BASE, \
                              "SECURITY_CORE", "COMBINED_PEIM_DRIVER", "PIC_PEIM", "RELOCATABLE_PEIM", \
-                                        "PE32_PEIM", "BS_DRIVER", "RT_DRIVER", "SAL_RT_DRIVER", "APPLICATION", "ACPITABLE", "SMM_CORE", "MM_STANDALONE", "MM_CORE_STANDALONE"):
+                                        "PE32_PEIM", "BS_DRIVER", "RT_DRIVER", "SAL_RT_DRIVER", "APPLICATION", "ACPITABLE", SUP_MODULE_SMM_CORE, SUP_MODULE_MM_STANDALONE, SUP_MODULE_MM_CORE_STANDALONE):
             raise Warning("Unknown Module type '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
         return self.__Token
 
@@ -3680,8 +3680,8 @@ class FdfParser:
             raise Warning("expected FFS type", self.FileName, self.CurrentLineNumber)
 
         Type = self.__Token.strip().upper()
-        if Type not in ("RAW", "FREEFORM", "SEC", "PEI_CORE", "PEIM",\
-                             "PEI_DXE_COMBO", "DRIVER", "DXE_CORE", "APPLICATION", "FV_IMAGE", "SMM", "SMM_CORE", "MM_STANDALONE", "MM_CORE_STANDALONE"):
+        if Type not in ("RAW", "FREEFORM", SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM,\
+                             "PEI_DXE_COMBO", "DRIVER", SUP_MODULE_DXE_CORE, "APPLICATION", "FV_IMAGE", "SMM", SUP_MODULE_SMM_CORE, SUP_MODULE_MM_STANDALONE, SUP_MODULE_MM_CORE_STANDALONE):
             raise Warning("Unknown FV type '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
 
         if not self.__IsToken("="):
diff --git a/BaseTools/Source/Python/GenFds/Ffs.py b/BaseTools/Source/Python/GenFds/Ffs.py
index a4178121118b..fc760ae8beda 100644
--- a/BaseTools/Source/Python/GenFds/Ffs.py
+++ b/BaseTools/Source/Python/GenFds/Ffs.py
@@ -16,6 +16,7 @@
 # Import Modules
 #
 from CommonDataClass.FdfClass import FDClassObject
+from Common.DataType import *
 
 ## generate FFS
 #
@@ -24,27 +25,27 @@ class Ffs(FDClassObject):
     
     # mapping between MODULE type in FDF (from INF) and file type for GenFfs
     ModuleTypeToFileType = {
-        'SEC'               : 'EFI_FV_FILETYPE_SECURITY_CORE',
-        'PEI_CORE'          : 'EFI_FV_FILETYPE_PEI_CORE',
-        'PEIM'              : 'EFI_FV_FILETYPE_PEIM',
-        'DXE_CORE'          : 'EFI_FV_FILETYPE_DXE_CORE',
-        'DXE_DRIVER'        : 'EFI_FV_FILETYPE_DRIVER',
-        'DXE_SAL_DRIVER'    : 'EFI_FV_FILETYPE_DRIVER',
-        'DXE_SMM_DRIVER'    : 'EFI_FV_FILETYPE_DRIVER',
-        'DXE_RUNTIME_DRIVER': 'EFI_FV_FILETYPE_DRIVER',
-        'UEFI_DRIVER'       : 'EFI_FV_FILETYPE_DRIVER',
-        'UEFI_APPLICATION'  : 'EFI_FV_FILETYPE_APPLICATION',
-        'SMM_CORE'          : 'EFI_FV_FILETYPE_SMM_CORE',
-        'MM_STANDALONE'     : 'EFI_FV_FILETYPE_MM_STANDALONE',
-        'MM_CORE_STANDALONE' : 'EFI_FV_FILETYPE_MM_CORE_STANDALONE'
+        SUP_MODULE_SEC               : 'EFI_FV_FILETYPE_SECURITY_CORE',
+        SUP_MODULE_PEI_CORE          : 'EFI_FV_FILETYPE_PEI_CORE',
+        SUP_MODULE_PEIM              : 'EFI_FV_FILETYPE_PEIM',
+        SUP_MODULE_DXE_CORE          : 'EFI_FV_FILETYPE_DXE_CORE',
+        SUP_MODULE_DXE_DRIVER        : 'EFI_FV_FILETYPE_DRIVER',
+        SUP_MODULE_DXE_SAL_DRIVER    : 'EFI_FV_FILETYPE_DRIVER',
+        SUP_MODULE_DXE_SMM_DRIVER    : 'EFI_FV_FILETYPE_DRIVER',
+        SUP_MODULE_DXE_RUNTIME_DRIVER: 'EFI_FV_FILETYPE_DRIVER',
+        SUP_MODULE_UEFI_DRIVER       : 'EFI_FV_FILETYPE_DRIVER',
+        SUP_MODULE_UEFI_APPLICATION  : 'EFI_FV_FILETYPE_APPLICATION',
+        SUP_MODULE_SMM_CORE          : 'EFI_FV_FILETYPE_SMM_CORE',
+        SUP_MODULE_MM_STANDALONE     : 'EFI_FV_FILETYPE_MM_STANDALONE',
+        SUP_MODULE_MM_CORE_STANDALONE : 'EFI_FV_FILETYPE_MM_CORE_STANDALONE'
     }
     
     # mapping between FILE type in FDF and file type for GenFfs
     FdfFvFileTypeToFileType = {
-        'SEC'               : 'EFI_FV_FILETYPE_SECURITY_CORE',
-        'PEI_CORE'          : 'EFI_FV_FILETYPE_PEI_CORE',
-        'PEIM'              : 'EFI_FV_FILETYPE_PEIM',
-        'DXE_CORE'          : 'EFI_FV_FILETYPE_DXE_CORE',
+        SUP_MODULE_SEC               : 'EFI_FV_FILETYPE_SECURITY_CORE',
+        SUP_MODULE_PEI_CORE          : 'EFI_FV_FILETYPE_PEI_CORE',
+        SUP_MODULE_PEIM              : 'EFI_FV_FILETYPE_PEIM',
+        SUP_MODULE_DXE_CORE          : 'EFI_FV_FILETYPE_DXE_CORE',
         'FREEFORM'          : 'EFI_FV_FILETYPE_FREEFORM',
         'DRIVER'            : 'EFI_FV_FILETYPE_DRIVER',
         'APPLICATION'       : 'EFI_FV_FILETYPE_APPLICATION',
@@ -52,9 +53,9 @@ class Ffs(FDClassObject):
         'RAW'               : 'EFI_FV_FILETYPE_RAW',
         'PEI_DXE_COMBO'     : 'EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER',
         'SMM'               : 'EFI_FV_FILETYPE_SMM',
-        'SMM_CORE'          : 'EFI_FV_FILETYPE_SMM_CORE',
-        'MM_STANDALONE'     : 'EFI_FV_FILETYPE_MM_STANDALONE',
-        'MM_CORE_STANDALONE' : 'EFI_FV_FILETYPE_MM_CORE_STANDALONE'
+        SUP_MODULE_SMM_CORE          : 'EFI_FV_FILETYPE_SMM_CORE',
+        SUP_MODULE_MM_STANDALONE     : 'EFI_FV_FILETYPE_MM_STANDALONE',
+        SUP_MODULE_MM_CORE_STANDALONE : 'EFI_FV_FILETYPE_MM_CORE_STANDALONE'
     }
     
     # mapping between section type in FDF and file suffix
diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
index 37624f3fa9d4..d31d03d43a18 100644
--- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py
+++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
@@ -88,7 +88,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
                 self.FinalTargetSuffixMap.setdefault(os.path.splitext(File)[1], []).append(File)
 
             # Check if current INF module has DEPEX
-            if '.depex' not in self.FinalTargetSuffixMap and self.InfModule.ModuleType != "USER_DEFINED" \
+            if '.depex' not in self.FinalTargetSuffixMap and self.InfModule.ModuleType != SUP_MODULE_USER_DEFINED \
                 and not self.InfModule.DxsFile and not self.InfModule.LibraryClass:
                 ModuleType = self.InfModule.ModuleType
                 PlatformDataBase = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, self.CurrentArch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
@@ -224,10 +224,10 @@ class FfsInfStatement(FfsInfStatementClassObject):
         if len(self.SourceFileList) != 0 and not self.InDsc:
             EdkLogger.warn("GenFds", GENFDS_ERROR, "Module %s NOT found in DSC file; Is it really a binary module?" % (self.InfFileName))
 
-        if self.ModuleType == 'SMM_CORE' and int(self.PiSpecVersion, 16) < 0x0001000A:
+        if self.ModuleType == SUP_MODULE_SMM_CORE and int(self.PiSpecVersion, 16) < 0x0001000A:
             EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "SMM_CORE module type can't be used in the module with PI_SPECIFICATION_VERSION less than 0x0001000A", File=self.InfFileName)      
 
-        if self.ModuleType == 'MM_CORE_STANDALONE' and int(self.PiSpecVersion, 16) < 0x00010032:
+        if self.ModuleType == SUP_MODULE_MM_CORE_STANDALONE and int(self.PiSpecVersion, 16) < 0x00010032:
             EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "MM_CORE_STANDALONE module type can't be used in the module with PI_SPECIFICATION_VERSION less than 0x00010032", File=self.InfFileName)
 
         if Inf._Defs is not None and len(Inf._Defs) > 0:
@@ -381,7 +381,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
         #
         # Only patch file if FileType is PE32 or ModuleType is USER_DEFINED
         #  
-        if FileType != 'PE32' and self.ModuleType != "USER_DEFINED":
+        if FileType != 'PE32' and self.ModuleType != SUP_MODULE_USER_DEFINED:
             return EfiFile
 
         #
@@ -488,14 +488,14 @@ class FfsInfStatement(FfsInfStatementClassObject):
         #
         # Convert Fv File Type for PI1.1 SMM driver.
         #
-        if self.ModuleType == 'DXE_SMM_DRIVER' and int(self.PiSpecVersion, 16) >= 0x0001000A:
+        if self.ModuleType == SUP_MODULE_DXE_SMM_DRIVER and int(self.PiSpecVersion, 16) >= 0x0001000A:
             if Rule.FvFileType == 'DRIVER':
                 Rule.FvFileType = 'SMM'
         #
         # Framework SMM Driver has no SMM FV file type
         #
-        if self.ModuleType == 'DXE_SMM_DRIVER' and int(self.PiSpecVersion, 16) < 0x0001000A:
-            if Rule.FvFileType == 'SMM' or Rule.FvFileType == 'SMM_CORE':
+        if self.ModuleType == SUP_MODULE_DXE_SMM_DRIVER and int(self.PiSpecVersion, 16) < 0x0001000A:
+            if Rule.FvFileType == 'SMM' or Rule.FvFileType == SUP_MODULE_SMM_CORE:
                 EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "Framework SMM module doesn't support SMM or SMM_CORE FV file type", File=self.InfFileName)
         #
         # For the rule only has simpleFile
@@ -738,17 +738,17 @@ class FfsInfStatement(FfsInfStatementClassObject):
         #
         # Convert Fv Section Type for PI1.1 SMM driver.
         #
-        if self.ModuleType == 'DXE_SMM_DRIVER' and int(self.PiSpecVersion, 16) >= 0x0001000A:
+        if self.ModuleType == SUP_MODULE_DXE_SMM_DRIVER and int(self.PiSpecVersion, 16) >= 0x0001000A:
             if SectionType == 'DXE_DEPEX':
                 SectionType = 'SMM_DEPEX'
         #
         # Framework SMM Driver has no SMM_DEPEX section type
         #
-        if self.ModuleType == 'DXE_SMM_DRIVER' and int(self.PiSpecVersion, 16) < 0x0001000A:
+        if self.ModuleType == SUP_MODULE_DXE_SMM_DRIVER and int(self.PiSpecVersion, 16) < 0x0001000A:
             if SectionType == 'SMM_DEPEX':
                 EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "Framework SMM module doesn't support SMM_DEPEX section type", File=self.InfFileName)
         NoStrip = True
-        if self.ModuleType in ('SEC', 'PEI_CORE', 'PEIM'):
+        if self.ModuleType in (SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM):
             if self.KeepReloc is not None:
                 NoStrip = self.KeepReloc
             elif Rule.KeepReloc is not None:
@@ -761,7 +761,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
 
                 SecNum = '%d' %Index
                 GenSecOutputFile= self.__ExtendMacro__(Rule.NameGuid) + \
-                              Ffs.Ffs.SectionSuffix[SectionType] + 'SEC' + SecNum
+                              Ffs.Ffs.SectionSuffix[SectionType] + SUP_MODULE_SEC + SecNum
                 Index = Index + 1
                 OutputFile = os.path.join(self.OutputPath, GenSecOutputFile)
                 File = GenFdsGlobalVariable.MacroExtend(File, Dict, self.CurrentArch)
@@ -804,7 +804,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
         else:
             SecNum = '%d' %Index
             GenSecOutputFile= self.__ExtendMacro__(Rule.NameGuid) + \
-                              Ffs.Ffs.SectionSuffix[SectionType] + 'SEC' + SecNum
+                              Ffs.Ffs.SectionSuffix[SectionType] + SUP_MODULE_SEC + SecNum
             OutputFile = os.path.join(self.OutputPath, GenSecOutputFile)
             GenSecInputFile = GenFdsGlobalVariable.MacroExtend(GenSecInputFile, Dict, self.CurrentArch)
 
@@ -902,7 +902,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
     #   @retval string       File name of the generated section file
     #
     def __GenComplexFileSection__(self, Rule, FvChildAddr, FvParentAddr, IsMakefile = False):
-        if self.ModuleType in ('SEC', 'PEI_CORE', 'PEIM'):
+        if self.ModuleType in (SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM):
             if Rule.KeepReloc is not None:
                 self.KeepRelocFromRule = Rule.KeepReloc
         SectFiles = []
@@ -941,13 +941,13 @@ class FfsInfStatement(FfsInfStatementClassObject):
             #
             # Convert Fv Section Type for PI1.1 SMM driver.
             #
-            if self.ModuleType == 'DXE_SMM_DRIVER' and int(self.PiSpecVersion, 16) >= 0x0001000A:
+            if self.ModuleType == SUP_MODULE_DXE_SMM_DRIVER and int(self.PiSpecVersion, 16) >= 0x0001000A:
                 if Sect.SectionType == 'DXE_DEPEX':
                     Sect.SectionType = 'SMM_DEPEX'
             #
             # Framework SMM Driver has no SMM_DEPEX section type
             #
-            if self.ModuleType == 'DXE_SMM_DRIVER' and int(self.PiSpecVersion, 16) < 0x0001000A:
+            if self.ModuleType == SUP_MODULE_DXE_SMM_DRIVER and int(self.PiSpecVersion, 16) < 0x0001000A:
                 if Sect.SectionType == 'SMM_DEPEX':
                     EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "Framework SMM module doesn't support SMM_DEPEX section type", File=self.InfFileName)
             #
diff --git a/BaseTools/Source/Python/GenFds/FvImageSection.py b/BaseTools/Source/Python/GenFds/FvImageSection.py
index 5026a3ffca2f..eb84b44bbec4 100644
--- a/BaseTools/Source/Python/GenFds/FvImageSection.py
+++ b/BaseTools/Source/Python/GenFds/FvImageSection.py
@@ -24,6 +24,7 @@ import Common.LongFilePathOs as os
 from CommonDataClass.FdfClass import FvImageSectionClassObject
 from Common import EdkLogger
 from Common.BuildToolError import *
+from Common.DataType import *
 
 ## generate FV image section
 #
@@ -74,7 +75,7 @@ class FvImageSection(FvImageSectionClassObject):
                 if FvAlignmentValue > MaxFvAlignment:
                     MaxFvAlignment = FvAlignmentValue
 
-                OutputFile = os.path.join(OutputPath, ModuleName + 'SEC' + Num + Ffs.SectionSuffix.get("FV_IMAGE"))
+                OutputFile = os.path.join(OutputPath, ModuleName + SUP_MODULE_SEC + Num + Ffs.SectionSuffix.get("FV_IMAGE"))
                 GenFdsGlobalVariable.GenerateSection(OutputFile, [FvFileName], 'EFI_SECTION_FIRMWARE_VOLUME_IMAGE', IsMakefile=IsMakefile)
                 OutputFileList.append(OutputFile)
 
@@ -138,7 +139,7 @@ class FvImageSection(FvImageSectionClassObject):
             #
             # Prepare the parameter of GenSection
             #
-            OutputFile = os.path.join(OutputPath, ModuleName + 'SEC' + SecNum + Ffs.SectionSuffix.get("FV_IMAGE"))
+            OutputFile = os.path.join(OutputPath, ModuleName + SUP_MODULE_SEC + SecNum + Ffs.SectionSuffix.get("FV_IMAGE"))
             GenFdsGlobalVariable.GenerateSection(OutputFile, [FvFileName], 'EFI_SECTION_FIRMWARE_VOLUME_IMAGE', IsMakefile=IsMakefile)
             OutputFileList.append(OutputFile)
 
diff --git a/BaseTools/Source/Python/GenFds/GuidSection.py b/BaseTools/Source/Python/GenFds/GuidSection.py
index 08665a3d4d49..1105689e0d79 100644
--- a/BaseTools/Source/Python/GenFds/GuidSection.py
+++ b/BaseTools/Source/Python/GenFds/GuidSection.py
@@ -28,6 +28,7 @@ from Common.BuildToolError import *
 from FvImageSection import FvImageSection
 from Common.LongFilePathSupport import OpenLongFilePath as open
 from GenFds import FindExtendTool
+from Common.DataType import *
 
 ## generate GUIDed section
 #
@@ -121,7 +122,7 @@ class GuidSection(GuidSectionClassObject) :
         OutputFile = OutputPath + \
                      os.sep + \
                      ModuleName + \
-                     'SEC' + \
+                     SUP_MODULE_SEC + \
                      SecNum + \
                      Ffs.SectionSuffix['GUIDED']
         OutputFile = os.path.normpath(OutputFile)
@@ -156,7 +157,7 @@ class GuidSection(GuidSectionClassObject) :
             TempFile = OutputPath + \
                        os.sep + \
                        ModuleName + \
-                       'SEC' + \
+                       SUP_MODULE_SEC + \
                        SecNum + \
                        '.tmp'
             TempFile = os.path.normpath(TempFile)
diff --git a/BaseTools/Source/Python/GenFds/UiSection.py b/BaseTools/Source/Python/GenFds/UiSection.py
index 6340520602ee..084f761e1285 100644
--- a/BaseTools/Source/Python/GenFds/UiSection.py
+++ b/BaseTools/Source/Python/GenFds/UiSection.py
@@ -22,6 +22,7 @@ import Common.LongFilePathOs as os
 from GenFdsGlobalVariable import GenFdsGlobalVariable
 from CommonDataClass.FdfClass import UiSectionClassObject
 from Common.LongFilePathSupport import OpenLongFilePath as open
+from Common.DataType import SUP_MODULE_SEC
 
 ## generate UI section
 #
@@ -57,7 +58,7 @@ class UiSection (UiSectionClassObject):
             self.StringData = FfsInf.__ExtendMacro__(self.StringData)
             self.FileName = FfsInf.__ExtendMacro__(self.FileName)
 
-        OutputFile = os.path.join(OutputPath, ModuleName + 'SEC' + SecNum + Ffs.SectionSuffix.get('UI'))
+        OutputFile = os.path.join(OutputPath, ModuleName + SUP_MODULE_SEC + SecNum + Ffs.SectionSuffix.get('UI'))
 
         if self.StringData is not None :
             NameString = self.StringData
diff --git a/BaseTools/Source/Python/GenFds/VerSection.py b/BaseTools/Source/Python/GenFds/VerSection.py
index 11e974b9936e..456a430079bb 100644
--- a/BaseTools/Source/Python/GenFds/VerSection.py
+++ b/BaseTools/Source/Python/GenFds/VerSection.py
@@ -22,6 +22,7 @@ import subprocess
 from GenFdsGlobalVariable import GenFdsGlobalVariable
 from CommonDataClass.FdfClass import VerSectionClassObject
 from Common.LongFilePathSupport import OpenLongFilePath as open
+from Common.DataType import SUP_MODULE_SEC
 
 ## generate version section
 #
@@ -59,7 +60,7 @@ class VerSection (VerSectionClassObject):
             self.FileName = FfsInf.__ExtendMacro__(self.FileName)
 
         OutputFile = os.path.join(OutputPath,
-                                  ModuleName + 'SEC' + SecNum + Ffs.SectionSuffix.get('VERSION'))
+                                  ModuleName + SUP_MODULE_SEC + SecNum + Ffs.SectionSuffix.get('VERSION'))
         OutputFile = os.path.normpath(OutputFile)
 
         # Get String Data
diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py b/BaseTools/Source/Python/Workspace/InfBuildData.py
index a725a2a2a772..f2d36d0ee0d4 100644
--- a/BaseTools/Source/Python/Workspace/InfBuildData.py
+++ b/BaseTools/Source/Python/Workspace/InfBuildData.py
@@ -68,22 +68,22 @@ class InfBuildData(ModuleBuildClassObject):
 
     # dict used to convert Component type to Module type
     _MODULE_TYPE_ = {
-        "LIBRARY"               :   "BASE",
-        "SECURITY_CORE"         :   "SEC",
-        "PEI_CORE"              :   "PEI_CORE",
-        "COMBINED_PEIM_DRIVER"  :   "PEIM",
-        "PIC_PEIM"              :   "PEIM",
-        "RELOCATABLE_PEIM"      :   "PEIM",
-        "PE32_PEIM"             :   "PEIM",
-        "BS_DRIVER"             :   "DXE_DRIVER",
-        "RT_DRIVER"             :   "DXE_RUNTIME_DRIVER",
-        "SAL_RT_DRIVER"         :   "DXE_SAL_DRIVER",
-        "DXE_SMM_DRIVER"        :   "DXE_SMM_DRIVER",
-    #    "SMM_DRIVER"            :   "DXE_SMM_DRIVER",
-    #    "BS_DRIVER"             :   "DXE_SMM_DRIVER",
-    #    "BS_DRIVER"             :   "UEFI_DRIVER",
-        "APPLICATION"           :   "UEFI_APPLICATION",
-        "LOGO"                  :   "BASE",
+        "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
@@ -461,9 +461,9 @@ class InfBuildData(ModuleBuildClassObject):
             if self._Header_ is None:
                 self._GetHeaderInfo()
             if self._ModuleType is None:
-                self._ModuleType = 'BASE'
+                self._ModuleType = SUP_MODULE_BASE
             if self._ModuleType not in SUP_MODULE_LIST:
-                self._ModuleType = "USER_DEFINED"
+                self._ModuleType = SUP_MODULE_USER_DEFINED
         return self._ModuleType
 
     ## Retrieve COMPONENT_TYPE
@@ -472,7 +472,7 @@ class InfBuildData(ModuleBuildClassObject):
             if self._Header_ is None:
                 self._GetHeaderInfo()
             if self._ComponentType is None:
-                self._ComponentType = 'USER_DEFINED'
+                self._ComponentType = SUP_MODULE_USER_DEFINED
         return self._ComponentType
 
     ## Retrieve "BUILD_TYPE"
@@ -481,7 +481,7 @@ class InfBuildData(ModuleBuildClassObject):
             if self._Header_ is None:
                 self._GetHeaderInfo()
             if not self._BuildType:
-                self._BuildType = "BASE"
+                self._BuildType = SUP_MODULE_BASE
         return self._BuildType
 
     ## Retrieve file guid
@@ -899,14 +899,14 @@ class InfBuildData(ModuleBuildClassObject):
 
             # PEIM and DXE drivers must have a valid [Depex] section
             if len(self.LibraryClass) == 0 and len(RecordList) == 0:
-                if self.ModuleType == 'DXE_DRIVER' or self.ModuleType == 'PEIM' or self.ModuleType == 'DXE_SMM_DRIVER' or \
-                    self.ModuleType == 'DXE_SAL_DRIVER' or self.ModuleType == 'DXE_RUNTIME_DRIVER':
+                if self.ModuleType == SUP_MODULE_DXE_DRIVER or self.ModuleType == SUP_MODULE_PEIM or self.ModuleType == SUP_MODULE_DXE_SMM_DRIVER or \
+                    self.ModuleType == SUP_MODULE_DXE_SAL_DRIVER or self.ModuleType == SUP_MODULE_DXE_RUNTIME_DRIVER:
                     EdkLogger.error('build', RESOURCE_NOT_AVAILABLE, "No [Depex] section or no valid expression in [Depex] section for [%s] module" \
                                     % self.ModuleType, File=self.MetaFile)
 
-            if len(RecordList) != 0 and self.ModuleType == 'USER_DEFINED':
+            if len(RecordList) != 0 and self.ModuleType == SUP_MODULE_USER_DEFINED:
                 for Record in RecordList:
-                    if Record[4] not in ['PEIM', 'DXE_DRIVER', 'DXE_SMM_DRIVER']:
+                    if Record[4] not in [SUP_MODULE_PEIM, SUP_MODULE_DXE_DRIVER, SUP_MODULE_DXE_SMM_DRIVER]:
                         EdkLogger.error('build', FORMAT_INVALID,
                                         "'%s' module must specify the type of [Depex] section" % self.ModuleType,
                                         File=self.MetaFile)
diff --git a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py
index 736ef6253453..573100081815 100644
--- a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py
+++ b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py
@@ -134,7 +134,7 @@ def _GetModuleLibraryInstances(Module, Platform, BuildDatabase, Arch, Target, To
                     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
                     return []
diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Source/Python/build/BuildReport.py
index 635c311f1a48..2dfd78cb9538 100644
--- a/BaseTools/Source/Python/build/BuildReport.py
+++ b/BaseTools/Source/Python/build/BuildReport.py
@@ -48,18 +48,18 @@ import collections
 from Common.Expression import *
 
 gComponentType2ModuleType = {
-    "LIBRARY"               :   "BASE",
-    "SECURITY_CORE"         :   "SEC",
-    "PEI_CORE"              :   "PEI_CORE",
-    "COMBINED_PEIM_DRIVER"  :   "PEIM",
-    "PIC_PEIM"              :   "PEIM",
-    "RELOCATABLE_PEIM"      :   "PEIM",
-    "PE32_PEIM"             :   "PEIM",
-    "BS_DRIVER"             :   "DXE_DRIVER",
-    "RT_DRIVER"             :   "DXE_RUNTIME_DRIVER",
-    "SAL_RT_DRIVER"         :   "DXE_SAL_DRIVER",
-    "APPLICATION"           :   "UEFI_APPLICATION",
-    "LOGO"                  :   "BASE",
+    "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
@@ -122,20 +122,20 @@ gPcdTypeMap = {
 
 ## The look up table to map module type to driver type
 gDriverTypeMap = {
-  'SEC'               : '0x3 (SECURITY_CORE)',
-  'PEI_CORE'          : '0x4 (PEI_CORE)',
-  'PEIM'              : '0x6 (PEIM)',
-  'DXE_CORE'          : '0x5 (DXE_CORE)',
-  'DXE_DRIVER'        : '0x7 (DRIVER)',
-  'DXE_SAL_DRIVER'    : '0x7 (DRIVER)',
-  'DXE_SMM_DRIVER'    : '0x7 (DRIVER)',
-  'DXE_RUNTIME_DRIVER': '0x7 (DRIVER)',
-  'UEFI_DRIVER'       : '0x7 (DRIVER)',
-  'UEFI_APPLICATION'  : '0x9 (APPLICATION)',
-  'SMM_CORE'          : '0xD (SMM_CORE)',
+  SUP_MODULE_SEC               : '0x3 (SECURITY_CORE)',
+  SUP_MODULE_PEI_CORE          : '0x4 (PEI_CORE)',
+  SUP_MODULE_PEIM              : '0x6 (PEIM)',
+  SUP_MODULE_DXE_CORE          : '0x5 (DXE_CORE)',
+  SUP_MODULE_DXE_DRIVER        : '0x7 (DRIVER)',
+  SUP_MODULE_DXE_SAL_DRIVER    : '0x7 (DRIVER)',
+  SUP_MODULE_DXE_SMM_DRIVER    : '0x7 (DRIVER)',
+  SUP_MODULE_DXE_RUNTIME_DRIVER: '0x7 (DRIVER)',
+  SUP_MODULE_UEFI_DRIVER       : '0x7 (DRIVER)',
+  SUP_MODULE_UEFI_APPLICATION  : '0x9 (APPLICATION)',
+  SUP_MODULE_SMM_CORE          : '0xD (SMM_CORE)',
   'SMM_DRIVER'        : '0xA (SMM)', # Extension of module type to support PI 1.1 SMM drivers
-  'MM_STANDALONE'     : '0xE (MM_STANDALONE)',
-  'MM_CORE_STANDALONE' : '0xF (MM_CORE_STANDALONE)'
+  SUP_MODULE_MM_STANDALONE     : '0xE (MM_STANDALONE)',
+  SUP_MODULE_MM_CORE_STANDALONE : '0xF (MM_CORE_STANDALONE)'
   }
 
 ## The look up table of the supported opcode in the dependency expression binaries
@@ -424,7 +424,7 @@ class DepexReport(object):
         if not ModuleType:
             ModuleType = gComponentType2ModuleType.get(M.ComponentType, "")
 
-        if ModuleType in ["SEC", "PEI_CORE", "DXE_CORE", "SMM_CORE", "MM_CORE_STANDALONE", "UEFI_APPLICATION"]:
+        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
       
         for Source in M.SourceFileList:
@@ -591,7 +591,7 @@ class ModuleReport(object):
             #
             # If a module complies to PI 1.1, promote Module type to "SMM_DRIVER"
             #
-            if ModuleType == "DXE_SMM_DRIVER":
+            if ModuleType == SUP_MODULE_DXE_SMM_DRIVER:
                 PiSpec = M.Module.Specification.get("PI_SPECIFICATION_VERSION", "0x00010000")
                 if int(PiSpec, 0) >= 0x0001000A:
                     ModuleType = "SMM_DRIVER"
@@ -1382,7 +1382,7 @@ class PredictionReport(object):
                 # their source code to find PPI/Protocol produce or consume
                 # information.
                 #
-                if Module.ModuleType == "BASE":
+                if Module.ModuleType == SUP_MODULE_BASE:
                     continue
                 #
                 # Add module referenced source files
diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/build/build.py
index 36bb1fecf7e5..81d59dd3eedf 100644
--- a/BaseTools/Source/Python/build/build.py
+++ b/BaseTools/Source/Python/build/build.py
@@ -1587,22 +1587,22 @@ class Build():
                     if not ImageClass.IsValid:
                         EdkLogger.error("build", FILE_PARSE_FAILURE, ExtraData=ImageClass.ErrorInfo)
                     ImageInfo = PeImageInfo(Module.Name, Module.Guid, Module.Arch, Module.OutputDir, Module.DebugDir, ImageClass)
-                    if Module.ModuleType in ['PEI_CORE', 'PEIM', 'COMBINED_PEIM_DRIVER', 'PIC_PEIM', 'RELOCATABLE_PEIM', 'DXE_CORE']:
+                    if Module.ModuleType in [SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM, 'COMBINED_PEIM_DRIVER', 'PIC_PEIM', 'RELOCATABLE_PEIM', SUP_MODULE_DXE_CORE]:
                         PeiModuleList[Module.MetaFile] = ImageInfo
                         PeiSize += ImageInfo.Image.Size
-                    elif Module.ModuleType in ['BS_DRIVER', 'DXE_DRIVER', 'UEFI_DRIVER']:
+                    elif Module.ModuleType in ['BS_DRIVER', SUP_MODULE_DXE_DRIVER, SUP_MODULE_UEFI_DRIVER]:
                         BtModuleList[Module.MetaFile] = ImageInfo
                         BtSize += ImageInfo.Image.Size
-                    elif Module.ModuleType in ['DXE_RUNTIME_DRIVER', 'RT_DRIVER', 'DXE_SAL_DRIVER', 'SAL_RT_DRIVER']:
+                    elif Module.ModuleType in [SUP_MODULE_DXE_RUNTIME_DRIVER, 'RT_DRIVER', SUP_MODULE_DXE_SAL_DRIVER, 'SAL_RT_DRIVER']:
                         RtModuleList[Module.MetaFile] = ImageInfo
                         #IPF runtime driver needs to be at 2 page alignment.
                         if IsIpfPlatform and ImageInfo.Image.Size % 0x2000 != 0:
                             ImageInfo.Image.Size = (ImageInfo.Image.Size / 0x2000 + 1) * 0x2000
                         RtSize += ImageInfo.Image.Size
-                    elif Module.ModuleType in ['SMM_CORE', 'DXE_SMM_DRIVER', 'MM_STANDALONE', 'MM_CORE_STANDALONE']:
+                    elif Module.ModuleType in [SUP_MODULE_SMM_CORE, SUP_MODULE_DXE_SMM_DRIVER, SUP_MODULE_MM_STANDALONE, SUP_MODULE_MM_CORE_STANDALONE]:
                         SmmModuleList[Module.MetaFile] = ImageInfo
                         SmmSize += ImageInfo.Image.Size
-                        if Module.ModuleType == 'DXE_SMM_DRIVER':
+                        if Module.ModuleType == SUP_MODULE_DXE_SMM_DRIVER:
                             PiSpecVersion = Module.Module.Specification.get('PI_SPECIFICATION_VERSION', '0x00000000')
                             # for PI specification < PI1.1, DXE_SMM_DRIVER also runs as BOOT time driver.
                             if int(PiSpecVersion, 16) < 0x0001000A:
-- 
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* Re: [PATCH v1 18/27] BaseTools: Replace PCD type strings with predefined constant
  2018-04-20 15:51 ` [PATCH v1 18/27] BaseTools: Replace PCD type strings with predefined constant Jaben Carsey
@ 2018-04-25  6:00   ` Zhu, Yonghong
  0 siblings, 0 replies; 56+ messages in thread
From: Zhu, Yonghong @ 2018-04-25  6:00 UTC (permalink / raw)
  To: Carsey, Jaben, edk2-devel@lists.01.org; +Cc: Gao, Liming, Zhu, Yonghong

GenFdsGlobalVariable.py: should use DataType.TAB_PCDS_FIXED_AT_BUILD format, because it use import Common.DataType as DataType in file header.

Best Regards,
Zhu Yonghong


-----Original Message-----
From: Carsey, Jaben 
Sent: Friday, April 20, 2018 11:52 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming <liming.gao@intel.com>; Zhu, Yonghong <yonghong.zhu@intel.com>
Subject: [PATCH v1 18/27] BaseTools: Replace PCD type strings with predefined constant

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>
---
 BaseTools/Source/Python/AutoGen/AutoGen.py             |  4 +--
 BaseTools/Source/Python/AutoGen/GenC.py                |  4 +--
 BaseTools/Source/Python/AutoGen/GenPcdDb.py            |  2 +-
 BaseTools/Source/Python/Common/DataType.py             |  3 ++
 BaseTools/Source/Python/Common/MigrationUtilities.py   |  2 +-
 BaseTools/Source/Python/GenFds/FfsInfStatement.py      |  2 +-
 BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py |  4 +--
 BaseTools/Source/Python/Workspace/DecBuildData.py      | 22 +++++++-------
 BaseTools/Source/Python/Workspace/DscBuildData.py      | 22 +++++++-------
 BaseTools/Source/Python/Workspace/InfBuildData.py      | 26 ++++++++---------
 BaseTools/Source/Python/build/BuildReport.py           | 30 ++++++++++----------
 11 files changed, 62 insertions(+), 59 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 2f60c17439c0..9b2164ed8216 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -870,8 +870,8 @@ class WorkspaceAutoGen(AutoGen):
     def _CheckPcdDefineAndType(self):
         PcdTypeList = [
             TAB_PCDS_FIXED_AT_BUILD, TAB_PCDS_PATCHABLE_IN_MODULE, TAB_PCDS_FEATURE_FLAG,
-            TAB_PCDS_DYNAMIC, #"DynamicHii", "DynamicVpd",
-            TAB_PCDS_DYNAMIC_EX, # "DynamicExHii", "DynamicExVpd"
+            TAB_PCDS_DYNAMIC, #TAB_PCDS_DYNAMIC_HII, TAB_PCDS_DYNAMIC_VPD,
+            TAB_PCDS_DYNAMIC_EX, # TAB_PCDS_DYNAMIC_EX_HII, 
+ TAB_PCDS_DYNAMIC_EX_VPD
         ]
 
         # This dict store PCDs which are not used by any modules with specified arches diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py
index 86b21de31eee..6b2ee87b2211 100644
--- a/BaseTools/Source/Python/AutoGen/GenC.py
+++ b/BaseTools/Source/Python/AutoGen/GenC.py
@@ -28,8 +28,8 @@ from IdfClassObject import *
 
 ## PCD type string
 gItemTypeStringDatabase  = {
-    TAB_PCDS_FEATURE_FLAG       :   'FixedAtBuild',
-    TAB_PCDS_FIXED_AT_BUILD     :   'FixedAtBuild',
+    TAB_PCDS_FEATURE_FLAG       :   TAB_PCDS_FIXED_AT_BUILD,
+    TAB_PCDS_FIXED_AT_BUILD     :   TAB_PCDS_FIXED_AT_BUILD,
     TAB_PCDS_PATCHABLE_IN_MODULE:   'BinaryPatch',
     TAB_PCDS_DYNAMIC            :   '',
     TAB_PCDS_DYNAMIC_DEFAULT    :   '',
diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
index afd690bc5b1b..9374ca4820ef 100644
--- a/BaseTools/Source/Python/AutoGen/GenPcdDb.py
+++ b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
@@ -1217,7 +1217,7 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase):
         Pcd.InitString = 'UNINIT'
 
         if Pcd.DatumType == 'VOID*':
-            if Pcd.Type not in ["DynamicVpd", "DynamicExVpd"]:
+            if Pcd.Type not in [TAB_PCDS_DYNAMIC_VPD, TAB_PCDS_DYNAMIC_EX_VPD]:
                 Pcd.TokenTypeList = ['PCD_TYPE_STRING']
             else:
                 Pcd.TokenTypeList = []
diff --git a/BaseTools/Source/Python/Common/DataType.py b/BaseTools/Source/Python/Common/DataType.py
index 13e9c96dd51b..40a162adf33c 100644
--- a/BaseTools/Source/Python/Common/DataType.py
+++ b/BaseTools/Source/Python/Common/DataType.py
@@ -218,6 +218,9 @@ TAB_PCDS_DYNAMIC_HII = 'DynamicHii'
 PCD_DYNAMIC_TYPE_SET = {TAB_PCDS_DYNAMIC, TAB_PCDS_DYNAMIC_DEFAULT, TAB_PCDS_DYNAMIC_VPD, TAB_PCDS_DYNAMIC_HII}  PCD_DYNAMIC_EX_TYPE_SET = {TAB_PCDS_DYNAMIC_EX, TAB_PCDS_DYNAMIC_EX_DEFAULT, TAB_PCDS_DYNAMIC_EX_VPD, TAB_PCDS_DYNAMIC_EX_HII}
 
+# leave as a list for order
+PCD_TYPE_LIST = [TAB_PCDS_FIXED_AT_BUILD, TAB_PCDS_PATCHABLE_IN_MODULE, 
+TAB_PCDS_FEATURE_FLAG, TAB_PCDS_DYNAMIC, TAB_PCDS_DYNAMIC_EX]
+
 TAB_PCDS_FIXED_AT_BUILD_NULL = TAB_PCDS + TAB_PCDS_FIXED_AT_BUILD  TAB_PCDS_FIXED_AT_BUILD_COMMON = TAB_PCDS + TAB_PCDS_FIXED_AT_BUILD + TAB_SPLIT + TAB_ARCH_COMMON
 TAB_PCDS_FIXED_AT_BUILD_IA32 = TAB_PCDS + TAB_PCDS_FIXED_AT_BUILD + TAB_SPLIT + TAB_ARCH_IA32 diff --git a/BaseTools/Source/Python/Common/MigrationUtilities.py b/BaseTools/Source/Python/Common/MigrationUtilities.py
index e9f1cabcb794..0c93c72a60f6 100644
--- a/BaseTools/Source/Python/Common/MigrationUtilities.py
+++ b/BaseTools/Source/Python/Common/MigrationUtilities.py
@@ -34,7 +34,7 @@ def SetCommon(Common, XmlCommon):
     XmlTag = "Usage"
     Common.Usage = XmlAttribute(XmlCommon, XmlTag).split()
 
-    XmlTag = "FeatureFlag"
+    XmlTag = TAB_PCDS_FEATURE_FLAG
     Common.FeatureFlag = XmlAttribute(XmlCommon, XmlTag)
     
     XmlTag = "SupArchList"
diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
index d31d03d43a18..8893fcbda1fc 100644
--- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py
+++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
@@ -249,7 +249,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
             Pcd = InfPcds[PcdKey]
             if not hasattr(Pcd, 'Offset'):
                 continue
-            if Pcd.Type != 'PatchableInModule':
+            if Pcd.Type != TAB_PCDS_PATCHABLE_IN_MODULE:
                 continue
             # Override Patchable PCD value by the value from DSC
             PatchPcd = None
diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
index 6a3873940ec0..e692e4e98504 100644
--- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
+++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
@@ -809,7 +809,7 @@ class GenFdsGlobalVariable:
             for Key in PcdDict:
                 PcdObj = PcdDict[Key]
                 if (PcdObj.TokenCName == TokenCName) and (PcdObj.TokenSpaceGuidCName == TokenSpace):
-                    if PcdObj.Type != 'FixedAtBuild':
+                    if PcdObj.Type != TAB_PCDS_FIXED_AT_BUILD:
                         EdkLogger.error("GenFds", GENFDS_ERROR, "%s is not FixedAtBuild type." % PcdPattern)
                     if PcdObj.DatumType != 'VOID*':
                         EdkLogger.error("GenFds", GENFDS_ERROR, "%s is not VOID* datum type." % PcdPattern) @@ -825,7 +825,7 @@ class GenFdsGlobalVariable:
                 for Key in PcdDict:
                     PcdObj = PcdDict[Key]
                     if (PcdObj.TokenCName == TokenCName) and (PcdObj.TokenSpaceGuidCName == TokenSpace):
-                        if PcdObj.Type != 'FixedAtBuild':
+                        if PcdObj.Type != TAB_PCDS_FIXED_AT_BUILD:
                             EdkLogger.error("GenFds", GENFDS_ERROR, "%s is not FixedAtBuild type." % PcdPattern)
                         if PcdObj.DatumType != 'VOID*':
                             EdkLogger.error("GenFds", GENFDS_ERROR, "%s is not VOID* datum type." % PcdPattern) diff --git a/BaseTools/Source/Python/Workspace/DecBuildData.py b/BaseTools/Source/Python/Workspace/DecBuildData.py
index 31870e078cec..1fbd095f743c 100644
--- a/BaseTools/Source/Python/Workspace/DecBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DecBuildData.py
@@ -27,17 +27,17 @@ from Workspace.BuildClassObject import PackageBuildClassObject, StructurePcd, Pc  class DecBuildData(PackageBuildClassObject):
     # dict used to convert PCD type in database to string used by build tool
     _PCD_TYPE_STRING_ = {
-        MODEL_PCD_FIXED_AT_BUILD        :   "FixedAtBuild",
-        MODEL_PCD_PATCHABLE_IN_MODULE   :   "PatchableInModule",
-        MODEL_PCD_FEATURE_FLAG          :   "FeatureFlag",
-        MODEL_PCD_DYNAMIC               :   "Dynamic",
-        MODEL_PCD_DYNAMIC_DEFAULT       :   "Dynamic",
-        MODEL_PCD_DYNAMIC_HII           :   "DynamicHii",
-        MODEL_PCD_DYNAMIC_VPD           :   "DynamicVpd",
-        MODEL_PCD_DYNAMIC_EX            :   "DynamicEx",
-        MODEL_PCD_DYNAMIC_EX_DEFAULT    :   "DynamicEx",
-        MODEL_PCD_DYNAMIC_EX_HII        :   "DynamicExHii",
-        MODEL_PCD_DYNAMIC_EX_VPD        :   "DynamicExVpd",
+        MODEL_PCD_FIXED_AT_BUILD        :   TAB_PCDS_FIXED_AT_BUILD,
+        MODEL_PCD_PATCHABLE_IN_MODULE   :   TAB_PCDS_PATCHABLE_IN_MODULE,
+        MODEL_PCD_FEATURE_FLAG          :   TAB_PCDS_FEATURE_FLAG,
+        MODEL_PCD_DYNAMIC               :   TAB_PCDS_DYNAMIC,
+        MODEL_PCD_DYNAMIC_DEFAULT       :   TAB_PCDS_DYNAMIC,
+        MODEL_PCD_DYNAMIC_HII           :   TAB_PCDS_DYNAMIC_HII,
+        MODEL_PCD_DYNAMIC_VPD           :   TAB_PCDS_DYNAMIC_VPD,
+        MODEL_PCD_DYNAMIC_EX            :   TAB_PCDS_DYNAMIC_EX,
+        MODEL_PCD_DYNAMIC_EX_DEFAULT    :   TAB_PCDS_DYNAMIC_EX,
+        MODEL_PCD_DYNAMIC_EX_HII        :   TAB_PCDS_DYNAMIC_EX_HII,
+        MODEL_PCD_DYNAMIC_EX_VPD        :   TAB_PCDS_DYNAMIC_EX_VPD,
     }
 
     # dict used to convert part of [Defines] to members of DecBuildData directly diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py
index eb435cece480..373441521723 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -164,17 +164,17 @@ def GetDependencyList(FileStack,SearchPathList):
 class DscBuildData(PlatformBuildClassObject):
     # dict used to convert PCD type in database to string used by build tool
     _PCD_TYPE_STRING_ = {
-        MODEL_PCD_FIXED_AT_BUILD        :   "FixedAtBuild",
-        MODEL_PCD_PATCHABLE_IN_MODULE   :   "PatchableInModule",
-        MODEL_PCD_FEATURE_FLAG          :   "FeatureFlag",
-        MODEL_PCD_DYNAMIC               :   "Dynamic",
-        MODEL_PCD_DYNAMIC_DEFAULT       :   "Dynamic",
-        MODEL_PCD_DYNAMIC_HII           :   "DynamicHii",
-        MODEL_PCD_DYNAMIC_VPD           :   "DynamicVpd",
-        MODEL_PCD_DYNAMIC_EX            :   "DynamicEx",
-        MODEL_PCD_DYNAMIC_EX_DEFAULT    :   "DynamicEx",
-        MODEL_PCD_DYNAMIC_EX_HII        :   "DynamicExHii",
-        MODEL_PCD_DYNAMIC_EX_VPD        :   "DynamicExVpd",
+        MODEL_PCD_FIXED_AT_BUILD        :   TAB_PCDS_FIXED_AT_BUILD,
+        MODEL_PCD_PATCHABLE_IN_MODULE   :   TAB_PCDS_PATCHABLE_IN_MODULE,
+        MODEL_PCD_FEATURE_FLAG          :   TAB_PCDS_FEATURE_FLAG,
+        MODEL_PCD_DYNAMIC               :   TAB_PCDS_DYNAMIC,
+        MODEL_PCD_DYNAMIC_DEFAULT       :   TAB_PCDS_DYNAMIC,
+        MODEL_PCD_DYNAMIC_HII           :   TAB_PCDS_DYNAMIC_HII,
+        MODEL_PCD_DYNAMIC_VPD           :   TAB_PCDS_DYNAMIC_VPD,
+        MODEL_PCD_DYNAMIC_EX            :   TAB_PCDS_DYNAMIC_EX,
+        MODEL_PCD_DYNAMIC_EX_DEFAULT    :   TAB_PCDS_DYNAMIC_EX,
+        MODEL_PCD_DYNAMIC_EX_HII        :   TAB_PCDS_DYNAMIC_EX_HII,
+        MODEL_PCD_DYNAMIC_EX_VPD        :   TAB_PCDS_DYNAMIC_EX_VPD,
     }
 
     # dict used to convert part of [Defines] to members of DscBuildData directly diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py b/BaseTools/Source/Python/Workspace/InfBuildData.py
index 94f142e8e617..157f7a2d2de8 100644
--- a/BaseTools/Source/Python/Workspace/InfBuildData.py
+++ b/BaseTools/Source/Python/Workspace/InfBuildData.py
@@ -28,17 +28,17 @@ from Workspace.BuildClassObject import ModuleBuildClassObject, LibraryClassObjec  class InfBuildData(ModuleBuildClassObject):
     # dict used to convert PCD type in database to string used by build tool
     _PCD_TYPE_STRING_ = {
-        MODEL_PCD_FIXED_AT_BUILD        :   "FixedAtBuild",
-        MODEL_PCD_PATCHABLE_IN_MODULE   :   "PatchableInModule",
-        MODEL_PCD_FEATURE_FLAG          :   "FeatureFlag",
-        MODEL_PCD_DYNAMIC               :   "Dynamic",
-        MODEL_PCD_DYNAMIC_DEFAULT       :   "Dynamic",
-        MODEL_PCD_DYNAMIC_HII           :   "DynamicHii",
-        MODEL_PCD_DYNAMIC_VPD           :   "DynamicVpd",
-        MODEL_PCD_DYNAMIC_EX            :   "DynamicEx",
-        MODEL_PCD_DYNAMIC_EX_DEFAULT    :   "DynamicEx",
-        MODEL_PCD_DYNAMIC_EX_HII        :   "DynamicExHii",
-        MODEL_PCD_DYNAMIC_EX_VPD        :   "DynamicExVpd",
+        MODEL_PCD_FIXED_AT_BUILD        :   TAB_PCDS_FIXED_AT_BUILD,
+        MODEL_PCD_PATCHABLE_IN_MODULE   :   TAB_PCDS_PATCHABLE_IN_MODULE,
+        MODEL_PCD_FEATURE_FLAG          :   TAB_PCDS_FEATURE_FLAG,
+        MODEL_PCD_DYNAMIC               :   TAB_PCDS_DYNAMIC,
+        MODEL_PCD_DYNAMIC_DEFAULT       :   TAB_PCDS_DYNAMIC,
+        MODEL_PCD_DYNAMIC_HII           :   TAB_PCDS_DYNAMIC_HII,
+        MODEL_PCD_DYNAMIC_VPD           :   TAB_PCDS_DYNAMIC_VPD,
+        MODEL_PCD_DYNAMIC_EX            :   TAB_PCDS_DYNAMIC_EX,
+        MODEL_PCD_DYNAMIC_EX_DEFAULT    :   TAB_PCDS_DYNAMIC_EX,
+        MODEL_PCD_DYNAMIC_EX_HII        :   TAB_PCDS_DYNAMIC_EX_HII,
+        MODEL_PCD_DYNAMIC_EX_VPD        :   TAB_PCDS_DYNAMIC_EX_VPD,
     }
 
     # dict used to convert part of [Defines] to members of InfBuildData directly @@ -1026,13 +1026,13 @@ class InfBuildData(ModuleBuildClassObject):
                 # if platform doesn't give its type, use 'lowest' one in the
                 # following order, if any
                 #
-                #   "FixedAtBuild", "PatchableInModule", "FeatureFlag", "Dynamic", "DynamicEx"
+                #   TAB_PCDS_FIXED_AT_BUILD, TAB_PCDS_PATCHABLE_IN_MODULE, TAB_PCDS_FEATURE_FLAG, TAB_PCDS_DYNAMIC, TAB_PCDS_DYNAMIC_EX
                 #
                 _GuidDict.update(Package.Guids)
                 PcdType = self._PCD_TYPE_STRING_[Type]
                 if Type == MODEL_PCD_DYNAMIC:
                     Pcd.Pending = True
-                    for T in ["FixedAtBuild", "PatchableInModule", "FeatureFlag", "Dynamic", "DynamicEx"]:
+                    for T in PCD_TYPE_LIST:
                         if (PcdRealName, TokenSpaceGuid) in GlobalData.MixedPcd:
                             for item in GlobalData.MixedPcd[(PcdRealName, TokenSpaceGuid)]:
                                 if str(item[0]).endswith(T) and (item[0], item[1], T) in Package.Pcds:
diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Source/Python/build/BuildReport.py
index 02e01a1fa2ab..c8948b5cfbd9 100644
--- a/BaseTools/Source/Python/build/BuildReport.py
+++ b/BaseTools/Source/Python/build/BuildReport.py
@@ -94,15 +94,15 @@ gSubSectionSep = "-" * gLineMaxLength
 
 ## The look up table to map PCD type to pair of report display type and DEC type  gPcdTypeMap = {
-  'FixedAtBuild'     : ('FIXED',  'FixedAtBuild'),
-  'PatchableInModule': ('PATCH',  'PatchableInModule'),
-  'FeatureFlag'      : ('FLAG',   'FeatureFlag'),
-  'Dynamic'          : ('DYN',    'Dynamic'),
-  'DynamicHii'       : ('DYNHII', 'Dynamic'),
-  'DynamicVpd'       : ('DYNVPD', 'Dynamic'),
-  'DynamicEx'        : ('DEX',    'DynamicEx'),
-  'DynamicExHii'     : ('DEXHII', 'DynamicEx'),
-  'DynamicExVpd'     : ('DEXVPD', 'DynamicEx'),
+  TAB_PCDS_FIXED_AT_BUILD     : ('FIXED',  TAB_PCDS_FIXED_AT_BUILD),
+  TAB_PCDS_PATCHABLE_IN_MODULE: ('PATCH',  TAB_PCDS_PATCHABLE_IN_MODULE),
+  TAB_PCDS_FEATURE_FLAG       : ('FLAG',   TAB_PCDS_FEATURE_FLAG),
+  TAB_PCDS_DYNAMIC            : ('DYN',    TAB_PCDS_DYNAMIC),
+  TAB_PCDS_DYNAMIC_HII        : ('DYNHII', TAB_PCDS_DYNAMIC),
+  TAB_PCDS_DYNAMIC_VPD        : ('DYNVPD', TAB_PCDS_DYNAMIC),
+  TAB_PCDS_DYNAMIC_EX         : ('DEX',    TAB_PCDS_DYNAMIC_EX),
+  TAB_PCDS_DYNAMIC_EX_HII     : ('DEXHII', TAB_PCDS_DYNAMIC_EX),
+  TAB_PCDS_DYNAMIC_EX_VPD     : ('DEXVPD', TAB_PCDS_DYNAMIC_EX),
   }
 
 ## The look up table to map module type to driver type @@ -784,7 +784,7 @@ class PcdReport(object):
                 Pcd = Pa.Platform.Pcds[item]
                 if not Pcd.Type:
                     # check the Pcd in FDF file, whether it is used in module first
-                    for T in ["FixedAtBuild", "PatchableInModule", "FeatureFlag", "Dynamic", "DynamicEx"]:
+                    for T in PCD_TYPE_LIST:
                         PcdList = self.AllPcds.setdefault(Pcd.TokenSpaceGuidCName, {}).setdefault(T, [])
                         if Pcd in PcdList:
                             Pcd.Type = T @@ -792,7 +792,7 @@ class PcdReport(object):
                 if not Pcd.Type:
                     PcdTypeFlag = False
                     for package in Pa.PackageList:
-                        for T in ["FixedAtBuild", "PatchableInModule", "FeatureFlag", "Dynamic", "DynamicEx"]:
+                        for T in PCD_TYPE_LIST:
                             if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, T) in package.Pcds:
                                 Pcd.Type = T
                                 PcdTypeFlag = True @@ -804,10 +804,10 @@ class PcdReport(object):
                 if not Pcd.DatumType:
                     PcdType = Pcd.Type
                     # Try to remove Hii and Vpd suffix
-                    if PcdType.startswith("DynamicEx"):
-                        PcdType = "DynamicEx"
-                    elif PcdType.startswith("Dynamic"):
-                        PcdType = "Dynamic"
+                    if PcdType.startswith(TAB_PCDS_DYNAMIC_EX):
+                        PcdType = TAB_PCDS_DYNAMIC_EX
+                    elif PcdType.startswith(TAB_PCDS_DYNAMIC):
+                        PcdType = TAB_PCDS_DYNAMIC
                     for package in Pa.PackageList:
                         if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, PcdType) in package.Pcds:
                             Pcd.DatumType = package.Pcds[(Pcd.TokenCName, Pcd.TokenSpaceGuidCName, PcdType)].DatumType
--
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* Re: [PATCH v1 21/27] BaseTools: replace string with predefined constant
  2018-04-20 15:51 ` [PATCH v1 21/27] BaseTools: replace string with predefined constant Jaben Carsey
@ 2018-04-25  6:04   ` Zhu, Yonghong
  0 siblings, 0 replies; 56+ messages in thread
From: Zhu, Yonghong @ 2018-04-25  6:04 UTC (permalink / raw)
  To: Carsey, Jaben, edk2-devel@lists.01.org; +Cc: Gao, Liming, Zhu, Yonghong

Should use DT.PLATFORM_COMPONENT_TYPE_LIBRARY_CLASS, because current in the file header it use "import Common.DataType as DT".

Best Regards,
Zhu Yonghong


-----Original Message-----
From: Carsey, Jaben 
Sent: Friday, April 20, 2018 11:52 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming <liming.gao@intel.com>; Zhu, Yonghong <yonghong.zhu@intel.com>
Subject: [PATCH v1 21/27] BaseTools: replace string with predefined constant

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>
---
 BaseTools/Source/Python/Ecc/Check.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Source/Python/Ecc/Check.py b/BaseTools/Source/Python/Ecc/Check.py
index c0e8006dcc51..6490670b0ddb 100644
--- a/BaseTools/Source/Python/Ecc/Check.py
+++ b/BaseTools/Source/Python/Ecc/Check.py
@@ -787,7 +787,7 @@ class Check(object):
                         continue
                     SqlCommand = """select Value3 from Inf where BelongsToFile =
                                     (select ID from File where lower(FullPath) = lower('%s'))
-                                    and Value2 = '%s'""" % (LibraryIns, 'LIBRARY_CLASS')
+                                    and Value2 = '%s'""" % (LibraryIns, PLATFORM_COMPONENT_TYPE_LIBRARY_CLASS)
                     RecordSet = EccGlobalData.gDb.TblInf.Exec(SqlCommand)
                     IsFound = False
                     for Record in RecordSet:
-- 
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* Re: [PATCH v1 01/27] BaseTools: Misc - refactor RegEx to minimize multiple compiling
  2018-04-20 15:51 ` [PATCH v1 01/27] BaseTools: Misc - refactor RegEx to minimize multiple compiling Jaben Carsey
@ 2018-04-25  8:49   ` Zhu, Yonghong
  0 siblings, 0 replies; 56+ messages in thread
From: Zhu, Yonghong @ 2018-04-25  8:49 UTC (permalink / raw)
  To: Carsey, Jaben, edk2-devel@lists.01.org; +Cc: Gao, Liming, Zhu, Yonghong

Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com> 

Best Regards,
Zhu Yonghong


-----Original Message-----
From: Carsey, Jaben 
Sent: Friday, April 20, 2018 11:51 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming <liming.gao@intel.com>; Zhu, Yonghong <yonghong.zhu@intel.com>
Subject: [PATCH v1 01/27] BaseTools: Misc - refactor RegEx to minimize multiple compiling

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>
---
 BaseTools/Source/Python/Common/Misc.py | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
index 4f2bfd63cfc3..bc7d0c2d9d00 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -84,6 +84,7 @@ def _parseForXcode(lines, efifilepath, varnames):
         if status == 1 and len(line) != 0:
             for varname in varnames:
                 if varname in line:
+                    # cannot pregenerate this RegEx since it uses varname from varnames.
                     m = re.match('^([\da-fA-FxX]+)([\s\S]*)([_]*%s)$' % varname, line)
                     if m is not None:
                         ret.append((varname, m.group(1))) @@ -91,6 +92,8 @@ def _parseForXcode(lines, efifilepath, varnames):
 
 def _parseForGCC(lines, efifilepath, varnames):
     """ Parse map file generated by GCC linker """
+    valuePattern = re.compile('^([\w_\.]+) +([\da-fA-Fx]+) +([\da-fA-Fx]+)$')
+    pcdPattern = re.compile('^([\da-fA-Fx]+) +([\da-fA-Fx]+)')
     status = 0
     sections = []
     varoffset = []
@@ -109,7 +112,7 @@ def _parseForGCC(lines, efifilepath, varnames):
 
         # status handler
         if status == 3:
-            m = re.match('^([\w_\.]+) +([\da-fA-Fx]+) +([\da-fA-Fx]+)$', line)
+            m = valuePattern.match(line)
             if m is not None:
                 sections.append(m.groups(0))
             for varname in varnames:
@@ -122,7 +125,7 @@ def _parseForGCC(lines, efifilepath, varnames):
                     else:
                         Str = line[len(".data.%s" % varname):]
                     if Str:
-                        m = re.match('^([\da-fA-Fx]+) +([\da-fA-Fx]+)', Str.strip())
+                        m = pcdPattern.match(Str.strip())
                         if m is not None:
                             varoffset.append((varname, int(m.groups(0)[0], 16) , int(sections[-1][1], 16), sections[-1][0]))
 
@@ -152,16 +155,18 @@ def _parseGeneral(lines, efifilepath, varnames):
     varoffset = []
     secRe = re.compile('^([\da-fA-F]+):([\da-fA-F]+) +([\da-fA-F]+)[Hh]? +([.\w\$]+) +(\w+)', re.UNICODE)
     symRe = re.compile('^([\da-fA-F]+):([\da-fA-F]+) +([\.:\\\\\w\?@\$]+) +([\da-fA-F]+)', re.UNICODE)
+    startRe = re.compile("^Start[' ']+Length[' ']+Name[' ']+Class")
+    addressRe = re.compile("^Address[' ']+Publics by Value[' 
+ ']+Rva\+Base")
 
     for line in lines:
         line = line.strip()
-        if re.match("^Start[' ']+Length[' ']+Name[' ']+Class", line):
+        if startRe.match(line):
             status = 1
             continue
-        if re.match("^Address[' ']+Publics by Value[' ']+Rva\+Base", line):
+        if addressRe.match(line):
             status = 2
             continue
-        if re.match("^entry point at", line):
+        if line.startswith("entry point at"):
             status = 3
             continue        
         if status == 1 and len(line) != 0:
@@ -177,6 +182,7 @@ def _parseGeneral(lines, efifilepath, varnames):
                 sec_no     = int(sec_no,     16)
                 sym_offset = int(sym_offset, 16)
                 vir_addr   = int(vir_addr,   16)
+                # cannot pregenerate this RegEx since it uses varname from varnames.
                 m2 = re.match('^[_]*(%s)' % varname, sym_name)
                 if m2 is not None:
                     # fond a binary pcd entry in map file
--
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* Re: [PATCH v1 04/27] BaseTools: Workspace - refactor RegEx to minimize multiple compiling
  2018-04-20 15:51 ` [PATCH v1 04/27] BaseTools: Workspace - refactor RegEx to minimize multiple compiling Jaben Carsey
@ 2018-04-25  8:50   ` Zhu, Yonghong
  0 siblings, 0 replies; 56+ messages in thread
From: Zhu, Yonghong @ 2018-04-25  8:50 UTC (permalink / raw)
  To: Carsey, Jaben, edk2-devel@lists.01.org; +Cc: Gao, Liming, Zhu, Yonghong

Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com> 

Best Regards,
Zhu Yonghong


-----Original Message-----
From: Carsey, Jaben 
Sent: Friday, April 20, 2018 11:51 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming <liming.gao@intel.com>; Zhu, Yonghong <yonghong.zhu@intel.com>
Subject: [PATCH v1 04/27] BaseTools: Workspace - refactor RegEx to minimize multiple compiling

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>
---
 BaseTools/Source/Python/Workspace/DscBuildData.py   | 4 +++-
 BaseTools/Source/Python/Workspace/MetaFileParser.py | 8 ++++++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py
index d6b8b761d607..be3f7b6881e8 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -41,6 +41,8 @@ from Common.Misc import SaveFileOnChange  from Workspace.BuildClassObject import PlatformBuildClassObject, StructurePcd, PcdClassObject, ModuleBuildClassObject  from collections import OrderedDict
 
+variablePattern = re.compile(r'[\t\s]*0[xX][a-fA-F0-9]+$')
+
 #
 # Treat CHAR16 as a synonym for UINT16.  CHAR16 support is required for VFR C structs  # @@ -2421,7 +2423,7 @@ class DscBuildData(PlatformBuildClassObject):
             if VariableOffset.isdigit():
                 if int(VariableOffset, 10) > 0xFFFF:
                     ExceedMax = True
-            elif re.match(r'[\t\s]*0[xX][a-fA-F0-9]+$', VariableOffset):
+            elif variablePattern.match(VariableOffset):
                 if int(VariableOffset, 16) > 0xFFFF:
                     ExceedMax = True
             # For Offset written in "A.B"
diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py
index 322ed3844966..550359f9abb2 100644
--- a/BaseTools/Source/Python/Workspace/MetaFileParser.py
+++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py
@@ -35,6 +35,10 @@ from Common.LongFilePathSupport import OpenLongFilePath as open  from MetaFileTable import MetaFileStorage  from MetaFileCommentParser import CheckInfComment
 
+## RegEx for finding file versions
+hexVersionPattern = re.compile(r'0[xX][\da-f-A-F]{5,8}')
+decVersionPattern = re.compile(r'\d+\.\d+')
+
 ## A decorator used to parse macro definition  def ParseMacro(Parser):
     def MacroParser(self):
@@ -366,9 +370,9 @@ class MetaFileParser(object):
                 EdkLogger.error("Parser", FORMAT_INVALID, "%s not defined" % (Macro), ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1)
         # Sometimes, we need to make differences between EDK and EDK2 modules 
         if Name == 'INF_VERSION':
-            if re.match(r'0[xX][\da-f-A-F]{5,8}', Value):
+            if hexVersionPattern.match(Value):
                 self._Version = int(Value, 0)   
-            elif re.match(r'\d+\.\d+', Value):
+            elif decVersionPattern.match(Value):
                 ValueList = Value.split('.')
                 Major = '%04o' % int(ValueList[0], 0)
                 Minor = '%04o' % int(ValueList[1], 0)
--
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* Re: [PATCH v1 05/27] BaseTools: Autogen - replace string constants with those from DataType
  2018-04-20 15:51 ` [PATCH v1 05/27] BaseTools: Autogen - replace string constants with those from DataType Jaben Carsey
@ 2018-04-25  8:50   ` Zhu, Yonghong
  0 siblings, 0 replies; 56+ messages in thread
From: Zhu, Yonghong @ 2018-04-25  8:50 UTC (permalink / raw)
  To: Carsey, Jaben, edk2-devel@lists.01.org; +Cc: Gao, Liming, Zhu, Yonghong

Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>

Best Regards,
Zhu Yonghong


-----Original Message-----
From: Carsey, Jaben 
Sent: Friday, April 20, 2018 11:51 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming <liming.gao@intel.com>; Zhu, Yonghong <yonghong.zhu@intel.com>
Subject: [PATCH v1 05/27] BaseTools: Autogen - replace string constants with those from DataType

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>
---
 BaseTools/Source/Python/AutoGen/AutoGen.py | 68 ++++++++++----------
 1 file changed, 34 insertions(+), 34 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 6152225943cf..3a2976181ac1 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -259,7 +259,7 @@ class WorkspaceAutoGen(AutoGen):
         self.BuildDatabase  = MetaFileDb
         self.MetaFile       = ActivePlatform
         self.WorkspaceDir   = WorkspaceDir
-        self.Platform       = self.BuildDatabase[self.MetaFile, TAB_COMMON, Target, Toolchain]
+        self.Platform       = self.BuildDatabase[self.MetaFile, TAB_ARCH_COMMON, Target, Toolchain]
         GlobalData.gActivePlatform = self.Platform
         self.BuildTarget    = Target
         self.ToolChain      = Toolchain
@@ -405,8 +405,8 @@ class WorkspaceAutoGen(AutoGen):
             Platform = self.BuildDatabase[self.MetaFile, Arch, Target, Toolchain]
             PlatformPcds = Platform.Pcds
             self._GuidDict = Platform._GuidDict
-            SourcePcdDict = {'DynamicEx':set(), 'PatchableInModule':set(),'Dynamic':set(),'FixedAtBuild':set()}
-            BinaryPcdDict = {'DynamicEx':set(), 'PatchableInModule':set()}
+            SourcePcdDict = {TAB_PCDS_DYNAMIC_EX:set(), TAB_PCDS_PATCHABLE_IN_MODULE:set(),TAB_PCDS_DYNAMIC:set(),TAB_PCDS_FIXED_AT_BUILD:set()}
+            BinaryPcdDict = {TAB_PCDS_DYNAMIC_EX:set(), 
+ TAB_PCDS_PATCHABLE_IN_MODULE:set()}
             SourcePcdDict_Keys = SourcePcdDict.keys()
             BinaryPcdDict_Keys = BinaryPcdDict.keys()
 
@@ -430,23 +430,23 @@ class WorkspaceAutoGen(AutoGen):
                                     if PcdInPlatform.Type not in [None, '']:
                                         BuildData.Pcds[key].Type = PcdInPlatform.Type
 
-                        if 'DynamicEx' in BuildData.Pcds[key].Type:
+                        if TAB_PCDS_DYNAMIC_EX in BuildData.Pcds[key].Type:
                             if BuildData.IsBinaryModule:
-                                BinaryPcdDict['DynamicEx'].add((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))
+                                
+ BinaryPcdDict[TAB_PCDS_DYNAMIC_EX].add((BuildData.Pcds[key].TokenCName
+ , BuildData.Pcds[key].TokenSpaceGuidCName))
                             else:
-                                SourcePcdDict['DynamicEx'].add((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))
+                                
+ SourcePcdDict[TAB_PCDS_DYNAMIC_EX].add((BuildData.Pcds[key].TokenCName
+ , BuildData.Pcds[key].TokenSpaceGuidCName))
 
-                        elif 'PatchableInModule' in BuildData.Pcds[key].Type:
+                        elif TAB_PCDS_PATCHABLE_IN_MODULE in BuildData.Pcds[key].Type:
                             if BuildData.MetaFile.Ext == '.inf':
                                 if BuildData.IsBinaryModule:
-                                    BinaryPcdDict['PatchableInModule'].add((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))
+                                    
+ BinaryPcdDict[TAB_PCDS_PATCHABLE_IN_MODULE].add((BuildData.Pcds[key].T
+ okenCName, BuildData.Pcds[key].TokenSpaceGuidCName))
                                 else:
-                                    SourcePcdDict['PatchableInModule'].add((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))
+                                    
+ SourcePcdDict[TAB_PCDS_PATCHABLE_IN_MODULE].add((BuildData.Pcds[key].T
+ okenCName, BuildData.Pcds[key].TokenSpaceGuidCName))
 
-                        elif 'Dynamic' in BuildData.Pcds[key].Type:
-                            SourcePcdDict['Dynamic'].add((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))
-                        elif 'FixedAtBuild' in BuildData.Pcds[key].Type:
-                            SourcePcdDict['FixedAtBuild'].add((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))
+                        elif TAB_PCDS_DYNAMIC in BuildData.Pcds[key].Type:
+                            SourcePcdDict[TAB_PCDS_DYNAMIC].add((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))
+                        elif TAB_PCDS_FIXED_AT_BUILD in BuildData.Pcds[key].Type:
+                            
+ SourcePcdDict[TAB_PCDS_FIXED_AT_BUILD].add((BuildData.Pcds[key].TokenC
+ Name, BuildData.Pcds[key].TokenSpaceGuidCName))
                 else:
                     pass
             #
@@ -788,7 +788,7 @@ class WorkspaceAutoGen(AutoGen):
                             # Here we just need to get FILE_GUID from INF file, use 'COMMON' as ARCH attribute. and use 
                             # BuildObject from one of AutoGenObjectList is enough.
                             #
-                            InfObj = self.AutoGenObjectList[0].BuildDatabase.WorkspaceDb.BuildObject[PathClassObj, TAB_COMMON, self.BuildTarget, self.ToolChain]
+                            InfObj = 
+ self.AutoGenObjectList[0].BuildDatabase.WorkspaceDb.BuildObject[PathCl
+ assObj, TAB_ARCH_COMMON, self.BuildTarget, self.ToolChain]
                             if InfObj.Guid.upper() not in _GuidDict:
                                 _GuidDict[InfObj.Guid.upper()] = FfsFile
                             else:
@@ -869,9 +869,9 @@ class WorkspaceAutoGen(AutoGen):
 
     def _CheckPcdDefineAndType(self):
         PcdTypeList = [
-            "FixedAtBuild", "PatchableInModule", "FeatureFlag",
-            "Dynamic", #"DynamicHii", "DynamicVpd",
-            "DynamicEx", # "DynamicExHii", "DynamicExVpd"
+            TAB_PCDS_FIXED_AT_BUILD, TAB_PCDS_PATCHABLE_IN_MODULE, TAB_PCDS_FEATURE_FLAG,
+            TAB_PCDS_DYNAMIC, #"DynamicHii", "DynamicVpd",
+            TAB_PCDS_DYNAMIC_EX, # "DynamicExHii", "DynamicExVpd"
         ]
 
         # This dict store PCDs which are not used by any modules with specified arches @@ -886,10 +886,10 @@ class WorkspaceAutoGen(AutoGen):
                     continue
 
                 # Try to remove Hii and Vpd suffix
-                if PcdType.startswith("DynamicEx"):
-                    PcdType = "DynamicEx"
-                elif PcdType.startswith("Dynamic"):
-                    PcdType = "Dynamic"
+                if PcdType.startswith(TAB_PCDS_DYNAMIC_EX):
+                    PcdType = TAB_PCDS_DYNAMIC_EX
+                elif PcdType.startswith(TAB_PCDS_DYNAMIC):
+                    PcdType = TAB_PCDS_DYNAMIC
 
                 for Package in Pa.PackageList:
                     # Key of DEC's Pcds dictionary is PcdCName, TokenSpaceGuid, PcdType @@ -1286,7 +1286,7 @@ class PlatformAutoGen(AutoGen):
                     continue
                 else:
                     DscPcd = self.NonDynamicPcdDict[(Pcd.TokenCName,Pcd.TokenSpaceGuidCName)]
-                    if DscPcd.Type != "FixedAtBuild":
+                    if DscPcd.Type != TAB_PCDS_FIXED_AT_BUILD:
                         continue
                 if key in ShareFixedAtBuildPcdsSameValue and ShareFixedAtBuildPcdsSameValue[key]:                    
                     LibAuto.ConstPcd[key] = FixedAtBuildPcds[key] @@ -2066,28 +2066,28 @@ class PlatformAutoGen(AutoGen):
             #
             for Pcd in self.DynamicPcdList:
                 if Pcd.Phase == "PEI":
-                    if Pcd.Type in ["Dynamic", "DynamicDefault", "DynamicVpd", "DynamicHii"]:
+                    if Pcd.Type in [TAB_PCDS_DYNAMIC, "DynamicDefault", "DynamicVpd", "DynamicHii"]:
                         EdkLogger.debug(EdkLogger.DEBUG_5, "%s %s (%s) -> %d" % (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Pcd.Phase, TokenNumber))
                         self._PcdTokenNumber[Pcd.TokenCName, Pcd.TokenSpaceGuidCName] = TokenNumber
                         TokenNumber += 1
 
             for Pcd in self.DynamicPcdList:
                 if Pcd.Phase == "PEI":
-                    if Pcd.Type in ["DynamicEx", "DynamicExDefault", "DynamicExVpd", "DynamicExHii"]:
+                    if Pcd.Type in [TAB_PCDS_DYNAMIC_EX, "DynamicExDefault", "DynamicExVpd", "DynamicExHii"]:
                         EdkLogger.debug(EdkLogger.DEBUG_5, "%s %s (%s) -> %d" % (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Pcd.Phase, TokenNumber))
                         self._PcdTokenNumber[Pcd.TokenCName, Pcd.TokenSpaceGuidCName] = TokenNumber
                         TokenNumber += 1
 
             for Pcd in self.DynamicPcdList:
                 if Pcd.Phase == "DXE":
-                    if Pcd.Type in ["Dynamic", "DynamicDefault", "DynamicVpd", "DynamicHii"]:
+                    if Pcd.Type in [TAB_PCDS_DYNAMIC, "DynamicDefault", "DynamicVpd", "DynamicHii"]:
                         EdkLogger.debug(EdkLogger.DEBUG_5, "%s %s (%s) -> %d" % (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Pcd.Phase, TokenNumber))
                         self._PcdTokenNumber[Pcd.TokenCName, Pcd.TokenSpaceGuidCName] = TokenNumber
                         TokenNumber += 1
 
             for Pcd in self.DynamicPcdList:
                 if Pcd.Phase == "DXE":
-                    if Pcd.Type in ["DynamicEx", "DynamicExDefault", "DynamicExVpd", "DynamicExHii"]:
+                    if Pcd.Type in [TAB_PCDS_DYNAMIC_EX, "DynamicExDefault", "DynamicExVpd", "DynamicExHii"]:
                         EdkLogger.debug(EdkLogger.DEBUG_5, "%s %s (%s) -> %d" % (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Pcd.Phase, TokenNumber))
                         self._PcdTokenNumber[Pcd.TokenCName, Pcd.TokenSpaceGuidCName] = TokenNumber
                         TokenNumber += 1 @@ -2331,7 +2331,7 @@ class PlatformAutoGen(AutoGen):
                 ToPcd.Type = FromPcd.Type
             elif (ToPcd.Type not in [None, '']) and (FromPcd.Type not in [None, ''])\
                 and (ToPcd.Type != FromPcd.Type) and (ToPcd.Type in FromPcd.Type):
-                if ToPcd.Type.strip() == "DynamicEx":
+                if ToPcd.Type.strip() == TAB_PCDS_DYNAMIC_EX:
                     ToPcd.Type = FromPcd.Type
             elif ToPcd.Type not in [None, ''] and FromPcd.Type not in [None, ''] \
                 and ToPcd.Type != FromPcd.Type:
@@ -2881,7 +2881,7 @@ class ModuleAutoGen(AutoGen):
         if self._FixedAtBuildPcds:
             return self._FixedAtBuildPcds
         for Pcd in self.ModulePcdList:
-            if Pcd.Type != "FixedAtBuild":
+            if Pcd.Type != TAB_PCDS_FIXED_AT_BUILD:
                 continue
             if Pcd not in self._FixedAtBuildPcds:
                 self._FixedAtBuildPcds.append(Pcd)
@@ -3418,7 +3418,7 @@ class ModuleAutoGen(AutoGen):
         if self._BinaryFileList is None:
             self._BinaryFileList = []
             for F in self.Module.Binaries:
-                if F.Target not in [TAB_COMMON, '*'] and F.Target != self.BuildTarget:
+                if F.Target not in [TAB_ARCH_COMMON, '*'] and F.Target != self.BuildTarget:
                     continue
                 self._BinaryFileList.append(F)
                 self._ApplyBuildRule(F, F.Type) @@ -3931,12 +3931,12 @@ class ModuleAutoGen(AutoGen):
         for Pcd in self.ModulePcdList + self.LibraryPcdList:
             if Pcd.Type == TAB_PCDS_PATCHABLE_IN_MODULE:
                 PatchablePcds += [Pcd]
-                PcdCheckList.append((Pcd.TokenCName, Pcd.TokenSpaceGuidCName, 'PatchableInModule'))
+                PcdCheckList.append((Pcd.TokenCName, 
+ Pcd.TokenSpaceGuidCName, TAB_PCDS_PATCHABLE_IN_MODULE))
             elif Pcd.Type in GenC.gDynamicExPcd:
                 if Pcd not in Pcds:
                     Pcds += [Pcd]
-                    PcdCheckList.append((Pcd.TokenCName, Pcd.TokenSpaceGuidCName, 'DynamicEx'))
-                    PcdCheckList.append((Pcd.TokenCName, Pcd.TokenSpaceGuidCName, 'Dynamic'))
+                    PcdCheckList.append((Pcd.TokenCName, Pcd.TokenSpaceGuidCName, TAB_PCDS_DYNAMIC_EX))
+                    PcdCheckList.append((Pcd.TokenCName, 
+ Pcd.TokenSpaceGuidCName, TAB_PCDS_DYNAMIC))
                     PcdTokenSpaceList.append(Pcd.TokenSpaceGuidCName)
         GuidList = OrderedDict()
         GuidList.update(self.GuidList)
@@ -3964,8 +3964,8 @@ class ModuleAutoGen(AutoGen):
             if Pkg in Packages:
                 continue
             for VfrPcd in VfrPcds:
-                if ((VfrPcd.TokenCName, VfrPcd.TokenSpaceGuidCName, 'DynamicEx') in Pkg.Pcds or
-                    (VfrPcd.TokenCName, VfrPcd.TokenSpaceGuidCName, 'Dynamic') in Pkg.Pcds):
+                if ((VfrPcd.TokenCName, VfrPcd.TokenSpaceGuidCName, TAB_PCDS_DYNAMIC_EX) in Pkg.Pcds or
+                    (VfrPcd.TokenCName, VfrPcd.TokenSpaceGuidCName, TAB_PCDS_DYNAMIC) in Pkg.Pcds):
                     Packages += [Pkg]
                     break
 
--
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* Re: [PATCH v1 12/27] BaseTools: remove dict from DscBuildData
  2018-04-20 15:51 ` [PATCH v1 12/27] BaseTools: remove dict from DscBuildData Jaben Carsey
@ 2018-04-25  8:50   ` Zhu, Yonghong
  0 siblings, 0 replies; 56+ messages in thread
From: Zhu, Yonghong @ 2018-04-25  8:50 UTC (permalink / raw)
  To: Carsey, Jaben, edk2-devel@lists.01.org; +Cc: Gao, Liming, Zhu, Yonghong

Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com> 

Best Regards,
Zhu Yonghong


-----Original Message-----
From: Carsey, Jaben 
Sent: Friday, April 20, 2018 11:52 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming <liming.gao@intel.com>; Zhu, Yonghong <yonghong.zhu@intel.com>
Subject: [PATCH v1 12/27] BaseTools: remove dict from DscBuildData

the dict is not needed as BaseTools can check the set

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>
---
 BaseTools/Source/Python/Workspace/DscBuildData.py | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py
index 904c52d9576a..eb435cece480 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -1953,13 +1953,11 @@ class DscBuildData(PlatformBuildClassObject):
         InitByteValue = ""
         CApp = PcdMainCHeader
 
-        Includes = {}
         IncludeFiles = set()
         for PcdName in StructuredPcds:
             Pcd = StructuredPcds[PcdName]
             for IncludeFile in Pcd.StructuredPcdIncludeFile:
-                if IncludeFile not in Includes:
-                    Includes[IncludeFile] = True
+                if IncludeFile not in IncludeFiles:
                     IncludeFiles.add(IncludeFile)
                     CApp = CApp + '#include <%s>\n' % (IncludeFile)
         CApp = CApp + '\n'
-- 
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* Re: [PATCH v1 02/27] BaseTools: GenPatchPcdTable - refactor RegEx to minimize multiple compiling
  2018-04-20 15:51 ` [PATCH v1 02/27] BaseTools: GenPatchPcdTable " Jaben Carsey
@ 2018-04-25  8:50   ` Zhu, Yonghong
  0 siblings, 0 replies; 56+ messages in thread
From: Zhu, Yonghong @ 2018-04-25  8:50 UTC (permalink / raw)
  To: Carsey, Jaben, edk2-devel@lists.01.org; +Cc: Gao, Liming, Zhu, Yonghong

Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com> 

Best Regards,
Zhu Yonghong


-----Original Message-----
From: Carsey, Jaben 
Sent: Friday, April 20, 2018 11:51 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming <liming.gao@intel.com>; Zhu, Yonghong <yonghong.zhu@intel.com>
Subject: [PATCH v1 02/27] BaseTools: GenPatchPcdTable - refactor RegEx to minimize multiple compiling

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>
---
 BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py | 24 ++++++++++++--------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py b/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py
index dc2ceaf775d8..59748763a553 100644
--- a/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py
+++ b/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py
@@ -63,6 +63,7 @@ def parsePcdInfoFromMapFile(mapfilepath, efifilepath):
     return _parseGeneral(lines, efifilepath)
 
 def _parseForXcode(lines, efifilepath):
+    valuePattern = re.compile('^([\da-fA-FxX]+)([\s\S]*)([_]*_gPcd_BinaryPatch_([\w]+))')
     status = 0
     pcds = []
     for line in lines:
@@ -72,13 +73,16 @@ def _parseForXcode(lines, efifilepath):
             continue
         if status == 1 and len(line) != 0:
             if '_gPcd_BinaryPatch_' in line:
-                m = re.match('^([\da-fA-FxX]+)([\s\S]*)([_]*_gPcd_BinaryPatch_([\w]+))', line)
+                m = valuePattern.match(line)
                 if m is not None:
                     pcds.append((m.groups(0)[3], int(m.groups(0)[0], 16)))
     return pcds
 
 def _parseForGCC(lines, efifilepath):
     """ Parse map file generated by GCC linker """
+    valuePattern = re.compile('^([\w_\.]+) +([\da-fA-Fx]+) +([\da-fA-Fx]+)$')
+    dataPattern = re.compile('^.data._gPcd_BinaryPatch_([\w_\d]+)$')
+    pcdPattern = re.compile('^([\da-fA-Fx]+) +([\da-fA-Fx]+)')
     status = 0
     imageBase = -1
     sections = []
@@ -98,15 +102,15 @@ def _parseForGCC(lines, efifilepath):
 
         # status handler
         if status == 3:
-            m = re.match('^([\w_\.]+) +([\da-fA-Fx]+) +([\da-fA-Fx]+)$', line)
+            m = valuePattern.match(line)
             if m is not None:
                 sections.append(m.groups(0))
         if status == 3:
-            m = re.match('^.data._gPcd_BinaryPatch_([\w_\d]+)$', line)
+            m = dataPattern.match(line)
             if m is not None:
                 if lines[index + 1]:
                     PcdName = m.groups(0)[0]
-                    m = re.match('^([\da-fA-Fx]+) +([\da-fA-Fx]+)', lines[index + 1].strip())
+                    m = pcdPattern.match(lines[index + 1].strip())
                     if m is not None:
                         bpcds.append((PcdName, int(m.groups(0)[0], 16) , int(sections[-1][1], 16), sections[-1][0]))
                 
@@ -137,17 +141,19 @@ def _parseGeneral(lines, efifilepath):
     status = 0    #0 - beginning of file; 1 - PE section definition; 2 - symbol table
     secs = []    # key = section name
     bPcds = []
-
+    startPattern = re.compile("^Start[' ']+Length[' ']+Name[' ']+Class")
+    addressPattern = re.compile("^Address[' ']+Publics by Value[' ']+Rva\+Base")
+    symPattern = re.compile('^[_]+gPcd_BinaryPatch_([\w]+)')
 
     for line in lines:
         line = line.strip()
-        if re.match("^Start[' ']+Length[' ']+Name[' ']+Class", line):
+        if startPattern.match(line):
             status = 1
             continue
-        if re.match("^Address[' ']+Publics by Value[' ']+Rva\+Base", line):
+        if addressPattern.match(line):
             status = 2
             continue
-        if re.match("^entry point at", line):
+        if line.startswith("entry point at"):
             status = 3
             continue
         if status == 1 and len(line) != 0:
@@ -162,7 +168,7 @@ def _parseGeneral(lines, efifilepath):
             sec_no = int(sec_no, 16)
             sym_offset = int(sym_offset, 16)
             vir_addr = int(vir_addr, 16)
-            m2 = re.match('^[_]+gPcd_BinaryPatch_([\w]+)', sym_name)
+            m2 = symPattern.match(sym_name)
             if m2 is not None:
                 # fond a binary pcd entry in map file
                 for sec in secs:
-- 
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* Re: [PATCH v1 08/27] BaseTools: AutoGen - remove dictionary populated, but never accessed
  2018-04-20 15:51 ` [PATCH v1 08/27] BaseTools: AutoGen - remove dictionary populated, but never accessed Jaben Carsey
@ 2018-04-25  8:50   ` Zhu, Yonghong
  0 siblings, 0 replies; 56+ messages in thread
From: Zhu, Yonghong @ 2018-04-25  8:50 UTC (permalink / raw)
  To: Carsey, Jaben, edk2-devel@lists.01.org; +Cc: Gao, Liming, Zhu, Yonghong

Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com> 

Best Regards,
Zhu Yonghong


-----Original Message-----
From: Carsey, Jaben 
Sent: Friday, April 20, 2018 11:51 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming <liming.gao@intel.com>; Zhu, Yonghong <yonghong.zhu@intel.com>
Subject: [PATCH v1 08/27] BaseTools: AutoGen - remove dictionary populated, but never accessed

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>
---
 BaseTools/Source/Python/AutoGen/GenPcdDb.py | 2 --
 1 file changed, 2 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
index 5937558e7038..4f4a8d856842 100644
--- a/BaseTools/Source/Python/AutoGen/GenPcdDb.py
+++ b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
@@ -980,7 +980,6 @@ def CreatePcdDatabaseCode (Info, AutoGenC, AutoGenH):
     Changed = SaveFileOnChange(DbFileName, DbFile.getvalue(), True)  def CreatePcdDataBase(PcdDBData):
     delta = {}
-    basedata = {}
     for skuname,skuid in PcdDBData:
         if len(PcdDBData[(skuname,skuid)][1]) != len(PcdDBData[(TAB_DEFAULT,"0")][1]):
             EdkLogger.ERROR("The size of each sku in one pcd are not same") @@ -988,7 +987,6 @@ def CreatePcdDataBase(PcdDBData):
         if skuname == TAB_DEFAULT:
             continue
         delta[(skuname,skuid)] = [(index,data,hex(data)) for index,data in enumerate(PcdDBData[(skuname,skuid)][1]) if PcdDBData[(skuname,skuid)][1][index] != PcdDBData[(TAB_DEFAULT,"0")][1][index]]
-        basedata[(skuname,skuid)] = [(index,PcdDBData[(TAB_DEFAULT,"0")][1][index],hex(PcdDBData[(TAB_DEFAULT,"0")][1][index])) for index,data in enumerate(PcdDBData[(skuname,skuid)][1]) if PcdDBData[(skuname,skuid)][1][index] != PcdDBData[(TAB_DEFAULT,"0")][1][index]]
     databasebuff = PcdDBData[(TAB_DEFAULT,"0")][0]
 
     for skuname,skuid in delta:
--
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* Re: [PATCH v1 06/27] BaseTools: simplify if call
  2018-04-20 15:51 ` [PATCH v1 06/27] BaseTools: simplify if call Jaben Carsey
@ 2018-04-25  8:50   ` Zhu, Yonghong
  0 siblings, 0 replies; 56+ messages in thread
From: Zhu, Yonghong @ 2018-04-25  8:50 UTC (permalink / raw)
  To: Carsey, Jaben, edk2-devel@lists.01.org; +Cc: Gao, Liming, Zhu, Yonghong

Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com> 

Best Regards,
Zhu Yonghong


-----Original Message-----
From: Carsey, Jaben 
Sent: Friday, April 20, 2018 11:51 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming <liming.gao@intel.com>; Zhu, Yonghong <yonghong.zhu@intel.com>
Subject: [PATCH v1 06/27] BaseTools: simplify if call

the variable is a string type since we just used .strip() on it.

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>
---
 BaseTools/Source/Python/Common/Expression.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Source/Python/Common/Expression.py
index 9a3415ccaabe..99929938fb5a 100644
--- a/BaseTools/Source/Python/Common/Expression.py
+++ b/BaseTools/Source/Python/Common/Expression.py
@@ -815,7 +815,7 @@ class ValueExpressionEx(ValueExpression):
         except BadExpression, Value:
             if self.PcdType in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN']:
                 PcdValue = PcdValue.strip()
-                if type(PcdValue) == type('') and PcdValue.startswith('{') and PcdValue.endswith('}'):
+                if PcdValue.startswith('{') and PcdValue.endswith('}'):
                     PcdValue = SplitPcdValueString(PcdValue[1:-1])
                 if type(PcdValue) == type([]):
                     TmpValue = 0
-- 
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* Re: [PATCH v1 07/27] BaseTools: Workspace - refactor GetStructurePcdInfo
  2018-04-20 15:51 ` [PATCH v1 07/27] BaseTools: Workspace - refactor GetStructurePcdInfo Jaben Carsey
@ 2018-04-25  8:50   ` Zhu, Yonghong
  0 siblings, 0 replies; 56+ messages in thread
From: Zhu, Yonghong @ 2018-04-25  8:50 UTC (permalink / raw)
  To: Carsey, Jaben, edk2-devel@lists.01.org; +Cc: Gao, Liming, Zhu, Yonghong

Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com> 

Best Regards,
Zhu Yonghong


-----Original Message-----
From: Carsey, Jaben 
Sent: Friday, April 20, 2018 11:51 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming <liming.gao@intel.com>; Zhu, Yonghong <yonghong.zhu@intel.com>
Subject: [PATCH v1 07/27] BaseTools: Workspace - refactor GetStructurePcdInfo

the function doesn't use self and can be static defaultdict replaces dict and removes the dict initialization code

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>
---
 BaseTools/Source/Python/Workspace/DscBuildData.py | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py
index be3f7b6881e8..904c52d9576a 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -39,7 +39,7 @@ import Common.GlobalData as GlobalData  import subprocess  from Common.Misc import SaveFileOnChange  from Workspace.BuildClassObject import PlatformBuildClassObject, StructurePcd, PcdClassObject, ModuleBuildClassObject -from collections import OrderedDict
+from collections import OrderedDict,defaultdict
 
 variablePattern = re.compile(r'[\t\s]*0[xX][a-fA-F0-9]+$')
 
@@ -1187,11 +1187,10 @@ class DscBuildData(PlatformBuildClassObject):
                             options[Key] += ' ' + Option
         return self._ModuleTypeOptions[Edk, ModuleType]
 
-    def GetStructurePcdInfo(self, PcdSet):
-        structure_pcd_data = {}
+    @staticmethod
+    def GetStructurePcdInfo(PcdSet):
+        structure_pcd_data = defaultdict(list)
         for item in PcdSet:
-            if (item[0],item[1]) not in structure_pcd_data:
-                structure_pcd_data[(item[0],item[1])] = []
             structure_pcd_data[(item[0],item[1])].append(item)
 
         return structure_pcd_data
@@ -1298,7 +1297,7 @@ class DscBuildData(PlatformBuildClassObject):
                 S_PcdSet.append([ TokenSpaceGuid.split(".")[0],TokenSpaceGuid.split(".")[1], PcdCName,SkuName, default_store,Dummy5, AnalyzePcdExpression(Setting)[0]])
 
         # handle pcd value override
-        StrPcdSet = self.GetStructurePcdInfo(S_PcdSet)
+        StrPcdSet = DscBuildData.GetStructurePcdInfo(S_PcdSet)
         S_pcd_set = OrderedDict()
         for str_pcd in StrPcdSet:
             str_pcd_obj = Pcds.get((str_pcd[1], str_pcd[0]), None)
--
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* Re: [PATCH v1 10/27] BaseTools: Remove extra .keys()
  2018-04-20 15:51 ` [PATCH v1 10/27] BaseTools: Remove extra .keys() Jaben Carsey
@ 2018-04-25  8:51   ` Zhu, Yonghong
  0 siblings, 0 replies; 56+ messages in thread
From: Zhu, Yonghong @ 2018-04-25  8:51 UTC (permalink / raw)
  To: Carsey, Jaben, edk2-devel@lists.01.org; +Cc: Gao, Liming, Zhu, Yonghong

Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com> 

Best Regards,
Zhu Yonghong


-----Original Message-----
From: Carsey, Jaben 
Sent: Friday, April 20, 2018 11:52 PM
To: edk2-devel@lists.01.org
Cc: Zhu, Yonghong <yonghong.zhu@intel.com>; Gao, Liming <liming.gao@intel.com>
Subject: [PATCH v1 10/27] BaseTools: Remove extra .keys()

Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
---
 BaseTools/Source/Python/GenFds/Fv.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Source/Python/GenFds/Fv.py b/BaseTools/Source/Python/GenFds/Fv.py
index 5228e155267f..71bcd4c72170 100644
--- a/BaseTools/Source/Python/GenFds/Fv.py
+++ b/BaseTools/Source/Python/GenFds/Fv.py
@@ -316,7 +316,7 @@ class FV (FvClassObject):
                                           ' %s' %ErasePloarity    + \
                                           T_CHAR_LF)
         if not (self.FvAttributeDict is None):
-            for FvAttribute in self.FvAttributeDict:
+            for FvAttribute in self.FvAttributeDict.keys() :
                 if FvAttribute == "FvUsedSizeEnable":
                     if self.FvAttributeDict[FvAttribute].upper() in ('TRUE', '1') :
                         self.UsedSizeEnable = True
-- 
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* Re: [PATCH v1 20/27] BaseTools: remove duplicate variable
  2018-04-20 15:51 ` [PATCH v1 20/27] BaseTools: remove duplicate variable Jaben Carsey
@ 2018-04-25  8:51   ` Zhu, Yonghong
  0 siblings, 0 replies; 56+ messages in thread
From: Zhu, Yonghong @ 2018-04-25  8:51 UTC (permalink / raw)
  To: Carsey, Jaben, edk2-devel@lists.01.org; +Cc: Gao, Liming, Zhu, Yonghong

Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com> 

Best Regards,
Zhu Yonghong


-----Original Message-----
From: Carsey, Jaben 
Sent: Friday, April 20, 2018 11:52 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming <liming.gao@intel.com>; Zhu, Yonghong <yonghong.zhu@intel.com>
Subject: [PATCH v1 20/27] BaseTools: remove duplicate variable

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>
---
 BaseTools/Source/Python/Common/DataType.py | 2 --
 1 file changed, 2 deletions(-)

diff --git a/BaseTools/Source/Python/Common/DataType.py b/BaseTools/Source/Python/Common/DataType.py
index 40a162adf33c..5c8cc82fc915 100644
--- a/BaseTools/Source/Python/Common/DataType.py
+++ b/BaseTools/Source/Python/Common/DataType.py
@@ -128,8 +128,6 @@ PLATFORM_COMPONENT_TYPE_LIBRARY = EDK_COMPONENT_TYPE_LIBRARY  PLATFORM_COMPONENT_TYPE_LIBRARY_CLASS = 'LIBRARY_CLASS'
 PLATFORM_COMPONENT_TYPE_MODULE = 'MODULE'
 
-TAB_LIBRARIES = 'Libraries'
-
 TAB_SOURCES = 'Sources'
 TAB_SOURCES_COMMON = TAB_SOURCES + TAB_SPLIT + TAB_ARCH_COMMON
 TAB_SOURCES_IA32 = TAB_SOURCES + TAB_SPLIT + TAB_ARCH_IA32
--
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* Re: [PATCH v1 24/27] BaseTools: GenFds - simplify testing for Hex number
  2018-04-20 15:51 ` [PATCH v1 24/27] BaseTools: GenFds - simplify testing for Hex number Jaben Carsey
@ 2018-04-25  8:51   ` Zhu, Yonghong
  0 siblings, 0 replies; 56+ messages in thread
From: Zhu, Yonghong @ 2018-04-25  8:51 UTC (permalink / raw)
  To: Carsey, Jaben, edk2-devel@lists.01.org; +Cc: Gao, Liming, Zhu, Yonghong

Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com> 

Best Regards,
Zhu Yonghong


-----Original Message-----
From: Carsey, Jaben 
Sent: Friday, April 20, 2018 11:52 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming <liming.gao@intel.com>; Zhu, Yonghong <yonghong.zhu@intel.com>
Subject: [PATCH v1 24/27] BaseTools: GenFds - simplify testing for Hex number

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>
---
 BaseTools/Source/Python/Common/GlobalData.py | 1 +  BaseTools/Source/Python/GenFds/FdfParser.py  | 9 +--------
 2 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/BaseTools/Source/Python/Common/GlobalData.py b/BaseTools/Source/Python/Common/GlobalData.py
index f58dc5a8dda2..e3131b86cc60 100644
--- a/BaseTools/Source/Python/Common/GlobalData.py
+++ b/BaseTools/Source/Python/Common/GlobalData.py
@@ -62,6 +62,7 @@ gGuidPatternEnd = re.compile(r'{}$'.format(_GuidPattern))
 ## Regular expressions for HEX matching  g4HexChar = re.compile(r'{}{{4}}'.format(_HexChar))
 gHexPattern = re.compile(r'0[xX]{}+'.format(_HexChar))
+gHexPatternAll = re.compile(r'0[xX]{}+$'.format(_HexChar))
 
 ## Regular expressions for string identifier checking  gIdentifierPattern = re.compile('^[a-zA-Z][a-zA-Z0-9_]*$', re.UNICODE) diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py
index b8848a25b4b2..fe4f2df0e1e1 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -1183,13 +1183,6 @@ class FdfParser:
 
         self.__GetOneChar()
 
-    def __IsHex(self, HexStr):
-        if not HexStr.upper().startswith("0X"):
-            return False
-        if len(self.__Token) <= 2:
-            return False
-        return True if all(x in string.hexdigits for x in HexStr[2:]) else False
-
     ## __GetNextHexNumber() method
     #
     #   Get next HEX data before a seperator
@@ -1202,7 +1195,7 @@ class FdfParser:
     def __GetNextHexNumber(self):
         if not self.__GetNextToken():
             return False
-        if self.__IsHex(self.__Token):
+        if gHexPatternAll.match(self.__Token):
             return True
         else:
             self.__UndoToken()
--
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* Re: [PATCH v1 03/27] BaseTools: Share RegEx between files
  2018-04-20 15:51 ` [PATCH v1 03/27] BaseTools: Share RegEx between files Jaben Carsey
@ 2018-04-25  8:51   ` Zhu, Yonghong
  0 siblings, 0 replies; 56+ messages in thread
From: Zhu, Yonghong @ 2018-04-25  8:51 UTC (permalink / raw)
  To: Carsey, Jaben, edk2-devel@lists.01.org; +Cc: Gao, Liming, Zhu, Yonghong

Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com> 

Best Regards,
Zhu Yonghong


-----Original Message-----
From: Carsey, Jaben 
Sent: Friday, April 20, 2018 11:51 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming <liming.gao@intel.com>; Zhu, Yonghong <yonghong.zhu@intel.com>
Subject: [PATCH v1 03/27] BaseTools: Share RegEx between files

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>
---
 BaseTools/Source/Python/Common/Misc.py                       | 22 +++++++++++---------
 BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py | 15 +++++--------
 2 files changed, 17 insertions(+), 20 deletions(-)

diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
index bc7d0c2d9d00..4a6a29c7ae80 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -42,6 +42,13 @@ import subprocess
 ## Regular expression used to find out place holders in string template  gPlaceholderPattern = re.compile("\$\{([^$()\s]+)\}", re.MULTILINE | re.UNICODE)
 
+## regular expressions for map file processing startPatternGeneral = 
+re.compile("^Start[' ']+Length[' ']+Name[' ']+Class") 
+addressPatternGeneral = re.compile("^Address[' ']+Publics by Value[' 
+']+Rva\+Base") valuePatternGcc = re.compile('^([\w_\.]+) 
++([\da-fA-Fx]+) +([\da-fA-Fx]+)$') pcdPatternGcc = 
+re.compile('^([\da-fA-Fx]+) +([\da-fA-Fx]+)') secReGeneral = 
+re.compile('^([\da-fA-F]+):([\da-fA-F]+) +([\da-fA-F]+)[Hh]? 
++([.\w\$]+) +(\w+)', re.UNICODE)
+
 ## Dictionary used to store file time stamp for quick re-access
 gFileTimeStampCache = {}    # {file path : file time stamp}
 
@@ -92,8 +99,6 @@ def _parseForXcode(lines, efifilepath, varnames):
 
 def _parseForGCC(lines, efifilepath, varnames):
     """ Parse map file generated by GCC linker """
-    valuePattern = re.compile('^([\w_\.]+) +([\da-fA-Fx]+) +([\da-fA-Fx]+)$')
-    pcdPattern = re.compile('^([\da-fA-Fx]+) +([\da-fA-Fx]+)')
     status = 0
     sections = []
     varoffset = []
@@ -112,7 +117,7 @@ def _parseForGCC(lines, efifilepath, varnames):
 
         # status handler
         if status == 3:
-            m = valuePattern.match(line)
+            m = valuePatternGcc.match(line)
             if m is not None:
                 sections.append(m.groups(0))
             for varname in varnames:
@@ -125,7 +130,7 @@ def _parseForGCC(lines, efifilepath, varnames):
                     else:
                         Str = line[len(".data.%s" % varname):]
                     if Str:
-                        m = pcdPattern.match(Str.strip())
+                        m = pcdPatternGcc.match(Str.strip())
                         if m is not None:
                             varoffset.append((varname, int(m.groups(0)[0], 16) , int(sections[-1][1], 16), sections[-1][0]))
 
@@ -153,24 +158,21 @@ def _parseGeneral(lines, efifilepath, varnames):
     status = 0    #0 - beginning of file; 1 - PE section definition; 2 - symbol table
     secs  = []    # key = section name
     varoffset = []
-    secRe = re.compile('^([\da-fA-F]+):([\da-fA-F]+) +([\da-fA-F]+)[Hh]? +([.\w\$]+) +(\w+)', re.UNICODE)
     symRe = re.compile('^([\da-fA-F]+):([\da-fA-F]+) +([\.:\\\\\w\?@\$]+) +([\da-fA-F]+)', re.UNICODE)
-    startRe = re.compile("^Start[' ']+Length[' ']+Name[' ']+Class")
-    addressRe = re.compile("^Address[' ']+Publics by Value[' ']+Rva\+Base")
 
     for line in lines:
         line = line.strip()
-        if startRe.match(line):
+        if startPatternGeneral.match(line):
             status = 1
             continue
-        if addressRe.match(line):
+        if addressPatternGeneral.match(line):
             status = 2
             continue
         if line.startswith("entry point at"):
             status = 3
             continue        
         if status == 1 and len(line) != 0:
-            m =  secRe.match(line)
+            m =  secReGeneral.match(line)
             assert m is not None, "Fail to parse the section in map file , line is %s" % line
             sec_no, sec_start, sec_length, sec_name, sec_class = m.groups(0)
             secs.append([int(sec_no, 16), int(sec_start, 16), int(sec_length, 16), sec_name, sec_class]) diff --git a/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py b/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py
index 59748763a553..2a039480a00a 100644
--- a/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py
+++ b/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py
@@ -24,7 +24,7 @@ import array
 
 from Common.BuildToolError import *
 import Common.EdkLogger as EdkLogger
-from Common.Misc import PeImageClass
+from Common.Misc import PeImageClass, startPatternGeneral, 
+addressPatternGeneral, valuePatternGcc, pcdPatternGcc, secReGeneral
 from Common.BuildVersion import gBUILD_VERSION  from Common.LongFilePathSupport import OpenLongFilePath as open
 
@@ -36,7 +36,6 @@ __copyright__ = "Copyright (c) 2008 - 2010, Intel Corporation. All rights reserv  #======================================  Internal Libraries ========================================
 
 #============================================== Code ===============================================
-secRe = re.compile('^([\da-fA-F]+):([\da-fA-F]+) +([\da-fA-F]+)[Hh]? +([.\w\$]+) +(\w+)', re.UNICODE)  symRe = re.compile('^([\da-fA-F]+):([\da-fA-F]+) +([\.\-:\\\\\w\?@\$<>]+) +([\da-fA-F]+)', re.UNICODE)
 
 def parsePcdInfoFromMapFile(mapfilepath, efifilepath):
@@ -80,9 +79,7 @@ def _parseForXcode(lines, efifilepath):
 
 def _parseForGCC(lines, efifilepath):
     """ Parse map file generated by GCC linker """
-    valuePattern = re.compile('^([\w_\.]+) +([\da-fA-Fx]+) +([\da-fA-Fx]+)$')
     dataPattern = re.compile('^.data._gPcd_BinaryPatch_([\w_\d]+)$')
-    pcdPattern = re.compile('^([\da-fA-Fx]+) +([\da-fA-Fx]+)')
     status = 0
     imageBase = -1
     sections = []
@@ -102,7 +99,7 @@ def _parseForGCC(lines, efifilepath):
 
         # status handler
         if status == 3:
-            m = valuePattern.match(line)
+            m = valuePatternGcc.match(line)
             if m is not None:
                 sections.append(m.groups(0))
         if status == 3:
@@ -110,7 +107,7 @@ def _parseForGCC(lines, efifilepath):
             if m is not None:
                 if lines[index + 1]:
                     PcdName = m.groups(0)[0]
-                    m = pcdPattern.match(lines[index + 1].strip())
+                    m = pcdPatternGcc.match(lines[index + 1].strip())
                     if m is not None:
                         bpcds.append((PcdName, int(m.groups(0)[0], 16) , int(sections[-1][1], 16), sections[-1][0]))
                 
@@ -141,16 +138,14 @@ def _parseGeneral(lines, efifilepath):
     status = 0    #0 - beginning of file; 1 - PE section definition; 2 - symbol table
     secs = []    # key = section name
     bPcds = []
-    startPattern = re.compile("^Start[' ']+Length[' ']+Name[' ']+Class")
-    addressPattern = re.compile("^Address[' ']+Publics by Value[' ']+Rva\+Base")
     symPattern = re.compile('^[_]+gPcd_BinaryPatch_([\w]+)')
 
     for line in lines:
         line = line.strip()
-        if startPattern.match(line):
+        if startPatternGeneral.match(line):
             status = 1
             continue
-        if addressPattern.match(line):
+        if addressPatternGeneral.match(line):
             status = 2
             continue
         if line.startswith("entry point at"):
--
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* Re: [PATCH v1 27/27] BaseTools: CommonClass - remove unused classes
  2018-04-20 15:51 ` [PATCH v1 27/27] BaseTools: CommonClass - remove unused classes Jaben Carsey
@ 2018-04-25  8:51   ` Zhu, Yonghong
  0 siblings, 0 replies; 56+ messages in thread
From: Zhu, Yonghong @ 2018-04-25  8:51 UTC (permalink / raw)
  To: Carsey, Jaben, edk2-devel@lists.01.org; +Cc: Gao, Liming, Zhu, Yonghong

Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com> 

Best Regards,
Zhu Yonghong


-----Original Message-----
From: Carsey, Jaben 
Sent: Friday, April 20, 2018 11:52 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming <liming.gao@intel.com>; Zhu, Yonghong <yonghong.zhu@intel.com>
Subject: [PATCH v1 27/27] BaseTools: CommonClass - remove unused classes

CommonDataClass/CommonClass has only 1 used class: SkuInfoClass remove all unused classes

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>
---
 BaseTools/Source/Python/CommonDataClass/CommonClass.py | 397 +-------------------
 1 file changed, 1 insertion(+), 396 deletions(-)

diff --git a/BaseTools/Source/Python/CommonDataClass/CommonClass.py b/BaseTools/Source/Python/CommonDataClass/CommonClass.py
index 6a8262e5e964..e29f5211d5c7 100644
--- a/BaseTools/Source/Python/CommonDataClass/CommonClass.py
+++ b/BaseTools/Source/Python/CommonDataClass/CommonClass.py
@@ -1,7 +1,7 @@
 ## @file
 # This file is used to define common items of class object  # -# Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2018, Intel Corporation. All rights 
+reserved.<BR>
 # This program and the accompanying materials  # are licensed and made available under the terms and conditions of the BSD License
 # which accompanies this distribution.    The full text of the license may be found at
@@ -11,240 +11,6 @@
 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 
 
-#
-# Generate help text
-#
-def GenerateHelpText(Text, Lang):
-    if Text:
-        Ht = HelpTextClass()
-        Ht.Lang = Lang
-        Ht.String = Text
-    
-        return Ht
-    
-    return None
-
-## CommonClass
-#
-# This class defined common items used in Module/Platform/Package files -# 
-# @param object:       Inherited from object class
-# @param Usage:        Input value for Usage, default is [] 
-# @param FeatureFlag:  Input value for FeatureFalg, default is ''
-# @param SupArchList:  Input value for SupArchList, default is []
-# @param HelpText:     Input value for HelpText, default is ''
-#
-# @var Usage:          To store value for Usage, selection scope is in below list
-#                      ALWAYS_CONSUMED | SOMETIMES_CONSUMED | ALWAYS_PRODUCED | SOMETIMES_PRODUCED | TO_START | BY_START | PRIVATE
-# @var FeatureFlag:    To store value for FeatureFlag
-# @var SupArchList:    To store value for SupArchList, selection scope is in below list
-#                      EBC | IA32 | X64 | IPF | ARM | PPC | AARCH64
-# @var HelpText:       To store value for HelpText
-#
-class CommonClass(object):
-    def __init__(self, Usage = None, FeatureFlag = '', SupArchList = None, HelpText = ''):
-        self.Usage = Usage
-        if self.Usage is None:
-            self.Usage = []
-        self.FeatureFlag = FeatureFlag
-        self.SupArchList = SupArchList
-        if self.SupArchList is None:
-            self.SupArchList = []
-        self.HelpText = HelpText
-        self.HelpTextList = []
-
-## CommonHeaderClass
-#
-# This class defined common items used in Module/Platform/Package files -# 
-# @param object:          Inherited from object class
-#
-# @var Abstract:          To store value for Abstract
-# @var Description:       To store value for Description
-# @var Copyright:         To store value for Copyright
-# @var License:           To store value for License
-# @var Specification:     To store value for Specification
-#
-class CommonHeaderClass(object):
-    def __init__(self):
-        self.Abstract = ''
-        self.Description = ''
-        self.Copyright = ''
-        self.License = ''
-        self.Specification = {}
-
-## HelpTextClass
-#
-# This class defined HelpText item used in PKG file -# 
-# @param object:     Inherited from object class
-#
-# @var Lang:         To store value for Lang
-# @var String:       To store value for String
-#
-class HelpTextClass(object):
-    def __init__(self):
-        self.Lang = ''
-        self.String = ''
-    
-## DefineClass
-#
-# This class defined item DEFINE used in Module/Platform/Package files -# -# @param object:  Inherited from object class -#
-# @var Define:    To store value for Define, it is a set structure as
-#                 { (DefineName, Arch) : DefineValue, ... }
-#
-class DefineClass(object):
-    def __init__(self):
-        self.Define = {}
-
-## ClonedRecordClass
-#
-# This class defined ClonedRecord items used in Module/Platform/Package files -# 
-# @param object:        Inherited from object class
-#
-# @var Id:              To store value for Id
-# @var FarGuid:         To store value for FarGuid
-# @var PackageGuid:     To store value for PackageGuid
-# @var PackageVersion:  To store value for PackageVersion
-# @var ModuleGuid:      To store value for ModuleGuid
-# @var ModuleVersion:   To store value for ModuleVersion
-#
-class ClonedRecordClass(object):
-    def __init__(self):
-        self.Id = 0
-        self.FarGuid = ''
-        self.PackageGuid = ''
-        self.PackageVersion = ''
-        self.ModuleGuid = ''
-        self.ModuleVersion = ''
-
-## IdentificationClass
-#
-# This class defined Identification items used in Module/Platform/Package files -# -# @param object:  Inherited from object class -#
-# @var Name:      To store value for Name
-#                 ModuleName(Inf) / PackageName(Dec) / PlatformName(Dsc)
-# @var Guid:      To store value for Guid
-# @var Version:   To store value for Version
-# @var FileName:  To store value for FileName -# @var FullPath:  To store value for FullPath -# -class IdentificationClass(object):
-    def __init__(self):
-        self.Name = ''
-        self.BaseName = ''
-        self.Guid = ''
-        self.Version = ''
-        self.FileName = ''
-        self.FullPath = ''
-        self.RelaPath = ''
-        self.PackagePath = ''
-        self.ModulePath = ''
-        self.CombinePath = ''
-
-## IncludeStatementClass
-#
-# This class defined IncludeFiles item used in Module/Platform/Package files -# 
-# @param object:      Inherited from object class
-#
-# @var IncludeFiles:  To store value for IncludeFiles
-#                     It is a set structure as { IncludeFile : [Arch1, Arch2, ...], ... }
-#
-class IncludeStatementClass(object):
-    def __init__(self):
-        self.IncludeFiles = {}                             
-
-## GuidProtocolPpiCommonClass
-#
-# This class defined Guid, Protocol and Ppi like items used in Module/Platform/Package files -# -# @param CommonClass:  Inherited from CommonClass class -#
-# @var Name:           To store value for Name
-# @var CName:          To store value for CName
-# @var Guid:           To store value for Guid
-# @var Notify:         To store value for Notify
-# @var GuidTypeList:   To store value for GuidTypeList, selection scope is in below list
-#                      DATA_HUB_RECORD | EFI_EVENT | EFI_SYSTEM_CONFIGURATION_TABLE | EFI_VARIABLE | GUID | HII_PACKAGE_LIST | HOB | TOKEN_SPACE_GUID
-# @var SupModuleList:  To store value for SupModuleList, selection scope is in below list
-#                      BASE | SEC | PEI_CORE | PEIM | DXE_CORE | DXE_DRIVER | DXE_RUNTIME_DRIVER | DXE_SAL_DRIVER | DXE_SMM_DRIVER | UEFI_DRIVER | UEFI_APPLICATION | USER_DEFINED | SMM_CORE | MM_STANDALONE | MM_CORE_STANDALONE
-#
-class GuidProtocolPpiCommonClass(CommonClass):
-    def __init__(self):
-        self.Name = ''
-        self.CName = ''
-        self.Guid = ''
-        self.VariableName = ''
-        self.Notify = False
-        self.GuidTypeList = []
-        self.GuidTypeLists = []
-        self.SupModuleList = []                           
-        CommonClass.__init__(self)
-
-## LibraryClassClass
-#
-# This class defined Library item used in Module/Platform/Package files -# 
-# @param CommonClass:               Inherited from CommonClass class
-# @param DefineClass:               Inherited from DefineClass class
-#
-# @var LibraryClass:                To store value for LibraryClass
-# @var IncludeHeader:               To store value for IncludeHeader
-# @var RecommendedInstanceVersion:  To store value for RecommendedInstanceVersion
-# @var RecommendedInstanceGuid:     To store value for RecommendedInstanceGuid
-# @var RecommendedInstance:         To store value for RecommendedInstance, selection scope is in below list
-#                                   DATA_HUB_RECORD | EFI_EVENT | EFI_SYSTEM_CONFIGURATION_TABLE | EFI_VARIABLE | GUID | HII_PACKAGE_LIST | HOB | TOKEN_SPACE_GUID
-# @var SupModuleList:               To store value for SupModuleList, selection scope is in below list
-#                                   BASE | SEC | PEI_CORE | PEIM | DXE_CORE | DXE_DRIVER | DXE_RUNTIME_DRIVER | DXE_SAL_DRIVER | DXE_SMM_DRIVER | UEFI_DRIVER | UEFI_APPLICATION | USER_DEFINED | SMM_CORE | MM_STANDALONE | MM_CORE_STANDALONE
-#
-class LibraryClassClass(CommonClass, DefineClass):
-    def __init__(self):
-        self.LibraryClass = ''
-        self.IncludeHeader = ''
-        self.RecommendedInstanceVersion = ''
-        self.RecommendedInstanceGuid = ''
-        self.RecommendedInstance = ''
-        self.SupModuleList = []
-        CommonClass.__init__(self)
-        DefineClass.__init__(self)
-
-## GuidClass
-#
-# This class defined Guid item used in Module/Platform/Package files -# -# @param GuidProtocolPpiCommonClass:  Inherited from GuidProtocolPpiCommonClass class -# -class GuidClass(GuidProtocolPpiCommonClass):
-    def __init__(self):
-        GuidProtocolPpiCommonClass.__init__(self)
-
-## ProtocolClass
-#
-# This class defined Protocol item used in Module/Platform/Package files -# -# @param GuidProtocolPpiCommonClass:  Inherited from GuidProtocolPpiCommonClass class -# -class ProtocolClass(GuidProtocolPpiCommonClass):
-    def __init__(self):
-        GuidProtocolPpiCommonClass.__init__(self)
-
-## PpiClass
-#
-# This class defined Ppi item used in Module/Platform/Package files -# -# @param GuidProtocolPpiCommonClass:  Inherited from GuidProtocolPpiCommonClass class -#
-class PpiClass(GuidProtocolPpiCommonClass):        
-    def __init__(self):
-        GuidProtocolPpiCommonClass.__init__(self)
-
 ## SkuInfoClass
 #
 # This class defined SkuInfo item used in Module/Platform/Package files @@ -314,164 +80,3 @@ class SkuInfoClass(object):
                     'VpdOffset = ' + str(self.VpdOffset) + "," + \
                     'DefaultValue = ' + str(self.DefaultValue) + ","
         return Rtn
-## PcdErrorClass
-#
-#
-#
-class PcdErrorClass(object):
-    def __init__(self):
-        self.ValidValueList = ''
-        self.ValidValueListLang = ''
-        self.ValidValueRange = ''
-        self.Expression = ''
-        self.ErrorNumber = ''
-        self.ErrorMessage = []
-
-## PcdClass
-#
-# This class defined Pcd item used in Module/Platform/Package files -# 
-# @param CommonClass:          Inherited from CommonClass class
-# @param CName:                Input value for CName, default is ''
-# @param Token:                Input value for Token, default is ''
-# @param TokenSpaceGuidCName:  Input value for TokenSpaceGuidCName, default is ''
-# @param DatumType:            Input value for DatumType, default is ''
-# @param MaxDatumSize:         Input value for MaxDatumSize, default is ''
-# @param DefaultValue:         Input value for DefaultValue, default is ''
-# @param ItemType:             Input value for ItemType, default is ''
-# @param ValidUsage:           Input value for ValidUsage, default is []
-# @param SkuInfoList:          Input value for SkuInfoList, default is {}
-# @param SupModuleList:        Input value for SupModuleList, default is []
-#
-# @var CName:                  To store value for CName
-# @var Token:                  To store value for Token
-# @var TokenSpaceGuidCName:    To store value for TokenSpaceGuidCName
-# @var DatumType:              To store value for DatumType, selection scope is in below list
-#                              UINT8 | UINT16 | UINT32 | UINT64 | VOID* | BOOLEAN 
-# @var MaxDatumSize:           To store value for MaxDatumSize
-# @var DefaultValue:           To store value for DefaultValue
-# @var ItemType:               To store value for ItemType, selection scope is in below list
-#                              FEATURE_FLAG | FIXED_AT_BUILD | PATCHABLE_IN_MODULE | DYNAMIC | DYNAMIC_EX
-# @var ValidUsage:             To store value for ValidUsage, selection scope is in below list
-#                              FEATURE_FLAG | FIXED_AT_BUILD | PATCHABLE_IN_MODULE | DYNAMIC | DYNAMIC_EX
-# @var SkuInfoList:            To store value for SkuInfoList
-#                              It is a set structure as { [SkuIdName] : SkuInfoClass } 
-# @var SupModuleList:          To store value for SupModuleList, selection scope is in below list
-#                              BASE | SEC | PEI_CORE | PEIM | DXE_CORE | DXE_DRIVER | DXE_RUNTIME_DRIVER | DXE_SAL_DRIVER | DXE_SMM_DRIVER | UEFI_DRIVER | UEFI_APPLICATION | USER_DEFINED | SMM_CORE | MM_STANDALONE | MM_CORE_STANDALONE
-#
-class PcdClass(CommonClass):
-    def __init__(self, CName = '', Token = '', TokenSpaceGuidCName = '', DatumType = '', MaxDatumSize = '', DefaultValue = '', ItemType = '', ValidUsage = None, SkuInfoList = None, SupModuleList = None):
-        self.CName = CName
-        self.Token = Token
-        self.TokenSpaceGuidCName = TokenSpaceGuidCName
-        self.DatumType = DatumType
-        self.MaxDatumSize = MaxDatumSize
-        self.DefaultValue = DefaultValue
-        self.ItemType = ItemType
-        self.ValidUsage = ValidUsage
-        self.PcdItemType = ''
-        self.TokenSpaceGuidValue = ''
-        self.PcdUsage = ''
-        self.PcdCName = ''
-        self.Value = ''
-        self.Offset = ''
-        if self.ValidUsage is None:
-            self.ValidUsage = []
-        self.SkuInfoList = SkuInfoList
-        if self.SkuInfoList  is None:
-            self.SkuInfoList  = {}
-        self.SupModuleList = SupModuleList
-        if self.SupModuleList is None:
-            self.SupModuleList = []
-        CommonClass.__init__(self)
-        self.PcdErrors = []
-
-## BuildOptionClass
-#
-# This class defined BuildOption item used in Module/Platform/Package files -# -# @param IncludeStatementClass:  Inherited from IncludeStatementClass class
-# @param ToolChainFamily:        Input value for ToolChainFamily, default is ''
-# @param ToolChain:              Input value for ToolChain, default is ''
-# @param Option:                 Input value for Option, default is ''
-#
-# @var Statement:                To store value for Statement
-#                                It is a string in a special format as "Family:Target_TagName_Tarch_ToolCode_FLAGS = String"
-# @var ToolChainFamily:          To store value for ToolChainFamily
-# @var ToolChain:                To store value for ToolChain
-# @var Option:                   To store value for Option
-# @var BuildTarget:              To store value for BuildTarget
-# @var TagName:                  To store value for TagName
-# @var ToolCode:                 To store value for ToolCode
-# @var SupArchList:              To store value for SupArchList, selection scope is in below list
-#                                EBC | IA32 | X64 | IPF | ARM | PPC | AARCH64
-#
-class BuildOptionClass(IncludeStatementClass):
-    def __init__(self, ToolChainFamily = '', ToolChain = '', Option = ''):
-        IncludeStatementClass.__init__(self)
-        self.Statement = ''                               
-        self.ToolChainFamily = ToolChainFamily
-        self.ToolChain = ToolChain
-        self.Option = Option
-        self.BuildTarget = ''
-        self.TagName = ''
-        self.ToolCode = ''
-        self.SupArchList = []
-
-## IncludeClass
-#
-# This class defined Include item used in Module/Platform/Package files -# -# @param CommonClass:  Inherited from CommonClass class -#
-# @var FilePath:       To store value for FilePath
-# @var ModuleType:     To store value for ModuleType
-# @var Comment:        To store value for Comment
-#
-class IncludeClass(CommonClass):
-    def __init__(self):
-        self.FilePath = ''
-        self.ModuleType = ''
-        self.SupModuleList = []
-        self.Comment = ''
-        CommonClass.__init__(self)        
-
-## FileClass
-#
-#
-class FileClass(CommonClass):
-    def __init__(self):
-        self.Filename = ''
-        self.Executable = ''
-        self.Family = ''
-        self.FileType = ''
-        CommonClass.__init__(self)
-        
-
-## MiscFileClass
-#
-#
-class MiscFileClass(CommonHeaderClass):
-    def __init__(self):
-        CommonHeaderClass.__init__(self)
-        self.Name = ''
-        self.Files = []
-    
-
-## UserExtensionsClass
-#
-# This class defined UserExtensions item used in Module/Platform/Package files -# 
-# @param object:    Inherited from object class
-#
-# @var UserID:      To store value for UserID
-# @var Identifier:  To store value for Identifier
-# @var Content:     To store value for Content
-#       
-class UserExtensionsClass(object):
-    def __init__(self):
-        self.UserID = ''
-        self.Identifier = 0
-        self.Content = ''
-        self.Defines = []
-        self.BuildOptions = []
--
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* Re: [PATCH v1 09/27] BaseTools: AutoGen - remove unused variables.
  2018-04-20 15:51 ` [PATCH v1 09/27] BaseTools: AutoGen - remove unused variables Jaben Carsey
@ 2018-04-25  8:52   ` Zhu, Yonghong
  0 siblings, 0 replies; 56+ messages in thread
From: Zhu, Yonghong @ 2018-04-25  8:52 UTC (permalink / raw)
  To: Carsey, Jaben, edk2-devel@lists.01.org; +Cc: Gao, Liming, Zhu, Yonghong

Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com> 

Best Regards,
Zhu Yonghong


-----Original Message-----
From: Carsey, Jaben 
Sent: Friday, April 20, 2018 11:51 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming <liming.gao@intel.com>; Zhu, Yonghong <yonghong.zhu@intel.com>
Subject: [PATCH v1 09/27] BaseTools: AutoGen - remove unused variables.

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>
---
 BaseTools/Source/Python/AutoGen/GenMake.py | 2 --
 1 file changed, 2 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/Python/AutoGen/GenMake.py
index 1bb5163e73e0..a37350742240 100644
--- a/BaseTools/Source/Python/AutoGen/GenMake.py
+++ b/BaseTools/Source/Python/AutoGen/GenMake.py
@@ -427,8 +427,6 @@ cleanlib:
         self.ResultFileList = []
         self.IntermediateDirectoryList = ["$(DEBUG_DIR)", "$(OUTPUT_DIR)"]
 
-        self.SourceFileDatabase = {}        # {file type : file path}
-        self.DestFileDatabase = {}          # {file type : file path}
         self.FileBuildTargetList = []       # [(src, target string)]
         self.BuildTargetList = []           # [target string]
         self.PendingBuildTargetList = []    # [FileBuildRule objects]
-- 
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* Re: [PATCH v1 25/27] BaseTools: AutoGen - use defaultdict to auto initialize
  2018-04-20 15:51 ` [PATCH v1 25/27] BaseTools: AutoGen - use defaultdict to auto initialize Jaben Carsey
@ 2018-04-25  8:52   ` Zhu, Yonghong
  0 siblings, 0 replies; 56+ messages in thread
From: Zhu, Yonghong @ 2018-04-25  8:52 UTC (permalink / raw)
  To: Carsey, Jaben, edk2-devel@lists.01.org; +Cc: Gao, Liming, Zhu, Yonghong

Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com> 

Best Regards,
Zhu Yonghong


-----Original Message-----
From: Carsey, Jaben 
Sent: Friday, April 20, 2018 11:52 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming <liming.gao@intel.com>; Zhu, Yonghong <yonghong.zhu@intel.com>
Subject: [PATCH v1 25/27] BaseTools: AutoGen - use defaultdict to auto initialize

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>
---
 BaseTools/Source/Python/AutoGen/GenVar.py | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/GenVar.py b/BaseTools/Source/Python/AutoGen/GenVar.py
index 37c168a84b43..99c6ed640c00 100644
--- a/BaseTools/Source/Python/AutoGen/GenVar.py
+++ b/BaseTools/Source/Python/AutoGen/GenVar.py
@@ -128,7 +128,7 @@ class VariableMgr(object):
         return var_value
     def process_variable_data(self):
 
-        var_data = dict()
+        var_data = collections.defaultdict(collections.OrderedDict)
 
         indexedvarinfo = collections.OrderedDict()
         for item in self.VarInfo:
@@ -155,8 +155,6 @@ class VariableMgr(object):
             for item in default_data_buffer:
                 default_data_array += unpack("B",item)
 
-            if (DataType.TAB_DEFAULT,DataType.TAB_DEFAULT_STORES_DEFAULT) not in var_data:
-                var_data[(DataType.TAB_DEFAULT,DataType.TAB_DEFAULT_STORES_DEFAULT)] = collections.OrderedDict()
             var_data[(DataType.TAB_DEFAULT,DataType.TAB_DEFAULT_STORES_DEFAULT)][index] = (default_data_buffer,sku_var_info[(DataType.TAB_DEFAULT,DataType.TAB_DEFAULT_STORES_DEFAULT)])
 
             for (skuid,defaultstoragename) in indexedvarinfo.get(index):
@@ -177,8 +175,6 @@ class VariableMgr(object):
 
                 data_delta = self.calculate_delta(default_data_array, others_data_array)
 
-                if (skuid,defaultstoragename) not in var_data:
-                    var_data[(skuid,defaultstoragename)] = collections.OrderedDict()
                 var_data[(skuid,defaultstoragename)][index] = (data_delta,sku_var_info[(skuid,defaultstoragename)])
         return var_data
 
-- 
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* Re: [PATCH v1 14/27] BaseTools: Define and use a set for common list
  2018-04-20 15:51 ` [PATCH v1 14/27] BaseTools: Define and use a set for common list Jaben Carsey
@ 2018-05-02  6:48   ` Zhu, Yonghong
  0 siblings, 0 replies; 56+ messages in thread
From: Zhu, Yonghong @ 2018-05-02  6:48 UTC (permalink / raw)
  To: Carsey, Jaben, edk2-devel@lists.01.org; +Cc: Gao, Liming, Zhu, Yonghong

Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com> 

Best Regards,
Zhu Yonghong


-----Original Message-----
From: Carsey, Jaben 
Sent: Friday, April 20, 2018 11:52 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming <liming.gao@intel.com>; Zhu, Yonghong <yonghong.zhu@intel.com>
Subject: [PATCH v1 14/27] BaseTools: Define and use a set for common list

share a set for both PEI module types

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>
---
 BaseTools/Source/Python/AutoGen/AutoGen.py | 4 ++--
 BaseTools/Source/Python/AutoGen/GenC.py    | 8 ++++----
 BaseTools/Source/Python/Common/DataType.py | 1 +
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 9c3bf864e360..60088c87a03b 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -1431,7 +1431,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 [SUP_MODULE_PEIM, SUP_MODULE_PEI_CORE]:
+                    if M.ModuleType in SUP_MODULE_SET_PEI:
                         PcdFromModule.Phase = "PEI"
                     if PcdFromModule not in self._DynaPcdList_:
                         self._DynaPcdList_.append(PcdFromModule)
@@ -1473,7 +1473,7 @@ class PlatformAutoGen(AutoGen):
                     # make sure that the "VOID*" kind of datum has MaxDatumSize set
                     if PcdFromModule.DatumType == "VOID*" and PcdFromModule.MaxDatumSize in [None, '']:
                         NoDatumTypePcdList.add("%s.%s [%s]" % (PcdFromModule.TokenSpaceGuidCName, PcdFromModule.TokenCName, InfName))
-                    if M.ModuleType in [SUP_MODULE_PEIM, SUP_MODULE_PEI_CORE]:
+                    if M.ModuleType in SUP_MODULE_SET_PEI:
                         PcdFromModule.Phase = "PEI"
                     if PcdFromModule not in self._DynaPcdList_ and PcdFromModule.Type in GenC.gDynamicExPcd:
                         self._DynaPcdList_.append(PcdFromModule)
diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py
index 7bc352274e66..57ff699a968a 100644
--- a/BaseTools/Source/Python/AutoGen/GenC.py
+++ b/BaseTools/Source/Python/AutoGen/GenC.py
@@ -1411,7 +1411,7 @@ def CreateLibraryConstructorCode(Info, AutoGenC, AutoGenH):
         if Lib.ModuleType in [SUP_MODULE_BASE, SUP_MODULE_SEC]:
             ConstructorPrototypeString.Append(gLibraryStructorPrototype[SUP_MODULE_BASE].Replace(Dict))
             ConstructorCallingString.Append(gLibraryStructorCall[SUP_MODULE_BASE].Replace(Dict))
-        elif Lib.ModuleType in [SUP_MODULE_PEI_CORE,SUP_MODULE_PEIM]:
+        elif Lib.ModuleType in SUP_MODULE_SET_PEI:
             ConstructorPrototypeString.Append(gLibraryStructorPrototype['PEI'].Replace(Dict))
             ConstructorCallingString.Append(gLibraryStructorCall['PEI'].Replace(Dict))
         elif Lib.ModuleType in [SUP_MODULE_DXE_CORE,SUP_MODULE_DXE_DRIVER,SUP_MODULE_DXE_SMM_DRIVER,SUP_MODULE_DXE_RUNTIME_DRIVER,
@@ -1441,7 +1441,7 @@ def CreateLibraryConstructorCode(Info, AutoGenC, AutoGenH):
     else:
         if Info.ModuleType in [SUP_MODULE_BASE, SUP_MODULE_SEC]:
             AutoGenC.Append(gLibraryString[SUP_MODULE_BASE].Replace(Dict))
-        elif Info.ModuleType in [SUP_MODULE_PEI_CORE,SUP_MODULE_PEIM]:
+        elif Info.ModuleType in SUP_MODULE_SET_PEI:
             AutoGenC.Append(gLibraryString['PEI'].Replace(Dict))
         elif Info.ModuleType in [SUP_MODULE_DXE_CORE,SUP_MODULE_DXE_DRIVER,SUP_MODULE_DXE_SMM_DRIVER,SUP_MODULE_DXE_RUNTIME_DRIVER,
                                  SUP_MODULE_DXE_SAL_DRIVER,SUP_MODULE_UEFI_DRIVER,SUP_MODULE_UEFI_APPLICATION,SUP_MODULE_SMM_CORE]:
@@ -1473,7 +1473,7 @@ def CreateLibraryDestructorCode(Info, AutoGenC, AutoGenH):
         if Lib.ModuleType in [SUP_MODULE_BASE, SUP_MODULE_SEC]:
             DestructorPrototypeString.Append(gLibraryStructorPrototype[SUP_MODULE_BASE].Replace(Dict))
             DestructorCallingString.Append(gLibraryStructorCall[SUP_MODULE_BASE].Replace(Dict))
-        elif Lib.ModuleType in [SUP_MODULE_PEI_CORE,SUP_MODULE_PEIM]:
+        elif Lib.ModuleType in SUP_MODULE_SET_PEI:
             DestructorPrototypeString.Append(gLibraryStructorPrototype['PEI'].Replace(Dict))
             DestructorCallingString.Append(gLibraryStructorCall['PEI'].Replace(Dict))
         elif Lib.ModuleType in [SUP_MODULE_DXE_CORE,SUP_MODULE_DXE_DRIVER,SUP_MODULE_DXE_SMM_DRIVER,SUP_MODULE_DXE_RUNTIME_DRIVER,
@@ -1503,7 +1503,7 @@ def CreateLibraryDestructorCode(Info, AutoGenC, AutoGenH):
     else:
         if Info.ModuleType in [SUP_MODULE_BASE, SUP_MODULE_SEC]:
             AutoGenC.Append(gLibraryString[SUP_MODULE_BASE].Replace(Dict))
-        elif Info.ModuleType in [SUP_MODULE_PEI_CORE,SUP_MODULE_PEIM]:
+        elif Info.ModuleType in SUP_MODULE_SET_PEI:
             AutoGenC.Append(gLibraryString['PEI'].Replace(Dict))
         elif Info.ModuleType in [SUP_MODULE_DXE_CORE,SUP_MODULE_DXE_DRIVER,SUP_MODULE_DXE_SMM_DRIVER,SUP_MODULE_DXE_RUNTIME_DRIVER,
                                  SUP_MODULE_DXE_SAL_DRIVER,SUP_MODULE_UEFI_DRIVER,SUP_MODULE_UEFI_APPLICATION,SUP_MODULE_SMM_CORE]:
diff --git a/BaseTools/Source/Python/Common/DataType.py b/BaseTools/Source/Python/Common/DataType.py
index 0bd55494df66..06e8defcf927 100644
--- a/BaseTools/Source/Python/Common/DataType.py
+++ b/BaseTools/Source/Python/Common/DataType.py
@@ -77,6 +77,7 @@ SUP_MODULE_LIST = [SUP_MODULE_BASE, SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MOD
                    SUP_MODULE_DXE_RUNTIME_DRIVER, SUP_MODULE_DXE_SAL_DRIVER, SUP_MODULE_DXE_SMM_DRIVER, SUP_MODULE_UEFI_DRIVER, \
                    SUP_MODULE_UEFI_APPLICATION, SUP_MODULE_USER_DEFINED, SUP_MODULE_SMM_CORE, SUP_MODULE_MM_STANDALONE, SUP_MODULE_MM_CORE_STANDALONE]  SUP_MODULE_LIST_STRING = TAB_VALUE_SPLIT.join(SUP_MODULE_LIST)
+SUP_MODULE_SET_PEI = {SUP_MODULE_PEIM, SUP_MODULE_PEI_CORE}
 
 EDK_COMPONENT_TYPE_LIBRARY = 'LIBRARY'
 EDK_COMPONENT_TYPE_SECUARITY_CORE = 'SECUARITY_CORE'
--
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* Re: [PATCH v1 22/27] BaseTools: remove redundant if comparison
  2018-04-20 15:51 ` [PATCH v1 22/27] BaseTools: remove redundant if comparison Jaben Carsey
@ 2018-05-02  6:49   ` Zhu, Yonghong
  0 siblings, 0 replies; 56+ messages in thread
From: Zhu, Yonghong @ 2018-05-02  6:49 UTC (permalink / raw)
  To: Carsey, Jaben, edk2-devel@lists.01.org; +Cc: Gao, Liming, Zhu, Yonghong

Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com> 

Best Regards,
Zhu Yonghong


-----Original Message-----
From: Carsey, Jaben 
Sent: Friday, April 20, 2018 11:52 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming <liming.gao@intel.com>; Zhu, Yonghong <yonghong.zhu@intel.com>
Subject: [PATCH v1 22/27] BaseTools: remove redundant if comparison

inherently python will check string and list for None and having data

if <x> in [None, ''] and similar are superflous.

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>
---
 BaseTools/Source/Python/AutoGen/AutoGen.py             | 26 ++++++++--------
 BaseTools/Source/Python/AutoGen/GenC.py                |  2 +-
 BaseTools/Source/Python/GenFds/FfsInfStatement.py      |  4 +--
 BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py | 32 ++++++++++----------
 BaseTools/Source/Python/Workspace/DscBuildData.py      |  8 ++---
 BaseTools/Source/Python/Workspace/InfBuildData.py      |  2 +-
 6 files changed, 37 insertions(+), 37 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 534fbe79fad9..871afedcde4b 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -420,14 +420,14 @@ class WorkspaceAutoGen(AutoGen):
                         if BuildData.Pcds[key].Pending:
                             if key in Platform.Pcds:
                                 PcdInPlatform = Platform.Pcds[key]
-                                if PcdInPlatform.Type not in [None, '']:
+                                if PcdInPlatform.Type:
                                     BuildData.Pcds[key].Type = PcdInPlatform.Type
 
                             if BuildData.MetaFile in Platform.Modules:
                                 PlatformModule = Platform.Modules[str(BuildData.MetaFile)]
                                 if key in PlatformModule.Pcds:
                                     PcdInPlatform = PlatformModule.Pcds[key]
-                                    if PcdInPlatform.Type not in [None, '']:
+                                    if PcdInPlatform.Type:
                                         BuildData.Pcds[key].Type = PcdInPlatform.Type
 
                         if TAB_PCDS_DYNAMIC_EX in BuildData.Pcds[key].Type:
@@ -1394,7 +1394,7 @@ class PlatformAutoGen(AutoGen):
 
             for PcdFromModule in M.ModulePcdList + M.LibraryPcdList:
                 # make sure that the "VOID*" kind of datum has MaxDatumSize set
-                if PcdFromModule.DatumType == "VOID*" and PcdFromModule.MaxDatumSize in [None, '']:
+                if PcdFromModule.DatumType == "VOID*" and not PcdFromModule.MaxDatumSize:
                     NoDatumTypePcdList.add("%s.%s [%s]" % (PcdFromModule.TokenSpaceGuidCName, PcdFromModule.TokenCName, F))
 
                 # Check the PCD from Binary INF or Source INF @@ -1471,7 +1471,7 @@ class PlatformAutoGen(AutoGen):
                                         ExtraData="\n\tExisted %s PCD %s in:\n\t\t%s\n"
                                         % (PcdFromModule.Type, PcdFromModule.TokenCName, InfName))
                     # make sure that the "VOID*" kind of datum has MaxDatumSize set
-                    if PcdFromModule.DatumType == "VOID*" and PcdFromModule.MaxDatumSize in [None, '']:
+                    if PcdFromModule.DatumType == "VOID*" and not PcdFromModule.MaxDatumSize:
                         NoDatumTypePcdList.add("%s.%s [%s]" % (PcdFromModule.TokenSpaceGuidCName, PcdFromModule.TokenCName, InfName))
                     if M.ModuleType in SUP_MODULE_SET_PEI:
                         PcdFromModule.Phase = "PEI"
@@ -1999,7 +1999,7 @@ class PlatformAutoGen(AutoGen):
             BuildRuleFile = None
             if TAB_TAT_DEFINES_BUILD_RULE_CONF in self.Workspace.TargetTxt.TargetTxtDictionary:
                 BuildRuleFile = self.Workspace.TargetTxt.TargetTxtDictionary[TAB_TAT_DEFINES_BUILD_RULE_CONF]
-            if BuildRuleFile in [None, '']:
+            if not BuildRuleFile:
                 BuildRuleFile = gDefaultBuildRuleFile
             self._BuildRule = BuildRule(BuildRuleFile)
             if self._BuildRule._FileVersion == "":
@@ -2327,13 +2327,13 @@ class PlatformAutoGen(AutoGen):
                 TokenCName = PcdItem[0]
                 break
         if FromPcd is not None:
-            if ToPcd.Pending and FromPcd.Type not in [None, '']:
+            if ToPcd.Pending and FromPcd.Type:
                 ToPcd.Type = FromPcd.Type
-            elif (ToPcd.Type not in [None, '']) and (FromPcd.Type not in [None, ''])\
+            elif (ToPcd.Type) and (FromPcd.Type)\
                 and (ToPcd.Type != FromPcd.Type) and (ToPcd.Type in FromPcd.Type):
                 if ToPcd.Type.strip() == TAB_PCDS_DYNAMIC_EX:
                     ToPcd.Type = FromPcd.Type
-            elif ToPcd.Type not in [None, ''] and FromPcd.Type not in [None, ''] \
+            elif ToPcd.Type and FromPcd.Type \
                 and ToPcd.Type != FromPcd.Type:
                 EdkLogger.error("build", OPTION_CONFLICT, "Mismatched PCD type",
                                 ExtraData="%s.%s is defined as [%s] in module %s, but as [%s] in platform."\ @@ -2369,11 +2369,11 @@ class PlatformAutoGen(AutoGen):
             ToPcd.validlists = FromPcd.validlists
             ToPcd.expressions = FromPcd.expressions
 
-        if FromPcd is not None and ToPcd.DatumType == "VOID*" and ToPcd.MaxDatumSize in ['', None]:
+        if FromPcd is not None and ToPcd.DatumType == "VOID*" and not ToPcd.MaxDatumSize:
             EdkLogger.debug(EdkLogger.DEBUG_9, "No MaxDatumSize specified for PCD %s.%s" \
                             % (ToPcd.TokenSpaceGuidCName, TokenCName))
             Value = ToPcd.DefaultValue
-            if Value in [None, '']:
+            if not Value:
                 ToPcd.MaxDatumSize = '1'
             elif Value[0] == 'L':
                 ToPcd.MaxDatumSize = str((len(Value) - 2) * 2) @@ -2384,7 +2384,7 @@ class PlatformAutoGen(AutoGen):
 
         # apply default SKU for dynamic PCDS if specified one is not available
         if (ToPcd.Type in PCD_DYNAMIC_TYPE_SET or ToPcd.Type in PCD_DYNAMIC_EX_TYPE_SET) \
-            and ToPcd.SkuInfoList in [None, {}, '']:
+            and not ToPcd.SkuInfoList:
             if self.Platform.SkuName in self.Platform.SkuIds:
                 SkuName = self.Platform.SkuName
             else:
@@ -2445,10 +2445,10 @@ class PlatformAutoGen(AutoGen):
         # use PCD value to calculate the MaxDatumSize when it is not specified
         for Name, Guid in Pcds:
             Pcd = Pcds[Name, Guid]
-            if Pcd.DatumType == "VOID*" and Pcd.MaxDatumSize in ['', None]:
+            if Pcd.DatumType == "VOID*" and not Pcd.MaxDatumSize:
                 Pcd.MaxSizeUserSet = None
                 Value = Pcd.DefaultValue
-                if Value in [None, '']:
+                if not Value:
                     Pcd.MaxDatumSize = '1'
                 elif Value[0] == 'L':
                     Pcd.MaxDatumSize = str((len(Value) - 2) * 2) diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py
index ca54ac107e5d..a020d5f5e58a 100644
--- a/BaseTools/Source/Python/AutoGen/GenC.py
+++ b/BaseTools/Source/Python/AutoGen/GenC.py
@@ -867,7 +867,7 @@ def DynExPcdTokenNumberMapping(Info, AutoGenH):
 def GetPcdSize(Pcd):
     if Pcd.DatumType not in _NumericDataTypesList:
         Value = Pcd.DefaultValue
-        if Value in [None, '']:
+        if not Value:
             return 1
         elif Value[0] == 'L':
             return (len(Value) - 2) * 2 diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
index b92fa4d8033c..a26097813bcc 100644
--- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py
+++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
@@ -297,7 +297,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
 
             # Check value, if value are equal, no need to patch
             if Pcd.DatumType == "VOID*":
-                if Pcd.InfDefaultValue == DefaultValue or DefaultValue in [None, '']:
+                if Pcd.InfDefaultValue == DefaultValue or not DefaultValue:
                     continue
                 # Get the string size from FDF or DSC
                 if DefaultValue[0] == 'L':
@@ -310,7 +310,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
                 if DscOverride:
                     Pcd.MaxDatumSize = PatchPcd.MaxDatumSize
                 # If no defined the maximum size in DSC, try to get current size from INF
-                if Pcd.MaxDatumSize in ['', None]:
+                if not Pcd.MaxDatumSize:
                     Pcd.MaxDatumSize = str(len(Pcd.InfDefaultValue.split(',')))
             else:
                 Base1 = Base2 = 10
diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
index 878b13d13c2d..3a745dc4175e 100644
--- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
+++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
@@ -102,7 +102,7 @@ class GenFdsGlobalVariable:
             TargetTxt.LoadTargetTxtFile(BuildConfigurationFile)
             if DataType.TAB_TAT_DEFINES_BUILD_RULE_CONF in TargetTxt.TargetTxtDictionary:
                 BuildRuleFile = TargetTxt.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_BUILD_RULE_CONF]
-            if BuildRuleFile in [None, '']:
+            if not BuildRuleFile:
                 BuildRuleFile = 'Conf/build_rule.txt'
             GenFdsGlobalVariable.__BuildRuleDatabase = BuildRule(BuildRuleFile)
             ToolDefinitionFile = TargetTxt.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TOOL_CHAIN_CONF]
@@ -441,15 +441,15 @@ class GenFdsGlobalVariable:
     def GenerateSection(Output, Input, Type=None, CompressionType=None, Guid=None,
                         GuidHdrLen=None, GuidAttr=[], Ui=None, Ver=None, InputAlign=None, BuildNumber=None, DummyFile=None, IsMakefile=False):
         Cmd = ["GenSec"]
-        if Type not in [None, '']:
+        if Type:
             Cmd += ["-s", Type]
-        if CompressionType not in [None, '']:
+        if CompressionType:
             Cmd += ["-c", CompressionType]
         if Guid is not None:
             Cmd += ["-g", Guid]
         if DummyFile is not None:
             Cmd += ["--dummy", DummyFile]
-        if GuidHdrLen not in [None, '']:
+        if GuidHdrLen:
             Cmd += ["-l", GuidHdrLen]
         if len(GuidAttr) != 0:
             #Add each guided attribute
@@ -461,7 +461,7 @@ class GenFdsGlobalVariable:
                 Cmd += ["--sectionalign", SecAlign]
 
         CommandFile = Output + '.txt'
-        if Ui not in [None, '']:
+        if Ui:
             #Cmd += ["-n", '"' + Ui + '"']
             if IsMakefile:
                 if Ui == "$(MODULE_NAME)":
@@ -480,7 +480,7 @@ class GenFdsGlobalVariable:
                 GenFdsGlobalVariable.SectionHeader.pack_into(SectionData, 0, Len & 0xff, (Len >> 8) & 0xff, (Len >> 16) & 0xff, 0x15)
                 SaveFileOnChange(Output, SectionData.tostring())
 
-        elif Ver not in [None, '']:
+        elif Ver:
             Cmd += ["-n", Ver]
             if BuildNumber:
                 Cmd += ["-j", BuildNumber] @@ -529,7 +529,7 @@ class GenFdsGlobalVariable:
             Cmd += ["-x"]
         if CheckSum:
             Cmd += ["-s"]
-        if Align not in [None, '']:
+        if Align:
             if Align not in mFfsValidAlign:
                 Align = GenFdsGlobalVariable.GetAlignment (Align)
                 for index in range(0, len(mFfsValidAlign) - 1):
@@ -541,7 +541,7 @@ class GenFdsGlobalVariable:
         Cmd += ["-o", Output]
         for I in range(0, len(Input)):
             Cmd += ("-i", Input[I])
-            if SectionAlign not in [None, '', []] and SectionAlign[I] not in [None, '']:
+            if SectionAlign and SectionAlign[I]:
                 Cmd += ("-n", SectionAlign[I])
 
         CommandFile = Output + '.txt'
@@ -566,7 +566,7 @@ class GenFdsGlobalVariable:
         GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input))
 
         Cmd = ["GenFv"]
-        if BaseAddress not in [None, '']:
+        if BaseAddress:
             Cmd += ["-r", BaseAddress]
 
         if ForceRebase == False:
@@ -578,9 +578,9 @@ class GenFdsGlobalVariable:
             Cmd += ["-c"]
         if Dump:
             Cmd += ["-p"]
-        if AddressFile not in [None, '']:
+        if AddressFile:
             Cmd += ["-a", AddressFile]
-        if MapFile not in [None, '']:
+        if MapFile:
             Cmd += ["-m", MapFile]
         if FileSystemGuid:
             Cmd += ["-g", FileSystemGuid] @@ -597,7 +597,7 @@ class GenFdsGlobalVariable:
         GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input))
 
         Cmd = ["GenVtf"]
-        if BaseAddress not in [None, ''] and FvSize not in [None, ''] \
+        if BaseAddress and FvSize \
             and len(BaseAddress) == len(FvSize):
             for I in range(0, len(BaseAddress)):
                 Cmd += ["-r", BaseAddress[I], "-s", FvSize[I]] @@ -618,13 +618,13 @@ class GenFdsGlobalVariable:
         Cmd = ["GenFw"]
         if Type.lower() == "te":
             Cmd += ["-t"]
-        if SubType not in [None, '']:
+        if SubType:
             Cmd += ["-e", SubType]
-        if TimeStamp not in [None, '']:
+        if TimeStamp:
             Cmd += ["-s", TimeStamp]
-        if Align not in [None, '']:
+        if Align:
             Cmd += ["-a", Align]
-        if Padding not in [None, '']:
+        if Padding:
             Cmd += ["-p", Padding]
         if Zero:
             Cmd += ["-z"]
diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py
index 6943fab4e5c8..91a9928c00d2 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -641,10 +641,10 @@ class DscBuildData(PlatformBuildClassObject):
             self._SkuIds = OrderedDict()
             RecordList = self._RawData[MODEL_EFI_SKU_ID, self._Arch]
             for Record in RecordList:
-                if Record[0] in [None, '']:
+                if not Record[0]:
                     EdkLogger.error('build', FORMAT_INVALID, 'No Sku ID number',
                                     File=self.MetaFile, Line=Record[-1])
-                if Record[1] in [None, '']:
+                if not Record[1]:
                     EdkLogger.error('build', FORMAT_INVALID, 'No Sku ID name',
                                     File=self.MetaFile, Line=Record[-1])
                 if not Pattern.match(Record[0]) and not HexPattern.match(Record[0]):
@@ -669,10 +669,10 @@ class DscBuildData(PlatformBuildClassObject):
             self.DefaultStores = OrderedDict()
             RecordList = self._RawData[MODEL_EFI_DEFAULT_STORES, self._Arch]
             for Record in RecordList:
-                if Record[0] in [None, '']:
+                if not Record[0]:
                     EdkLogger.error('build', FORMAT_INVALID, 'No DefaultStores ID number',
                                     File=self.MetaFile, Line=Record[-1])
-                if Record[1] in [None, '']:
+                if not Record[1]:
                     EdkLogger.error('build', FORMAT_INVALID, 'No DefaultStores ID name',
                                     File=self.MetaFile, Line=Record[-1])
                 if not Pattern.match(Record[0]) and not HexPattern.match(Record[0]):
diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py b/BaseTools/Source/Python/Workspace/InfBuildData.py
index cf5e1df3a523..602746de32f7 100644
--- a/BaseTools/Source/Python/Workspace/InfBuildData.py
+++ b/BaseTools/Source/Python/Workspace/InfBuildData.py
@@ -1116,7 +1116,7 @@ class InfBuildData(ModuleBuildClassObject):
                     Pcd.DatumType = PcdInPackage.DatumType
                     Pcd.MaxDatumSize = PcdInPackage.MaxDatumSize
                     Pcd.InfDefaultValue = Pcd.DefaultValue
-                    if Pcd.DefaultValue in [None, '']:
+                    if not Pcd.DefaultValue:
                         Pcd.DefaultValue = PcdInPackage.DefaultValue
                     else:
                         try:
--
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* Re: [PATCH v1 26/27] BaseTools: remove unused MigrationUtilities.py
  2018-04-20 15:51 ` [PATCH v1 26/27] BaseTools: remove unused MigrationUtilities.py Jaben Carsey
@ 2018-05-02  6:49   ` Zhu, Yonghong
  0 siblings, 0 replies; 56+ messages in thread
From: Zhu, Yonghong @ 2018-05-02  6:49 UTC (permalink / raw)
  To: Carsey, Jaben, edk2-devel@lists.01.org; +Cc: Gao, Liming, Zhu, Yonghong

Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com> 

Best Regards,
Zhu Yonghong


-----Original Message-----
From: Carsey, Jaben 
Sent: Friday, April 20, 2018 11:52 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming <liming.gao@intel.com>; Zhu, Yonghong <yonghong.zhu@intel.com>
Subject: [PATCH v1 26/27] BaseTools: remove unused MigrationUtilities.py

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>
---
 BaseTools/Source/Python/Common/MigrationUtilities.py | 568 --------------------
 BaseTools/Source/Python/Makefile                     |   1 -
 2 files changed, 569 deletions(-)

diff --git a/BaseTools/Source/Python/Common/MigrationUtilities.py b/BaseTools/Source/Python/Common/MigrationUtilities.py
deleted file mode 100644
index 0c93c72a60f6..000000000000
--- a/BaseTools/Source/Python/Common/MigrationUtilities.py
+++ /dev/null
@@ -1,568 +0,0 @@
-## @file
-# Contains several utilitities shared by migration tools.
-#
-# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR> -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution.  The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-
-##
-# Import Modules
-#
-import Common.LongFilePathOs as os
-import re
-import EdkLogger
-from optparse import OptionParser
-from Common.BuildToolError import *
-from XmlRoutines import *
-from CommonDataClass.CommonClass import * -from Common.LongFilePathSupport import OpenLongFilePath as open
-
-## Set all fields of CommonClass object.
-#
-# Set all attributes of CommonClass object from XML Dom object of XmlCommon.
-#
-# @param  Common     The destine CommonClass object.
-# @param  XmlCommon  The source XML Dom object.
-#
-def SetCommon(Common, XmlCommon):
-    XmlTag = "Usage"
-    Common.Usage = XmlAttribute(XmlCommon, XmlTag).split()
-
-    XmlTag = TAB_PCDS_FEATURE_FLAG
-    Common.FeatureFlag = XmlAttribute(XmlCommon, XmlTag)
-    
-    XmlTag = "SupArchList"
-    Common.SupArchList = XmlAttribute(XmlCommon, XmlTag).split()
-    
-    XmlTag = XmlNodeName(XmlCommon) + "/" + "HelpText"
-    Common.HelpText = XmlElement(XmlCommon, XmlTag)
-
-
-## Set some fields of CommonHeaderClass object.
-#
-# Set Name, Guid, FileName and FullPath fields of CommonHeaderClass object from -# XML Dom object of XmlCommonHeader, NameTag and FileName.
-#
-# @param  CommonHeader       The destine CommonClass object.
-# @param  XmlCommonHeader    The source XML Dom object.
-# @param  NameTag            The name tag in XML Dom object.
-# @param  FileName           The file name of the XML file.
-#
-def SetIdentification(CommonHeader, XmlCommonHeader, NameTag, FileName):
-    XmlParentTag = XmlNodeName(XmlCommonHeader)
-    
-    XmlTag = XmlParentTag + "/" + NameTag
-    CommonHeader.Name = XmlElement(XmlCommonHeader, XmlTag)
-
-    XmlTag = XmlParentTag + "/" + "GuidValue"
-    CommonHeader.Guid = XmlElement(XmlCommonHeader, XmlTag)
-
-    XmlTag = XmlParentTag + "/" + "Version"
-    CommonHeader.Version = XmlElement(XmlCommonHeader, XmlTag)
-
-    CommonHeader.FileName = os.path.basename(FileName)
-    CommonHeader.FullPath = os.path.abspath(FileName)
-
-
-## Regular expression to match specification and value.
-mReSpecification = re.compile(r"(?P<Specification>\w+)\s+(?P<Value>\w*)")
-
-## Add specification to specification dictionary.
-#
-# Abstract specification name, value pair from Specification String and add them -# to specification dictionary.
-#
-# @param  SpecificationDict   The destine Specification dictionary.
-# @param  SpecificationString The source Specification String from which the
-#                             specification name and value pair is abstracted.
-#
-def AddToSpecificationDict(SpecificationDict, SpecificationString):
-    """Abstract specification name, value pair from Specification String"""
-    for SpecificationMatch in mReSpecification.finditer(SpecificationString):
-        Specification = SpecificationMatch.group("Specification")
-        Value = SpecificationMatch.group("Value")
-        SpecificationDict[Specification] = Value
-
-## Set all fields of CommonHeaderClass object.
-#
-# Set all attributes of CommonHeaderClass object from XML Dom object of -# XmlCommonHeader, NameTag and FileName.
-#
-# @param  CommonHeader       The destine CommonClass object.
-# @param  XmlCommonHeader    The source XML Dom object.
-# @param  NameTag            The name tag in XML Dom object.
-# @param  FileName           The file name of the XML file.
-#
-def SetCommonHeader(CommonHeader, XmlCommonHeader):
-    """Set all attributes of CommonHeaderClass object from XmlCommonHeader"""
-    XmlParent = XmlNodeName(XmlCommonHeader)
-    
-    XmlTag = XmlParent + "/" + "Abstract"
-    CommonHeader.Abstract = XmlElement(XmlCommonHeader, XmlTag)
-
-    XmlTag = XmlParent + "/" + "Description"
-    CommonHeader.Description = XmlElement(XmlCommonHeader, XmlTag)
-
-    XmlTag = XmlParent + "/" + "Copyright"
-    CommonHeader.Copyright = XmlElement(XmlCommonHeader, XmlTag)
-
-    XmlTag = XmlParent + "/" + "License"
-    CommonHeader.License = XmlElement(XmlCommonHeader, XmlTag)
-
-    XmlTag = XmlParent + "/" + "Specification"
-    Specification = XmlElement(XmlCommonHeader, XmlTag)
-
-    AddToSpecificationDict(CommonHeader.Specification, Specification)
-
-    XmlTag = XmlParent + "/" + "ModuleType"
-    CommonHeader.ModuleType = XmlElement(XmlCommonHeader, XmlTag)
-
-
-## Load a new Cloned Record class object.
-#
-# Read an input XML ClonedRecord DOM object and return an object of Cloned Record -# contained in the DOM object.
-#
-# @param  XmlCloned            A child XML DOM object in a Common XML DOM.
-#
-# @retvel ClonedRecord         A new Cloned Record object created by XmlCloned.
-#
-def LoadClonedRecord(XmlCloned):
-    ClonedRecord = ClonedRecordClass()
-
-    XmlTag = "Id"
-    ClonedRecord.Id = int(XmlAttribute(XmlCloned, XmlTag))
-
-    XmlTag = "FarGuid"
-    ClonedRecord.FarGuid = XmlAttribute(XmlCloned, XmlTag)
-
-    XmlTag = "Cloned/PackageGuid"
-    ClonedRecord.PackageGuid = XmlElement(XmlCloned, XmlTag)
-    
-    XmlTag = "Cloned/PackageVersion"
-    ClonedRecord.PackageVersion = XmlElement(XmlCloned, XmlTag)
-    
-    XmlTag = "Cloned/ModuleGuid"
-    ClonedRecord.ModuleGuid = XmlElement(XmlCloned, XmlTag)
-    
-    XmlTag = "Cloned/ModuleVersion"
-    ClonedRecord.ModuleVersion = XmlElement(XmlCloned, XmlTag)
-    
-    return ClonedRecord
-
-
-## Load a new Guid/Protocol/Ppi common class object.
-#
-# Read an input XML Guid/Protocol/Ppi DOM object and return an object of -# Guid/Protocol/Ppi contained in the DOM object.
-#
-# @param  XmlGuidProtocolPpiCommon A child XML DOM object in a Common XML DOM.
-#
-# @retvel GuidProtocolPpiCommon    A new GuidProtocolPpiCommon class object
-#                                  created by XmlGuidProtocolPpiCommon.
-#
-def LoadGuidProtocolPpiCommon(XmlGuidProtocolPpiCommon):
-    GuidProtocolPpiCommon = GuidProtocolPpiCommonClass()
-    
-    XmlTag = "Name"
-    GuidProtocolPpiCommon.Name = XmlAttribute(XmlGuidProtocolPpiCommon, XmlTag)
-
-    XmlParent = XmlNodeName(XmlGuidProtocolPpiCommon)
-    if XmlParent == "Entry":
-        XmlTag = "%s/C_Name" % XmlParent
-    elif XmlParent == "GuidCNames":
-        XmlTag = "%s/GuidCName" % XmlParent
-    else:
-        XmlTag = "%s/%sCName" % (XmlParent, XmlParent)
-        
-    GuidProtocolPpiCommon.CName = XmlElement(XmlGuidProtocolPpiCommon, XmlTag)
-    
-    XmlTag = XmlParent + "/" + "GuidValue"
-    GuidProtocolPpiCommon.Guid = XmlElement(XmlGuidProtocolPpiCommon, XmlTag)
-    
-    if XmlParent.endswith("Notify"):
-        GuidProtocolPpiCommon.Notify = True
-
-    XmlTag = "GuidTypeList"
-    GuidTypes = XmlAttribute(XmlGuidProtocolPpiCommon, XmlTag)
-    GuidProtocolPpiCommon.GuidTypeList = GuidTypes.split()
-    
-    XmlTag = "SupModuleList"
-    SupModules = XmlAttribute(XmlGuidProtocolPpiCommon, XmlTag)
-    GuidProtocolPpiCommon.SupModuleList = SupModules.split()
-
-    SetCommon(GuidProtocolPpiCommon, XmlGuidProtocolPpiCommon)
-
-    return GuidProtocolPpiCommon
-
-
-## Load a new Pcd class object.
-#
-# Read an input XML Pcd DOM object and return an object of Pcd -# contained in the DOM object.
-#
-# @param  XmlPcd               A child XML DOM object in a Common XML DOM.
-#
-# @retvel Pcd                  A new Pcd object created by XmlPcd.
-#
-def LoadPcd(XmlPcd):
-    """Return a new PcdClass object equivalent to XmlPcd"""
-    Pcd = PcdClass()
-
-    XmlTag = "PcdEntry/C_Name"
-    Pcd.CName = XmlElement(XmlPcd, XmlTag)
-
-    XmlTag = "PcdEntry/Token"
-    Pcd.Token = XmlElement(XmlPcd, XmlTag)
-
-    XmlTag = "PcdEntry/TokenSpaceGuidCName"
-    Pcd.TokenSpaceGuidCName = XmlElement(XmlPcd, XmlTag)
-
-    XmlTag = "PcdEntry/DatumType"
-    Pcd.DatumType = XmlElement(XmlPcd, XmlTag)
-
-    XmlTag = "PcdEntry/MaxDatumSize"
-    Pcd.MaxDatumSize = XmlElement(XmlPcd, XmlTag)
-
-    XmlTag = "PcdEntry/DefaultValue"
-    Pcd.DefaultValue = XmlElement(XmlPcd, XmlTag)
-
-    XmlTag = "PcdItemType"
-    Pcd.ItemType = XmlAttribute(XmlPcd, XmlTag)
-
-    XmlTag = "PcdEntry/ValidUsage"
-    Pcd.ValidUsage = XmlElement(XmlPcd, XmlTag).split()
-
-    XmlTag = "SupModuleList"
-    Pcd.SupModuleList = XmlAttribute(XmlPcd, XmlTag).split()
-
-    SetCommon(Pcd, XmlPcd)
-
-    return Pcd
-
-
-## Load a new LibraryClass class object.
-#
-# Read an input XML LibraryClass DOM object and return an object of LibraryClass -# contained in the DOM object.
-#
-# @param  XmlLibraryClass    A child XML DOM object in a Common XML DOM.
-#
-# @retvel LibraryClass       A new LibraryClass object created by XmlLibraryClass.
-#
-def LoadLibraryClass(XmlLibraryClass):
-    LibraryClass = LibraryClassClass()
-
-    XmlTag = "LibraryClass/Keyword"
-    LibraryClass.LibraryClass = XmlElement(XmlLibraryClass, XmlTag)
-    if LibraryClass.LibraryClass == "":
-        XmlTag = "Name"
-        LibraryClass.LibraryClass = XmlAttribute(XmlLibraryClass, XmlTag)
-    
-    XmlTag = "LibraryClass/IncludeHeader"
-    LibraryClass.IncludeHeader = XmlElement(XmlLibraryClass, XmlTag)
-    
-    XmlTag = "RecommendedInstanceVersion"
-    RecommendedInstanceVersion = XmlAttribute(XmlLibraryClass, XmlTag)
-    LibraryClass.RecommendedInstanceVersion = RecommendedInstanceVersion
-    
-    XmlTag = "RecommendedInstanceGuid"
-    RecommendedInstanceGuid = XmlAttribute(XmlLibraryClass, XmlTag)
-    LibraryClass.RecommendedInstanceGuid = RecommendedInstanceGuid
-    
-    XmlTag = "SupModuleList"
-    SupModules = XmlAttribute(XmlLibraryClass, XmlTag)
-    LibraryClass.SupModuleList = SupModules.split()
-    
-    SetCommon(LibraryClass, XmlLibraryClass)
-    
-    return LibraryClass
-
-
-## Load a new Build Option class object.
-#
-# Read an input XML BuildOption DOM object and return an object of Build Option -# contained in the DOM object.
-#
-# @param  XmlBuildOption       A child XML DOM object in a Common XML DOM.
-#
-# @retvel BuildOption          A new Build Option object created by XmlBuildOption.
-#
-def LoadBuildOption(XmlBuildOption):
-    """Return a new BuildOptionClass object equivalent to XmlBuildOption"""
-    BuildOption = BuildOptionClass()
-    
-    BuildOption.Option = XmlElementData(XmlBuildOption)
-
-    XmlTag = "BuildTargets"
-    BuildOption.BuildTargetList = XmlAttribute(XmlBuildOption, XmlTag).split()
-    
-    XmlTag = "ToolChainFamily"
-    BuildOption.ToolChainFamily = XmlAttribute(XmlBuildOption, XmlTag)
-    
-    XmlTag = "TagName"
-    BuildOption.TagName = XmlAttribute(XmlBuildOption, XmlTag)
-    
-    XmlTag = "ToolCode"
-    BuildOption.ToolCode = XmlAttribute(XmlBuildOption, XmlTag)
-    
-    XmlTag = "SupArchList"
-    BuildOption.SupArchList = XmlAttribute(XmlBuildOption, XmlTag).split()
-    
-    return BuildOption
-
-
-## Load a new User Extensions class object.
-#
-# Read an input XML UserExtensions DOM object and return an object of User -# Extensions contained in the DOM object.
-#
-# @param  XmlUserExtensions    A child XML DOM object in a Common XML DOM.
-#
-# @retvel UserExtensions       A new User Extensions object created by
-#                              XmlUserExtensions.
-#
-def LoadUserExtensions(XmlUserExtensions):
-    UserExtensions = UserExtensionsClass()
-    
-    XmlTag = "UserID"
-    UserExtensions.UserID = XmlAttribute(XmlUserExtensions, XmlTag)
-    
-    XmlTag = "Identifier"
-    UserExtensions.Identifier = XmlAttribute(XmlUserExtensions, XmlTag)
-    
-    UserExtensions.Content = XmlElementData(XmlUserExtensions)
-    
-    return UserExtensions
-
-
-## Store content to a text file object.
-#
-# Write some text file content to a text file object. The contents may echo -# in screen in a verbose way.
-#
-# @param  TextFile           The text file object.
-# @param  Content            The string object to be written to a text file.
-#
-def StoreTextFile(TextFile, Content):
-    EdkLogger.verbose(Content)
-    TextFile.write(Content)
-
-
-## Add item to a section.
-#
-# Add an Item with specific CPU architecture to section dictionary.
-# The possible duplication is ensured to be removed.
-#
-# @param  Section            Section dictionary indexed by CPU architecture.
-# @param  Arch               CPU architecture: Ia32, X64, Ipf, ARM, AARCH64, Ebc or Common.
-# @param  Item               The Item to be added to section dictionary.
-#
-def AddToSection(Section, Arch, Item):
-    SectionArch = Section.get(Arch, [])
-    if Item not in SectionArch:
-        SectionArch.append(Item)
-        Section[Arch] = SectionArch
-
-
-## Get section contents.
-#
-# Return the content of section named SectionName.
-# the contents is based on Methods and ObjectLists.
-#
-# @param  SectionName        The name of the section.
-# @param  Method             A function returning a string item of an object.
-# @param  ObjectList         The list of object.
-#
-# @retval Section            The string content of a section.
-#
-def GetSection(SectionName, Method, ObjectList):
-    SupportedArches = ["common", "Ia32", "X64", "Ipf", "Ebc", "ARM", "AARCH64"]
-    SectionDict = {}
-    for Object in ObjectList:
-        Item = Method(Object)
-        if Item == "":
-            continue
-        Item = "  %s" % Item
-        Arches = Object.SupArchList
-        if len(Arches) == 0:
-            AddToSection(SectionDict, "common", Item)
-        else:
-            for Arch in SupportedArches:
-                if Arch.upper() in Arches:
-                    AddToSection(SectionDict, Arch, Item)
-
-    Section = ""
-    for Arch in SupportedArches:
-        SectionArch = "\n".join(SectionDict.get(Arch, []))
-        if SectionArch != "":
-            Section += "[%s.%s]\n%s\n" % (SectionName, Arch, SectionArch)
-            Section += "\n"
-    if Section != "":
-        Section += "\n"
-    return Section
-
-
-## Store file header to a text file.
-#
-# Write standard file header to a text file. The content includes copyright, -# abstract, description and license extracted from CommonHeader class object.
-#
-# @param  TextFile           The text file object.
-# @param  CommonHeader       The source CommonHeader class object.
-#
-def StoreHeader(TextFile, CommonHeader):
-    CopyRight = CommonHeader.Copyright
-    Abstract = CommonHeader.Abstract
-    Description = CommonHeader.Description
-    License = CommonHeader.License
-
-    Header = "#/** @file\n#\n"
-    Header += "# " + Abstract + "\n#\n"
-    Header += "# " + Description.strip().replace("\n", "\n# ") + "\n"
-    Header += "# " + CopyRight + "\n#\n"
-    Header += "#  " + License.replace("\n", "\n# ").replace("  ", " ")
-    Header += "\n#\n#**/\n\n"
-
-    StoreTextFile(TextFile, Header)
-
-## Store file header to a text file.
-#
-# Write Defines section to a text file. DefinesTupleList determines the content.
-#
-# @param  TextFile           The text file object.
-# @param  DefinesTupleList   The list of (Tag, Value) to be added as one item.
-#
-def StoreDefinesSection(TextFile, DefinesTupleList):
-    Section = "[Defines]\n"
-    for DefineItem in DefinesTupleList:
-        Section += "  %-30s = %s\n" % DefineItem
-
-    Section += "\n\n"
-    StoreTextFile(TextFile, Section)
-
-
-## Return one User Extension section.
-#
-# Read the input UserExtentsions class object and return one section.
-#
-# @param  UserExtensions       An input UserExtensions class object.
-#
-# @retval UserExtensionSection A section representing UserExtensions object.
-#
-def GetUserExtensions(UserExtensions):
-    UserId = UserExtensions.UserID
-    Identifier = UserExtensions.Identifier
-    Content = UserExtensions.Content
-
-    return "[UserExtensions.%s.%s]\n  %s\n\n" % (UserId, Identifier, Content)
-
-## Regular expression to match an equation.
-mReEquation = re.compile(r"\s*(\S+)\s*=\s*(\S*)\s*")
-
-## Return a value tuple matching information in a text fle.
-#
-# Parse the text file and return a value tuple corresponding to an input tag -# tuple. In case of any error, an tuple of empty strings is returned.
-#
-# @param  FileName           The file name of the text file.
-# @param  TagTuple           A tuple of tags as the key to the value.
-#
-# @param  ValueTupe          The returned tuple corresponding to the tag tuple.
-#
-def GetTextFileInfo(FileName, TagTuple):
-    ValueTuple = [""] * len(TagTuple)
-    try:
-        for Line in open(FileName):
-            Line = Line.split("#", 1)[0]
-            MatchEquation = mReEquation.match(Line)
-            if MatchEquation:
-                Tag = MatchEquation.group(1).upper()
-                Value = MatchEquation.group(2)
-                for Index in range(len(TagTuple)):
-                    if TagTuple[Index] == Tag:
-                        ValueTuple[Index] = Value
-    except:
-        EdkLogger.info("IO Error in reading file %s" % FileName)
-        
-    return ValueTuple
-
-
-## Return a value tuple matching information in an XML fle.
-#
-# Parse the XML file and return a value tuple corresponding to an input tag -# tuple. In case of any error, an tuple of empty strings is returned.
-#
-# @param  FileName           The file name of the XML file.
-# @param  TagTuple           A tuple of tags as the key to the value.
-#
-# @param  ValueTupe          The returned tuple corresponding to the tag tuple.
-#
-def GetXmlFileInfo(FileName, TagTuple):
-    XmlDom = XmlParseFile(FileName)
-    return tuple([XmlElement(XmlDom, XmlTag) for XmlTag in TagTuple])
-
-
-## Parse migration command line options -# -# Use standard Python module optparse to parse command line option of this tool.
-#
-# @param  Source             The source file type.
-# @param  Destinate          The destinate file type.
-#
-# @retval Options            A optparse object containing the parsed options.
-# @retval InputFile          Path of an source file to be migrated.
-#
-def MigrationOptionParser(Source, Destinate, ToolName, VersionNumber=1.0):
-    # use clearer usage to override default usage message
-    UsageString = "%s [-a] [-v|-q] [-o <output_file>] <input_file>" % ToolName
-    Version = "%s Version %.2f" % (ToolName, VersionNumber)
-    Copyright = "Copyright (c) 2007, Intel Corporation. All rights reserved."
-    
-    Parser = OptionParser(description=Copyright, version=Version, usage=UsageString)
-    Parser.add_option("-o", "--output", dest="OutputFile", help="The name of the %s file to be created." % Destinate)
-    Parser.add_option("-a", "--auto", dest="AutoWrite", action="store_true", default=False, help="Automatically create the %s file using the name of the %s file and replacing file extension" % (Source, Destinate))
-    Parser.add_option("-q", "--quiet", action="store_true", type=None, help="Disable all messages except FATAL ERRORS.")
-    Parser.add_option("-v", "--verbose", action="store_true", type=None, help="Turn on verbose output with informational messages printed.")
-
-    Options, Args = Parser.parse_args()
-
-    # Set logging level
-    if Options.verbose:
-        EdkLogger.setLevel(EdkLogger.VERBOSE)
-    elif Options.quiet:
-        EdkLogger.setLevel(EdkLogger.QUIET)
-    else:
-        EdkLogger.setLevel(EdkLogger.INFO)
-        
-    # error check
-    if len(Args) == 0:
-        raise MigrationError(PARAMETER_MISSING, name="Input file", usage=Parser.get_usage())
-    if len(Args) > 1:
-        raise MigrationError(PARAMETER_INVALID, name="Too many input files", usage=Parser.get_usage())
-
-    InputFile = Args[0]
-    if not os.path.exists(InputFile):
-        raise MigrationError(FILE_NOT_FOUND, name=InputFile)
-
-    if Options.OutputFile:
-        if Options.AutoWrite:
-            raise MigrationError(OPTION_CONFLICT, arg1="-o", arg2="-a", usage=Parser.get_usage())
-    else:
-        if Options.AutoWrite:
-            Options.OutputFile = os.path.splitext(InputFile)[0] + "." + Destinate.lower()
-        else:
-            raise MigrationError(OPTION_MISSING, name="-o", usage=Parser.get_usage())
-
-    return Options, InputFile
-
-# This acts like the main() function for the script, unless it is 'import'ed -# into another script.
-if __name__ == '__main__':
-    pass
diff --git a/BaseTools/Source/Python/Makefile b/BaseTools/Source/Python/Makefile
index a51207d3d831..7652d2b80901 100644
--- a/BaseTools/Source/Python/Makefile
+++ b/BaseTools/Source/Python/Makefile
@@ -45,7 +45,6 @@ COMMON_PYTHON=$(BASE_TOOLS_PATH)\Source\Python\Common\BuildToolError.py \
               $(BASE_TOOLS_PATH)\Source\Python\Common\LongFilePathOs.py \
               $(BASE_TOOLS_PATH)\Source\Python\Common\LongFilePathOsPath.py \
               $(BASE_TOOLS_PATH)\Source\Python\Common\LongFilePathSupport.py \
-              $(BASE_TOOLS_PATH)\Source\Python\Common\MigrationUtilities.py \
               $(BASE_TOOLS_PATH)\Source\Python\Common\Misc.py \
               $(BASE_TOOLS_PATH)\Source\Python\Common\Parsing.py \
               $(BASE_TOOLS_PATH)\Source\Python\Common\String.py \
--
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* Re: [PATCH v1 17/27] BaseTools: DataType - cleanup list constants
  2018-04-20 15:51 ` [PATCH v1 17/27] BaseTools: DataType - cleanup list constants Jaben Carsey
@ 2018-05-04 11:14   ` Laszlo Ersek
  2018-05-04 14:18     ` Carsey, Jaben
  0 siblings, 1 reply; 56+ messages in thread
From: Laszlo Ersek @ 2018-05-04 11:14 UTC (permalink / raw)
  To: Jaben Carsey; +Cc: edk2-devel, Liming Gao

Hi,

On 04/20/18 17:51, Jaben Carsey wrote:
> remove unused ones
> convert lists used for membership testing to sets
> use shared ones not local ones
>
> 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>
> ---
>  BaseTools/Source/Python/AutoGen/AutoGen.py           | 32 ++++++++---------
>  BaseTools/Source/Python/AutoGen/GenC.py              | 36 ++++++++------------
>  BaseTools/Source/Python/AutoGen/GenPcdDb.py          |  4 +--
>  BaseTools/Source/Python/Common/DataType.py           | 29 ++++++----------
>  BaseTools/Source/Python/Ecc/Configuration.py         |  2 +-
>  BaseTools/Source/Python/Ecc/c.py                     |  2 +-
>  BaseTools/Source/Python/GenFds/FdfParser.py          |  2 +-
>  BaseTools/Source/Python/GenFds/Ffs.py                | 20 +----------
>  BaseTools/Source/Python/GenFds/OptRomInfStatement.py |  1 -
>  BaseTools/Source/Python/Workspace/InfBuildData.py    |  2 +-
>  BaseTools/Source/Python/Workspace/MetaFileParser.py  |  4 +--
>  BaseTools/Source/Python/build/build.py               |  4 +--
>  12 files changed, 53 insertions(+), 85 deletions(-)

I think this patch (commit eece4292acc80) broke the Ecc tool:

> diff --git a/BaseTools/Source/Python/Ecc/Configuration.py b/BaseTools/Source/Python/Ecc/Configuration.py
> index b523858e1b1f..b5b583be8c4a 100644
> --- a/BaseTools/Source/Python/Ecc/Configuration.py
> +++ b/BaseTools/Source/Python/Ecc/Configuration.py
> @@ -53,7 +53,7 @@ class Configuration(object):
>
>          # List customized Modifer here, split with ','
>          # Defaultly use the definition in class DataType
> -        self.ModifierList = MODIFIER_LIST
> +        self.ModifierSet = MODIFIER_SET
>
>          ## General Checking
>          self.GeneralCheckAll = 0

When I run Ecc, it prints:

  BaseTools/Source/Python/Ecc/config.ini(44): error F004: Invalid
  configuration option 'ModifierList' was found

The error comes from "BaseTools/Source/Python/Ecc/Configuration.py":

        LineNo = 0
        for Line in open(Filepath, 'r'):
            LineNo = LineNo + 1
            Line = CleanString(Line)
            if Line != '':
                List = GetSplitValueList(Line, TAB_EQUAL_SPLIT)
                if List[0] not in self.__dict__:
                    ErrorMsg = "Invalid configuration option '%s' was found" % List[0]
                    EdkLogger.error("Ecc", EdkLogger.ECC_ERROR, ErrorMsg, File = Filepath, Line = LineNo)
                if List[0] == 'ModifierList':
                    List[1] = GetSplitValueList(List[1], TAB_COMMA_SPLIT)
                if List[0] == 'MetaDataFileCheckPathOfGenerateFileList' and List[1] == "":
                    continue
                if List[0] == 'SkipDirList':
                    List[1] = GetSplitValueList(List[1], TAB_COMMA_SPLIT)
                if List[0] == 'SkipFileList':
                    List[1] = GetSplitValueList(List[1], TAB_COMMA_SPLIT)
                if List[0] == 'BinaryExtList':
                    List[1] = GetSplitValueList(List[1], TAB_COMMA_SPLIT)
                if List[0] == 'Copyright':
                    List[1] = GetSplitValueList(List[1], TAB_COMMA_SPLIT)
                self.__dict__[List[0]] = List[1]

Basically, the condition

  List[0] not in self.__dict__

expects that option names in the "config.ini" file match the attributes
/ members of the Python object directly. Thus, if we rename a member,
such as from "ModifierList" to "ModifierSet", then all the config files
that used to contain "ModifierList" now have to rename their
"ModifierList" options to "ModifierSet" as well.

This looks brittle to me; option names in config files are public, while
object member names are an implementation detail. They shouldn't be
coupled.

Thanks
Laszlo


^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH v1 17/27] BaseTools: DataType - cleanup list constants
  2018-05-04 11:14   ` Laszlo Ersek
@ 2018-05-04 14:18     ` Carsey, Jaben
  2018-05-04 15:03       ` Laszlo Ersek
  0 siblings, 1 reply; 56+ messages in thread
From: Carsey, Jaben @ 2018-05-04 14:18 UTC (permalink / raw)
  To: Laszlo Ersek; +Cc: edk2-devel@lists.01.org, Gao, Liming

Laszlo,

Wow.  I thought I had tested, but clearly I missed that.

Do you think we just revert back the name change short term?  I agree that mixing internal data structure names and names in the config file seems wrong, I don’t know the ROI for separation.  Maybe use a dict to translate?

-Jaben

> -----Original Message-----
> From: Laszlo Ersek [mailto:lersek@redhat.com]
> Sent: Friday, May 04, 2018 4:15 AM
> To: Carsey, Jaben <jaben.carsey@intel.com>
> Cc: edk2-devel@lists.01.org; Gao, Liming <liming.gao@intel.com>
> Subject: Re: [edk2] [PATCH v1 17/27] BaseTools: DataType - cleanup list
> constants
> Importance: High
> 
> Hi,
> 
> On 04/20/18 17:51, Jaben Carsey wrote:
> > remove unused ones
> > convert lists used for membership testing to sets
> > use shared ones not local ones
> >
> > 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>
> > ---
> >  BaseTools/Source/Python/AutoGen/AutoGen.py           | 32 ++++++++------
> ---
> >  BaseTools/Source/Python/AutoGen/GenC.py              | 36 ++++++++--------
> ----
> >  BaseTools/Source/Python/AutoGen/GenPcdDb.py          |  4 +--
> >  BaseTools/Source/Python/Common/DataType.py           | 29 ++++++--------
> --
> >  BaseTools/Source/Python/Ecc/Configuration.py         |  2 +-
> >  BaseTools/Source/Python/Ecc/c.py                     |  2 +-
> >  BaseTools/Source/Python/GenFds/FdfParser.py          |  2 +-
> >  BaseTools/Source/Python/GenFds/Ffs.py                | 20 +----------
> >  BaseTools/Source/Python/GenFds/OptRomInfStatement.py |  1 -
> >  BaseTools/Source/Python/Workspace/InfBuildData.py    |  2 +-
> >  BaseTools/Source/Python/Workspace/MetaFileParser.py  |  4 +--
> >  BaseTools/Source/Python/build/build.py               |  4 +--
> >  12 files changed, 53 insertions(+), 85 deletions(-)
> 
> I think this patch (commit eece4292acc80) broke the Ecc tool:
> 
> > diff --git a/BaseTools/Source/Python/Ecc/Configuration.py
> b/BaseTools/Source/Python/Ecc/Configuration.py
> > index b523858e1b1f..b5b583be8c4a 100644
> > --- a/BaseTools/Source/Python/Ecc/Configuration.py
> > +++ b/BaseTools/Source/Python/Ecc/Configuration.py
> > @@ -53,7 +53,7 @@ class Configuration(object):
> >
> >          # List customized Modifer here, split with ','
> >          # Defaultly use the definition in class DataType
> > -        self.ModifierList = MODIFIER_LIST
> > +        self.ModifierSet = MODIFIER_SET
> >
> >          ## General Checking
> >          self.GeneralCheckAll = 0
> 
> When I run Ecc, it prints:
> 
>   BaseTools/Source/Python/Ecc/config.ini(44): error F004: Invalid
>   configuration option 'ModifierList' was found
> 
> The error comes from "BaseTools/Source/Python/Ecc/Configuration.py":
> 
>         LineNo = 0
>         for Line in open(Filepath, 'r'):
>             LineNo = LineNo + 1
>             Line = CleanString(Line)
>             if Line != '':
>                 List = GetSplitValueList(Line, TAB_EQUAL_SPLIT)
>                 if List[0] not in self.__dict__:
>                     ErrorMsg = "Invalid configuration option '%s' was found" % List[0]
>                     EdkLogger.error("Ecc", EdkLogger.ECC_ERROR, ErrorMsg, File =
> Filepath, Line = LineNo)
>                 if List[0] == 'ModifierList':
>                     List[1] = GetSplitValueList(List[1], TAB_COMMA_SPLIT)
>                 if List[0] == 'MetaDataFileCheckPathOfGenerateFileList' and List[1]
> == "":
>                     continue
>                 if List[0] == 'SkipDirList':
>                     List[1] = GetSplitValueList(List[1], TAB_COMMA_SPLIT)
>                 if List[0] == 'SkipFileList':
>                     List[1] = GetSplitValueList(List[1], TAB_COMMA_SPLIT)
>                 if List[0] == 'BinaryExtList':
>                     List[1] = GetSplitValueList(List[1], TAB_COMMA_SPLIT)
>                 if List[0] == 'Copyright':
>                     List[1] = GetSplitValueList(List[1], TAB_COMMA_SPLIT)
>                 self.__dict__[List[0]] = List[1]
> 
> Basically, the condition
> 
>   List[0] not in self.__dict__
> 
> expects that option names in the "config.ini" file match the attributes
> / members of the Python object directly. Thus, if we rename a member,
> such as from "ModifierList" to "ModifierSet", then all the config files
> that used to contain "ModifierList" now have to rename their
> "ModifierList" options to "ModifierSet" as well.
> 
> This looks brittle to me; option names in config files are public, while
> object member names are an implementation detail. They shouldn't be
> coupled.
> 
> Thanks
> Laszlo

^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH v1 17/27] BaseTools: DataType - cleanup list constants
  2018-05-04 14:18     ` Carsey, Jaben
@ 2018-05-04 15:03       ` Laszlo Ersek
  0 siblings, 0 replies; 56+ messages in thread
From: Laszlo Ersek @ 2018-05-04 15:03 UTC (permalink / raw)
  To: Carsey, Jaben; +Cc: edk2-devel@lists.01.org, Gao, Liming

On 05/04/18 16:18, Carsey, Jaben wrote:
> Laszlo,
> 
> Wow.  I thought I had tested, but clearly I missed that.
> 
> Do you think we just revert back the name change short term?  I agree
> that mixing internal data structure names and names in the config
> file seems wrong, I don’t know the ROI for separation.  Maybe use a
> dict to translate?
Using a dictionary to translate seems OK to me -- it doesn't look large
or complex, and it should be extensible in the future.

Thanks,
Laszlo


^ permalink raw reply	[flat|nested] 56+ messages in thread

end of thread, other threads:[~2018-05-04 15:03 UTC | newest]

Thread overview: 56+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-20 15:51 [PATCH v1 00/27] BaseTools refactoring Jaben Carsey
2018-04-20 15:51 ` [PATCH v1 01/27] BaseTools: Misc - refactor RegEx to minimize multiple compiling Jaben Carsey
2018-04-25  8:49   ` Zhu, Yonghong
2018-04-20 15:51 ` [PATCH v1 02/27] BaseTools: GenPatchPcdTable " Jaben Carsey
2018-04-25  8:50   ` Zhu, Yonghong
2018-04-20 15:51 ` [PATCH v1 03/27] BaseTools: Share RegEx between files Jaben Carsey
2018-04-25  8:51   ` Zhu, Yonghong
2018-04-20 15:51 ` [PATCH v1 04/27] BaseTools: Workspace - refactor RegEx to minimize multiple compiling Jaben Carsey
2018-04-25  8:50   ` Zhu, Yonghong
2018-04-20 15:51 ` [PATCH v1 05/27] BaseTools: Autogen - replace string constants with those from DataType Jaben Carsey
2018-04-25  8:50   ` Zhu, Yonghong
2018-04-20 15:51 ` [PATCH v1 06/27] BaseTools: simplify if call Jaben Carsey
2018-04-25  8:50   ` Zhu, Yonghong
2018-04-20 15:51 ` [PATCH v1 07/27] BaseTools: Workspace - refactor GetStructurePcdInfo Jaben Carsey
2018-04-25  8:50   ` Zhu, Yonghong
2018-04-20 15:51 ` [PATCH v1 08/27] BaseTools: AutoGen - remove dictionary populated, but never accessed Jaben Carsey
2018-04-25  8:50   ` Zhu, Yonghong
2018-04-20 15:51 ` [PATCH v1 09/27] BaseTools: AutoGen - remove unused variables Jaben Carsey
2018-04-25  8:52   ` Zhu, Yonghong
2018-04-20 15:51 ` [PATCH v1 10/27] BaseTools: Remove extra .keys() Jaben Carsey
2018-04-25  8:51   ` Zhu, Yonghong
2018-04-20 15:51 ` [PATCH v1 11/27] BaseTools: Workspace/MetaFileParser - refactor dicts Jaben Carsey
2018-04-20 15:51 ` [PATCH v1 12/27] BaseTools: remove dict from DscBuildData Jaben Carsey
2018-04-25  8:50   ` Zhu, Yonghong
2018-04-20 15:51 ` [PATCH v1 13/27] BaseTools: replace string constants used for module types Jaben Carsey
2018-04-25  5:57   ` Zhu, Yonghong
2018-04-20 15:51 ` [PATCH v1 14/27] BaseTools: Define and use a set for common list Jaben Carsey
2018-05-02  6:48   ` Zhu, Yonghong
2018-04-20 15:51 ` [PATCH v1 15/27] BaseTools: Share a dictionary instead of keeping multiples Jaben Carsey
2018-04-20 15:51 ` [PATCH v1 16/27] BaseTools: Replace EDK Component strings with predefined constant Jaben Carsey
2018-04-24  7:42   ` Zhu, Yonghong
2018-04-24 14:13     ` Carsey, Jaben
2018-04-20 15:51 ` [PATCH v1 17/27] BaseTools: DataType - cleanup list constants Jaben Carsey
2018-05-04 11:14   ` Laszlo Ersek
2018-05-04 14:18     ` Carsey, Jaben
2018-05-04 15:03       ` Laszlo Ersek
2018-04-20 15:51 ` [PATCH v1 18/27] BaseTools: Replace PCD type strings with predefined constant Jaben Carsey
2018-04-25  6:00   ` Zhu, Yonghong
2018-04-20 15:51 ` [PATCH v1 19/27] BaseTools: Replace Binary File " Jaben Carsey
2018-04-24  7:38   ` Zhu, Yonghong
2018-04-24 14:12     ` Carsey, Jaben
2018-04-20 15:51 ` [PATCH v1 20/27] BaseTools: remove duplicate variable Jaben Carsey
2018-04-25  8:51   ` Zhu, Yonghong
2018-04-20 15:51 ` [PATCH v1 21/27] BaseTools: replace string with predefined constant Jaben Carsey
2018-04-25  6:04   ` Zhu, Yonghong
2018-04-20 15:51 ` [PATCH v1 22/27] BaseTools: remove redundant if comparison Jaben Carsey
2018-05-02  6:49   ` Zhu, Yonghong
2018-04-20 15:51 ` [PATCH v1 23/27] BaseTools: AutoGen - use dafultdict instead of dict Jaben Carsey
2018-04-20 15:51 ` [PATCH v1 24/27] BaseTools: GenFds - simplify testing for Hex number Jaben Carsey
2018-04-25  8:51   ` Zhu, Yonghong
2018-04-20 15:51 ` [PATCH v1 25/27] BaseTools: AutoGen - use defaultdict to auto initialize Jaben Carsey
2018-04-25  8:52   ` Zhu, Yonghong
2018-04-20 15:51 ` [PATCH v1 26/27] BaseTools: remove unused MigrationUtilities.py Jaben Carsey
2018-05-02  6:49   ` Zhu, Yonghong
2018-04-20 15:51 ` [PATCH v1 27/27] BaseTools: CommonClass - remove unused classes Jaben Carsey
2018-04-25  8:51   ` Zhu, Yonghong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox