BaseTools: Add shared data for processes

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

Add shared data for autogen processes.

Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
Acked-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
Feng, Bob C 2019-07-30 18:04:14 +08:00
parent 673d09a2dd
commit 3285fbda88
2 changed files with 8 additions and 5 deletions

View File

@ -64,7 +64,7 @@ class AutoGenManager(threading.Thread):
def kill(self): def kill(self):
self.feedback_q.put(None) self.feedback_q.put(None)
class AutoGenWorkerInProcess(mp.Process): class AutoGenWorkerInProcess(mp.Process):
def __init__(self,module_queue,data_pipe_file_path,feedback_q,file_lock,error_event): def __init__(self,module_queue,data_pipe_file_path,feedback_q,file_lock, share_data,error_event):
mp.Process.__init__(self) mp.Process.__init__(self)
self.module_queue = module_queue self.module_queue = module_queue
self.data_pipe_file_path =data_pipe_file_path self.data_pipe_file_path =data_pipe_file_path
@ -72,6 +72,7 @@ class AutoGenWorkerInProcess(mp.Process):
self.feedback_q = feedback_q self.feedback_q = feedback_q
self.PlatformMetaFileSet = {} self.PlatformMetaFileSet = {}
self.file_lock = file_lock self.file_lock = file_lock
self.share_data = share_data
self.error_event = error_event self.error_event = error_event
def GetPlatformMetaFile(self,filepath,root): def GetPlatformMetaFile(self,filepath,root):
try: try:

View File

@ -52,6 +52,7 @@ from PatchPcdValue.PatchPcdValue import PatchBinaryFile
import Common.GlobalData as GlobalData import Common.GlobalData as GlobalData
from GenFds.GenFds import GenFds, GenFdsApi from GenFds.GenFds import GenFds, GenFdsApi
import multiprocessing as mp import multiprocessing as mp
from multiprocessing import Manager
# Version and Copyright # Version and Copyright
VersionNumber = "0.60" + ' ' + gBUILD_VERSION VersionNumber = "0.60" + ' ' + gBUILD_VERSION
@ -828,14 +829,15 @@ class Build():
self.AutoGenMgr = None self.AutoGenMgr = None
EdkLogger.info("") EdkLogger.info("")
os.chdir(self.WorkspaceDir) 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):
try: try:
if SkipAutoGen: if SkipAutoGen:
return True,0 return True,0
feedback_q = mp.Queue() feedback_q = mp.Queue()
file_lock = mp.Lock() file_lock = mp.Lock()
error_event = mp.Event() error_event = mp.Event()
auto_workers = [AutoGenWorkerInProcess(mqueue,DataPipe.dump_file,feedback_q,file_lock,error_event) for _ in range(self.ThreadNumber)] auto_workers = [AutoGenWorkerInProcess(mqueue,DataPipe.dump_file,feedback_q,file_lock,share_data,error_event) for _ in range(self.ThreadNumber)]
self.AutoGenMgr = AutoGenManager(auto_workers,feedback_q,error_event) self.AutoGenMgr = AutoGenManager(auto_workers,feedback_q,error_event)
self.AutoGenMgr.start() self.AutoGenMgr.start()
for w in auto_workers: for w in auto_workers:
@ -1230,7 +1232,7 @@ class Build():
self.Progress.Start("Generating makefile and code") self.Progress.Start("Generating makefile and code")
data_pipe_file = os.path.join(AutoGenObject.BuildDir, "GlobalVar_%s_%s.bin" % (str(AutoGenObject.Guid),AutoGenObject.Arch)) data_pipe_file = os.path.join(AutoGenObject.BuildDir, "GlobalVar_%s_%s.bin" % (str(AutoGenObject.Guid),AutoGenObject.Arch))
AutoGenObject.DataPipe.dump(data_pipe_file) AutoGenObject.DataPipe.dump(data_pipe_file)
autogen_rt,errorcode = self.StartAutoGen(mqueue, AutoGenObject.DataPipe, self.SkipAutoGen, PcdMaList) autogen_rt, errorcode = self.StartAutoGen(mqueue, AutoGenObject.DataPipe, self.SkipAutoGen, PcdMaList,self.share_data)
self.Progress.Stop("done!") self.Progress.Stop("done!")
if not autogen_rt: if not autogen_rt:
self.AutoGenMgr.TerminateWorkers() self.AutoGenMgr.TerminateWorkers()
@ -2070,7 +2072,7 @@ class Build():
mqueue.put(m) mqueue.put(m)
data_pipe_file = os.path.join(Pa.BuildDir, "GlobalVar_%s_%s.bin" % (str(Pa.Guid),Pa.Arch)) data_pipe_file = os.path.join(Pa.BuildDir, "GlobalVar_%s_%s.bin" % (str(Pa.Guid),Pa.Arch))
Pa.DataPipe.dump(data_pipe_file) Pa.DataPipe.dump(data_pipe_file)
autogen_rt, errorcode = self.StartAutoGen(mqueue, Pa.DataPipe, self.SkipAutoGen, PcdMaList) autogen_rt, errorcode = self.StartAutoGen(mqueue, Pa.DataPipe, self.SkipAutoGen, PcdMaList,self.share_data)
self.Progress.Stop("done!") self.Progress.Stop("done!")
self.AutoGenTime += int(round((time.time() - AutoGenStart))) self.AutoGenTime += int(round((time.time() - AutoGenStart)))
if not autogen_rt: if not autogen_rt: