[edk2-devel] [Patch 6/9] BaseTools: Add shared data for processes

Bob Feng bob.c.feng at intel.com
Thu Jul 18 06:14:20 UTC 2019


BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1875

Add shared data for autogen processes.

Cc: Liming Gao <liming.gao at intel.com>
Signed-off-by: Bob Feng <bob.c.feng at intel.com>
---
 BaseTools/Source/Python/AutoGen/AutoGenWorker.py |  3 ++-
 BaseTools/Source/Python/build/build.py           | 10 ++++++----
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGenWorker.py b/BaseTools/Source/Python/AutoGen/AutoGenWorker.py
index a0415f0d3420..150de0891c6e 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGenWorker.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGenWorker.py
@@ -52,18 +52,19 @@ class AutoGenManager(threading.Thread):
         for w in self.autogen_workers:
             if w.is_alive():
                 w.terminate()
 
 class AutoGenWorkerInProcess(mp.Process):
-    def __init__(self,module_queue,data_pipe_file_path,feedback_q,file_lock):
+    def __init__(self,module_queue,data_pipe_file_path,feedback_q,file_lock, share_data):
         mp.Process.__init__(self)
         self.module_queue = module_queue
         self.data_pipe_file_path =data_pipe_file_path
         self.data_pipe = None
         self.feedback_q = feedback_q
         self.PlatformMetaFileSet = {}
         self.file_lock = file_lock
+        self.share_data = share_data
     def GetPlatformMetaFile(self,filepath,root):
         try:
             return self.PlatformMetaFileSet[(filepath,root)]
         except:
             self.PlatformMetaFileSet[(filepath,root)]  = filepath
diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/build/build.py
index b4916a32171a..46aed15bd9d1 100644
--- a/BaseTools/Source/Python/build/build.py
+++ b/BaseTools/Source/Python/build/build.py
@@ -50,10 +50,11 @@ from GenPatchPcdTable.GenPatchPcdTable import PeImageClass,parsePcdInfoFromMapFi
 from PatchPcdValue.PatchPcdValue import PatchBinaryFile
 
 import Common.GlobalData as GlobalData
 from GenFds.GenFds import GenFds, GenFdsApi
 import multiprocessing as mp
+from multiprocessing import Manager
 
 # Version and Copyright
 VersionNumber = "0.60" + ' ' + gBUILD_VERSION
 __version__ = "%prog Version " + VersionNumber
 __copyright__ = "Copyright (c) 2007 - 2018, Intel Corporation  All rights reserved."
@@ -825,16 +826,17 @@ class Build():
             self.InitBuild()
 
         self.AutoGenMgr = None
         EdkLogger.info("")
         os.chdir(self.WorkspaceDir)
-    def StartAutoGen(self,mqueue, DataPipe,SkipAutoGen,PcdMaList):
+        self.share_data = Manager().dict()
+    def StartAutoGen(self,mqueue, DataPipe,SkipAutoGen,PcdMaList,share_data):
         if SkipAutoGen:
             return
         feedback_q = mp.Queue()
         file_lock = mp.Lock()
-        auto_workers = [AutoGenWorkerInProcess(mqueue,DataPipe.dump_file,feedback_q,file_lock) for _ in range(mp.cpu_count()//2)]
+        auto_workers = [AutoGenWorkerInProcess(mqueue,DataPipe.dump_file,feedback_q,file_lock,share_data) for _ in range(mp.cpu_count()//2)]
         self.AutoGenMgr = AutoGenManager(auto_workers,feedback_q)
         self.AutoGenMgr.start()
         for w in auto_workers:
             w.start()
         if PcdMaList is not None:
@@ -1227,11 +1229,11 @@ class Build():
 
             AutoGenObject.DataPipe.DataContainer = {"FfsCommand":FfsCommand}
             self.Progress.Start("Generating makefile and code")
             data_pipe_file = os.path.join(self.WorkspaceDir, "GlobalVar_%s_%s.bin" % (str(AutoGenObject.Guid),AutoGenObject.Arch))
             AutoGenObject.DataPipe.dump(data_pipe_file)
-            autogen_rt = self.StartAutoGen(mqueue, AutoGenObject.DataPipe, self.SkipAutoGen, PcdMaList)
+            autogen_rt = self.StartAutoGen(mqueue, AutoGenObject.DataPipe, self.SkipAutoGen, PcdMaList,self.share_data)
             self.Progress.Stop("done!")
             return autogen_rt
         else:
             # always recreate top/platform makefile when clean, just in case of inconsistency
             AutoGenObject.CreateCodeFile(False)
@@ -2059,11 +2061,11 @@ class Build():
                     for m in Pa.GetAllModuleInfo:
                         mqueue.put(m)
                     Pa.DataPipe.DataContainer = {"FfsCommand":CmdListDict}
                     data_pipe_file = os.path.join(self.WorkspaceDir, "GlobalVar_%s_%s.bin" % (str(Pa.Guid),Pa.Arch))
                     Pa.DataPipe.dump(data_pipe_file)
-                    autogen_rt = self.StartAutoGen(mqueue, Pa.DataPipe, self.SkipAutoGen, PcdMaList)
+                    autogen_rt = self.StartAutoGen(mqueue, Pa.DataPipe, self.SkipAutoGen, PcdMaList,self.share_data)
                     self.Progress.Stop("done!")
                     self.AutoGenTime += int(round((time.time() - AutoGenStart)))
                     if not autogen_rt:
                         return
                 for Arch in Wa.ArchList:
-- 
2.20.1.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#43913): https://edk2.groups.io/g/devel/message/43913
Mute This Topic: https://groups.io/mt/32512457/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-




More information about the edk2-devel-archive mailing list