summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
diff options
context:
space:
mode:
authorEd Bartosh <ed.bartosh@linux.intel.com>2016-04-06 17:46:22 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-04-06 23:10:28 +0100
commita43a16b9fd471d719761354eaab81409d4b07470 (patch)
tree9faa22850bd1251a58d9e315936514337a6c3558 /bitbake/lib
parentab18c208b205bb5e536f7ed4093bacd071e2d8df (diff)
downloadpoky-a43a16b9fd471d719761354eaab81409d4b07470.tar.gz
bitbake: toaster: reimplement triggerBuild
Reimplemented triggerBuild method to support one build directory per project: - start bitbake server from the cloned repository - don't run observer - run bitbake build directly instead of triggering it through xmlrpc [YOCTO #7880] [YOCTO #9058] [YOCTO #8958] (Bitbake rev: aba8e19bf609196f749e185d43571f706707e408) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Michael Wood <michael.g.wood@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rw-r--r--bitbake/lib/toaster/bldcontrol/localhostbecontroller.py102
1 files changed, 67 insertions, 35 deletions
diff --git a/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py b/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py
index 0a2e41d8c8..2e3aa37d01 100644
--- a/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py
+++ b/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py
@@ -250,44 +250,76 @@ class LocalhostBEController(BuildEnvironmentController):
250 250
251 251
252 def triggerBuild(self, bitbake, layers, variables, targets, brbe): 252 def triggerBuild(self, bitbake, layers, variables, targets, brbe):
253 # set up the build environment with the needed layers 253 layers = self.setLayers(bitbake, layers, targets)
254 self.setLayers(bitbake, layers, targets) 254
255 # init build environment from the clone
256 builddir = '%s-toaster-%d' % (self.be.builddir, bitbake.req.project.id)
257 oe_init = os.path.join(self.pokydirname, 'oe-init-build-env')
258 # init build environment
259 self._shellcmd('source %s %s' % (oe_init, builddir), self.be.sourcedir)
260
261 # update bblayers.conf
262 bblconfpath = os.path.join(builddir, "conf/bblayers.conf")
263 conflines = open(bblconfpath, "r").readlines()
264 skip = False
265 with open(bblconfpath, 'w') as bblayers:
266 for line in conflines:
267 if line.startswith("# line added by toaster"):
268 skip = True
269 continue
270 if skip:
271 skip = False
272 else:
273 bblayers.write(line)
274
275 bblayers.write('# line added by toaster build control\n'
276 'BBLAYERS = "%s"' % ' '.join(layers))
255 277
256 # write configuration file 278 # write configuration file
257 filepath = os.path.join(self.be.builddir, "conf/toaster.conf") 279 confpath = os.path.join(builddir, 'conf/toaster.conf')
258 with open(filepath, 'w') as conf: 280 with open(confpath, 'w') as conf:
259 for var in variables: 281 for var in variables:
260 conf.write('%s="%s"\n' % (var.name, var.value)) 282 conf.write('%s="%s"\n' % (var.name, var.value))
261 conf.write('INHERIT+="toaster buildhistory"') 283 conf.write('INHERIT+="toaster buildhistory"')
262 284
263 # get the bb server running with the build req id and build env id 285 # run bitbake server from the clone
264 bbctrl = self.getBBController() 286 bitbake = os.path.join(self.pokydirname, 'bitbake', 'bin', 'bitbake')
265 287 self._shellcmd('source %s %s; BITBAKE_UI="" %s --read %s '
266 # set variables; TOASTER_BRBE is not set on the server, as this 288 '--server-only -t xmlrpc -B 0.0.0.0:0' % (oe_init, builddir,
267 # causes events from command-line builds to be attached to the last 289 bitbake, confpath), self.be.sourcedir)
268 # Toaster-triggered build; instead, TOASTER_BRBE is fired as an event so 290
269 # that toasterui can set it on the buildinfohelper; 291 # read port number from bitbake.lock
270 # see https://bugzilla.yoctoproject.org/show_bug.cgi?id=9021 292 self.be.bbport = ""
271 for var in variables: 293 bblock = os.path.join(builddir, 'bitbake.lock')
272 if var.name == 'TOASTER_BRBE': 294 with open(bblock) as fplock:
273 bbctrl.triggerEvent('bb.event.MetadataEvent("SetBRBE", "%s")' \ 295 for line in fplock:
274 % var.value) 296 if ":" in line:
275 else: 297 self.be.bbport = line.split(":")[-1].strip()
276 bbctrl.setVariable(var.name, var.value) 298 logger.debug("localhostbecontroller: bitbake port %s", self.be.bbport)
277 299 break
278 # Add 'toaster' and 'buildhistory' to INHERIT variable 300
279 inherit = {item.strip() for item in bbctrl.getVariable('INHERIT').split()} 301 if not self.be.bbport:
280 inherit = inherit.union(["toaster", "buildhistory"]) 302 raise BuildSetupException("localhostbecontroller: can't read bitbake port from %s" % bblock)
281 bbctrl.setVariable('INHERIT', ' '.join(inherit)) 303
282 304 self.be.bbaddress = "localhost"
283 # trigger the build command 305 self.be.bbstate = BuildEnvironment.SERVER_STARTED
284 task = reduce(lambda x, y: x if len(y)== 0 else y, map(lambda y: y.task, targets)) 306 self.be.lock = BuildEnvironment.LOCK_RUNNING
285 if len(task) == 0: 307 self.be.save()
286 task = None 308
287 309 bbtargets = ''
288 bbctrl.build(list(map(lambda x:x.target, targets)), task) 310 for target in targets:
289 311 task = target.task
290 logger.debug("localhostbecontroller: Build launched, exiting. Follow build logs at %s/toaster_ui.log" % self.be.builddir) 312 if task:
291 313 if not task.startswith('do_'):
292 # disconnect from the server 314 task = 'do_' + task
293 bbctrl.disconnect() 315 task = ':%s' % task
316 bbtargets += '%s%s ' % (target.target, task)
317
318 # run build with local bitbake
319 log = os.path.join(builddir, 'toaster_ui.log')
320 self._shellcmd('TOASTER_BRBE="%s" BBSERVER="0.0.0.0:-1" '
321 '../bitbake/bin/bitbake %s -u toasterui '
322 '>>%s 2>&1 &' % (brbe, bbtargets, log), builddir)
323
324 logger.debug('localhostbecontroller: Build launched, exiting. '
325 'Follow build logs at %s' % log)