public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch v1 0/5] cleanup shared functions
@ 2019-01-10 18:39 Jaben Carsey
  2019-01-10 18:39 ` [Patch v1 1/5] BaseTools/build/build: refactor and move functions Jaben Carsey
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Jaben Carsey @ 2019-01-10 18:39 UTC (permalink / raw)
  To: edk2-devel; +Cc: Bob Feng, Liming Gao

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=42

Many shared functions are not used by more than one consumer. 
Move them local to consumer until the use arises for sharing.

Cc: Bob Feng <bob.c.feng@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>

Jaben Carsey (5):
  BaseTools/build/build: refactor and move functions
  BaseTools/Workspace/InfBuildData: move functions
  BaseTools/DscBuildData: move function
  BaseTools/AutoGen: move functions
  BaseTools/GenFds/Capsule: move function logic

 BaseTools/Source/Python/AutoGen/AutoGen.py        |  77 ++++++++-
 BaseTools/Source/Python/Common/Misc.py            | 167 +-------------------
 BaseTools/Source/Python/GenFds/Capsule.py         |   4 +-
 BaseTools/Source/Python/Workspace/DscBuildData.py |  50 ++++--
 BaseTools/Source/Python/Workspace/InfBuildData.py |  46 +++++-
 BaseTools/Source/Python/build/build.py            |  46 +++++-
 6 files changed, 192 insertions(+), 198 deletions(-)

-- 
2.16.2.windows.1



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

* [Patch v1 1/5] BaseTools/build/build: refactor and move functions
  2019-01-10 18:39 [Patch v1 0/5] cleanup shared functions Jaben Carsey
@ 2019-01-10 18:39 ` Jaben Carsey
  2019-01-17  7:46   ` Feng, Bob C
  2019-01-10 18:39 ` [Patch v1 2/5] BaseTools/Workspace/InfBuildData: " Jaben Carsey
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Jaben Carsey @ 2019-01-10 18:39 UTC (permalink / raw)
  To: edk2-devel; +Cc: Bob Feng, Liming Gao

Move DataDump and DataRestore from Common.Misc to this file.
There were no other consumers of these 2 functions.

Import threading since that module is used in build.

Cc: Bob Feng <bob.c.feng@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/Common/Misc.py | 37 ----------------
 BaseTools/Source/Python/build/build.py | 46 ++++++++++++++++++--
 2 files changed, 42 insertions(+), 41 deletions(-)

diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
index 76a73d1c33db..43e016febcbb 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -487,43 +487,6 @@ def SaveFileOnChange(File, Content, IsBinaryFile=True):
 
     return True
 
-## Make a Python object persistent on file system
-#
-#   @param      Data    The object to be stored in file
-#   @param      File    The path of file to store the object
-#
-def DataDump(Data, File):
-    Fd = None
-    try:
-        Fd = open(File, 'wb')
-        pickle.dump(Data, Fd, pickle.HIGHEST_PROTOCOL)
-    except:
-        EdkLogger.error("", FILE_OPEN_FAILURE, ExtraData=File, RaiseError=False)
-    finally:
-        if Fd is not None:
-            Fd.close()
-
-## Restore a Python object from a file
-#
-#   @param      File    The path of file stored the object
-#
-#   @retval     object  A python object
-#   @retval     None    If failure in file operation
-#
-def DataRestore(File):
-    Data = None
-    Fd = None
-    try:
-        Fd = open(File, 'rb')
-        Data = pickle.load(Fd)
-    except Exception as e:
-        EdkLogger.verbose("Failed to load [%s]\n\t%s" % (File, str(e)))
-        Data = None
-    finally:
-        if Fd is not None:
-            Fd.close()
-    return Data
-
 ## Retrieve and cache the real path name in file system
 #
 #   @param      Root    The root directory of path relative to
diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/build/build.py
index b992a4c1b303..85b36cacd00c 100644
--- a/BaseTools/Source/Python/build/build.py
+++ b/BaseTools/Source/Python/build/build.py
@@ -32,6 +32,7 @@ import multiprocessing
 
 from struct import *
 from threading import *
+import threading
 from optparse import OptionParser
 from subprocess import *
 from Common import Misc as Utils
@@ -71,6 +72,43 @@ gToolsDefinition = "tools_def.txt"
 TemporaryTablePattern = re.compile(r'^_\d+_\d+_[a-fA-F0-9]+$')
 TmpTableDict = {}
 
+## Make a Python object persistent on file system
+#
+#   @param      Data    The object to be stored in file
+#   @param      File    The path of file to store the object
+#
+def _DataDump(Data, File):
+    Fd = None
+    try:
+        Fd = open(File, 'wb')
+        pickle.dump(Data, Fd, pickle.HIGHEST_PROTOCOL)
+    except:
+        EdkLogger.error("", FILE_OPEN_FAILURE, ExtraData=File, RaiseError=False)
+    finally:
+        if Fd is not None:
+            Fd.close()
+
+## Restore a Python object from a file
+#
+#   @param      File    The path of file stored the object
+#
+#   @retval     object  A python object
+#   @retval     None    If failure in file operation
+#
+def _DataRestore(File):
+    Data = None
+    Fd = None
+    try:
+        Fd = open(File, 'rb')
+        Data = pickle.load(Fd)
+    except Exception as e:
+        EdkLogger.verbose("Failed to load [%s]\n\t%s" % (File, str(e)))
+        Data = None
+    finally:
+        if Fd is not None:
+            Fd.close()
+    return Data
+
 ## Check environment PATH variable to make sure the specified tool is found
 #
 #   If the tool is found in the PATH, then True is returned
@@ -2242,19 +2280,19 @@ class Build():
     def DumpBuildData(self):
         CacheDirectory = os.path.dirname(GlobalData.gDatabasePath)
         Utils.CreateDirectory(CacheDirectory)
-        Utils.DataDump(Utils.gFileTimeStampCache, os.path.join(CacheDirectory, "gFileTimeStampCache"))
-        Utils.DataDump(Utils.gDependencyDatabase, os.path.join(CacheDirectory, "gDependencyDatabase"))
+        Utils._DataDump(Utils.gFileTimeStampCache, os.path.join(CacheDirectory, "gFileTimeStampCache"))
+        Utils._DataDump(Utils.gDependencyDatabase, os.path.join(CacheDirectory, "gDependencyDatabase"))
 
     def RestoreBuildData(self):
         FilePath = os.path.join(os.path.dirname(GlobalData.gDatabasePath), "gFileTimeStampCache")
         if Utils.gFileTimeStampCache == {} and os.path.isfile(FilePath):
-            Utils.gFileTimeStampCache = Utils.DataRestore(FilePath)
+            Utils.gFileTimeStampCache = Utils._DataRestore(FilePath)
             if Utils.gFileTimeStampCache is None:
                 Utils.gFileTimeStampCache = {}
 
         FilePath = os.path.join(os.path.dirname(GlobalData.gDatabasePath), "gDependencyDatabase")
         if Utils.gDependencyDatabase == {} and os.path.isfile(FilePath):
-            Utils.gDependencyDatabase = Utils.DataRestore(FilePath)
+            Utils.gDependencyDatabase = Utils._DataRestore(FilePath)
             if Utils.gDependencyDatabase is None:
                 Utils.gDependencyDatabase = {}
 
-- 
2.16.2.windows.1



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

* [Patch v1 2/5] BaseTools/Workspace/InfBuildData: move functions
  2019-01-10 18:39 [Patch v1 0/5] cleanup shared functions Jaben Carsey
  2019-01-10 18:39 ` [Patch v1 1/5] BaseTools/build/build: refactor and move functions Jaben Carsey
@ 2019-01-10 18:39 ` Jaben Carsey
  2019-01-17  7:46   ` Feng, Bob C
  2019-01-10 18:39 ` [Patch v1 3/5] BaseTools/DscBuildData: move function Jaben Carsey
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Jaben Carsey @ 2019-01-10 18:39 UTC (permalink / raw)
  To: edk2-devel; +Cc: Bob Feng, Liming Gao

Move ProtocolValue and PpiValue from Common.Misc to this file.
There were no other consumers of these 2 functions.

Cc: Bob Feng <bob.c.feng@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/Common/Misc.py            | 38 ----------------
 BaseTools/Source/Python/Workspace/InfBuildData.py | 46 ++++++++++++++++++--
 2 files changed, 42 insertions(+), 42 deletions(-)

diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
index 43e016febcbb..25d8f9807fa3 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -611,44 +611,6 @@ def GuidValue(CName, PackageList, Inffile = None):
             return P.Guids[CName]
     return None
 
-## Get Protocol value from given packages
-#
-#   @param      CName           The CName of the GUID
-#   @param      PackageList     List of packages looking-up in
-#   @param      Inffile         The driver file
-#
-#   @retval     GuidValue   if the CName is found in any given package
-#   @retval     None        if the CName is not found in all given packages
-#
-def ProtocolValue(CName, PackageList, Inffile = None):
-    for P in PackageList:
-        ProtocolKeys = P.Protocols.keys()
-        if Inffile and P._PrivateProtocols:
-            if not Inffile.startswith(P.MetaFile.Dir):
-                ProtocolKeys = [x for x in P.Protocols if x not in P._PrivateProtocols]
-        if CName in ProtocolKeys:
-            return P.Protocols[CName]
-    return None
-
-## Get PPI value from given packages
-#
-#   @param      CName           The CName of the GUID
-#   @param      PackageList     List of packages looking-up in
-#   @param      Inffile         The driver file
-#
-#   @retval     GuidValue   if the CName is found in any given package
-#   @retval     None        if the CName is not found in all given packages
-#
-def PpiValue(CName, PackageList, Inffile = None):
-    for P in PackageList:
-        PpiKeys = P.Ppis.keys()
-        if Inffile and P._PrivatePpis:
-            if not Inffile.startswith(P.MetaFile.Dir):
-                PpiKeys = [x for x in P.Ppis if x not in P._PrivatePpis]
-        if CName in PpiKeys:
-            return P.Ppis[CName]
-    return None
-
 ## A string template class
 #
 #  This class implements a template for string replacement. A string template
diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py b/BaseTools/Source/Python/Workspace/InfBuildData.py
index 99bbecfd1f87..351f596d76b4 100644
--- a/BaseTools/Source/Python/Workspace/InfBuildData.py
+++ b/BaseTools/Source/Python/Workspace/InfBuildData.py
@@ -21,6 +21,44 @@ from .MetaFileParser import *
 from collections import OrderedDict
 from Workspace.BuildClassObject import ModuleBuildClassObject, LibraryClassObject, PcdClassObject
 
+## Get Protocol value from given packages
+#
+#   @param      CName           The CName of the GUID
+#   @param      PackageList     List of packages looking-up in
+#   @param      Inffile         The driver file
+#
+#   @retval     GuidValue   if the CName is found in any given package
+#   @retval     None        if the CName is not found in all given packages
+#
+def _ProtocolValue(CName, PackageList, Inffile = None):
+    for P in PackageList:
+        ProtocolKeys = P.Protocols.keys()
+        if Inffile and P._PrivateProtocols:
+            if not Inffile.startswith(P.MetaFile.Dir):
+                ProtocolKeys = [x for x in P.Protocols if x not in P._PrivateProtocols]
+        if CName in ProtocolKeys:
+            return P.Protocols[CName]
+    return None
+
+## Get PPI value from given packages
+#
+#   @param      CName           The CName of the GUID
+#   @param      PackageList     List of packages looking-up in
+#   @param      Inffile         The driver file
+#
+#   @retval     GuidValue   if the CName is found in any given package
+#   @retval     None        if the CName is not found in all given packages
+#
+def _PpiValue(CName, PackageList, Inffile = None):
+    for P in PackageList:
+        PpiKeys = P.Ppis.keys()
+        if Inffile and P._PrivatePpis:
+            if not Inffile.startswith(P.MetaFile.Dir):
+                PpiKeys = [x for x in P.Ppis if x not in P._PrivatePpis]
+        if CName in PpiKeys:
+            return P.Ppis[CName]
+    return None
+
 ## Module build information from INF file
 #
 #  This class is used to retrieve information stored in database and convert them
@@ -645,7 +683,7 @@ class InfBuildData(ModuleBuildClassObject):
         RecordList = self._RawData[MODEL_EFI_PROTOCOL, self._Arch, self._Platform]
         for Record in RecordList:
             CName = Record[0]
-            Value = ProtocolValue(CName, self.Packages, self.MetaFile.Path)
+            Value = _ProtocolValue(CName, self.Packages, self.MetaFile.Path)
             if Value is None:
                 PackageList = "\n\t".join(str(P) for P in self.Packages)
                 EdkLogger.error('build', RESOURCE_NOT_AVAILABLE,
@@ -669,7 +707,7 @@ class InfBuildData(ModuleBuildClassObject):
         RecordList = self._RawData[MODEL_EFI_PPI, self._Arch, self._Platform]
         for Record in RecordList:
             CName = Record[0]
-            Value = PpiValue(CName, self.Packages, self.MetaFile.Path)
+            Value = _PpiValue(CName, self.Packages, self.MetaFile.Path)
             if Value is None:
                 PackageList = "\n\t".join(str(P) for P in self.Packages)
                 EdkLogger.error('build', RESOURCE_NOT_AVAILABLE,
@@ -875,9 +913,9 @@ class InfBuildData(ModuleBuildClassObject):
                         Value = Token
                     else:
                         # get the GUID value now
-                        Value = ProtocolValue(Token, self.Packages, self.MetaFile.Path)
+                        Value = _ProtocolValue(Token, self.Packages, self.MetaFile.Path)
                         if Value is None:
-                            Value = PpiValue(Token, self.Packages, self.MetaFile.Path)
+                            Value = _PpiValue(Token, self.Packages, self.MetaFile.Path)
                             if Value is None:
                                 Value = GuidValue(Token, self.Packages, self.MetaFile.Path)
 
-- 
2.16.2.windows.1



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

* [Patch v1 3/5] BaseTools/DscBuildData: move function
  2019-01-10 18:39 [Patch v1 0/5] cleanup shared functions Jaben Carsey
  2019-01-10 18:39 ` [Patch v1 1/5] BaseTools/build/build: refactor and move functions Jaben Carsey
  2019-01-10 18:39 ` [Patch v1 2/5] BaseTools/Workspace/InfBuildData: " Jaben Carsey
@ 2019-01-10 18:39 ` Jaben Carsey
  2019-01-17  7:47   ` Feng, Bob C
  2019-01-10 18:39 ` [Patch v1 4/5] BaseTools/AutoGen: move functions Jaben Carsey
  2019-01-10 18:39 ` [Patch v1 5/5] BaseTools/GenFds/Capsule: move function logic Jaben Carsey
  4 siblings, 1 reply; 10+ messages in thread
From: Jaben Carsey @ 2019-01-10 18:39 UTC (permalink / raw)
  To: edk2-devel; +Cc: Bob Feng, Liming Gao

Move IsFieldValuieAnArray from Common.Misc to this file.
There were no other consumers of the function.

Cc: Bob Feng <bob.c.feng@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/Common/Misc.py            | 18 +------
 BaseTools/Source/Python/Workspace/DscBuildData.py | 50 +++++++++++++-------
 2 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
index 25d8f9807fa3..7e8077558da5 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -1,7 +1,7 @@
 ## @file
 # Common routines used by all tools
 #
-# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2019, 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
@@ -1149,22 +1149,6 @@ class tdict:
                 keys |= self.data[Key].GetKeys(KeyIndex - 1)
             return keys
 
-def IsFieldValueAnArray (Value):
-    Value = Value.strip()
-    if Value.startswith(TAB_GUID) and Value.endswith(')'):
-        return True
-    if Value.startswith('L"') and Value.endswith('"')  and len(list(Value[2:-1])) > 1:
-        return True
-    if Value[0] == '"' and Value[-1] == '"' and len(list(Value[1:-1])) > 1:
-        return True
-    if Value[0] == '{' and Value[-1] == '}':
-        return True
-    if Value.startswith("L'") and Value.endswith("'") and len(list(Value[2:-1])) > 1:
-        return True
-    if Value[0] == "'" and Value[-1] == "'" and len(list(Value[1:-1])) > 1:
-        return True
-    return False
-
 def AnalyzePcdExpression(Setting):
     RanStr = ''.join(sample(string.ascii_letters + string.digits, 8))
     Setting = Setting.replace('\\\\', RanStr).strip()
diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py
index 3b0b23ca8fcb..f4a8212f412d 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -1,7 +1,7 @@
 ## @file
 # This file is used to create a database used by build tool
 #
-# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2008 - 2019, 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
@@ -44,6 +44,22 @@ from Workspace.BuildClassObject import PlatformBuildClassObject, StructurePcd, P
 from collections import OrderedDict, defaultdict
 from .BuildClassObject import ArrayIndex
 
+def _IsFieldValueAnArray (Value):
+    Value = Value.strip()
+    if Value.startswith(TAB_GUID) and Value.endswith(')'):
+        return True
+    if Value.startswith('L"') and Value.endswith('"')  and len(list(Value[2:-1])) > 1:
+        return True
+    if Value[0] == '"' and Value[-1] == '"' and len(list(Value[1:-1])) > 1:
+        return True
+    if Value[0] == '{' and Value[-1] == '}':
+        return True
+    if Value.startswith("L'") and Value.endswith("'") and len(list(Value[2:-1])) > 1:
+        return True
+    if Value[0] == "'" and Value[-1] == "'" and len(list(Value[1:-1])) > 1:
+        return True
+    return False
+
 PcdValueInitName = 'PcdValueInit'
 
 PcdMainCHeader = '''
@@ -1105,7 +1121,7 @@ class DscBuildData(PlatformBuildClassObject):
             IsArray = False
             TokenCName += '.' + FieldName
         if PcdValue.startswith('H'):
-            if FieldName and IsFieldValueAnArray(PcdValue[1:]):
+            if FieldName and _IsFieldValueAnArray(PcdValue[1:]):
                 PcdDatumType = TAB_VOID
                 IsArray = True
             if FieldName and not IsArray:
@@ -1116,7 +1132,7 @@ class DscBuildData(PlatformBuildClassObject):
                 EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s",  %s' %
                                 (TokenSpaceGuidCName, TokenCName, PcdValue, Value))
         elif PcdValue.startswith("L'") or PcdValue.startswith("'"):
-            if FieldName and IsFieldValueAnArray(PcdValue):
+            if FieldName and _IsFieldValueAnArray(PcdValue):
                 PcdDatumType = TAB_VOID
                 IsArray = True
             if FieldName and not IsArray:
@@ -1128,7 +1144,7 @@ class DscBuildData(PlatformBuildClassObject):
                                 (TokenSpaceGuidCName, TokenCName, PcdValue, Value))
         elif PcdValue.startswith('L'):
             PcdValue = 'L"' + PcdValue[1:] + '"'
-            if FieldName and IsFieldValueAnArray(PcdValue):
+            if FieldName and _IsFieldValueAnArray(PcdValue):
                 PcdDatumType = TAB_VOID
                 IsArray = True
             if FieldName and not IsArray:
@@ -1157,7 +1173,7 @@ class DscBuildData(PlatformBuildClassObject):
                     Num = int(PcdValue, Base)
                 except:
                     PcdValue = '"' + PcdValue + '"'
-                if IsFieldValueAnArray(PcdValue):
+                if _IsFieldValueAnArray(PcdValue):
                     PcdDatumType = TAB_VOID
                     IsArray = True
                 if not IsArray:
@@ -1762,7 +1778,7 @@ class DscBuildData(PlatformBuildClassObject):
                 continue
             for FieldName in FieldList:
                 FieldName = "." + FieldName
-                IsArray = IsFieldValueAnArray(FieldList[FieldName.strip(".")][0])
+                IsArray = _IsFieldValueAnArray(FieldList[FieldName.strip(".")][0])
                 if IsArray and not (FieldList[FieldName.strip(".")][0].startswith('{GUID') and FieldList[FieldName.strip(".")][0].endswith('}')):
                     try:
                         Value = ValueExpressionEx(FieldList[FieldName.strip(".")][0], TAB_VOID, self._GuidDict)(True)
@@ -1793,7 +1809,7 @@ class DscBuildData(PlatformBuildClassObject):
                             continue
                         for FieldName in FieldList:
                             FieldName = "." + FieldName
-                            IsArray = IsFieldValueAnArray(FieldList[FieldName.strip(".")][0])
+                            IsArray = _IsFieldValueAnArray(FieldList[FieldName.strip(".")][0])
                             if IsArray and not (FieldList[FieldName.strip(".")][0].startswith('{GUID') and FieldList[FieldName.strip(".")][0].endswith('}')):
                                 try:
                                     Value = ValueExpressionEx(FieldList[FieldName.strip(".")][0], TAB_VOID, self._GuidDict)(True)
@@ -1817,7 +1833,7 @@ class DscBuildData(PlatformBuildClassObject):
             CApp = CApp + "// From fdf \n"
         for FieldName in Pcd.PcdFieldValueFromFdf:
             FieldName = "." + FieldName
-            IsArray = IsFieldValueAnArray(Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][0])
+            IsArray = _IsFieldValueAnArray(Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][0])
             if IsArray and not (Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][0].startswith('{GUID') and Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][0].endswith('}')):
                 try:
                     Value = ValueExpressionEx(Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][0], TAB_VOID, self._GuidDict)(True)
@@ -1841,7 +1857,7 @@ class DscBuildData(PlatformBuildClassObject):
             CApp = CApp + "// From Command Line \n"
         for FieldName in Pcd.PcdFieldValueFromComm:
             FieldName = "." + FieldName
-            IsArray = IsFieldValueAnArray(Pcd.PcdFieldValueFromComm[FieldName.strip(".")][0])
+            IsArray = _IsFieldValueAnArray(Pcd.PcdFieldValueFromComm[FieldName.strip(".")][0])
             if IsArray and not (Pcd.PcdFieldValueFromComm[FieldName.strip(".")][0].startswith('{GUID') and Pcd.PcdFieldValueFromComm[FieldName.strip(".")][0].endswith('}')):
                 try:
                     Value = ValueExpressionEx(Pcd.PcdFieldValueFromComm[FieldName.strip(".")][0], TAB_VOID, self._GuidDict)(True)
@@ -1943,7 +1959,7 @@ class DscBuildData(PlatformBuildClassObject):
         CApp = CApp + '  UINT32  FieldSize;\n'
         CApp = CApp + '  CHAR8   *Value;\n'
         DefaultValueFromDec = Pcd.DefaultValueFromDec
-        IsArray = IsFieldValueAnArray(Pcd.DefaultValueFromDec)
+        IsArray = _IsFieldValueAnArray(Pcd.DefaultValueFromDec)
         if IsArray:
             try:
                 DefaultValueFromDec = ValueExpressionEx(Pcd.DefaultValueFromDec, TAB_VOID)(True)
@@ -1968,7 +1984,7 @@ class DscBuildData(PlatformBuildClassObject):
             if not FieldList:
                 continue
             for FieldName in FieldList:
-                IsArray = IsFieldValueAnArray(FieldList[FieldName][0])
+                IsArray = _IsFieldValueAnArray(FieldList[FieldName][0])
                 if IsArray:
                     try:
                         FieldList[FieldName][0] = ValueExpressionEx(FieldList[FieldName][0], TAB_VOID, self._GuidDict)(True)
@@ -2032,7 +2048,7 @@ class DscBuildData(PlatformBuildClassObject):
         pcddefaultvalue = self.GetPcdDscRawDefaultValue(Pcd, SkuName, DefaultStoreName)
         if pcddefaultvalue:
             FieldList = pcddefaultvalue
-            IsArray = IsFieldValueAnArray(FieldList)
+            IsArray = _IsFieldValueAnArray(FieldList)
             if IsArray:
                 if "{CODE(" not in FieldList:
                     try:
@@ -2083,7 +2099,7 @@ class DscBuildData(PlatformBuildClassObject):
             if (SkuName, DefaultStoreName) == (TAB_DEFAULT, TAB_DEFAULT_STORES_DEFAULT) or (( (SkuName, '') not in Pcd.ValueChain) and ( (SkuName, DefaultStoreName) not in Pcd.ValueChain )):
                 for FieldName in FieldList:
                     indicator = self.GetIndicator(index, FieldName,Pcd)
-                    IsArray = IsFieldValueAnArray(FieldList[FieldName][0])
+                    IsArray = _IsFieldValueAnArray(FieldList[FieldName][0])
                     if IsArray:
                         try:
                             FieldList[FieldName][0] = ValueExpressionEx(FieldList[FieldName][0], TAB_VOID, self._GuidDict)(True)
@@ -2132,7 +2148,7 @@ class DscBuildData(PlatformBuildClassObject):
             if not FieldList:
                 continue
             if pcddefaultvalue and FieldList == pcddefaultvalue:
-                IsArray = IsFieldValueAnArray(FieldList)
+                IsArray = _IsFieldValueAnArray(FieldList)
                 if IsArray:
                     try:
                         FieldList = ValueExpressionEx(FieldList, TAB_VOID)(True)
@@ -2151,7 +2167,7 @@ class DscBuildData(PlatformBuildClassObject):
                     CApp = CApp + '  memcpy (Pcd, Value, %d);\n' % (ValueSize)
                 continue
             for FieldName in FieldList:
-                IsArray = IsFieldValueAnArray(FieldList[FieldName][0])
+                IsArray = _IsFieldValueAnArray(FieldList[FieldName][0])
                 if IsArray:
                     try:
                         FieldList[FieldName][0] = ValueExpressionEx(FieldList[FieldName][0], TAB_VOID, self._GuidDict)(True)
@@ -2200,7 +2216,7 @@ class DscBuildData(PlatformBuildClassObject):
             if not FieldList:
                 continue
             if pcddefaultvalue and FieldList == pcddefaultvalue:
-                IsArray = IsFieldValueAnArray(FieldList)
+                IsArray = _IsFieldValueAnArray(FieldList)
                 if IsArray:
                     try:
                         FieldList = ValueExpressionEx(FieldList, TAB_VOID)(True)
@@ -2219,7 +2235,7 @@ class DscBuildData(PlatformBuildClassObject):
                     CApp = CApp + '  memcpy (Pcd, Value, %d);\n' % (ValueSize)
                 continue
             for FieldName in FieldList:
-                IsArray = IsFieldValueAnArray(FieldList[FieldName][0])
+                IsArray = _IsFieldValueAnArray(FieldList[FieldName][0])
                 if IsArray:
                     try:
                         FieldList[FieldName][0] = ValueExpressionEx(FieldList[FieldName][0], TAB_VOID, self._GuidDict)(True)
-- 
2.16.2.windows.1



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

* [Patch v1 4/5] BaseTools/AutoGen: move functions
  2019-01-10 18:39 [Patch v1 0/5] cleanup shared functions Jaben Carsey
                   ` (2 preceding siblings ...)
  2019-01-10 18:39 ` [Patch v1 3/5] BaseTools/DscBuildData: move function Jaben Carsey
@ 2019-01-10 18:39 ` Jaben Carsey
  2019-01-17  7:47   ` Feng, Bob C
  2019-01-10 18:39 ` [Patch v1 5/5] BaseTools/GenFds/Capsule: move function logic Jaben Carsey
  4 siblings, 1 reply; 10+ messages in thread
From: Jaben Carsey @ 2019-01-10 18:39 UTC (permalink / raw)
  To: edk2-devel; +Cc: Bob Feng, Liming Gao

Move SplitOption and ConvertStringToByteArray from Common.Misc to this file.
There were no other consumers of the functions.

Cc: Bob Feng <bob.c.feng@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/AutoGen/AutoGen.py | 77 ++++++++++++++++++--
 BaseTools/Source/Python/Common/Misc.py     | 68 -----------------
 2 files changed, 72 insertions(+), 73 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
index acd34692b6c2..f68166403edf 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -30,7 +30,7 @@ from io import BytesIO
 
 from .StrGather import *
 from .BuildEngine import BuildRule
-
+import shutil
 from Common.LongFilePathSupport import CopyLongFilePath
 from Common.BuildToolError import *
 from Common.DataType import *
@@ -170,6 +170,73 @@ ${tail_comments}
 ## @AsBuilt${BEGIN}
 ##   ${flags_item}${END}
 """)
+## Split command line option string to list
+#
+# subprocess.Popen needs the args to be a sequence. Otherwise there's problem
+# in non-windows platform to launch command
+#
+def _SplitOption(OptionString):
+    OptionList = []
+    LastChar = " "
+    OptionStart = 0
+    QuotationMark = ""
+    for Index in range(0, len(OptionString)):
+        CurrentChar = OptionString[Index]
+        if CurrentChar in ['"', "'"]:
+            if QuotationMark == CurrentChar:
+                QuotationMark = ""
+            elif QuotationMark == "":
+                QuotationMark = CurrentChar
+            continue
+        elif QuotationMark:
+            continue
+
+        if CurrentChar in ["/", "-"] and LastChar in [" ", "\t", "\r", "\n"]:
+            if Index > OptionStart:
+                OptionList.append(OptionString[OptionStart:Index - 1])
+            OptionStart = Index
+        LastChar = CurrentChar
+    OptionList.append(OptionString[OptionStart:])
+    return OptionList
+
+#
+# Convert string to C format array
+#
+def _ConvertStringToByteArray(Value):
+    Value = Value.strip()
+    if not Value:
+        return None
+    if Value[0] == '{':
+        if not Value.endswith('}'):
+            return None
+        Value = Value.replace(' ', '').replace('{', '').replace('}', '')
+        ValFields = Value.split(',')
+        try:
+            for Index in range(len(ValFields)):
+                ValFields[Index] = str(int(ValFields[Index], 0))
+        except ValueError:
+            return None
+        Value = '{' + ','.join(ValFields) + '}'
+        return Value
+
+    Unicode = False
+    if Value.startswith('L"'):
+        if not Value.endswith('"'):
+            return None
+        Value = Value[1:]
+        Unicode = True
+    elif not Value.startswith('"') or not Value.endswith('"'):
+        return None
+
+    Value = eval(Value)         # translate escape character
+    NewValue = '{'
+    for Index in range(0, len(Value)):
+        if Unicode:
+            NewValue = NewValue + str(ord(Value[Index]) % 0x10000) + ','
+        else:
+            NewValue = NewValue + str(ord(Value[Index]) % 0x100) + ','
+    Value = NewValue + '0}'
+    return Value
 
 ## Base class for AutoGen
 #
@@ -1719,11 +1786,11 @@ class PlatformAutoGen(AutoGen):
     def BuildCommand(self):
         RetVal = []
         if "MAKE" in self.ToolDefinition and "PATH" in self.ToolDefinition["MAKE"]:
-            RetVal += SplitOption(self.ToolDefinition["MAKE"]["PATH"])
+            RetVal += _SplitOption(self.ToolDefinition["MAKE"]["PATH"])
             if "FLAGS" in self.ToolDefinition["MAKE"]:
                 NewOption = self.ToolDefinition["MAKE"]["FLAGS"].strip()
                 if NewOption != '':
-                    RetVal += SplitOption(NewOption)
+                    RetVal += _SplitOption(NewOption)
             if "MAKE" in self.EdkIIBuildOption:
                 if "FLAGS" in self.EdkIIBuildOption["MAKE"]:
                     Flags = self.EdkIIBuildOption["MAKE"]["FLAGS"]
@@ -3425,7 +3492,7 @@ class ModuleAutoGen(AutoGen):
                 Guid = gEfiVarStoreGuidPattern.search(Content, Pos)
                 if not Guid:
                     break
-                NameArray = ConvertStringToByteArray('L"' + Name.group(1) + '"')
+                NameArray = _ConvertStringToByteArray('L"' + Name.group(1) + '"')
                 NameGuids.add((NameArray, GuidStructureStringToGuidString(Guid.group(1))))
                 Pos = Content.find('efivarstore', Name.end())
         if not NameGuids:
@@ -3438,7 +3505,7 @@ class ModuleAutoGen(AutoGen):
                 Value = GuidValue(SkuInfo.VariableGuid, self.PlatformInfo.PackageList, self.MetaFile.Path)
                 if not Value:
                     continue
-                Name = ConvertStringToByteArray(SkuInfo.VariableName)
+                Name = _ConvertStringToByteArray(SkuInfo.VariableName)
                 Guid = GuidStructureStringToGuidString(Value)
                 if (Name, Guid) in NameGuids and Pcd not in HiiExPcds:
                     HiiExPcds.append(Pcd)
diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
index 7e8077558da5..5968a3de4e1f 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -1514,35 +1514,6 @@ def CheckPcdDatum(Type, Value):
 
     return True, ""
 
-## Split command line option string to list
-#
-# subprocess.Popen needs the args to be a sequence. Otherwise there's problem
-# in non-windows platform to launch command
-#
-def SplitOption(OptionString):
-    OptionList = []
-    LastChar = " "
-    OptionStart = 0
-    QuotationMark = ""
-    for Index in range(0, len(OptionString)):
-        CurrentChar = OptionString[Index]
-        if CurrentChar in ['"', "'"]:
-            if QuotationMark == CurrentChar:
-                QuotationMark = ""
-            elif QuotationMark == "":
-                QuotationMark = CurrentChar
-            continue
-        elif QuotationMark:
-            continue
-
-        if CurrentChar in ["/", "-"] and LastChar in [" ", "\t", "\r", "\n"]:
-            if Index > OptionStart:
-                OptionList.append(OptionString[OptionStart:Index - 1])
-            OptionStart = Index
-        LastChar = CurrentChar
-    OptionList.append(OptionString[OptionStart:])
-    return OptionList
-
 def CommonPath(PathList):
     P1 = min(PathList).split(os.path.sep)
     P2 = max(PathList).split(os.path.sep)
@@ -1551,45 +1522,6 @@ def CommonPath(PathList):
             return os.path.sep.join(P1[:Index])
     return os.path.sep.join(P1)
 
-#
-# Convert string to C format array
-#
-def ConvertStringToByteArray(Value):
-    Value = Value.strip()
-    if not Value:
-        return None
-    if Value[0] == '{':
-        if not Value.endswith('}'):
-            return None
-        Value = Value.replace(' ', '').replace('{', '').replace('}', '')
-        ValFields = Value.split(',')
-        try:
-            for Index in range(len(ValFields)):
-                ValFields[Index] = str(int(ValFields[Index], 0))
-        except ValueError:
-            return None
-        Value = '{' + ','.join(ValFields) + '}'
-        return Value
-
-    Unicode = False
-    if Value.startswith('L"'):
-        if not Value.endswith('"'):
-            return None
-        Value = Value[1:]
-        Unicode = True
-    elif not Value.startswith('"') or not Value.endswith('"'):
-        return None
-
-    Value = eval(Value)         # translate escape character
-    NewValue = '{'
-    for Index in range(0, len(Value)):
-        if Unicode:
-            NewValue = NewValue + str(ord(Value[Index]) % 0x10000) + ','
-        else:
-            NewValue = NewValue + str(ord(Value[Index]) % 0x100) + ','
-    Value = NewValue + '0}'
-    return Value
-
 class PathClass(object):
     def __init__(self, File='', Root='', AlterRoot='', Type='', IsBinary=False,
                  Arch='COMMON', ToolChainFamily='', Target='', TagName='', ToolCode=''):
-- 
2.16.2.windows.1



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

* [Patch v1 5/5] BaseTools/GenFds/Capsule: move function logic
  2019-01-10 18:39 [Patch v1 0/5] cleanup shared functions Jaben Carsey
                   ` (3 preceding siblings ...)
  2019-01-10 18:39 ` [Patch v1 4/5] BaseTools/AutoGen: move functions Jaben Carsey
@ 2019-01-10 18:39 ` Jaben Carsey
  4 siblings, 0 replies; 10+ messages in thread
From: Jaben Carsey @ 2019-01-10 18:39 UTC (permalink / raw)
  To: edk2-devel; +Cc: Bob Feng, Liming Gao

Move PackRegistryFormatGuid logic from Common.Misc to this file.
There were no other consumers of the function.
As it is one line, just replace the logic without the separate function.

Cc: Bob Feng <bob.c.feng@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/Common/Misc.py    | 6 ------
 BaseTools/Source/Python/GenFds/Capsule.py | 4 ++--
 2 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
index 5968a3de4e1f..a1bfc502477c 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -1906,12 +1906,6 @@ class SkuClass():
         else:
             return 'DEFAULT'
 
-#
-# Pack a registry format GUID
-#
-def PackRegistryFormatGuid(Guid):
-    return PackGUID(Guid.split('-'))
-
 ##  Get the integer value from string like "14U" or integer like 2
 #
 #   @param      Input   The object that may be either a integer value or a string
diff --git a/BaseTools/Source/Python/GenFds/Capsule.py b/BaseTools/Source/Python/GenFds/Capsule.py
index df29c40dbd20..bc1d124bdddc 100644
--- a/BaseTools/Source/Python/GenFds/Capsule.py
+++ b/BaseTools/Source/Python/GenFds/Capsule.py
@@ -20,7 +20,7 @@ from .GenFdsGlobalVariable import GenFdsGlobalVariable, FindExtendTool
 from CommonDataClass.FdfClass import CapsuleClassObject
 import Common.LongFilePathOs as os
 from io import BytesIO
-from Common.Misc import SaveFileOnChange, PackRegistryFormatGuid
+from Common.Misc import SaveFileOnChange
 import uuid
 from struct import pack
 from Common import EdkLogger
@@ -66,7 +66,7 @@ class Capsule (CapsuleClassObject):
         #
         # Use FMP capsule GUID: 6DCBD5ED-E82D-4C44-BDA1-7194199AD92A
         #
-        Header.write(PackRegistryFormatGuid('6DCBD5ED-E82D-4C44-BDA1-7194199AD92A'))
+        Header.write(PackGUID('6DCBD5ED-E82D-4C44-BDA1-7194199AD92A'.split('-')))
         HdrSize = 0
         if 'CAPSULE_HEADER_SIZE' in self.TokensDict:
             Header.write(pack('=I', int(self.TokensDict['CAPSULE_HEADER_SIZE'], 16)))
-- 
2.16.2.windows.1



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

* Re: [Patch v1 1/5] BaseTools/build/build: refactor and move functions
  2019-01-10 18:39 ` [Patch v1 1/5] BaseTools/build/build: refactor and move functions Jaben Carsey
@ 2019-01-17  7:46   ` Feng, Bob C
  0 siblings, 0 replies; 10+ messages in thread
From: Feng, Bob C @ 2019-01-17  7:46 UTC (permalink / raw)
  To: Carsey, Jaben, edk2-devel@lists.01.org; +Cc: Gao, Liming

Reviewed-by: Bob Feng <bob.c.feng@intel.com> 

-----Original Message-----
From: Carsey, Jaben 
Sent: Friday, January 11, 2019 2:40 AM
To: edk2-devel@lists.01.org
Cc: Feng, Bob C <bob.c.feng@intel.com>; Gao, Liming <liming.gao@intel.com>
Subject: [Patch v1 1/5] BaseTools/build/build: refactor and move functions

Move DataDump and DataRestore from Common.Misc to this file.
There were no other consumers of these 2 functions.

Import threading since that module is used in build.

Cc: Bob Feng <bob.c.feng@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/Common/Misc.py | 37 ----------------  BaseTools/Source/Python/build/build.py | 46 ++++++++++++++++++--
 2 files changed, 42 insertions(+), 41 deletions(-)

diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
index 76a73d1c33db..43e016febcbb 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -487,43 +487,6 @@ def SaveFileOnChange(File, Content, IsBinaryFile=True):
 
     return True
 
-## Make a Python object persistent on file system -#
-#   @param      Data    The object to be stored in file
-#   @param      File    The path of file to store the object
-#
-def DataDump(Data, File):
-    Fd = None
-    try:
-        Fd = open(File, 'wb')
-        pickle.dump(Data, Fd, pickle.HIGHEST_PROTOCOL)
-    except:
-        EdkLogger.error("", FILE_OPEN_FAILURE, ExtraData=File, RaiseError=False)
-    finally:
-        if Fd is not None:
-            Fd.close()
-
-## Restore a Python object from a file
-#
-#   @param      File    The path of file stored the object
-#
-#   @retval     object  A python object
-#   @retval     None    If failure in file operation
-#
-def DataRestore(File):
-    Data = None
-    Fd = None
-    try:
-        Fd = open(File, 'rb')
-        Data = pickle.load(Fd)
-    except Exception as e:
-        EdkLogger.verbose("Failed to load [%s]\n\t%s" % (File, str(e)))
-        Data = None
-    finally:
-        if Fd is not None:
-            Fd.close()
-    return Data
-
 ## Retrieve and cache the real path name in file system  #
 #   @param      Root    The root directory of path relative to
diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/build/build.py
index b992a4c1b303..85b36cacd00c 100644
--- a/BaseTools/Source/Python/build/build.py
+++ b/BaseTools/Source/Python/build/build.py
@@ -32,6 +32,7 @@ import multiprocessing
 
 from struct import *
 from threading import *
+import threading
 from optparse import OptionParser
 from subprocess import *
 from Common import Misc as Utils
@@ -71,6 +72,43 @@ gToolsDefinition = "tools_def.txt"
 TemporaryTablePattern = re.compile(r'^_\d+_\d+_[a-fA-F0-9]+$')
 TmpTableDict = {}
 
+## Make a Python object persistent on file system #
+#   @param      Data    The object to be stored in file
+#   @param      File    The path of file to store the object
+#
+def _DataDump(Data, File):
+    Fd = None
+    try:
+        Fd = open(File, 'wb')
+        pickle.dump(Data, Fd, pickle.HIGHEST_PROTOCOL)
+    except:
+        EdkLogger.error("", FILE_OPEN_FAILURE, ExtraData=File, RaiseError=False)
+    finally:
+        if Fd is not None:
+            Fd.close()
+
+## Restore a Python object from a file
+#
+#   @param      File    The path of file stored the object
+#
+#   @retval     object  A python object
+#   @retval     None    If failure in file operation
+#
+def _DataRestore(File):
+    Data = None
+    Fd = None
+    try:
+        Fd = open(File, 'rb')
+        Data = pickle.load(Fd)
+    except Exception as e:
+        EdkLogger.verbose("Failed to load [%s]\n\t%s" % (File, str(e)))
+        Data = None
+    finally:
+        if Fd is not None:
+            Fd.close()
+    return Data
+
 ## Check environment PATH variable to make sure the specified tool is found  #
 #   If the tool is found in the PATH, then True is returned
@@ -2242,19 +2280,19 @@ class Build():
     def DumpBuildData(self):
         CacheDirectory = os.path.dirname(GlobalData.gDatabasePath)
         Utils.CreateDirectory(CacheDirectory)
-        Utils.DataDump(Utils.gFileTimeStampCache, os.path.join(CacheDirectory, "gFileTimeStampCache"))
-        Utils.DataDump(Utils.gDependencyDatabase, os.path.join(CacheDirectory, "gDependencyDatabase"))
+        Utils._DataDump(Utils.gFileTimeStampCache, os.path.join(CacheDirectory, "gFileTimeStampCache"))
+        Utils._DataDump(Utils.gDependencyDatabase, 
+ os.path.join(CacheDirectory, "gDependencyDatabase"))
 
     def RestoreBuildData(self):
         FilePath = os.path.join(os.path.dirname(GlobalData.gDatabasePath), "gFileTimeStampCache")
         if Utils.gFileTimeStampCache == {} and os.path.isfile(FilePath):
-            Utils.gFileTimeStampCache = Utils.DataRestore(FilePath)
+            Utils.gFileTimeStampCache = Utils._DataRestore(FilePath)
             if Utils.gFileTimeStampCache is None:
                 Utils.gFileTimeStampCache = {}
 
         FilePath = os.path.join(os.path.dirname(GlobalData.gDatabasePath), "gDependencyDatabase")
         if Utils.gDependencyDatabase == {} and os.path.isfile(FilePath):
-            Utils.gDependencyDatabase = Utils.DataRestore(FilePath)
+            Utils.gDependencyDatabase = Utils._DataRestore(FilePath)
             if Utils.gDependencyDatabase is None:
                 Utils.gDependencyDatabase = {}
 
--
2.16.2.windows.1



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

* Re: [Patch v1 2/5] BaseTools/Workspace/InfBuildData: move functions
  2019-01-10 18:39 ` [Patch v1 2/5] BaseTools/Workspace/InfBuildData: " Jaben Carsey
@ 2019-01-17  7:46   ` Feng, Bob C
  0 siblings, 0 replies; 10+ messages in thread
From: Feng, Bob C @ 2019-01-17  7:46 UTC (permalink / raw)
  To: Carsey, Jaben, edk2-devel@lists.01.org; +Cc: Gao, Liming

Reviewed-by: Bob Feng <bob.c.feng@intel.com>

-----Original Message-----
From: Carsey, Jaben 
Sent: Friday, January 11, 2019 2:40 AM
To: edk2-devel@lists.01.org
Cc: Feng, Bob C <bob.c.feng@intel.com>; Gao, Liming <liming.gao@intel.com>
Subject: [Patch v1 2/5] BaseTools/Workspace/InfBuildData: move functions

Move ProtocolValue and PpiValue from Common.Misc to this file.
There were no other consumers of these 2 functions.

Cc: Bob Feng <bob.c.feng@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/Common/Misc.py            | 38 ----------------
 BaseTools/Source/Python/Workspace/InfBuildData.py | 46 ++++++++++++++++++--
 2 files changed, 42 insertions(+), 42 deletions(-)

diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
index 43e016febcbb..25d8f9807fa3 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -611,44 +611,6 @@ def GuidValue(CName, PackageList, Inffile = None):
             return P.Guids[CName]
     return None
 
-## Get Protocol value from given packages -#
-#   @param      CName           The CName of the GUID
-#   @param      PackageList     List of packages looking-up in
-#   @param      Inffile         The driver file
-#
-#   @retval     GuidValue   if the CName is found in any given package
-#   @retval     None        if the CName is not found in all given packages
-#
-def ProtocolValue(CName, PackageList, Inffile = None):
-    for P in PackageList:
-        ProtocolKeys = P.Protocols.keys()
-        if Inffile and P._PrivateProtocols:
-            if not Inffile.startswith(P.MetaFile.Dir):
-                ProtocolKeys = [x for x in P.Protocols if x not in P._PrivateProtocols]
-        if CName in ProtocolKeys:
-            return P.Protocols[CName]
-    return None
-
-## Get PPI value from given packages
-#
-#   @param      CName           The CName of the GUID
-#   @param      PackageList     List of packages looking-up in
-#   @param      Inffile         The driver file
-#
-#   @retval     GuidValue   if the CName is found in any given package
-#   @retval     None        if the CName is not found in all given packages
-#
-def PpiValue(CName, PackageList, Inffile = None):
-    for P in PackageList:
-        PpiKeys = P.Ppis.keys()
-        if Inffile and P._PrivatePpis:
-            if not Inffile.startswith(P.MetaFile.Dir):
-                PpiKeys = [x for x in P.Ppis if x not in P._PrivatePpis]
-        if CName in PpiKeys:
-            return P.Ppis[CName]
-    return None
-
 ## A string template class
 #
 #  This class implements a template for string replacement. A string template diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py b/BaseTools/Source/Python/Workspace/InfBuildData.py
index 99bbecfd1f87..351f596d76b4 100644
--- a/BaseTools/Source/Python/Workspace/InfBuildData.py
+++ b/BaseTools/Source/Python/Workspace/InfBuildData.py
@@ -21,6 +21,44 @@ from .MetaFileParser import *  from collections import OrderedDict  from Workspace.BuildClassObject import ModuleBuildClassObject, LibraryClassObject, PcdClassObject
 
+## Get Protocol value from given packages #
+#   @param      CName           The CName of the GUID
+#   @param      PackageList     List of packages looking-up in
+#   @param      Inffile         The driver file
+#
+#   @retval     GuidValue   if the CName is found in any given package
+#   @retval     None        if the CName is not found in all given packages
+#
+def _ProtocolValue(CName, PackageList, Inffile = None):
+    for P in PackageList:
+        ProtocolKeys = P.Protocols.keys()
+        if Inffile and P._PrivateProtocols:
+            if not Inffile.startswith(P.MetaFile.Dir):
+                ProtocolKeys = [x for x in P.Protocols if x not in P._PrivateProtocols]
+        if CName in ProtocolKeys:
+            return P.Protocols[CName]
+    return None
+
+## Get PPI value from given packages
+#
+#   @param      CName           The CName of the GUID
+#   @param      PackageList     List of packages looking-up in
+#   @param      Inffile         The driver file
+#
+#   @retval     GuidValue   if the CName is found in any given package
+#   @retval     None        if the CName is not found in all given packages
+#
+def _PpiValue(CName, PackageList, Inffile = None):
+    for P in PackageList:
+        PpiKeys = P.Ppis.keys()
+        if Inffile and P._PrivatePpis:
+            if not Inffile.startswith(P.MetaFile.Dir):
+                PpiKeys = [x for x in P.Ppis if x not in P._PrivatePpis]
+        if CName in PpiKeys:
+            return P.Ppis[CName]
+    return None
+
 ## Module build information from INF file  #  #  This class is used to retrieve information stored in database and convert them @@ -645,7 +683,7 @@ class InfBuildData(ModuleBuildClassObject):
         RecordList = self._RawData[MODEL_EFI_PROTOCOL, self._Arch, self._Platform]
         for Record in RecordList:
             CName = Record[0]
-            Value = ProtocolValue(CName, self.Packages, self.MetaFile.Path)
+            Value = _ProtocolValue(CName, self.Packages, 
+ self.MetaFile.Path)
             if Value is None:
                 PackageList = "\n\t".join(str(P) for P in self.Packages)
                 EdkLogger.error('build', RESOURCE_NOT_AVAILABLE, @@ -669,7 +707,7 @@ class InfBuildData(ModuleBuildClassObject):
         RecordList = self._RawData[MODEL_EFI_PPI, self._Arch, self._Platform]
         for Record in RecordList:
             CName = Record[0]
-            Value = PpiValue(CName, self.Packages, self.MetaFile.Path)
+            Value = _PpiValue(CName, self.Packages, self.MetaFile.Path)
             if Value is None:
                 PackageList = "\n\t".join(str(P) for P in self.Packages)
                 EdkLogger.error('build', RESOURCE_NOT_AVAILABLE, @@ -875,9 +913,9 @@ class InfBuildData(ModuleBuildClassObject):
                         Value = Token
                     else:
                         # get the GUID value now
-                        Value = ProtocolValue(Token, self.Packages, self.MetaFile.Path)
+                        Value = _ProtocolValue(Token, self.Packages, 
+ self.MetaFile.Path)
                         if Value is None:
-                            Value = PpiValue(Token, self.Packages, self.MetaFile.Path)
+                            Value = _PpiValue(Token, self.Packages, 
+ self.MetaFile.Path)
                             if Value is None:
                                 Value = GuidValue(Token, self.Packages, self.MetaFile.Path)
 
--
2.16.2.windows.1



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

* Re: [Patch v1 4/5] BaseTools/AutoGen: move functions
  2019-01-10 18:39 ` [Patch v1 4/5] BaseTools/AutoGen: move functions Jaben Carsey
@ 2019-01-17  7:47   ` Feng, Bob C
  0 siblings, 0 replies; 10+ messages in thread
From: Feng, Bob C @ 2019-01-17  7:47 UTC (permalink / raw)
  To: Carsey, Jaben, edk2-devel@lists.01.org; +Cc: Gao, Liming

Reviewed-by: Bob Feng <bob.c.feng@intel.com>

-----Original Message-----
From: Carsey, Jaben 
Sent: Friday, January 11, 2019 2:40 AM
To: edk2-devel@lists.01.org
Cc: Feng, Bob C <bob.c.feng@intel.com>; Gao, Liming <liming.gao@intel.com>
Subject: [Patch v1 4/5] BaseTools/AutoGen: move functions

Move SplitOption and ConvertStringToByteArray from Common.Misc to this file.
There were no other consumers of the functions.

Cc: Bob Feng <bob.c.feng@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/AutoGen/AutoGen.py | 77 ++++++++++++++++++--
 BaseTools/Source/Python/Common/Misc.py     | 68 -----------------
 2 files changed, 72 insertions(+), 73 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
index acd34692b6c2..f68166403edf 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -30,7 +30,7 @@ from io import BytesIO
 
 from .StrGather import *
 from .BuildEngine import BuildRule
-
+import shutil
 from Common.LongFilePathSupport import CopyLongFilePath  from Common.BuildToolError import *  from Common.DataType import * @@ -170,6 +170,73 @@ ${tail_comments}  ## @AsBuilt${BEGIN}
 ##   ${flags_item}${END}
 """)
+## Split command line option string to list # # subprocess.Popen needs 
+the args to be a sequence. Otherwise there's problem # in non-windows 
+platform to launch command # def _SplitOption(OptionString):
+    OptionList = []
+    LastChar = " "
+    OptionStart = 0
+    QuotationMark = ""
+    for Index in range(0, len(OptionString)):
+        CurrentChar = OptionString[Index]
+        if CurrentChar in ['"', "'"]:
+            if QuotationMark == CurrentChar:
+                QuotationMark = ""
+            elif QuotationMark == "":
+                QuotationMark = CurrentChar
+            continue
+        elif QuotationMark:
+            continue
+
+        if CurrentChar in ["/", "-"] and LastChar in [" ", "\t", "\r", "\n"]:
+            if Index > OptionStart:
+                OptionList.append(OptionString[OptionStart:Index - 1])
+            OptionStart = Index
+        LastChar = CurrentChar
+    OptionList.append(OptionString[OptionStart:])
+    return OptionList
+
+#
+# Convert string to C format array
+#
+def _ConvertStringToByteArray(Value):
+    Value = Value.strip()
+    if not Value:
+        return None
+    if Value[0] == '{':
+        if not Value.endswith('}'):
+            return None
+        Value = Value.replace(' ', '').replace('{', '').replace('}', '')
+        ValFields = Value.split(',')
+        try:
+            for Index in range(len(ValFields)):
+                ValFields[Index] = str(int(ValFields[Index], 0))
+        except ValueError:
+            return None
+        Value = '{' + ','.join(ValFields) + '}'
+        return Value
+
+    Unicode = False
+    if Value.startswith('L"'):
+        if not Value.endswith('"'):
+            return None
+        Value = Value[1:]
+        Unicode = True
+    elif not Value.startswith('"') or not Value.endswith('"'):
+        return None
+
+    Value = eval(Value)         # translate escape character
+    NewValue = '{'
+    for Index in range(0, len(Value)):
+        if Unicode:
+            NewValue = NewValue + str(ord(Value[Index]) % 0x10000) + ','
+        else:
+            NewValue = NewValue + str(ord(Value[Index]) % 0x100) + ','
+    Value = NewValue + '0}'
+    return Value
 
 ## Base class for AutoGen
 #
@@ -1719,11 +1786,11 @@ class PlatformAutoGen(AutoGen):
     def BuildCommand(self):
         RetVal = []
         if "MAKE" in self.ToolDefinition and "PATH" in self.ToolDefinition["MAKE"]:
-            RetVal += SplitOption(self.ToolDefinition["MAKE"]["PATH"])
+            RetVal += _SplitOption(self.ToolDefinition["MAKE"]["PATH"])
             if "FLAGS" in self.ToolDefinition["MAKE"]:
                 NewOption = self.ToolDefinition["MAKE"]["FLAGS"].strip()
                 if NewOption != '':
-                    RetVal += SplitOption(NewOption)
+                    RetVal += _SplitOption(NewOption)
             if "MAKE" in self.EdkIIBuildOption:
                 if "FLAGS" in self.EdkIIBuildOption["MAKE"]:
                     Flags = self.EdkIIBuildOption["MAKE"]["FLAGS"]
@@ -3425,7 +3492,7 @@ class ModuleAutoGen(AutoGen):
                 Guid = gEfiVarStoreGuidPattern.search(Content, Pos)
                 if not Guid:
                     break
-                NameArray = ConvertStringToByteArray('L"' + Name.group(1) + '"')
+                NameArray = _ConvertStringToByteArray('L"' + 
+ Name.group(1) + '"')
                 NameGuids.add((NameArray, GuidStructureStringToGuidString(Guid.group(1))))
                 Pos = Content.find('efivarstore', Name.end())
         if not NameGuids:
@@ -3438,7 +3505,7 @@ class ModuleAutoGen(AutoGen):
                 Value = GuidValue(SkuInfo.VariableGuid, self.PlatformInfo.PackageList, self.MetaFile.Path)
                 if not Value:
                     continue
-                Name = ConvertStringToByteArray(SkuInfo.VariableName)
+                Name = _ConvertStringToByteArray(SkuInfo.VariableName)
                 Guid = GuidStructureStringToGuidString(Value)
                 if (Name, Guid) in NameGuids and Pcd not in HiiExPcds:
                     HiiExPcds.append(Pcd) diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
index 7e8077558da5..5968a3de4e1f 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -1514,35 +1514,6 @@ def CheckPcdDatum(Type, Value):
 
     return True, ""
 
-## Split command line option string to list -# -# subprocess.Popen needs the args to be a sequence. Otherwise there's problem -# in non-windows platform to launch command -# -def SplitOption(OptionString):
-    OptionList = []
-    LastChar = " "
-    OptionStart = 0
-    QuotationMark = ""
-    for Index in range(0, len(OptionString)):
-        CurrentChar = OptionString[Index]
-        if CurrentChar in ['"', "'"]:
-            if QuotationMark == CurrentChar:
-                QuotationMark = ""
-            elif QuotationMark == "":
-                QuotationMark = CurrentChar
-            continue
-        elif QuotationMark:
-            continue
-
-        if CurrentChar in ["/", "-"] and LastChar in [" ", "\t", "\r", "\n"]:
-            if Index > OptionStart:
-                OptionList.append(OptionString[OptionStart:Index - 1])
-            OptionStart = Index
-        LastChar = CurrentChar
-    OptionList.append(OptionString[OptionStart:])
-    return OptionList
-
 def CommonPath(PathList):
     P1 = min(PathList).split(os.path.sep)
     P2 = max(PathList).split(os.path.sep) @@ -1551,45 +1522,6 @@ def CommonPath(PathList):
             return os.path.sep.join(P1[:Index])
     return os.path.sep.join(P1)
 
-#
-# Convert string to C format array
-#
-def ConvertStringToByteArray(Value):
-    Value = Value.strip()
-    if not Value:
-        return None
-    if Value[0] == '{':
-        if not Value.endswith('}'):
-            return None
-        Value = Value.replace(' ', '').replace('{', '').replace('}', '')
-        ValFields = Value.split(',')
-        try:
-            for Index in range(len(ValFields)):
-                ValFields[Index] = str(int(ValFields[Index], 0))
-        except ValueError:
-            return None
-        Value = '{' + ','.join(ValFields) + '}'
-        return Value
-
-    Unicode = False
-    if Value.startswith('L"'):
-        if not Value.endswith('"'):
-            return None
-        Value = Value[1:]
-        Unicode = True
-    elif not Value.startswith('"') or not Value.endswith('"'):
-        return None
-
-    Value = eval(Value)         # translate escape character
-    NewValue = '{'
-    for Index in range(0, len(Value)):
-        if Unicode:
-            NewValue = NewValue + str(ord(Value[Index]) % 0x10000) + ','
-        else:
-            NewValue = NewValue + str(ord(Value[Index]) % 0x100) + ','
-    Value = NewValue + '0}'
-    return Value
-
 class PathClass(object):
     def __init__(self, File='', Root='', AlterRoot='', Type='', IsBinary=False,
                  Arch='COMMON', ToolChainFamily='', Target='', TagName='', ToolCode=''):
--
2.16.2.windows.1



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

* Re: [Patch v1 3/5] BaseTools/DscBuildData: move function
  2019-01-10 18:39 ` [Patch v1 3/5] BaseTools/DscBuildData: move function Jaben Carsey
@ 2019-01-17  7:47   ` Feng, Bob C
  0 siblings, 0 replies; 10+ messages in thread
From: Feng, Bob C @ 2019-01-17  7:47 UTC (permalink / raw)
  To: Carsey, Jaben, edk2-devel@lists.01.org; +Cc: Gao, Liming

Reviewed-by: Bob Feng <bob.c.feng@intel.com>

-----Original Message-----
From: Carsey, Jaben 
Sent: Friday, January 11, 2019 2:40 AM
To: edk2-devel@lists.01.org
Cc: Feng, Bob C <bob.c.feng@intel.com>; Gao, Liming <liming.gao@intel.com>
Subject: [Patch v1 3/5] BaseTools/DscBuildData: move function

Move IsFieldValuieAnArray from Common.Misc to this file.
There were no other consumers of the function.

Cc: Bob Feng <bob.c.feng@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/Common/Misc.py            | 18 +------
 BaseTools/Source/Python/Workspace/DscBuildData.py | 50 +++++++++++++-------
 2 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
index 25d8f9807fa3..7e8077558da5 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -1,7 +1,7 @@
 ## @file
 # Common routines used by all tools
 #
-# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2019, 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 @@ -1149,22 +1149,6 @@ class tdict:
                 keys |= self.data[Key].GetKeys(KeyIndex - 1)
             return keys
 
-def IsFieldValueAnArray (Value):
-    Value = Value.strip()
-    if Value.startswith(TAB_GUID) and Value.endswith(')'):
-        return True
-    if Value.startswith('L"') and Value.endswith('"')  and len(list(Value[2:-1])) > 1:
-        return True
-    if Value[0] == '"' and Value[-1] == '"' and len(list(Value[1:-1])) > 1:
-        return True
-    if Value[0] == '{' and Value[-1] == '}':
-        return True
-    if Value.startswith("L'") and Value.endswith("'") and len(list(Value[2:-1])) > 1:
-        return True
-    if Value[0] == "'" and Value[-1] == "'" and len(list(Value[1:-1])) > 1:
-        return True
-    return False
-
 def AnalyzePcdExpression(Setting):
     RanStr = ''.join(sample(string.ascii_letters + string.digits, 8))
     Setting = Setting.replace('\\\\', RanStr).strip() diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py
index 3b0b23ca8fcb..f4a8212f412d 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -1,7 +1,7 @@
 ## @file
 # This file is used to create a database used by build tool  # -# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2008 - 2019, 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 @@ -44,6 +44,22 @@ from Workspace.BuildClassObject import PlatformBuildClassObject, StructurePcd, P  from collections import OrderedDict, defaultdict  from .BuildClassObject import ArrayIndex
 
+def _IsFieldValueAnArray (Value):
+    Value = Value.strip()
+    if Value.startswith(TAB_GUID) and Value.endswith(')'):
+        return True
+    if Value.startswith('L"') and Value.endswith('"')  and len(list(Value[2:-1])) > 1:
+        return True
+    if Value[0] == '"' and Value[-1] == '"' and len(list(Value[1:-1])) > 1:
+        return True
+    if Value[0] == '{' and Value[-1] == '}':
+        return True
+    if Value.startswith("L'") and Value.endswith("'") and len(list(Value[2:-1])) > 1:
+        return True
+    if Value[0] == "'" and Value[-1] == "'" and len(list(Value[1:-1])) > 1:
+        return True
+    return False
+
 PcdValueInitName = 'PcdValueInit'
 
 PcdMainCHeader = '''
@@ -1105,7 +1121,7 @@ class DscBuildData(PlatformBuildClassObject):
             IsArray = False
             TokenCName += '.' + FieldName
         if PcdValue.startswith('H'):
-            if FieldName and IsFieldValueAnArray(PcdValue[1:]):
+            if FieldName and _IsFieldValueAnArray(PcdValue[1:]):
                 PcdDatumType = TAB_VOID
                 IsArray = True
             if FieldName and not IsArray:
@@ -1116,7 +1132,7 @@ class DscBuildData(PlatformBuildClassObject):
                 EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s",  %s' %
                                 (TokenSpaceGuidCName, TokenCName, PcdValue, Value))
         elif PcdValue.startswith("L'") or PcdValue.startswith("'"):
-            if FieldName and IsFieldValueAnArray(PcdValue):
+            if FieldName and _IsFieldValueAnArray(PcdValue):
                 PcdDatumType = TAB_VOID
                 IsArray = True
             if FieldName and not IsArray:
@@ -1128,7 +1144,7 @@ class DscBuildData(PlatformBuildClassObject):
                                 (TokenSpaceGuidCName, TokenCName, PcdValue, Value))
         elif PcdValue.startswith('L'):
             PcdValue = 'L"' + PcdValue[1:] + '"'
