public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v1 00/10] BaseTools: refactor code
@ 2018-04-03 21:03 Jaben Carsey
  2018-04-03 21:03 ` [PATCH v1 01/10] BaseTools: Use local variable for list of constants Jaben Carsey
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: Jaben Carsey @ 2018-04-03 21:03 UTC (permalink / raw)
  To: edk2-devel

remove sdict class use and replace with built in types
remove unused code

Jaben Carsey (10):
  BaseTools: Use local variable for list of constants.
  BaseTools: use built in dict instead of custom version.
  BaseTools: Eot tool never populates this dictionary
  BaseTools: remove unused include statement
  BaseTools - AutoGen - replace custom dictionary class with python
    standard one
  BaseTools: Eot remove unused code
  BaseTools: use built in dict instead of custom version.
  BaseTools: use combined version of standard dicts
  BaseTools: Workspace - use built in OrderedDict instead of custom
    version.
  BaseTools: Remove unused code from Misc

 BaseTools/Source/Python/AutoGen/AutoGen.py              |  31 +--
 BaseTools/Source/Python/AutoGen/GenC.py                 |  30 ++-
 BaseTools/Source/Python/AutoGen/GenMake.py              |   3 +-
 BaseTools/Source/Python/Common/DscClassObject.py        |   4 +-
 BaseTools/Source/Python/Common/EdkIIWorkspaceBuild.py   |  10 +-
 BaseTools/Source/Python/Common/Misc.py                  | 280 +-------------------
 BaseTools/Source/Python/CommonDataClass/PackageClass.py |   4 +-
 BaseTools/Source/Python/Eot/Eot.py                      |   9 -
 BaseTools/Source/Python/Eot/EotGlobalData.py            |  16 +-
 BaseTools/Source/Python/Eot/FvImage.py                  |  21 --
 BaseTools/Source/Python/Eot/Parser.py                   |   3 +-
 BaseTools/Source/Python/GenFds/GenFds.py                |   1 -
 BaseTools/Source/Python/Workspace/BuildClassObject.py   |   4 +-
 BaseTools/Source/Python/Workspace/DecBuildData.py       |  24 +-
 BaseTools/Source/Python/Workspace/DscBuildData.py       |  24 +-
 BaseTools/Source/Python/Workspace/InfBuildData.py       |  52 ++--
 BaseTools/Source/Python/Workspace/WorkspaceCommon.py    |  21 +-
 BaseTools/Source/Python/build/build.py                  |  10 +-
 18 files changed, 118 insertions(+), 429 deletions(-)

-- 
2.16.2.windows.1



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

* [PATCH v1 01/10] BaseTools: Use local variable for list of constants.
  2018-04-03 21:03 [PATCH v1 00/10] BaseTools: refactor code Jaben Carsey
@ 2018-04-03 21:03 ` Jaben Carsey
  2018-04-03 21:03 ` [PATCH v1 02/10] BaseTools: use built in dict instead of custom version Jaben Carsey
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Jaben Carsey @ 2018-04-03 21:03 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Yonghong Zhu

instead of listing in multiple places, use a single list.

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/GenC.py | 30 +++++++++++---------
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py
index 4d9ea1b2a8b1..8d76aabd5367 100644
--- a/BaseTools/Source/Python/AutoGen/GenC.py
+++ b/BaseTools/Source/Python/AutoGen/GenC.py
@@ -41,6 +41,8 @@ gItemTypeStringDatabase  = {
     TAB_PCDS_DYNAMIC_EX_HII     :   '',
 }
 
+_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]
 
@@ -869,7 +871,7 @@ def DynExPcdTokenNumberMapping(Info, AutoGenH):
                 TokenCNameList.append(TokenCName)
 
 def GetPcdSize(Pcd):
-    if Pcd.DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN']:
+    if Pcd.DatumType not in _NumericDataTypesList:
         Value = Pcd.DefaultValue
         if Value in [None, '']:
             return 1
@@ -975,7 +977,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
             AutoGenH.Append('// #define %s  %s\n' % (PcdTokenName, PcdExTokenName))
             AutoGenH.Append('// #define %s  LibPcdGetEx%s(&%s, %s)\n' % (GetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
             AutoGenH.Append('// #define %s  LibPcdGetExSize(&%s, %s)\n' % (GetModeSizeName,Pcd.TokenSpaceGuidCName, PcdTokenName))
-            if Pcd.DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN']:
+            if Pcd.DatumType not in _NumericDataTypesList:
                 AutoGenH.Append('// #define %s(SizeOfBuffer, Buffer)  LibPcdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
                 AutoGenH.Append('// #define %s(SizeOfBuffer, Buffer)  LibPcdSetEx%sS(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
             else:
@@ -985,7 +987,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
             AutoGenH.Append('#define %s  %s\n' % (PcdTokenName, PcdExTokenName))
             AutoGenH.Append('#define %s  LibPcdGetEx%s(&%s, %s)\n' % (GetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
             AutoGenH.Append('#define %s LibPcdGetExSize(&%s, %s)\n' % (GetModeSizeName,Pcd.TokenSpaceGuidCName, PcdTokenName))
-            if Pcd.DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN']:
+            if Pcd.DatumType not in _NumericDataTypesList:
                 AutoGenH.Append('#define %s(SizeOfBuffer, Buffer)  LibPcdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
                 AutoGenH.Append('#define %s(SizeOfBuffer, Buffer)  LibPcdSetEx%sS(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
             else:
@@ -1004,7 +1006,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
         else:
             AutoGenH.Append('#define %s  LibPcdGet%s(%s)\n' % (GetModeName, DatumSizeLib, PcdTokenName))
             AutoGenH.Append('#define %s  LibPcdGetSize(%s)\n' % (GetModeSizeName, PcdTokenName))
-            if Pcd.DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN']:
+            if Pcd.DatumType not in _NumericDataTypesList:
                 AutoGenH.Append('#define %s(SizeOfBuffer, Buffer)  LibPcdSet%s(%s, (SizeOfBuffer), (Buffer))\n' %(SetModeName, DatumSizeLib, PcdTokenName))
                 AutoGenH.Append('#define %s(SizeOfBuffer, Buffer)  LibPcdSet%sS(%s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSizeLib, PcdTokenName))
             else:
@@ -1081,7 +1083,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
                                     ExtraData="[%s]" % str(Info))
                 if not Value.endswith('U'):
                     Value += 'U'
-        if Pcd.DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN']:
+        if Pcd.DatumType not in _NumericDataTypesList:
             if Pcd.MaxDatumSize is None or Pcd.MaxDatumSize == '':
                 EdkLogger.error("build", AUTOGEN_ERROR,
                                 "Unknown [MaxDatumSize] of PCD [%s.%s]" % (Pcd.TokenSpaceGuidCName, TokenCName),
@@ -1132,7 +1134,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
         else:
             PcdValueName = '_PCD_VALUE_' + TokenCName
             
-        if Pcd.DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN']:
+        if Pcd.DatumType not in _NumericDataTypesList:
             #
             # For unicode, UINT16 array will be generated, so the alignment of unicode is guaranteed.
             #
@@ -1180,7 +1182,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
             AutoGenH.Append('#define %s  %s%s\n' % (GetModeName, Type, PcdVariableName))
 
         if Pcd.Type == TAB_PCDS_PATCHABLE_IN_MODULE:
-            if Pcd.DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN']:
+            if Pcd.DatumType not in _NumericDataTypesList:
                 AutoGenH.Append('#define %s(SizeOfBuffer, Buffer)  LibPatchPcdSetPtrAndSize((VOID *)_gPcd_BinaryPatch_%s, &_gPcd_BinaryPatch_Size_%s, (UINTN)_PCD_PATCHABLE_%s_SIZE, (SizeOfBuffer), (Buffer))\n' % (SetModeName, Pcd.TokenCName, Pcd.TokenCName, Pcd.TokenCName))
                 AutoGenH.Append('#define %s(SizeOfBuffer, Buffer)  LibPatchPcdSetPtrAndSizeS((VOID *)_gPcd_BinaryPatch_%s, &_gPcd_BinaryPatch_Size_%s, (UINTN)_PCD_PATCHABLE_%s_SIZE, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, Pcd.TokenCName, Pcd.TokenCName, Pcd.TokenCName))
             else:
@@ -1250,7 +1252,7 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd):
 
     Type = ''
     Array = ''
-    if Pcd.DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN']:
+    if Pcd.DatumType not in _NumericDataTypesList:
         if Pcd.DefaultValue[0]== '{':
             Type = '(VOID *)'
         Array = '[]'
@@ -1275,7 +1277,7 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd):
             AutoGenH.Append('// #define %s  %s\n' % (PcdTokenName, PcdExTokenName))
             AutoGenH.Append('// #define %s  LibPcdGetEx%s(&%s, %s)\n' % (GetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
             AutoGenH.Append('// #define %s  LibPcdGetExSize(&%s, %s)\n' % (GetModeSizeName,Pcd.TokenSpaceGuidCName, PcdTokenName))
-            if Pcd.DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN']:
+            if Pcd.DatumType not in _NumericDataTypesList:
                 AutoGenH.Append('// #define %s(SizeOfBuffer, Buffer)  LibPcdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
                 AutoGenH.Append('// #define %s(SizeOfBuffer, Buffer)  LibPcdSetEx%sS(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
             else:
@@ -1285,7 +1287,7 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd):
             AutoGenH.Append('#define %s  %s\n' % (PcdTokenName, PcdExTokenName))
             AutoGenH.Append('#define %s  LibPcdGetEx%s(&%s, %s)\n' % (GetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
             AutoGenH.Append('#define %s LibPcdGetExSize(&%s, %s)\n' % (GetModeSizeName,Pcd.TokenSpaceGuidCName, PcdTokenName))
-            if Pcd.DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN']:
+            if Pcd.DatumType not in _NumericDataTypesList:
                 AutoGenH.Append('#define %s(SizeOfBuffer, Buffer)  LibPcdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
                 AutoGenH.Append('#define %s(SizeOfBuffer, Buffer)  LibPcdSetEx%sS(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
             else:
@@ -1306,7 +1308,7 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd):
         else:
             AutoGenH.Append('#define %s  LibPcdGet%s(%s)\n' % (GetModeName, DatumSizeLib, PcdTokenName))
             AutoGenH.Append('#define %s  LibPcdGetSize(%s)\n' % (GetModeSizeName, PcdTokenName))
-            if DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN']:
+            if DatumType not in _NumericDataTypesList:
                 AutoGenH.Append('#define %s(SizeOfBuffer, Buffer)  LibPcdSet%s(%s, (SizeOfBuffer), (Buffer))\n' %(SetModeName, DatumSizeLib, PcdTokenName))
                 AutoGenH.Append('#define %s(SizeOfBuffer, Buffer)  LibPcdSet%sS(%s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSizeLib, PcdTokenName))
             else:
@@ -1314,7 +1316,7 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd):
                 AutoGenH.Append('#define %s(Value)  LibPcdSet%sS(%s, (Value))\n' % (SetModeStatusName, DatumSizeLib, PcdTokenName))
     if PcdItemType == TAB_PCDS_PATCHABLE_IN_MODULE:
         PcdVariableName = '_gPcd_' + gItemTypeStringDatabase[TAB_PCDS_PATCHABLE_IN_MODULE] + '_' + TokenCName
-        if DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN']:
+        if DatumType not in _NumericDataTypesList:
             ArraySize = int(Pcd.MaxDatumSize, 0)
             if Pcd.DefaultValue[0] == 'L':
                 ArraySize = ArraySize / 2
@@ -1325,7 +1327,7 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd):
             AutoGenH.Append('extern volatile  %s  %s%s;\n' % (DatumType, PcdVariableName, Array))
         AutoGenH.Append('#define %s  %s_gPcd_BinaryPatch_%s\n' %(GetModeName, Type, TokenCName))
         PcdDataSize = GetPcdSize(Pcd)
-        if Pcd.DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN']:
+        if Pcd.DatumType not in _NumericDataTypesList:
             AutoGenH.Append('#define %s(SizeOfBuffer, Buffer)  LibPatchPcdSetPtrAndSize((VOID *)_gPcd_BinaryPatch_%s, &_gPcd_BinaryPatch_Size_%s, (UINTN)_PCD_PATCHABLE_%s_SIZE, (SizeOfBuffer), (Buffer))\n' % (SetModeName, TokenCName, TokenCName, TokenCName))
             AutoGenH.Append('#define %s(SizeOfBuffer, Buffer)  LibPatchPcdSetPtrAndSizeS((VOID *)_gPcd_BinaryPatch_%s, &_gPcd_BinaryPatch_Size_%s, (UINTN)_PCD_PATCHABLE_%s_SIZE, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, TokenCName, TokenCName, TokenCName))
             AutoGenH.Append('#define %s %s\n' % (PatchPcdSizeTokenName, Pcd.MaxDatumSize))
@@ -1349,7 +1351,7 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd):
         AutoGenH.Append('//#define %s  ASSERT(FALSE)  // It is not allowed to set value for a FIXED_AT_BUILD PCD\n' % SetModeName)
         
         if PcdItemType == TAB_PCDS_FIXED_AT_BUILD and (key in Info.ConstPcd or (Info.IsLibrary and not Info._ReferenceModules)):
-            if Pcd.DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN']:
+            if Pcd.DatumType not in _NumericDataTypesList:
                 AutoGenH.Append('#define _PCD_VALUE_%s %s%s\n' %(TokenCName, Type, PcdVariableName))
             else:
                 AutoGenH.Append('#define _PCD_VALUE_%s %s\n' %(TokenCName, Pcd.DefaultValue))
-- 
2.16.2.windows.1



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

* [PATCH v1 02/10] BaseTools: use built in dict instead of custom version.
  2018-04-03 21:03 [PATCH v1 00/10] BaseTools: refactor code Jaben Carsey
  2018-04-03 21:03 ` [PATCH v1 01/10] BaseTools: Use local variable for list of constants Jaben Carsey
