summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbitbake/bin/bitbake23
-rw-r--r--bitbake/lib/bb/command.py2
-rw-r--r--bitbake/lib/bb/cooker.py11
-rw-r--r--bitbake/lib/bb/server/none.py59
-rw-r--r--bitbake/lib/bb/server/xmlrpc.py50
5 files changed, 92 insertions, 53 deletions
diff --git a/bitbake/bin/bitbake b/bitbake/bin/bitbake
index acd086753f..8f2fece2ca 100755
--- a/bitbake/bin/bitbake
+++ b/bitbake/bin/bitbake
@@ -40,7 +40,7 @@ from bb import cooker
40from bb import ui 40from bb import ui
41from bb import server 41from bb import server
42from bb.server import none 42from bb.server import none
43#from bb.server import xmlrpc 43from bb.server import xmlrpc
44 44
45__version__ = "1.13.0" 45__version__ = "1.13.0"
46logger = logging.getLogger("BitBake") 46logger = logging.getLogger("BitBake")
@@ -173,9 +173,6 @@ Default BBFILES are the .bb files in the current directory.""")
173 173
174 ui_main = get_ui(configuration) 174 ui_main = get_ui(configuration)
175 175
176 #server = bb.server.xmlrpc
177 server = bb.server.none
178
179 # Save a logfile for cooker into the current working directory. When the 176 # Save a logfile for cooker into the current working directory. When the
180 # server is daemonized this logfile will be truncated. 177 # server is daemonized this logfile will be truncated.
181 cooker_logfile = os.path.join(os.getcwd(), "cooker.log") 178 cooker_logfile = os.path.join(os.getcwd(), "cooker.log")
@@ -192,21 +189,29 @@ Default BBFILES are the .bb files in the current directory.""")
192 # of the UIs (e.g. for DISPLAY, etc.) 189 # of the UIs (e.g. for DISPLAY, etc.)
193 bb.utils.clean_environment() 190 bb.utils.clean_environment()
194 191
195 cooker = bb.cooker.BBCooker(configuration, server) 192 #server = bb.server.xmlrpc.BitBakeServer()
193 server = bb.server.none.BitBakeServer()
194
195 server.initServer()
196 idle = server.getServerIdleCB()
197
198 cooker = bb.cooker.BBCooker(configuration, idle)
196 cooker.parseCommandLine() 199 cooker.parseCommandLine()
197 200
198 serverinfo = server.BitbakeServerInfo(cooker.server) 201 server.addcooker(cooker)
202 server.saveConnectionDetails()
203 server.detach(cooker_logfile)
199 204
200 server.BitBakeServerFork(cooker, cooker.server, serverinfo, cooker_logfile) 205 # Should no longer need to ever reference cooker
201 del cooker 206 del cooker
202 207
203 logger.removeHandler(handler) 208 logger.removeHandler(handler)
204 209
205 # Setup a connection to the server (cooker) 210 # Setup a connection to the server (cooker)
206 server_connection = server.BitBakeServerConnection(serverinfo) 211 server_connection = server.establishConnection()
207 212
208 try: 213 try:
209 return server.BitbakeUILauch().launch(serverinfo, ui_main, server_connection.connection, server_connection.events) 214 return server.launchUI(ui_main, server_connection.connection, server_connection.events)
210 finally: 215 finally:
211 server_connection.terminate() 216 server_connection.terminate()
212 217
diff --git a/bitbake/lib/bb/command.py b/bitbake/lib/bb/command.py
index e83751a2fa..9841e6874e 100644
--- a/bitbake/lib/bb/command.py
+++ b/bitbake/lib/bb/command.py
@@ -82,7 +82,7 @@ class Command:
82 if command not in CommandsAsync.__dict__: 82 if command not in CommandsAsync.__dict__:
83 return "No such command" 83 return "No such command"
84 self.currentAsyncCommand = (command, commandline) 84 self.currentAsyncCommand = (command, commandline)
85 self.cooker.server.register_idle_function(self.cooker.runCommands, self.cooker) 85 self.cooker.server_registration_cb(self.cooker.runCommands, self.cooker)
86 return True 86 return True
87 except: 87 except:
88 import traceback 88 import traceback
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index 8379d0caf1..94495e1399 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -63,12 +63,11 @@ class BBCooker:
63 Manages one bitbake build run 63 Manages one bitbake build run
64 """ 64 """
65 65
66 def __init__(self, configuration, server): 66 def __init__(self, configuration, server_registration_cb):
67 self.status = None 67 self.status = None
68 self.appendlist = {} 68 self.appendlist = {}
69 69
70 if server: 70 self.server_registration_cb = server_registration_cb
71 self.server = server.BitBakeServer(self)
72 71
73 self.configuration = configuration 72 self.configuration = configuration
74 73
@@ -109,7 +108,7 @@ class BBCooker:
109 108
110 self.configuration.data = bb.data.init() 109 self.configuration.data = bb.data.init()
111 110
112 if not server: 111 if not self.server_registration_cb:
113 bb.data.setVar("BB_WORKERCONTEXT", "1", self.configuration.data) 112 bb.data.setVar("BB_WORKERCONTEXT", "1", self.configuration.data)
114 113
115 bb.data.inheritFromOS(self.configuration.data) 114 bb.data.inheritFromOS(self.configuration.data)
@@ -831,7 +830,7 @@ class BBCooker:
831 return True 830 return True
832 return retval 831 return retval
833 832
834 self.server.register_idle_function(buildFileIdle, rq) 833 self.server_registration_cb(buildFileIdle, rq)
835 834
836 def buildTargets(self, targets, task): 835 def buildTargets(self, targets, task):
837 """ 836 """
@@ -890,7 +889,7 @@ class BBCooker:
890 889
891 rq = bb.runqueue.RunQueue(self, self.configuration.data, self.status, taskdata, runlist) 890 rq = bb.runqueue.RunQueue(self, self.configuration.data, self.status, taskdata, runlist)
892 891
893 self.server.register_idle_function(buildTargetsIdle, rq) 892 self.server_registration_cb(buildTargetsIdle, rq)
894 893
895 def updateCache(self): 894 def updateCache(self):
896 if self.state == state.running: 895 if self.state == state.running:
diff --git a/bitbake/lib/bb/server/none.py b/bitbake/lib/bb/server/none.py
index 45cda2f5f4..6083631fe7 100644
--- a/bitbake/lib/bb/server/none.py
+++ b/bitbake/lib/bb/server/none.py
@@ -36,8 +36,7 @@ DEBUG = False
36import inspect, select 36import inspect, select
37 37
38class BitBakeServerCommands(): 38class BitBakeServerCommands():
39 def __init__(self, server, cooker): 39 def __init__(self, server):
40 self.cooker = cooker
41 self.server = server 40 self.server = server
42 41
43 def runCommand(self, command): 42 def runCommand(self, command):
@@ -106,13 +105,17 @@ class BBUIEventQueue:
106def chldhandler(signum, stackframe): 105def chldhandler(signum, stackframe):
107 pass 106 pass
108 107
109class BitBakeServer(): 108class BitBakeNoneServer():
110 # remove this when you're done with debugging 109 # remove this when you're done with debugging
111 # allow_reuse_address = True 110 # allow_reuse_address = True
112 111
113 def __init__(self, cooker): 112 def __init__(self):
114 self._idlefuns = {} 113 self._idlefuns = {}
115 self.commands = BitBakeServerCommands(self, cooker) 114 self.commands = BitBakeServerCommands(self)
115
116 def addcooker(self, cooker):
117 self.cooker = cooker
118 self.commands.cooker = cooker
116 119
117 def register_idle_function(self, function, data): 120 def register_idle_function(self, function, data):
118 """Register a function to be called while the server is idle""" 121 """Register a function to be called while the server is idle"""
@@ -157,25 +160,10 @@ class BitBakeServer():
157 except: 160 except:
158 pass 161 pass
159 162
160class BitbakeServerInfo():
161 def __init__(self, server):
162 self.server = server
163 self.commands = server.commands
164
165class BitBakeServerFork():
166 def __init__(self, cooker, server, serverinfo, logfile):
167 serverinfo.logfile = logfile
168 serverinfo.cooker = cooker
169 serverinfo.server = server
170
171class BitbakeUILauch():
172 def launch(self, serverinfo, uifunc, *args):
173 return bb.cooker.server_main(serverinfo.cooker, uifunc, *args)
174
175class BitBakeServerConnection(): 163class BitBakeServerConnection():
176 def __init__(self, serverinfo): 164 def __init__(self, server):
177 self.server = serverinfo.server 165 self.server = server.server
178 self.connection = serverinfo.commands 166 self.connection = self.server.commands
179 self.events = bb.server.none.BBUIEventQueue(self.server) 167 self.events = bb.server.none.BBUIEventQueue(self.server)
180 for event in bb.event.ui_queue: 168 for event in bb.event.ui_queue:
181 self.events.queue_event(event) 169 self.events.queue_event(event)
@@ -189,3 +177,28 @@ class BitBakeServerConnection():
189 self.connection.terminateServer() 177 self.connection.terminateServer()
190 except: 178 except:
191 pass 179 pass
180
181class BitBakeServer(object):
182 def initServer(self):
183 self.server = BitBakeNoneServer()
184
185 def addcooker(self, cooker):
186 self.cooker = cooker
187 self.server.addcooker(cooker)
188
189 def getServerIdleCB(self):
190 return self.server.register_idle_function
191
192 def saveConnectionDetails(self):
193 return
194
195 def detach(self, cooker_logfile):
196 self.logfile = cooker_logfile
197
198 def establishConnection(self):
199 self.connection = BitBakeServerConnection(self)
200 return self.connection
201
202 def launchUI(self, uifunc, *args):
203 return bb.cooker.server_main(self.cooker, uifunc, *args)
204
diff --git a/bitbake/lib/bb/server/xmlrpc.py b/bitbake/lib/bb/server/xmlrpc.py
index e7b6010874..4a16f9d525 100644
--- a/bitbake/lib/bb/server/xmlrpc.py
+++ b/bitbake/lib/bb/server/xmlrpc.py
@@ -122,8 +122,7 @@ def _create_server(host, port):
122 return s 122 return s
123 123
124class BitBakeServerCommands(): 124class BitBakeServerCommands():
125 def __init__(self, server, cooker): 125 def __init__(self, server):
126 self.cooker = cooker
127 self.server = server 126 self.server = server
128 127
129 def registerEventHandler(self, host, port): 128 def registerEventHandler(self, host, port):
@@ -160,11 +159,11 @@ class BitBakeServerCommands():
160 """ 159 """
161 return True 160 return True
162 161
163class BitBakeServer(SimpleXMLRPCServer): 162class BitBakeXMLRPCServer(SimpleXMLRPCServer):
164 # remove this when you're done with debugging 163 # remove this when you're done with debugging
165 # allow_reuse_address = True 164 # allow_reuse_address = True
166 165
167 def __init__(self, cooker, interface = ("localhost", 0)): 166 def __init__(self, interface = ("localhost", 0)):
168 """ 167 """
169 Constructor 168 Constructor
170 """ 169 """
@@ -174,9 +173,12 @@ class BitBakeServer(SimpleXMLRPCServer):
174 self._idlefuns = {} 173 self._idlefuns = {}
175 self.host, self.port = self.socket.getsockname() 174 self.host, self.port = self.socket.getsockname()
176 #self.register_introspection_functions() 175 #self.register_introspection_functions()
177 commands = BitBakeServerCommands(self, cooker) 176 self.commands = BitBakeServerCommands(self)
178 self.autoregister_all_functions(commands, "") 177 self.autoregister_all_functions(self.commands, "")
178
179 def addcooker(self, cooker):
179 self.cooker = cooker 180 self.cooker = cooker
181 self.commands.cooker = cooker
180 182
181 def autoregister_all_functions(self, context, prefix): 183 def autoregister_all_functions(self, context, prefix):
182 """ 184 """
@@ -244,14 +246,6 @@ class BitbakeServerInfo():
244 self.host = server.host 246 self.host = server.host
245 self.port = server.port 247 self.port = server.port
246 248
247class BitBakeServerFork():
248 def __init__(self, cooker, server, serverinfo, logfile):
249 daemonize.createDaemon(server.serve_forever, logfile)
250
251class BitbakeUILauch():
252 def launch(self, serverinfo, uifunc, *args):
253 return uifunc(*args)
254
255class BitBakeServerConnection(): 249class BitBakeServerConnection():
256 def __init__(self, serverinfo): 250 def __init__(self, serverinfo):
257 self.connection = _create_server(serverinfo.host, serverinfo.port) 251 self.connection = _create_server(serverinfo.host, serverinfo.port)
@@ -271,3 +265,31 @@ class BitBakeServerConnection():
271 self.connection.terminateServer() 265 self.connection.terminateServer()
272 except: 266 except:
273 pass 267 pass
268
269class BitBakeServer(object):
270 def initServer(self):
271 self.server = BitBakeXMLRPCServer()
272
273 def addcooker(self, cooker):
274 self.cooker = cooker
275 self.server.addcooker(cooker)
276
277 def getServerIdleCB(self):
278 return self.server.register_idle_function
279
280 def saveConnectionDetails(self):
281 self.serverinfo = BitbakeServerInfo(self.server)
282
283 def detach(self, cooker_logfile):
284 daemonize.createDaemon(self.server.serve_forever, cooker_logfile)
285 del self.cooker
286 del self.server
287
288 def establishConnection(self):
289 self.connection = BitBakeServerConnection(self.serverinfo)
290 return self.connection
291
292 def launchUI(self, uifunc, *args):
293 return uifunc(*args)
294
295