-            if FieldName and IsFieldValueAnArray(PcdValue):
+            if FieldName and _IsFieldValueAnArray(PcdValue):
                 PcdDatumType = TAB_VOID
                 IsArray = True
             if FieldName and not IsArray:
@@ -1157,7 +1173,7 @@ class DscBuildData(PlatformBuildClassObject):
                     Num = int(PcdValue, Base)
                 except:
                     PcdValue = '"' + PcdValue + '"'
-                if IsFieldValueAnArray(PcdValue):
+                if _IsFieldValueAnArray(PcdValue):
                     PcdDatumType = TAB_VOID
                     IsArray = True
                 if not IsArray:
@@ -1762,7 +1778,7 @@ class DscBuildData(PlatformBuildClassObject):
                 continue
             for FieldName in FieldList:
                 FieldName = "." + FieldName
-                IsArray = IsFieldValueAnArray(FieldList[FieldName.strip(".")][0])
+                IsArray = 
+ _IsFieldValueAnArray(FieldList[FieldName.strip(".")][0])
                 if IsArray and not (FieldList[FieldName.strip(".")][0].startswith('{GUID') and FieldList[FieldName.strip(".")][0].endswith('}')):
                     try:
                         Value = ValueExpressionEx(FieldList[FieldName.strip(".")][0], TAB_VOID, self._GuidDict)(True) @@ -1793,7 +1809,7 @@ class DscBuildData(PlatformBuildClassObject):
                             continue
                         for FieldName in FieldList:
                             FieldName = "." + FieldName