@ 2018-04-03 21:03 ` Jaben Carsey
  2018-04-03 21:03 ` [PATCH v1 03/10] BaseTools: Eot tool never populates this dictionary Jaben Carsey
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Jaben Carsey @ 2018-04-03 21:03 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Yonghong Zhu

We dont use any feature added by custom dictionary class.

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/Eot/EotGlobalData.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Source/Python/Eot/EotGlobalData.py b/BaseTools/Source/Python/Eot/EotGlobalData.py
index dd4ff4cf5eb6..a4654853ab5e 100644
--- a/BaseTools/Source/Python/Eot/EotGlobalData.py
+++ b/BaseTools/Source/Python/Eot/EotGlobalData.py
@@ -70,7 +70,7 @@ gSOURCE_FILES = 'Log_SourceFiles.log'
 gOP_SOURCE_FILES = open(gSOURCE_FILES, 'w+')
 
 # Dict for GUID found in DEC files
-gGuidDict = sdict()
+gGuidDict = dict()
 
 # Dict for hard coded GUID Macros
 # {GuidName : [GuidMacro : GuidValue]}
-- 
2.16.2.windows.1



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

* [PATCH v1 03/10] BaseTools: Eot tool never populates this dictionary
  2018-04-03 21:03 [PATCH v1 00/10] BaseTools: refactor code Jaben Carsey
  2018-04-03 21:03 ` [PATCH v1 01/10] BaseTools: Use local variable for list of constants Jaben Carsey
  2018-04-03 21:03 ` [PATCH v1 02/10] BaseTools: use built in dict instead of custom version Jaben Carsey
@ 2018-04-03 21:03 ` Jaben Carsey
  2018-04-03 21:03 ` [PATCH v1 04/10] BaseTools: remove unused import statement Jaben Carsey
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Jaben Carsey @ 2018-04-03 21:03 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Yonghong Zhu

we initialize this dict and then check it's contents, but never add items.
we can remove it without any effect.

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/Eot/Eot.py           | 8 --------
 BaseTools/Source/Python/Eot/EotGlobalData.py | 4 ----
 2 files changed, 12 deletions(-)

diff --git a/BaseTools/Source/Python/Eot/Eot.py b/BaseTools/Source/Python/Eot/Eot.py
index c4164199acf3..45c97bb258f2 100644
--- a/BaseTools/Source/Python/Eot/Eot.py
+++ b/BaseTools/Source/Python/Eot/Eot.py
@@ -340,14 +340,6 @@ class Eot(object):
             GuidMacro2 = ''
             GuidValue = ''
 
-            # Find value for hardcode guid macro
-            if GuidName in EotGlobalData.gGuidMacroDict:
-                GuidMacro = EotGlobalData.gGuidMacroDict[GuidName][0]
-                GuidValue = EotGlobalData.gGuidMacroDict[GuidName][1]
-                SqlCommand = """update Report set GuidMacro = '%s', GuidValue = '%s' where GuidName = '%s'""" %(GuidMacro, GuidValue, GuidName)
-                EotGlobalData.gDb.TblReport.Exec(SqlCommand)
-                continue
-
             # Find guid value defined in Dec file
             if GuidName in EotGlobalData.gGuidDict:
                 GuidValue = EotGlobalData.gGuidDict[GuidName]
diff --git a/BaseTools/Source/Python/Eot/EotGlobalData.py b/BaseTools/Source/Python/Eot/EotGlobalData.py
index a4654853ab5e..dea4206e9d48 100644
--- a/BaseTools/Source/Python/Eot/EotGlobalData.py
+++ b/BaseTools/Source/Python/Eot/EotGlobalData.py
@@ -72,10 +72,6 @@ gOP_SOURCE_FILES = open(gSOURCE_FILES, 'w+')
 # Dict for GUID found in DEC files
 gGuidDict = dict()
 
-# Dict for hard coded GUID Macros
-# {GuidName : [GuidMacro : GuidValue]}
-gGuidMacroDict = sdict()
-
 # Dict for PPI
 gPpiList = {}
 
-- 
2.16.2.windows.1



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

* [PATCH v1 04/10] BaseTools: remove unused import statement
  2018-04-03 21:03 [PATCH v1 00/10] BaseTools: refactor code Jaben Carsey
                   ` (2 preceding siblings ...)
  2018-04-03 21:03 ` [PATCH v1 03/10] BaseTools: Eot tool never populates this dictionary Jaben Carsey
@ 2018-04-03 21:03 ` Jaben Carsey
  2018-04-03 21:03 ` [PATCH v1 05/10] BaseTools - AutoGen - replace custom dictionary class with python standard one Jaben Carsey
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Jaben Carsey @ 2018-04-03 21:03 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/GenFds/GenFds.py | 1 -
 1 file changed, 1 deletion(-)

diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Python/GenFds/GenFds.py
index 49e26424bbfc..810a1f86e948 100644
--- a/BaseTools/Source/Python/GenFds/GenFds.py
+++ b/BaseTools/Source/Python/GenFds/GenFds.py
@@ -24,7 +24,6 @@ import Common.BuildToolError as BuildToolError
 from GenFdsGlobalVariable import GenFdsGlobalVariable
 from Workspace.WorkspaceDatabase import WorkspaceDatabase
 from Workspace.BuildClassObject import PcdClassObject
-from Workspace.BuildClassObject import ModuleBuildClassObject
 import RuleComplexFile
 from EfiSection import EfiSection
 import StringIO
-- 
2.16.2.windows.1



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

* [PATCH v1 05/10] BaseTools - AutoGen - replace custom dictionary class with python standard one
  2018-04-03 21:03 [PATCH v1 00/10] BaseTools: refactor code Jaben Carsey
                   ` (3 preceding siblings ...)
  2018-04-03 21:03 ` [PATCH v1 04/10] BaseTools: remove unused import statement Jaben Carsey
@ 2018-04-03 21:03 ` Jaben Carsey
  2018-04-03 21:03 ` [PATCH v1 06/10] BaseTools: Eot remove unused code Jaben Carsey
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Jaben Carsey @ 2018-04-03 21:03 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Yonghong Zhu

We have a custom ordered dictionary class.  works fine with python OrderedDict version.

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 | 31 ++++++++++----------
 BaseTools/Source/Python/AutoGen/GenMake.py |  3 +-
 2 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 3384fdb70b7e..3865827f26df 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -45,6 +45,7 @@ import InfSectionParser
 import datetime
 import hashlib
 from GenVar import VariableMgr,var_info
+from collections import OrderedDict
 
 ## Regular expression for splitting Dependency Expression string into tokens
 gDepexTokenPattern = re.compile("(\(|\)|\w+| \S+\.inf)")
@@ -892,7 +893,7 @@ class WorkspaceAutoGen(AutoGen):
         ]
 
         # This dict store PCDs which are not used by any modules with specified arches
-        UnusedPcd = sdict()
+        UnusedPcd = OrderedDict()
         for Pa in self.AutoGenObjectList:
             # Key of DSC's Pcds dictionary is PcdCName, TokenSpaceGuid
             for Pcd in Pa.Platform.Pcds:
