mirror of
https://git.yoctoproject.org/poky
synced 2026-05-30 00:20:08 +00:00
bitbake: Simplfy pre and post cooker hooks
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
This commit is contained in:
@@ -70,7 +70,7 @@ class BBCooker:
|
|||||||
self.bb_cache = None
|
self.bb_cache = None
|
||||||
|
|
||||||
if server:
|
if server:
|
||||||
self.server = server.BitBakeServer(self, self.pre_serve, self.post_serve)
|
self.server = server.BitBakeServer(self)
|
||||||
|
|
||||||
self.configuration = configuration
|
self.configuration = configuration
|
||||||
|
|
||||||
@@ -925,6 +925,8 @@ class BBCooker:
|
|||||||
|
|
||||||
|
|
||||||
def server_main(cooker, func, *args):
|
def server_main(cooker, func, *args):
|
||||||
|
cooker.pre_serve()
|
||||||
|
|
||||||
if cooker.configuration.profile:
|
if cooker.configuration.profile:
|
||||||
try:
|
try:
|
||||||
import cProfile as profile
|
import cProfile as profile
|
||||||
@@ -956,11 +958,12 @@ def server_main(cooker, func, *args):
|
|||||||
|
|
||||||
print("Raw profiling information saved to profile.log and processed statistics to profile.log.processed")
|
print("Raw profiling information saved to profile.log and processed statistics to profile.log.processed")
|
||||||
|
|
||||||
return ret
|
|
||||||
else:
|
else:
|
||||||
return func(*args)
|
ret = func(*args)
|
||||||
|
|
||||||
|
cooker.post_serve()
|
||||||
|
|
||||||
|
return ret
|
||||||
|
|
||||||
class CookerExit(bb.event.Event):
|
class CookerExit(bb.event.Event):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -109,11 +109,9 @@ class BitBakeServer():
|
|||||||
# remove this when you're done with debugging
|
# remove this when you're done with debugging
|
||||||
# allow_reuse_address = True
|
# allow_reuse_address = True
|
||||||
|
|
||||||
def __init__(self, cooker, pre_serve, post_serve):
|
def __init__(self, cooker):
|
||||||
self._idlefuns = {}
|
self._idlefuns = {}
|
||||||
self.commands = BitBakeServerCommands(self, cooker)
|
self.commands = BitBakeServerCommands(self, cooker)
|
||||||
self.pre_serve = pre_serve
|
|
||||||
self.post_serve = post_serve
|
|
||||||
|
|
||||||
def register_idle_function(self, function, data):
|
def register_idle_function(self, function, data):
|
||||||
"""Register a function to be called while the server is idle"""
|
"""Register a function to be called while the server is idle"""
|
||||||
@@ -169,10 +167,7 @@ class BitBakeServerFork():
|
|||||||
|
|
||||||
class BitbakeUILauch():
|
class BitbakeUILauch():
|
||||||
def launch(self, serverinfo, uifunc, *args):
|
def launch(self, serverinfo, uifunc, *args):
|
||||||
serverinfo.server.pre_serve()
|
return bb.cooker.server_main(serverinfo.cooker, uifunc, *args)
|
||||||
ret = bb.cooker.server_main(serverinfo.cooker, uifunc, *args)
|
|
||||||
serverinfo.server.post_serve()
|
|
||||||
return ret
|
|
||||||
|
|
||||||
class BitBakeServerConnection():
|
class BitBakeServerConnection():
|
||||||
def __init__(self, serverinfo):
|
def __init__(self, serverinfo):
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ class BitBakeServer(SimpleXMLRPCServer):
|
|||||||
# remove this when you're done with debugging
|
# remove this when you're done with debugging
|
||||||
# allow_reuse_address = True
|
# allow_reuse_address = True
|
||||||
|
|
||||||
def __init__(self, cooker, pre_serve, post_serve, interface = ("localhost", 0)):
|
def __init__(self, cooker, interface = ("localhost", 0)):
|
||||||
"""
|
"""
|
||||||
Constructor
|
Constructor
|
||||||
"""
|
"""
|
||||||
@@ -100,8 +100,6 @@ class BitBakeServer(SimpleXMLRPCServer):
|
|||||||
commands = BitBakeServerCommands(self, cooker)
|
commands = BitBakeServerCommands(self, cooker)
|
||||||
self.autoregister_all_functions(commands, "")
|
self.autoregister_all_functions(commands, "")
|
||||||
self.cooker = cooker
|
self.cooker = cooker
|
||||||
self.pre_serve = pre_serve
|
|
||||||
self.post_serve = post_serve
|
|
||||||
|
|
||||||
def autoregister_all_functions(self, context, prefix):
|
def autoregister_all_functions(self, context, prefix):
|
||||||
"""
|
"""
|
||||||
@@ -125,8 +123,6 @@ class BitBakeServer(SimpleXMLRPCServer):
|
|||||||
"""
|
"""
|
||||||
Serve Requests. Overloaded to honor a quit command
|
Serve Requests. Overloaded to honor a quit command
|
||||||
"""
|
"""
|
||||||
self.pre_serve()
|
|
||||||
|
|
||||||
self.quit = False
|
self.quit = False
|
||||||
self.timeout = 0 # Run Idle calls for our first callback
|
self.timeout = 0 # Run Idle calls for our first callback
|
||||||
while not self.quit:
|
while not self.quit:
|
||||||
@@ -163,7 +159,6 @@ class BitBakeServer(SimpleXMLRPCServer):
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
self.post_serve()
|
|
||||||
self.server_close()
|
self.server_close()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user