summaryrefslogtreecommitdiff
path: root/BaseTools/Source/Python
diff options
context:
space:
mode:
authorCarsey, Jaben <jaben.carsey@intel.com>2019-01-11 02:39:45 +0800
committerFeng, Bob C <bob.c.feng@intel.com>2019-01-21 18:03:30 +0800
commitb298567268c42ce40e1872ca3e9352b5774b0d9a (patch)
tree625ffcb1ab049d8218d7ac376a3db57fb19504ae /BaseTools/Source/Python
parentdd1988cf019050395575d57703b64186ba930711 (diff)
downloadedk2-b298567268c42ce40e1872ca3e9352b5774b0d9a.zip
edk2-b298567268c42ce40e1872ca3e9352b5774b0d9a.tar.gz
edk2-b298567268c42ce40e1872ca3e9352b5774b0d9a.tar.bz2
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> Reviewed-by: Bob Feng <bob.c.feng@intel.com>
Diffstat (limited to 'BaseTools/Source/Python')
-rw-r--r--BaseTools/Source/Python/Common/Misc.py37
-rw-r--r--BaseTools/Source/Python/build/build.py46
2 files changed, 42 insertions, 41 deletions
diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
index feb2c7e..32de5d9 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 f41b175..44ad86b 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
@@ -2163,19 +2201,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 = {}