@@ -2084,7 +2085,7 @@ class PlatformAutoGen(AutoGen):
     ## Generate Token Number for all PCD
     def _GetPcdTokenNumbers(self):
         if self._PcdTokenNumber is None:
-            self._PcdTokenNumber = sdict()
+            self._PcdTokenNumber = OrderedDict()
             TokenNumber = 1
             #
             # Make the Dynamic and DynamicEx PCD use within different TokenNumber area. 
@@ -2207,8 +2208,8 @@ class PlatformAutoGen(AutoGen):
         # EdkII module
         LibraryConsumerList = [Module]
         Constructor         = []
-        ConsumedByList      = sdict()
-        LibraryInstance     = sdict()
+        ConsumedByList      = OrderedDict()
+        LibraryInstance     = OrderedDict()
 
         EdkLogger.verbose("")
         EdkLogger.verbose("Library instances of module [%s] [%s]:" % (str(Module), self.Arch))
@@ -2880,14 +2881,14 @@ class ModuleAutoGen(AutoGen):
         self._DerivedPackageList      = None
         self._ModulePcdList           = None
         self._LibraryPcdList          = None
-        self._PcdComments = sdict()
+        self._PcdComments = OrderedDict()
         self._GuidList                = None
         self._GuidsUsedByPcd = None
-        self._GuidComments = sdict()
+        self._GuidComments = OrderedDict()
         self._ProtocolList            = None
-        self._ProtocolComments = sdict()
+        self._ProtocolComments = OrderedDict()
         self._PpiList                 = None
-        self._PpiComments = sdict()
+        self._PpiComments = OrderedDict()
         self._DepexList               = None
         self._DepexExpressionList     = None
         self._BuildOption             = None
@@ -2943,7 +2944,7 @@ class ModuleAutoGen(AutoGen):
     # Macros could be used in build_rule.txt (also Makefile)
     def _GetMacros(self):
         if self._Macro is None:
-            self._Macro = sdict()
+            self._Macro = OrderedDict()
             self._Macro["WORKSPACE"             ] = self.WorkspaceDir
             self._Macro["MODULE_NAME"           ] = self.Name
             self._Macro["MODULE_NAME_GUID"      ] = self._GetUniqueBaseName()
@@ -3695,7 +3696,7 @@ class ModuleAutoGen(AutoGen):
     #
     def _GetLibraryPcdList(self):
         if self._LibraryPcdList is None:
-            Pcds = sdict()
+            Pcds = OrderedDict()
             if not self.IsLibrary:
                 # get PCDs from dependent libraries
                 for Library in self.DependentLibraryList:
@@ -3717,7 +3718,7 @@ class ModuleAutoGen(AutoGen):
     #
     def _GetGuidList(self):
         if self._GuidList is None:
-            self._GuidList = sdict()
+            self._GuidList = OrderedDict()
             self._GuidList.update(self.Module.Guids)
             for Library in self.DependentLibraryList:
                 self._GuidList.update(Library.Guids)
@@ -3727,7 +3728,7 @@ class ModuleAutoGen(AutoGen):
 
     def GetGuidsUsedByPcd(self):
         if self._GuidsUsedByPcd is None:
-            self._GuidsUsedByPcd = sdict()
+            self._GuidsUsedByPcd = OrderedDict()
             self._GuidsUsedByPcd.update(self.Module.GetGuidsUsedByPcd())
             for Library in self.DependentLibraryList:
                 self._GuidsUsedByPcd.update(Library.GetGuidsUsedByPcd())
@@ -3738,7 +3739,7 @@ class ModuleAutoGen(AutoGen):
     #
     def _GetProtocolList(self):
         if self._ProtocolList is None:
-            self._ProtocolList = sdict()
+            self._ProtocolList = OrderedDict()
             self._ProtocolList.update(self.Module.Protocols)
             for Library in self.DependentLibraryList:
                 self._ProtocolList.update(Library.Protocols)
@@ -3752,7 +3753,7 @@ class ModuleAutoGen(AutoGen):
     #
     def _GetPpiList(self):
         if self._PpiList is None:
-            self._PpiList = sdict()
+            self._PpiList = OrderedDict()
             self._PpiList.update(self.Module.Ppis)
             for Library in self.DependentLibraryList:
                 self._PpiList.update(Library.Ppis)
@@ -3983,7 +3984,7 @@ class ModuleAutoGen(AutoGen):
                     PcdCheckList.append((Pcd.TokenCName, Pcd.TokenSpaceGuidCName, 'DynamicEx'))
                     PcdCheckList.append((Pcd.TokenCName, Pcd.TokenSpaceGuidCName, 'Dynamic'))
                     PcdTokenSpaceList.append(Pcd.TokenSpaceGuidCName)
-        GuidList = sdict()
+        GuidList = OrderedDict()
         GuidList.update(self.GuidList)
         for TokenSpace in self.GetGuidsUsedByPcd():
             # If token space is not referred by patch PCD or Ex PCD, remove the GUID from GUID list
diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/Python/AutoGen/GenMake.py
index dcdfcca1a5b0..533fdb54231c 100644
--- a/BaseTools/Source/Python/AutoGen/GenMake.py
+++ b/BaseTools/Source/Python/AutoGen/GenMake.py
@@ -25,6 +25,7 @@ from Common.Misc import *
 from Common.String import *
 from BuildEngine import *
 import Common.GlobalData as GlobalData
+from collections import OrderedDict
 
 ## Regular expression for finding header file inclusions
 gIncludePattern = re.compile(r"^[ \t]*#?[ \t]*include(?:[ \t]*(?:\\(?:\r\n|\r|\n))*[ \t]*)*(?:\(?[\"<]?[ \t]*)([-\w.\\/() \t]+)(?:[ \t]*[\">]?\)?)", re.MULTILINE | re.UNICODE | re.IGNORECASE)
@@ -442,7 +443,7 @@ cleanlib:
         self.LibraryMakefileList = []
         self.LibraryBuildDirectoryList = []
         self.SystemLibraryList = []
-        self.Macros = sdict()
+        self.Macros = OrderedDict()
         self.Macros["OUTPUT_DIR"      ] = self._AutoGenObject.Macros["OUTPUT_DIR"]
         self.Macros["DEBUG_DIR"       ] = self._AutoGenObject.Macros["DEBUG_DIR"]
         self.Macros["MODULE_BUILD_DIR"] = self._AutoGenObject.Macros["MODULE_BUILD_DIR"]
-- 
2.16.2.windows.1



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

* [PATCH v1 06/10] BaseTools: Eot remove unused code
  2018-04-03 21:03 [PATCH v1 00/10] BaseTools: refactor code Jaben Carsey
                   ` (4 preceding siblings ...)
  2018-04-03 21:03 ` [PATCH v1 05/10] BaseTools - AutoGen - replace custom dictionary class with python standard one Jaben Carsey
@ 2018-04-03 21:03 ` Jaben Carsey
  2018-04-03 21:03 ` [PATCH v1 07/10] BaseTools: use built in OrderedDict instead of custom version Jaben Carsey
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Jaben Carsey @ 2018-04-03 21:03 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Yonghong Zhu

2 functions and a dictionary that are not used.

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/Eot/FvImage.py | 21 --------------------
 1 file changed, 21 deletions(-)

diff --git a/BaseTools/Source/Python/Eot/FvImage.py b/BaseTools/Source/Python/Eot/FvImage.py
index affca4e71e8a..472ae400506d 100644
--- a/BaseTools/Source/Python/Eot/FvImage.py
+++ b/BaseTools/Source/Python/Eot/FvImage.py
@@ -138,7 +138,6 @@ class FirmwareVolume(Image):
         self.FfsDict = sdict()
         self.OrderedFfsDict = sdict()
         self.UnDispatchedFfsDict = sdict()
-        self.NoDepexFfsDict = sdict()
         self.ProtocolList = sdict()
 
     def CheckArchProtocol(self):
@@ -284,26 +283,6 @@ class FirmwareVolume(Image):
 
         self.DisPatchDxe(Db)
 