-                            IsArray = IsFieldValueAnArray(FieldList[FieldName.strip(".")][0])
+                            IsArray = 
+ _IsFieldValueAnArray(FieldList[FieldName.strip(".")][0])
                             if IsArray and not (FieldList[FieldName.strip(".")][0].startswith('{GUID') and FieldList[FieldName.strip(".")][0].endswith('}')):
                                 try:
                                     Value = ValueExpressionEx(FieldList[FieldName.strip(".")][0], TAB_VOID, self._GuidDict)(True) @@ -1817,7 +1833,7 @@ class DscBuildData(PlatformBuildClassObject):
             CApp = CApp + "// From fdf \n"
         for FieldName in Pcd.PcdFieldValueFromFdf:
             FieldName = "." + FieldName
-            IsArray = IsFieldValueAnArray(Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][0])
+            IsArray = 
+ _IsFieldValueAnArray(Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][0]
+ )
             if IsArray and not (Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][0].startswith('{GUID') and Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][0].endswith('}')):
                 try:
                     Value = ValueExpressionEx(Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][0], TAB_VOID, self._GuidDict)(True) @@ -1841,7 +1857,7 @@ class DscBuildData(PlatformBuildClassObject):
             CApp = CApp + "// From Command Line \n"
         for FieldName in Pcd.PcdFieldValueFromComm:
             FieldName = "." + FieldName