-    def DisPatchNoDepexFfs(self, Db):
-        # Last Load Drivers without Depex
-        for FfsID in self.NoDepexFfsDict:
-            NewFfs = self.NoDepexFfsDict.pop(FfsID)
-            self.OrderedFfsDict[FfsID] = NewFfs
-            self.LoadProtocol(Db, FfsID)
-
-        return True
-
-    def LoadCallbackProtocol(self):
-        IsLoad = True
-        for Protocol in self.ProtocolList:
-            for Callback in self.ProtocolList[Protocol][1]:
-                if Callback[0] not in self.OrderedFfsDict.keys():
-                    IsLoad = False
-                    continue
-            if IsLoad:
-                EotGlobalData.gProtocolList[Protocol.lower()] = self.ProtocolList[Protocol][0]
-                self.ProtocolList.pop(Protocol)
-
     def LoadProtocol(self, Db, ModuleGuid):
         SqlCommand = """select GuidValue from Report
                         where SourceFileFullPath in
-- 
2.16.2.windows.1



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

* [PATCH v1 07/10] BaseTools: use built in OrderedDict instead of custom version.
  2018-04-03 21:03 [PATCH v1 00/10] BaseTools: refactor code Jaben Carsey
                   ` (5 preceding siblings ...)
  2018-04-03 21:03 ` [PATCH v1 06/10] BaseTools: Eot remove unused code Jaben Carsey
@ 2018-04-03 21:03 ` Jaben Carsey
  2018-04-03 21:03 ` [PATCH v1 08/10] BaseTools: use combined version of OrderedDict Jaben Carsey
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Jaben Carsey @ 2018-04-03 21:03 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Yonghong Zhu

We dont use any feature added by custom dictionary class.

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/DscClassObject.py        |  4 ++--
 BaseTools/Source/Python/Common/EdkIIWorkspaceBuild.py   | 10 ++++----
 BaseTools/Source/Python/CommonDataClass/PackageClass.py |  4 ++--
 BaseTools/Source/Python/Eot/EotGlobalData.py            | 10 ++++----
 BaseTools/Source/Python/Eot/Parser.py                   |  3 +--
 BaseTools/Source/Python/Workspace/BuildClassObject.py   |  4 ++--
 BaseTools/Source/Python/Workspace/DecBuildData.py       | 24 ++++++++++----------
 BaseTools/Source/Python/build/build.py                  | 10 ++++----
 8 files changed, 35 insertions(+), 34 deletions(-)

diff --git a/BaseTools/Source/Python/Common/DscClassObject.py b/BaseTools/Source/Python/Common/DscClassObject.py
index da3101ae0fe9..cff9ab0eefb2 100644
--- a/BaseTools/Source/Python/Common/DscClassObject.py
+++ b/BaseTools/Source/Python/Common/DscClassObject.py
@@ -25,7 +25,7 @@ from Dictionary import *
 from CommonDataClass.PlatformClass import *
 from CommonDataClass.CommonClass import SkuInfoClass
 from BuildToolError import *
-from Misc import sdict
+from collections import OrderedDict
 import GlobalData
 from Table.TableDsc import TableDsc
 from Common.LongFilePathSupport import OpenLongFilePath as open
@@ -732,7 +732,7 @@ class Dsc(object):
     #
     def GenComponents(self, ContainerFile):
         EdkLogger.debug(2, "Generate %s ..." % TAB_COMPONENTS)
-        Components = sdict()
+        Components = OrderedDict()
         #
         # Get all include files
         #
diff --git a/BaseTools/Source/Python/Common/EdkIIWorkspaceBuild.py b/BaseTools/Source/Python/Common/EdkIIWorkspaceBuild.py
index c0966d526519..c4f45b7c59c2 100644
--- a/BaseTools/Source/Python/Common/EdkIIWorkspaceBuild.py
+++ b/BaseTools/Source/Python/Common/EdkIIWorkspaceBuild.py
@@ -22,7 +22,7 @@ from DecClassObject import *
 from DscClassObject import *
 from String import *
 from BuildToolError import *
-from Misc import sdict
+from collections import OrderedDict
 import Database as Database
 import time as time
 
@@ -189,7 +189,7 @@ class ModuleBuildClassObject(object):
 
         self.Binaries                = []
         self.Sources                 = []
-        self.LibraryClasses          = sdict()
+        self.LibraryClasses          = OrderedDict()
         self.Libraries               = []
         self.Protocols               = []
         self.Ppis                    = []
@@ -955,8 +955,8 @@ class WorkspaceBuild(object):
         # EdkII module
         LibraryConsumerList = [Module]
         Constructor         = []
-        ConsumedByList      = sdict()
-        LibraryInstance     = sdict()
+        ConsumedByList      = OrderedDict()
+        LibraryInstance     = OrderedDict()
 
         EdkLogger.verbose("")
         EdkLogger.verbose("Library instances of module [%s] [%s]:" % (str(Module), Arch))
@@ -1097,7 +1097,7 @@ class WorkspaceBuild(object):
         # The DAG Topo sort produces the destructor order, so the list of constructors must generated in the reverse order
         #
         SortedLibraryList.reverse()
-        Module.LibraryClasses = sdict()
+        Module.LibraryClasses = OrderedDict()
         for L in SortedLibraryList:
             for Lc in L.LibraryClass:
                 Module.LibraryClasses[Lc.LibraryClass, ModuleType] = str(L)
diff --git a/BaseTools/Source/Python/CommonDataClass/PackageClass.py b/BaseTools/Source/Python/CommonDataClass/PackageClass.py
index 89d4d0797fe1..ba7d7eb67911 100644
--- a/BaseTools/Source/Python/CommonDataClass/PackageClass.py
+++ b/BaseTools/Source/Python/CommonDataClass/PackageClass.py
@@ -14,7 +14,7 @@
 # Import Modules
 #
 from CommonClass import *
-from Common.Misc import sdict
+from collections import OrderedDict
 
 ## PackageHeaderClass
 #
@@ -107,7 +107,7 @@ class PackageClass(object):
         self.IndustryStdHeaders = []
         self.ModuleFiles = []
         # {[Guid, Value, Path(relative to WORKSPACE)]: ModuleClassObj}
-        self.Modules = sdict()
+        self.Modules = OrderedDict()
         self.PackageIncludePkgHeaders = []
         self.GuidDeclarations = []
         self.ProtocolDeclarations = []
diff --git a/BaseTools/Source/Python/Eot/EotGlobalData.py b/BaseTools/Source/Python/Eot/EotGlobalData.py
index dea4206e9d48..7689b76da9d6 100644
--- a/BaseTools/Source/Python/Eot/EotGlobalData.py
+++ b/BaseTools/Source/Python/Eot/EotGlobalData.py
@@ -11,7 +11,7 @@
 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #
 
-from Common.Misc import sdict
+from collections import OrderedDict
 from Common.LongFilePathSupport import OpenLongFilePath as open
 
 gEFI_SOURCE = ''
@@ -79,12 +79,12 @@ gPpiList = {}
 gProtocolList = {}
 
 # Dict for consumed PPI function calling
-gConsumedPpiLibrary = sdict()
+gConsumedPpiLibrary = OrderedDict()
 gConsumedPpiLibrary['EfiCommonLocateInterface'] = 0
 gConsumedPpiLibrary['PeiServicesLocatePpi'] = 0
 
 # Dict for produced PROTOCOL function calling
-gProducedProtocolLibrary = sdict()
+gProducedProtocolLibrary = OrderedDict()
 gProducedProtocolLibrary['RegisterEsalClass'] = 0
 gProducedProtocolLibrary['CoreInstallProtocolInterface'] = 1
 gProducedProtocolLibrary['CoreInstallMultipleProtocolInterfaces'] = -1
@@ -95,14 +95,14 @@ gProducedProtocolLibrary['LibInstallProtocolInterfaces'] = 1
 gProducedProtocolLibrary['LibReinstallProtocolInterfaces'] = 1
 
 # Dict for consumed PROTOCOL function calling
-gConsumedProtocolLibrary = sdict()
+gConsumedProtocolLibrary = OrderedDict()
 gConsumedProtocolLibrary['EfiHandleProtocol'] = 0
 gConsumedProtocolLibrary['EfiLocateProtocolHandleBuffers'] = 0
 gConsumedProtocolLibrary['EfiLocateProtocolInterface'] = 0
 gConsumedProtocolLibrary['EfiHandleProtocol'] = 1
 
 # Dict for callback PROTOCOL function callling
-gCallbackProtocolLibrary = sdict()
+gCallbackProtocolLibrary = OrderedDict()
 gCallbackProtocolLibrary['EfiRegisterProtocolCallback'] = 2
 
 # Dict for ARCH PROTOCOL
diff --git a/BaseTools/Source/Python/Eot/Parser.py b/BaseTools/Source/Python/Eot/Parser.py
index ab19e30b69aa..14c287588a01 100644
--- a/BaseTools/Source/Python/Eot/Parser.py
+++ b/BaseTools/Source/Python/Eot/Parser.py
@@ -21,7 +21,6 @@ from Common.DataType import *
 from CommonDataClass.DataClass import *
 from Common.String import CleanString, GetSplitValueList, ReplaceMacro
 import EotGlobalData
-from Common.Misc import sdict
 from Common.String import GetSplitList
 from Common.LongFilePathSupport import OpenLongFilePath as open
 
@@ -623,7 +622,7 @@ def SearchProtocols(SqlCommand, Table, SourceFileID, SourceFileFullPath, ItemMod
 #  @param ItemMode: Mode of item
 #
 def SearchFunctionCalling(Table, SourceFileID, SourceFileFullPath, ItemType, ItemMode):
-    LibraryList = sdict()
+    LibraryList = {}
     Db = EotGlobalData.gDb.TblReport
     Parameters, ItemName, GuidName, GuidMacro, GuidValue, BelongsToFunction = [], '', '', '', '', ''
     if ItemType == 'Protocol' and ItemMode == 'Produced':
diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py b/BaseTools/Source/Python/Workspace/BuildClassObject.py
index 90c8246806d8..e95a8fd24b94 100644
--- a/BaseTools/Source/Python/Workspace/BuildClassObject.py
+++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py
@@ -13,7 +13,7 @@
 
 import Common.LongFilePathOs as os
 
-from Common.Misc import sdict
+from collections import OrderedDict
 from Common.Misc import RealPath2
 from Common.BuildToolError import *
 from Common.DataType import *
@@ -281,7 +281,7 @@ class ModuleBuildClassObject(object):
 
         self.Binaries                = []
         self.Sources                 = []
-        self.LibraryClasses          = sdict()
+        self.LibraryClasses          = OrderedDict()
         self.Libraries               = []
         self.Protocols               = []
         self.Ppis                    = []
diff --git a/BaseTools/Source/Python/Workspace/DecBuildData.py b/BaseTools/Source/Python/Workspace/DecBuildData.py
index 49ef1df4aa76..ccd6cc6a3754 100644
--- a/BaseTools/Source/Python/Workspace/DecBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DecBuildData.py
@@ -199,9 +199,9 @@ class DecBuildData(PackageBuildClassObject):
                 if Name not in NameList:
                     NameList.append(Name)
                 ProtocolDict[Arch, Name] = Guid
-            # use sdict to keep the order
-            self._Protocols = sdict()
-            self._PrivateProtocols = sdict()
+            # use OrderedDict to keep the order
+            self._Protocols = OrderedDict()
+            self._PrivateProtocols = OrderedDict()
             for Name in NameList:
                 #
                 # limit the ARCH to self._Arch, if no self._Arch found, tdict
@@ -241,9 +241,9 @@ class DecBuildData(PackageBuildClassObject):
                 if Name not in NameList:
                     NameList.append(Name)
                 PpiDict[Arch, Name] = Guid
-            # use sdict to keep the order
-            self._Ppis = sdict()
-            self._PrivatePpis = sdict()
+            # use OrderedDict to keep the order
+            self._Ppis = OrderedDict()
+            self._PrivatePpis = OrderedDict()
             for Name in NameList:
                 #
                 # limit the ARCH to self._Arch, if no self._Arch found, tdict
@@ -283,9 +283,9 @@ class DecBuildData(PackageBuildClassObject):
                 if Name not in NameList:
                     NameList.append(Name)
                 GuidDict[Arch, Name] = Guid
-            # use sdict to keep the order
-            self._Guids = sdict()
-            self._PrivateGuids = sdict()
+            # use OrderedDict to keep the order
+            self._Guids = OrderedDict()
+            self._PrivateGuids = OrderedDict()
             for Name in NameList:
                 #
                 # limit the ARCH to self._Arch, if no self._Arch found, tdict
@@ -350,7 +350,7 @@ class DecBuildData(PackageBuildClassObject):
                     EdkLogger.error('build', ErrorCode, ExtraData=ErrorInfo, File=self.MetaFile, Line=LineNo)
                 LibraryClassSet.add(LibraryClass)
                 LibraryClassDict[Arch, LibraryClass] = File
-            self._LibraryClasses = sdict()
+            self._LibraryClasses = OrderedDict()
             for LibraryClass in LibraryClassSet:
                 self._LibraryClasses[LibraryClass] = LibraryClassDict[self._Arch, LibraryClass]
         return self._LibraryClasses
@@ -358,7 +358,7 @@ class DecBuildData(PackageBuildClassObject):
     ## Retrieve PCD declarations
     def _GetPcds(self):
         if self._Pcds is None:
-            self._Pcds = sdict()
+            self._Pcds = OrderedDict()
             self._Pcds.update(self._GetPcd(MODEL_PCD_FIXED_AT_BUILD))
             self._Pcds.update(self._GetPcd(MODEL_PCD_PATCHABLE_IN_MODULE))
             self._Pcds.update(self._GetPcd(MODEL_PCD_FEATURE_FLAG))
@@ -399,7 +399,7 @@ class DecBuildData(PackageBuildClassObject):
 
     ## Retrieve PCD declarations for given type
     def _GetPcd(self, Type):
-        Pcds = sdict()
+        Pcds = OrderedDict()
         #
         # tdict is a special kind of dict, used for selecting correct
         # PCD declaration for given ARCH
diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/build/build.py
index f211f8c64116..4aca28098462 100644
--- a/BaseTools/Source/Python/build/build.py
+++ b/BaseTools/Source/Python/build/build.py
@@ -53,6 +53,8 @@ import Common.EdkLogger
 import Common.GlobalData as GlobalData
 from GenFds.GenFds import GenFds
 
+from collections import OrderedDict
+
 # Version and Copyright
 VersionNumber = "0.60" + ' ' + gBUILD_VERSION
 __version__ = "%prog Version " + VersionNumber
@@ -438,19 +440,19 @@ class PlatformMakeUnit(BuildUnit):
 #
 class BuildTask:
     # queue for tasks waiting for schedule
-    _PendingQueue = sdict()
+    _PendingQueue = OrderedDict()
     _PendingQueueLock = threading.Lock()
 
     # queue for tasks ready for running
-    _ReadyQueue = sdict()
+    _ReadyQueue = OrderedDict()
     _ReadyQueueLock = threading.Lock()
 
     # queue for run tasks
-    _RunningQueue = sdict()
+    _RunningQueue = OrderedDict()
     _RunningQueueLock = threading.Lock()
 
     # queue containing all build tasks, in case duplicate build
-    _TaskQueue = sdict()
+    _TaskQueue = OrderedDict()
 
     # flag indicating error occurs in a running thread
     _ErrorFlag = threading.Event()
-- 
2.16.2.windows.1



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

* [PATCH v1 08/10] BaseTools: use combined version of OrderedDict
  2018-04-03 21:03 [PATCH v1 00/10] BaseTools: refactor code Jaben Carsey
                   ` (6 preceding siblings ...)
  2018-04-03 21:03 ` [PATCH v1 07/10] BaseTools: use built in OrderedDict instead of custom version Jaben Carsey
@ 2018-04-03 21:03 ` Jaben Carsey
  2018-04-03 21:03 ` [PATCH v1 09/10] BaseTools: Workspace - use built in OrderedDict instead of custom version Jaben Carsey
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Jaben Carsey @ 2018-04-03 21:03 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Yonghong Zhu

since we need order and a default entry, use collections dicts to
auto generate.

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/WorkspaceCommon.py | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py
index abe34cf9a071..8c27b4ad5b9b 100644
--- a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py
+++ b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py
@@ -12,11 +12,17 @@
 #
 
 from Common.Misc import sdict
+from collections import OrderedDict, defaultdict
 from Common.DataType import SUP_MODULE_USER_DEFINED
 from BuildClassObject import LibraryClassObject
 import Common.GlobalData as GlobalData
 from Workspace.BuildClassObject import StructurePcd
 
+class OrderedListDict(OrderedDict, defaultdict):
+    def __init__(self, *args, **kwargs):
+        super(OrderedListDict, self).__init__(*args, **kwargs)
+        self.default_factory = list
+
 ## Get all packages from platform for specified arch, target and toolchain
 #
 #  @param Platform: DscBuildData instance
@@ -106,7 +112,7 @@ def _GetModuleLibraryInstances(Module, Platform, BuildDatabase, Arch, Target, To
     # EdkII module
     LibraryConsumerList = [Module]
     Constructor = []
-    ConsumedByList = sdict()
+    ConsumedByList = OrderedListDict()
     LibraryInstance = sdict()
 
     while len(LibraryConsumerList) > 0:
@@ -145,8 +151,6 @@ def _GetModuleLibraryInstances(Module, Platform, BuildDatabase, Arch, Target, To
             if LibraryModule.ConstructorList != [] and LibraryModule not in Constructor:
                 Constructor.append(LibraryModule)
 
-            if LibraryModule not in ConsumedByList:
-                ConsumedByList[LibraryModule] = []
             # don't add current module itself to consumer list
             if M != Module:
                 if M in ConsumedByList[LibraryModule]:
@@ -164,7 +168,7 @@ def _GetModuleLibraryInstances(Module, Platform, BuildDatabase, Arch, Target, To
     for LibraryClassName in LibraryInstance:
         M = LibraryInstance[LibraryClassName]
         LibraryList.append(M)
-        if ConsumedByList[M] == []:
+        if len(ConsumedByList[M]) == 0:
             Q.append(M)
 
     #
@@ -185,7 +189,7 @@ def _GetModuleLibraryInstances(Module, Platform, BuildDatabase, Arch, Target, To
                     # remove edge e from the graph if Node has no constructor
                     ConsumedByList[Item].remove(Node)
                     EdgeRemoved = True
-                    if ConsumedByList[Item] == []:
+                    if len(ConsumedByList[Item]) == 0:
                         # insert Item into Q
                         Q.insert(0, Item)
                         break
@@ -207,7 +211,7 @@ def _GetModuleLibraryInstances(Module, Platform, BuildDatabase, Arch, Target, To
             # remove edge e from the graph
             ConsumedByList[Item].remove(Node)
 
-            if ConsumedByList[Item] != []:
+            if len(ConsumedByList[Item]) != 0:
                 continue
             # insert Item into Q, if Item has no other incoming edges
             Q.insert(0, Item)
@@ -216,7 +220,7 @@ def _GetModuleLibraryInstances(Module, Platform, BuildDatabase, Arch, Target, To
     # if any remaining node Item in the graph has a constructor and an incoming edge, then the graph has a cycle
     #
     for Item in LibraryList:
-        if ConsumedByList[Item] != [] and Item in Constructor and len(Constructor) > 1:
+        if len(ConsumedByList[Item]) != 0 and Item in Constructor and len(Constructor) > 1:
             return []
         if Item not in SortedLibraryList:
             SortedLibraryList.append(Item)
-- 
2.16.2.windows.1



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

* [PATCH v1 09/10] BaseTools: Workspace - use built in OrderedDict instead of custom version.
  2018-04-03 21:03 [PATCH v1 00/10] BaseTools: refactor code Jaben Carsey
                   ` (7 preceding siblings ...)
  2018-04-03 21:03 ` [PATCH v1 08/10] BaseTools: use combined version of OrderedDict Jaben Carsey
@ 2018-04-03 21:03 ` Jaben Carsey
  2018-04-03 21:03 ` [PATCH v1 10/10] BaseTools: Remove unused code from Misc Jaben Carsey
  2018-04-08  6:40 ` [PATCH v1 00/10] BaseTools: refactor code Zhu, Yonghong
  10 siblings, 0 replies; 12+ messages in thread
From: Jaben Carsey @ 2018-04-03 21:03 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Yonghong Zhu

We dont use any feature added by custom dictionary class.

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    | 24 ++++-----
 BaseTools/Source/Python/Workspace/InfBuildData.py    | 52 +++++++++-----------
 BaseTools/Source/Python/Workspace/WorkspaceCommon.py |  3 +-
 3 files changed, 36 insertions(+), 43 deletions(-)

diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py
index cf9608651269..6766f059b0f7 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -635,7 +635,7 @@ class DscBuildData(PlatformBuildClassObject):
     ## Retrieve [SkuIds] section information
     def _GetSkuIds(self):
         if self._SkuIds is None:
-            self._SkuIds = sdict()
+            self._SkuIds = OrderedDict()
             RecordList = self._RawData[MODEL_EFI_SKU_ID, self._Arch]
             for Record in RecordList:
                 if Record[0] in [None, '']:
@@ -662,7 +662,7 @@ class DscBuildData(PlatformBuildClassObject):
         return int(intstr,16) if intstr.upper().startswith("0X") else int(intstr)
     def _GetDefaultStores(self):
         if self.DefaultStores is None:
-            self.DefaultStores = sdict()
+            self.DefaultStores = OrderedDict()
             RecordList = self._RawData[MODEL_EFI_DEFAULT_STORES, self._Arch]
             for Record in RecordList:
                 if Record[0] in [None, '']:
@@ -692,7 +692,7 @@ class DscBuildData(PlatformBuildClassObject):
         if self._Modules is not None:
             return self._Modules
 
-        self._Modules = sdict()
+        self._Modules = OrderedDict()
         RecordList = self._RawData[MODEL_META_DATA_COMPONENT, self._Arch]
         Macros = self._Macros
         Macros["EDK_SOURCE"] = GlobalData.gEcpSource
@@ -1122,7 +1122,7 @@ class DscBuildData(PlatformBuildClassObject):
     ## Retrieve all PCD settings in platform
     def _GetPcds(self):
         if self._Pcds is None:
-            self._Pcds = sdict()
+            self._Pcds = OrderedDict()
             self.__ParsePcdFromCommandLine()
             self._Pcds.update(self._GetPcd(MODEL_PCD_FIXED_AT_BUILD))
             self._Pcds.update(self._GetPcd(MODEL_PCD_PATCHABLE_IN_MODULE))
@@ -1157,7 +1157,7 @@ class DscBuildData(PlatformBuildClassObject):
     ## Retrieve [BuildOptions]
     def _GetBuildOptions(self):
         if self._BuildOptions is None:
-            self._BuildOptions = sdict()
+            self._BuildOptions = OrderedDict()
             #
             # Retrieve build option for EDKII and EDK style module
             #
@@ -1179,9 +1179,9 @@ class DscBuildData(PlatformBuildClassObject):
 
     def GetBuildOptionsByModuleType(self, Edk, ModuleType):
         if self._ModuleTypeOptions is None:
-            self._ModuleTypeOptions = sdict()
+            self._ModuleTypeOptions = OrderedDict()
         if (Edk, ModuleType) not in self._ModuleTypeOptions:
-            options = sdict()
+            options = OrderedDict()
             self._ModuleTypeOptions[Edk, ModuleType] = options
             DriverType = '%s.%s' % (Edk, ModuleType)
             CommonDriverType = '%s.%s' % ('COMMON', ModuleType)
@@ -1446,7 +1446,7 @@ class DscBuildData(PlatformBuildClassObject):
     #   @retval a dict object contains settings of given PCD type
     #
     def _GetPcd(self, Type):
-        Pcds = sdict()
+        Pcds = OrderedDict()
         #
         # tdict is a special dict kind of type, used for selecting correct
         # PCD settings for certain ARCH
@@ -1457,7 +1457,7 @@ class DscBuildData(PlatformBuildClassObject):
         PcdSet = set()
         # Find out all possible PCD candidates for self._Arch
         RecordList = self._RawData[Type, self._Arch]
-        PcdValueDict = sdict()
+        PcdValueDict = OrderedDict()
         for TokenSpaceGuid, PcdCName, Setting, Arch, SkuName, Dummy3, Dummy4,Dummy5 in RecordList:
             SkuName = SkuName.upper()
             SkuName = 'DEFAULT' if SkuName == 'COMMON' else SkuName
@@ -2230,7 +2230,7 @@ class DscBuildData(PlatformBuildClassObject):
     def _GetDynamicPcd(self, Type):
 
 
-        Pcds = sdict()
+        Pcds = OrderedDict()
         #
         # tdict is a special dict kind of type, used for selecting correct
         # PCD settings for certain ARCH and SKU
@@ -2395,7 +2395,7 @@ class DscBuildData(PlatformBuildClassObject):
 
         VariableAttrs = {}
 
-        Pcds = sdict()
+        Pcds = OrderedDict()
         #
         # tdict is a special dict kind of type, used for selecting correct
         # PCD settings for certain ARCH and SKU
@@ -2557,7 +2557,7 @@ class DscBuildData(PlatformBuildClassObject):
     def _GetDynamicVpdPcd(self, Type):
 
 
-        Pcds = sdict()
+        Pcds = OrderedDict()
         #
         # tdict is a special dict kind of type, used for selecting correct
         # PCD settings for certain ARCH and SKU
diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py b/BaseTools/Source/Python/Workspace/InfBuildData.py
index ded8f610c9c1..a7ffd43a0972 100644
--- a/BaseTools/Source/Python/Workspace/InfBuildData.py
+++ b/BaseTools/Source/Python/Workspace/InfBuildData.py
@@ -1,7 +1,7 @@
 ## @file
 # This file is used to create a database used by build tool
 #
-# Copyright (c) 2008 - 2017, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>
 # (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
 # This program and the accompanying materials
 # are licensed and made available under the terms and conditions of the BSD License
@@ -17,6 +17,7 @@ from Common.DataType import *
 from Common.Misc import *
 from types import *
 from MetaFileParser import *
+from collections import OrderedDict
 
 from Workspace.BuildClassObject import ModuleBuildClassObject, LibraryClassObject, PcdClassObject
 ## Module build information from INF file
@@ -156,7 +157,7 @@ class InfBuildData(ModuleBuildClassObject):
         self._ModuleUnloadImageList = None
         self._ConstructorList       = None
         self._DestructorList        = None
-        self._Defs                  = None
+        self._Defs                  = OrderedDict()
         self._Binaries              = None
         self._Sources               = None
         self._LibraryClasses        = None
@@ -166,7 +167,7 @@ class InfBuildData(ModuleBuildClassObject):
         self._Ppis                  = None
         self._PpiComments           = None
         self._Guids                 = None
-        self._GuidsUsedByPcd        = sdict()
+        self._GuidsUsedByPcd        = OrderedDict()
         self._GuidComments          = None
         self._Includes              = None
         self._Packages              = None
@@ -246,8 +247,6 @@ class InfBuildData(ModuleBuildClassObject):
             # items defined _PROPERTY_ don't need additional processing
             if Name in self:
                 self[Name] = Value
-                if self._Defs is None:
-                    self._Defs = sdict()
                 self._Defs[Name] = Value
                 self._Macros[Name] = Value
             # some special items in [Defines] section need special treatment
@@ -255,7 +254,7 @@ class InfBuildData(ModuleBuildClassObject):
                 if Name in ('EFI_SPECIFICATION_VERSION', 'UEFI_SPECIFICATION_VERSION'):
                     Name = 'UEFI_SPECIFICATION_VERSION'
                 if self._Specification is None:
-                    self._Specification = sdict()
+                    self._Specification = OrderedDict()
                 self._Specification[Name] = GetHexVerValue(Value)
                 if self._Specification[Name] is None:
                     EdkLogger.error("build", FORMAT_NOT_SUPPORTED,
@@ -307,8 +306,6 @@ class InfBuildData(ModuleBuildClassObject):
                                         File=self.MetaFile, Line=Record[-1])
                     self._CustomMakefile[TokenList[0]] = TokenList[1]
             else:
-                if self._Defs is None:
-                    self._Defs = sdict()
                 self._Defs[Name] = Value
                 self._Macros[Name] = Value
 
@@ -337,14 +334,14 @@ class InfBuildData(ModuleBuildClassObject):
                     EdkLogger.error("build", FORMAT_NOT_SUPPORTED, "MM_CORE_STANDALONE module type can't be used in the module with PI_SPECIFICATION_VERSION less than 0x00010032", File=self.MetaFile)
                 if self._ModuleType == SUP_MODULE_MM_STANDALONE:
                     EdkLogger.error("build", FORMAT_NOT_SUPPORTED, "MM_STANDALONE module type can't be used in the module with PI_SPECIFICATION_VERSION less than 0x00010032", File=self.MetaFile)
-            if self._Defs and 'PCI_DEVICE_ID' in self._Defs and 'PCI_VENDOR_ID' in self._Defs \
+            if 'PCI_DEVICE_ID' in self._Defs and 'PCI_VENDOR_ID' in self._Defs \
                and 'PCI_CLASS_CODE' in self._Defs and 'PCI_REVISION' in self._Defs:
                 self._BuildType = 'UEFI_OPTIONROM'
                 if 'PCI_COMPRESS' in self._Defs:
                     if self._Defs['PCI_COMPRESS'] not in ('TRUE', 'FALSE'):
                         EdkLogger.error("build", FORMAT_INVALID, "Expected TRUE/FALSE for PCI_COMPRESS: %s" % self.MetaFile)
 
-            elif self._Defs and 'UEFI_HII_RESOURCE_SECTION' in self._Defs \
+            elif 'UEFI_HII_RESOURCE_SECTION' in self._Defs \
                and self._Defs['UEFI_HII_RESOURCE_SECTION'] == 'TRUE':
                 self._BuildType = 'UEFI_HII'
             else:
@@ -398,7 +395,7 @@ class InfBuildData(ModuleBuildClassObject):
 #                                       File=self.MetaFile, Line=LineNo)
                     else:
                         if self._BuildOptions is None:
-                            self._BuildOptions = sdict()
+                            self._BuildOptions = OrderedDict()
 
                         if ToolList[0] in self._TOOL_CODE_:
                             Tool = self._TOOL_CODE_[ToolList[0]]
@@ -590,11 +587,8 @@ class InfBuildData(ModuleBuildClassObject):
 
     ## Retrieve definies other than above ones
     def _GetDefines(self):
-        if self._Defs is None:
-            if self._Header_ is None:
-                self._GetHeaderInfo()
-            if self._Defs is None:
-                self._Defs = sdict()
+        if len(self._Defs) == 0 and self._Header_ is None:
+            self._GetHeaderInfo()
         return self._Defs
 
     ## Retrieve binary files
@@ -688,7 +682,7 @@ class InfBuildData(ModuleBuildClassObject):
     ## Retrieve library classes employed by this module
     def _GetLibraryClassUses(self):
         if self._LibraryClasses is None:
-            self._LibraryClasses = sdict()
+            self._LibraryClasses = OrderedDict()
             RecordList = self._RawData[MODEL_EFI_LIBRARY_CLASS, self._Arch, self._Platform]
             for Record in RecordList:
                 Lib = Record[0]
@@ -717,8 +711,8 @@ class InfBuildData(ModuleBuildClassObject):
     ## Retrieve protocols consumed/produced by this module
     def _GetProtocols(self):
         if self._Protocols is None:
-            self._Protocols = sdict()
-            self._ProtocolComments = sdict()
+            self._Protocols = OrderedDict()
+            self._ProtocolComments = OrderedDict()
             RecordList = self._RawData[MODEL_EFI_PROTOCOL, self._Arch, self._Platform]
             for Record in RecordList:
                 CName = Record[0]
@@ -742,8 +736,8 @@ class InfBuildData(ModuleBuildClassObject):
     ## Retrieve PPIs consumed/produced by this module
     def _GetPpis(self):
         if self._Ppis is None:
-            self._Ppis = sdict()
-            self._PpiComments = sdict()
+            self._Ppis = OrderedDict()
+            self._PpiComments = OrderedDict()
             RecordList = self._RawData[MODEL_EFI_PPI, self._Arch, self._Platform]
             for Record in RecordList:
                 CName = Record[0]
@@ -767,8 +761,8 @@ class InfBuildData(ModuleBuildClassObject):
     ## Retrieve GUIDs consumed/produced by this module
     def _GetGuids(self):
         if self._Guids is None:
-            self._Guids = sdict()
-            self._GuidComments = sdict()
+            self._Guids = OrderedDict()
+            self._GuidComments = OrderedDict()
             RecordList = self._RawData[MODEL_EFI_GUID, self._Arch, self._Platform]
             for Record in RecordList:
                 CName = Record[0]
@@ -869,8 +863,8 @@ class InfBuildData(ModuleBuildClassObject):
     ## Retrieve PCDs used in this module
     def _GetPcds(self):
         if self._Pcds is None:
-            self._Pcds = sdict()
-            self._PcdComments = sdict()
+            self._Pcds = OrderedDict()
+            self._PcdComments = OrderedDict()
             self._Pcds.update(self._GetPcd(MODEL_PCD_FIXED_AT_BUILD))
             self._Pcds.update(self._GetPcd(MODEL_PCD_PATCHABLE_IN_MODULE))
             self._Pcds.update(self._GetPcd(MODEL_PCD_FEATURE_FLAG))
@@ -881,7 +875,7 @@ class InfBuildData(ModuleBuildClassObject):
     ## Retrieve build options specific to this module
     def _GetBuildOptions(self):
         if self._BuildOptions is None:
-            self._BuildOptions = sdict()
+            self._BuildOptions = OrderedDict()
             RecordList = self._RawData[MODEL_META_DATA_BUILD_OPTION, self._Arch, self._Platform]
             for Record in RecordList:
                 ToolChainFamily = Record[0]
@@ -920,7 +914,7 @@ class InfBuildData(ModuleBuildClassObject):
                                         "'%s' module must specify the type of [Depex] section" % self.ModuleType,
                                         File=self.MetaFile)
 
-            Depex = sdict()
+            Depex = OrderedDict()
             for Record in RecordList:
                 DepexStr = ReplaceMacro(Record[0], self._Macros, False)
                 Arch = Record[3]
@@ -961,7 +955,7 @@ class InfBuildData(ModuleBuildClassObject):
         if self._DepexExpression is None:
             self._DepexExpression = tdict(False, 2)
             RecordList = self._RawData[MODEL_EFI_DEPEX, self._Arch]
-            DepexExpression = sdict()
+            DepexExpression = OrderedDict()
             for Record in RecordList:
                 DepexStr = ReplaceMacro(Record[0], self._Macros, False)
                 Arch = Record[3]
@@ -979,7 +973,7 @@ class InfBuildData(ModuleBuildClassObject):
         return self._GuidsUsedByPcd
     ## Retrieve PCD for given type
     def _GetPcd(self, Type):
-        Pcds = sdict()
+        Pcds = OrderedDict()
         PcdDict = tdict(True, 4)
         PcdList = []
         RecordList = self._RawData[Type, self._Arch, self._Platform]
diff --git a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py
index 8c27b4ad5b9b..17ac3b105431 100644
--- a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py
+++ b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py
@@ -11,7 +11,6 @@
 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #
 
-from Common.Misc import sdict
 from collections import OrderedDict, defaultdict
 from Common.DataType import SUP_MODULE_USER_DEFINED
 from BuildClassObject import LibraryClassObject
@@ -113,7 +112,7 @@ def _GetModuleLibraryInstances(Module, Platform, BuildDatabase, Arch, Target, To
     LibraryConsumerList = [Module]
     Constructor = []
     ConsumedByList = OrderedListDict()
-    LibraryInstance = sdict()
+    LibraryInstance = OrderedDict()
 
     while len(LibraryConsumerList) > 0:
         M = LibraryConsumerList.pop()
-- 
2.16.2.windows.1



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

* [PATCH v1 10/10] BaseTools: Remove unused code from Misc
  2018-04-03 21:03 [PATCH v1 00/10] BaseTools: refactor code Jaben Carsey
                   ` (8 preceding siblings ...)
  2018-04-03 21:03 ` [PATCH v1 09/10] BaseTools: Workspace - use built in OrderedDict instead of custom version Jaben Carsey
@ 2018-04-03 21:03 ` Jaben Carsey
  2018-04-08  6:40 ` [PATCH v1 00/10] BaseTools: refactor code Zhu, Yonghong
  10 siblings, 0 replies; 12+ messages in thread
From: Jaben Carsey @ 2018-04-03 21:03 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Yonghong Zhu

remove the functions and classes
remove any imports of these

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 | 280 +-------------------
 BaseTools/Source/Python/Eot/Eot.py     |   1 -
 2 files changed, 1 insertion(+), 280 deletions(-)

diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
index d1752d8a624e..5e9a104305c2 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -287,32 +287,6 @@ def ClearDuplicatedInf():
         if os.path.exists(File):
             os.remove(File)
 
-## callback routine for processing variable option
-#
-# This function can be used to process variable number of option values. The
-# typical usage of it is specify architecure list on command line.
-# (e.g. <tool> -a IA32 X64 IPF)
-#
-# @param  Option        Standard callback function parameter
-# @param  OptionString  Standard callback function parameter
-# @param  Value         Standard callback function parameter
-# @param  Parser        Standard callback function parameter
-#
-# @retval
-#
-def ProcessVariableArgument(Option, OptionString, Value, Parser):
-    assert Value is None
-    Value = []
-    RawArgs = Parser.rargs
-    while RawArgs:
-        Arg = RawArgs[0]
-        if (Arg[:2] == "--" and len(Arg) > 2) or \
-           (Arg[:1] == "-" and len(Arg) > 1 and Arg[1] != "-"):
-            break
-        Value.append(Arg)
-        del RawArgs[0]
-    setattr(Parser.values, Option.dest, Value)
-
 ## Convert GUID string in xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx style to C structure style
 #
 #   @param      Guid    The GUID string
@@ -450,32 +424,6 @@ def RemoveDirectory(Directory, Recursively=False):
         os.chdir(CurrentDirectory)
     os.rmdir(Directory)
 
-## Check if given file is changed or not
-#
-#  This method is used to check if a file is changed or not between two build
-#  actions. It makes use a cache to store files timestamp.
-#
-#   @param      File    The path of file
-#
-#   @retval     True    If the given file is changed, doesn't exist, or can't be
-#                       found in timestamp cache
-#   @retval     False   If the given file is changed
-#
-def IsChanged(File):
-    if not os.path.exists(File):
-        return True
-
-    FileState = os.stat(File)
-    TimeStamp = FileState[-2]
-
-    if File in gFileTimeStampCache and TimeStamp == gFileTimeStampCache[File]:
-        FileChanged = False
-    else:
-        FileChanged = True
-        gFileTimeStampCache[File] = TimeStamp
-
-    return FileChanged
-
 ## Store content in file
 #
 #  This method is used to save file only when its content is changed. This is
@@ -635,47 +583,6 @@ class DirCache:
             return os.path.join(self._Root, self._UPPER_CACHE_[UpperPath])
         return None
 
-## Get all files of a directory
-#
-# @param Root:       Root dir
-# @param SkipList :  The files need be skipped
-#
-# @retval  A list of all files
-#
-def GetFiles(Root, SkipList=None, FullPath=True):
-    OriPath = Root
-    FileList = []
-    for Root, Dirs, Files in os.walk(Root):
-        if SkipList:
-            for Item in SkipList:
-                if Item in Dirs:
-                    Dirs.remove(Item)
-
-        for File in Files:
-            File = os.path.normpath(os.path.join(Root, File))
-            if not FullPath:
-                File = File[len(OriPath) + 1:]
-            FileList.append(File)
-
-    return FileList
-
-## Check if gvien file exists or not
-#
-#   @param      File    File name or path to be checked
-#   @param      Dir     The directory the file is relative to
-#
-#   @retval     True    if file exists
-#   @retval     False   if file doesn't exists
-#
-def ValidFile(File, Ext=None):
-    if Ext is not None:
-        Dummy, FileExt = os.path.splitext(File)
-        if FileExt.lower() != Ext.lower():
-            return False
-    if not os.path.exists(File):
-        return False
-    return True
-
 def RealPath(File, Dir='', OverrideDir=''):
     NewFile = os.path.normpath(os.path.join(Dir, File))
     NewFile = GlobalData.gAllFiles[NewFile]
@@ -710,115 +617,6 @@ def RealPath2(File, Dir='', OverrideDir=''):
 
     return None, None
 
-## Check if gvien file exists or not
-#
-#
-def ValidFile2(AllFiles, File, Ext=None, Workspace='', EfiSource='', EdkSource='', Dir='.', OverrideDir=''):
-    NewFile = File
-    if Ext is not None:
-        Dummy, FileExt = os.path.splitext(File)
-        if FileExt.lower() != Ext.lower():
-            return False, File
-
-    # Replace the Edk macros
-    if OverrideDir != '' and OverrideDir is not None:
-        if OverrideDir.find('$(EFI_SOURCE)') > -1:
-            OverrideDir = OverrideDir.replace('$(EFI_SOURCE)', EfiSource)
-        if OverrideDir.find('$(EDK_SOURCE)') > -1:
-            OverrideDir = OverrideDir.replace('$(EDK_SOURCE)', EdkSource)
-
-    # Replace the default dir to current dir
-    if Dir == '.':
-        Dir = os.getcwd()
-        Dir = Dir[len(Workspace) + 1:]
-
-    # First check if File has Edk definition itself
-    if File.find('$(EFI_SOURCE)') > -1 or File.find('$(EDK_SOURCE)') > -1:
-        NewFile = File.replace('$(EFI_SOURCE)', EfiSource)
-        NewFile = NewFile.replace('$(EDK_SOURCE)', EdkSource)
-        NewFile = AllFiles[os.path.normpath(NewFile)]
-        if NewFile is not None:
-            return True, NewFile
-
-    # Second check the path with override value
-    if OverrideDir != '' and OverrideDir is not None:
-        NewFile = AllFiles[os.path.normpath(os.path.join(OverrideDir, File))]
-        if NewFile is not None:
-            return True, NewFile
-
-    # Last check the path with normal definitions
-    File = os.path.join(Dir, File)
-    NewFile = AllFiles[os.path.normpath(File)]
-    if NewFile is not None:
-        return True, NewFile
-
-    return False, File
-
-## Check if gvien file exists or not
-#
-#
-def ValidFile3(AllFiles, File, Workspace='', EfiSource='', EdkSource='', Dir='.', OverrideDir=''):
-    # Replace the Edk macros
-    if OverrideDir != '' and OverrideDir is not None:
-        if OverrideDir.find('$(EFI_SOURCE)') > -1:
-            OverrideDir = OverrideDir.replace('$(EFI_SOURCE)', EfiSource)
-        if OverrideDir.find('$(EDK_SOURCE)') > -1:
-            OverrideDir = OverrideDir.replace('$(EDK_SOURCE)', EdkSource)
-
-    # Replace the default dir to current dir
-    # Dir is current module dir related to workspace
-    if Dir == '.':
-        Dir = os.getcwd()
-        Dir = Dir[len(Workspace) + 1:]
-
-    NewFile = File
-    RelaPath = AllFiles[os.path.normpath(Dir)]
-    NewRelaPath = RelaPath
-
-    while(True):
-        # First check if File has Edk definition itself
-        if File.find('$(EFI_SOURCE)') > -1 or File.find('$(EDK_SOURCE)') > -1:
-            File = File.replace('$(EFI_SOURCE)', EfiSource)
-            File = File.replace('$(EDK_SOURCE)', EdkSource)
-            NewFile = AllFiles[os.path.normpath(File)]
-            if NewFile is not None:
-                NewRelaPath = os.path.dirname(NewFile)
-                File = os.path.basename(NewFile)
-                #NewRelaPath = NewFile[:len(NewFile) - len(File.replace("..\\", '').replace("../", '')) - 1]
-                break
-
-        # Second check the path with override value
-        if OverrideDir != '' and OverrideDir is not None:
-            NewFile = AllFiles[os.path.normpath(os.path.join(OverrideDir, File))]
-            if NewFile is not None:
-                #NewRelaPath = os.path.dirname(NewFile)
-                NewRelaPath = NewFile[:len(NewFile) - len(File.replace("..\\", '').replace("../", '')) - 1]
-                break
-
-        # Last check the path with normal definitions
-        NewFile = AllFiles[os.path.normpath(os.path.join(Dir, File))]
-        if NewFile is not None:
-            break
-
-        # No file found
-        break
-
-    return NewRelaPath, RelaPath, File
-
-
-def GetRelPath(Path1, Path2):
-    FileName = os.path.basename(Path2)
-    L1 = os.path.normpath(Path1).split(os.path.normpath('/'))
-    L2 = os.path.normpath(Path2).split(os.path.normpath('/'))
-    for Index in range(0, len(L1)):
-        if L1[Index] != L2[Index]:
-            FileName = '../' * (len(L1) - Index)
-            for Index2 in range(Index, len(L2)):
-                FileName = os.path.join(FileName, L2[Index2])
-            break
-    return os.path.normpath(FileName)
-
-
 ## Get GUID value from given packages
 #
 #   @param      CName           The CName of the GUID
@@ -1411,36 +1209,6 @@ class tdict:
                 keys |= self.data[Key].GetKeys(KeyIndex - 1)
             return keys
 
-## Boolean chain list
-#
-class Blist(UserList):
-    def __init__(self, initlist=None):
-        UserList.__init__(self, initlist)
-    def __setitem__(self, i, item):
-        if item not in [True, False]:
-            if item == 0:
-                item = False
-            else:
-                item = True
-        self.data[i] = item
-    def _GetResult(self):
-        Value = True
-        for item in self.data:
-            Value &= item
-        return Value
-    Result = property(_GetResult)
-
-def ParseConsoleLog(Filename):
-    Opr = open(os.path.normpath(Filename), 'r')
-    Opw = open(os.path.normpath(Filename + '.New'), 'w+')
-    for Line in Opr.readlines():
-        if Line.find('.efi') > -1:
-            Line = Line[Line.rfind(' ') : Line.rfind('.efi')].strip()
-            Opw.write('%s\n' % Line)
-
-    Opr.close()
-    Opw.close()
-
 def IsFieldValueAnArray (Value):
     Value = Value.strip()
     if Value.startswith('GUID') and Value.endswith(')'):
@@ -1649,7 +1417,7 @@ def ParseFieldValue (Value):
 ## AnalyzeDscPcd
 #
 #  Analyze DSC PCD value, since there is no data type info in DSC
-#  This fuction is used to match functions (AnalyzePcdData, AnalyzeHiiPcdData, AnalyzeVpdPcdData) used for retrieving PCD value from database
+#  This fuction is used to match functions (AnalyzePcdData) used for retrieving PCD value from database
 #  1. Feature flag: TokenSpace.PcdCName|PcdValue
 #  2. Fix and Patch:TokenSpace.PcdCName|PcdValue[|MaxSize]
 #  3. Dynamic default:
@@ -1785,52 +1553,6 @@ def AnalyzePcdData(Setting):
         
     return ValueList   
  
-## AnalyzeHiiPcdData
-#
-#  Analyze the pcd Value, variable name, variable Guid and variable offset.
-#  Used to avoid split issue while the value string contain "|" character
-#
-#  @param[in] Setting:  A String contain VariableName, VariableGuid, VariableOffset, DefaultValue information;
-#  
-#  @retval   ValueList: A List contaian VariableName, VariableGuid, VariableOffset, DefaultValue. 
-#
-def AnalyzeHiiPcdData(Setting):
-    ValueList = ['', '', '', '']
-
-    TokenList = GetSplitValueList(Setting)
-    ValueList[0:len(TokenList)] = TokenList
-
-    return ValueList
-
-## AnalyzeVpdPcdData
-#
-#  Analyze the vpd pcd VpdOffset, MaxDatumSize and InitialValue.
-#  Used to avoid split issue while the value string contain "|" character
-#
-#  @param[in] Setting:  A String contain VpdOffset/MaxDatumSize/InitialValue information;
-#  
-#  @retval   ValueList: A List contain VpdOffset, MaxDatumSize and InitialValue. 
-#
-def AnalyzeVpdPcdData(Setting):
-    ValueList = ['', '', '']
-
-    ValueRe = re.compile(r'\s*L?\".*\|.*\"\s*$')
-    PtrValue = ValueRe.findall(Setting)
-    
-    ValueUpdateFlag = False
-    
-    if len(PtrValue) >= 1:
-        Setting = re.sub(ValueRe, '', Setting)
-        ValueUpdateFlag = True
-
-    TokenList = Setting.split(TAB_VALUE_SPLIT)
-    ValueList[0:len(TokenList)] = TokenList
-    
-    if ValueUpdateFlag:
-        ValueList[2] = PtrValue[0]
-        
-    return ValueList     
-
 ## check format of PCD value against its the datum type
 #
 # For PCD value setting
diff --git a/BaseTools/Source/Python/Eot/Eot.py b/BaseTools/Source/Python/Eot/Eot.py
index 45c97bb258f2..96c339613476 100644
--- a/BaseTools/Source/Python/Eot/Eot.py
+++ b/BaseTools/Source/Python/Eot/Eot.py
@@ -27,7 +27,6 @@ import Database
 from FvImage import *
 from array import array
 from Report import Report
-from Common.Misc import ParseConsoleLog
 from Common.BuildVersion import gBUILD_VERSION
 from Parser import ConvertGuid
 from Common.LongFilePathSupport import OpenLongFilePath as open
-- 
2.16.2.windows.1



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

* Re: [PATCH v1 00/10] BaseTools: refactor code
  2018-04-03 21:03 [PATCH v1 00/10] BaseTools: refactor code Jaben Carsey
                   ` (9 preceding siblings ...)
  2018-04-03 21:03 ` [PATCH v1 10/10] BaseTools: Remove unused code from Misc Jaben Carsey
@ 2018-04-08  6:40 ` Zhu, Yonghong
  10 siblings, 0 replies; 12+ messages in thread
From: Zhu, Yonghong @ 2018-04-08  6:40 UTC (permalink / raw)
  To: Carsey, Jaben, edk2-devel@lists.01.org

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

Best Regards,
Zhu Yonghong

-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Jaben Carsey
Sent: Wednesday, April 04, 2018 5:03 AM
To: edk2-devel@lists.01.org
Subject: [edk2] [PATCH v1 00/10] BaseTools: refactor code

remove sdict class use and replace with built in types remove unused code

Jaben Carsey (10):
  BaseTools: Use local variable for list of constants.
  BaseTools: use built in dict instead of custom version.
  BaseTools: Eot tool never populates this dictionary
  BaseTools: remove unused include statement
  BaseTools - AutoGen - replace custom dictionary class with python
    standard one
  BaseTools: Eot remove unused code
  BaseTools: use built in dict instead of custom version.
  BaseTools: use combined version of standard dicts
  BaseTools: Workspace - use built in OrderedDict instead of custom
    version.
  BaseTools: Remove unused code from Misc

 BaseTools/Source/Python/AutoGen/AutoGen.py              |  31 +--
 BaseTools/Source/Python/AutoGen/GenC.py                 |  30 ++-
 BaseTools/Source/Python/AutoGen/GenMake.py              |   3 +-
 BaseTools/Source/Python/Common/DscClassObject.py        |   4 +-
 BaseTools/Source/Python/Common/EdkIIWorkspaceBuild.py   |  10 +-
 BaseTools/Source/Python/Common/Misc.py                  | 280 +-------------------
 BaseTools/Source/Python/CommonDataClass/PackageClass.py |   4 +-
 BaseTools/Source/Python/Eot/Eot.py                      |   9 -
 BaseTools/Source/Python/Eot/EotGlobalData.py            |  16 +-
 BaseTools/Source/Python/Eot/FvImage.py                  |  21 --
 BaseTools/Source/Python/Eot/Parser.py                   |   3 +-
 BaseTools/Source/Python/GenFds/GenFds.py                |   1 -
 BaseTools/Source/Python/Workspace/BuildClassObject.py   |   4 +-
 BaseTools/Source/Python/Workspace/DecBuildData.py       |  24 +-
 BaseTools/Source/Python/Workspace/DscBuildData.py       |  24 +-
 BaseTools/Source/Python/Workspace/InfBuildData.py       |  52 ++--
 BaseTools/Source/Python/Workspace/WorkspaceCommon.py    |  21 +-
 BaseTools/Source/Python/build/build.py                  |  10 +-
 18 files changed, 118 insertions(+), 429 deletions(-)

--
2.16.2.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


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

end of thread, other threads:[~2018-04-08  6:40 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-03 21:03 [PATCH v1 00/10] BaseTools: refactor code Jaben Carsey
2018-04-03 21:03 ` [PATCH v1 01/10] BaseTools: Use local variable for list of constants Jaben Carsey
2018-04-03 21:03 ` [PATCH v1 02/10] BaseTools: use built in dict instead of custom version Jaben Carsey
2018-04-03 21:03 ` [PATCH v1 03/10] BaseTools: Eot tool never populates this dictionary Jaben Carsey
2018-04-03 21:03 ` [PATCH v1 04/10] BaseTools: remove unused import statement Jaben Carsey
2018-04-03 21:03 ` [PATCH v1 05/10] BaseTools - AutoGen - replace custom dictionary class with python standard one Jaben Carsey
2018-04-03 21:03 ` [PATCH v1 06/10] BaseTools: Eot remove unused code Jaben Carsey
2018-04-03 21:03 ` [PATCH v1 07/10] BaseTools: use built in OrderedDict instead of custom version Jaben Carsey
2018-04-03 21:03 ` [PATCH v1 08/10] BaseTools: use combined version of OrderedDict Jaben Carsey
2018-04-03 21:03 ` [PATCH v1 09/10] BaseTools: Workspace - use built in OrderedDict instead of custom version Jaben Carsey
2018-04-03 21:03 ` [PATCH v1 10/10] BaseTools: Remove unused code from Misc Jaben Carsey
2018-04-08  6:40 ` [PATCH v1 00/10] BaseTools: refactor code Zhu, Yonghong

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