-            IsArray = IsFieldValueAnArray(Pcd.PcdFieldValueFromComm[FieldName.strip(".")][0])
+            IsArray = 
+ _IsFieldValueAnArray(Pcd.PcdFieldValueFromComm[FieldName.strip(".")][0
+ ])
             if IsArray and not (Pcd.PcdFieldValueFromComm[FieldName.strip(".")][0].startswith('{GUID') and Pcd.PcdFieldValueFromComm[FieldName.strip(".")][0].endswith('}')):
                 try:
                     Value = ValueExpressionEx(Pcd.PcdFieldValueFromComm[FieldName.strip(".")][0], TAB_VOID, self._GuidDict)(True) @@ -1943,7 +1959,7 @@ class DscBuildData(PlatformBuildClassObject):
         CApp = CApp + '  UINT32  FieldSize;\n'
         CApp = CApp + '  CHAR8   *Value;\n'
         DefaultValueFromDec = Pcd.DefaultValueFromDec
-        IsArray = IsFieldValueAnArray(Pcd.DefaultValueFromDec)
+        IsArray = _IsFieldValueAnArray(Pcd.DefaultValueFromDec)
         if IsArray:
             try:
                 DefaultValueFromDec = ValueExpressionEx(Pcd.DefaultValueFromDec, TAB_VOID)(True) @@ -1968,7 +1984,7 @@ class DscBuildData(PlatformBuildClassObject):
             if not FieldList:
                 continue
             for FieldName in FieldList:
-                IsArray = IsFieldValueAnArray(FieldList[FieldName][0])
+                IsArray = _IsFieldValueAnArray(FieldList[FieldName][0])
                 if IsArray:
                     try:
                         FieldList[FieldName][0] = ValueExpressionEx(FieldList[FieldName][0], TAB_VOID, self._GuidDict)(True) @@ -2032,7 +2048,7 @@ class DscBuildData(PlatformBuildClassObject):
         pcddefaultvalue = self.GetPcdDscRawDefaultValue(Pcd, SkuName, DefaultStoreName)
         if pcddefaultvalue:
             FieldList = pcddefaultvalue
-            IsArray = IsFieldValueAnArray(FieldList)
+            IsArray = _IsFieldValueAnArray(FieldList)
             if IsArray:
                 if "{CODE(" not in FieldList:
                     try:
@@ -2083,7 +2099,7 @@ class DscBuildData(PlatformBuildClassObject):
             if (SkuName, DefaultStoreName) == (TAB_DEFAULT, TAB_DEFAULT_STORES_DEFAULT) or (( (SkuName, '') not in Pcd.ValueChain) and ( (SkuName, DefaultStoreName) not in Pcd.ValueChain )):
                 for FieldName in FieldList:
                     indicator = self.GetIndicator(index, FieldName,Pcd)
-                    IsArray = IsFieldValueAnArray(FieldList[FieldName][0])
+                    IsArray = 
+ _IsFieldValueAnArray(FieldList[FieldName][0])
                     if IsArray:
                         try:
                             FieldList[FieldName][0] = ValueExpressionEx(FieldList[FieldName][0], TAB_VOID, self._GuidDict)(True) @@ -2132,7 +2148,7 @@ class DscBuildData(PlatformBuildClassObject):
             if not FieldList:
                 continue
             if pcddefaultvalue and FieldList == pcddefaultvalue:
-                IsArray = IsFieldValueAnArray(FieldList)
+                IsArray = _IsFieldValueAnArray(FieldList)
                 if IsArray:
                     try:
                         FieldList = ValueExpressionEx(FieldList, TAB_VOID)(True) @@ -2151,7 +2167,7 @@ class DscBuildData(PlatformBuildClassObject):
                     CApp = CApp + '  memcpy (Pcd, Value, %d);\n' % (ValueSize)
                 continue
             for FieldName in FieldList:
-                IsArray = IsFieldValueAnArray(FieldList[FieldName][0])
+                IsArray = _IsFieldValueAnArray(FieldList[FieldName][0])
                 if IsArray:
                     try:
                         FieldList[FieldName][0] = ValueExpressionEx(FieldList[FieldName][0], TAB_VOID, self._GuidDict)(True) @@ -2200,7 +2216,7 @@ class DscBuildData(PlatformBuildClassObject):
             if not FieldList:
                 continue
             if pcddefaultvalue and FieldList == pcddefaultvalue:
-                IsArray = IsFieldValueAnArray(FieldList)
+                IsArray = _IsFieldValueAnArray(FieldList)
                 if IsArray:
                     try:
                         FieldList = ValueExpressionEx(FieldList, TAB_VOID)(True) @@ -2219,7 +2235,7 @@ class DscBuildData(PlatformBuildClassObject):
                     CApp = CApp + '  memcpy (Pcd, Value, %d);\n' % (ValueSize)
                 continue
             for FieldName in FieldList:
-                IsArray = IsFieldValueAnArray(FieldList[FieldName][0])
+                IsArray = _IsFieldValueAnArray(FieldList[FieldName][0])
                 if IsArray:
                     try:
                         FieldList[FieldName][0] = ValueExpressionEx(FieldList[FieldName][0], TAB_VOID, self._GuidDict)(True)
--
2.16.2.windows.1



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

end of thread, other threads:[~2019-01-17  7:50 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-10 18:39 [Patch v1 0/5] cleanup shared functions Jaben Carsey
2019-01-10 18:39 ` [Patch v1 1/5] BaseTools/build/build: refactor and move functions Jaben Carsey
2019-01-17  7:46   ` Feng, Bob C
2019-01-10 18:39 ` [Patch v1 2/5] BaseTools/Workspace/InfBuildData: " Jaben Carsey
2019-01-17  7:46   ` Feng, Bob C
2019-01-10 18:39 ` [Patch v1 3/5] BaseTools/DscBuildData: move function Jaben Carsey
2019-01-17  7:47   ` Feng, Bob C
2019-01-10 18:39 ` [Patch v1 4/5] BaseTools/AutoGen: move functions Jaben Carsey
2019-01-17  7:47   ` Feng, Bob C
2019-01-10 18:39 ` [Patch v1 5/5] BaseTools/GenFds/Capsule: move function logic Jaben Carsey

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