From 8d315820aa2c860bee05175a42360e549601a16f Mon Sep 17 00:00:00 2001 From: Paul Eggleton Date: Tue, 13 Dec 2016 20:07:12 +1300 Subject: bitbake: runqueue: enable setVariable command to affect task execution Allow the client to set variables with the setVariable command and have those changes take effect when running tasks. This is accomplished by collecting changes made by setVariable separately and pass these to the worker so it can be applied on top of the datastore it creates. (Bitbake rev: 69a3cd790da35c3898a8f50c284ad1a4677682a4) Signed-off-by: Paul Eggleton Signed-off-by: Richard Purdie --- bitbake/bin/bitbake-worker | 12 ++++++++++-- bitbake/lib/bb/command.py | 1 + bitbake/lib/bb/cooker.py | 1 + bitbake/lib/bb/runqueue.py | 1 + 4 files changed, 13 insertions(+), 2 deletions(-) (limited to 'bitbake') diff --git a/bitbake/bin/bitbake-worker b/bitbake/bin/bitbake-worker index 97b32c3878..4dbd681172 100755 --- a/bitbake/bin/bitbake-worker +++ b/bitbake/bin/bitbake-worker @@ -136,7 +136,7 @@ def sigterm_handler(signum, frame): os.killpg(0, signal.SIGTERM) sys.exit() -def fork_off_task(cfg, data, databuilder, workerdata, fn, task, taskname, appends, taskdepdata, quieterrors=False): +def fork_off_task(cfg, data, databuilder, workerdata, fn, task, taskname, appends, taskdepdata, extraconfigdata, quieterrors=False): # We need to setup the environment BEFORE the fork, since # a fork() or exec*() activates PSEUDO... @@ -223,6 +223,9 @@ def fork_off_task(cfg, data, databuilder, workerdata, fn, task, taskname, append the_data.setVar("BUILDNAME", workerdata["buildname"]) the_data.setVar("DATE", workerdata["date"]) the_data.setVar("TIME", workerdata["time"]) + for varname, value in extraconfigdata.items(): + the_data.setVar(varname, value) + bb.parse.siggen.set_taskdata(workerdata["sigdata"]) ret = 0 @@ -329,6 +332,7 @@ class BitbakeWorker(object): self.cookercfg = None self.databuilder = None self.data = None + self.extraconfigdata = None self.build_pids = {} self.build_pipes = {} @@ -363,6 +367,7 @@ class BitbakeWorker(object): pass if len(self.queue): self.handle_item(b"cookerconfig", self.handle_cookercfg) + self.handle_item(b"extraconfigdata", self.handle_extraconfigdata) self.handle_item(b"workerdata", self.handle_workerdata) self.handle_item(b"runtask", self.handle_runtask) self.handle_item(b"finishnow", self.handle_finishnow) @@ -391,6 +396,9 @@ class BitbakeWorker(object): self.databuilder.parseBaseConfiguration() self.data = self.databuilder.data + def handle_extraconfigdata(self, data): + self.extraconfigdata = pickle.loads(data) + def handle_workerdata(self, data): self.workerdata = pickle.loads(data) bb.msg.loggerDefaultDebugLevel = self.workerdata["logdefaultdebug"] @@ -416,7 +424,7 @@ class BitbakeWorker(object): fn, task, taskname, quieterrors, appends, taskdepdata = pickle.loads(data) workerlog_write("Handling runtask %s %s %s\n" % (task, fn, taskname)) - pid, pipein, pipeout = fork_off_task(self.cookercfg, self.data, self.databuilder, self.workerdata, fn, task, taskname, appends, taskdepdata, quieterrors) + pid, pipein, pipeout = fork_off_task(self.cookercfg, self.data, self.databuilder, self.workerdata, fn, task, taskname, appends, taskdepdata, self.extraconfigdata, quieterrors) self.build_pids[pid] = task self.build_pipes[pid] = runQueueWorkerPipe(pipein, pipeout) diff --git a/bitbake/lib/bb/command.py b/bitbake/lib/bb/command.py index 3b68c1aaa2..5bce796b7c 100644 --- a/bitbake/lib/bb/command.py +++ b/bitbake/lib/bb/command.py @@ -187,6 +187,7 @@ class CommandsSync: """ varname = params[0] value = str(params[1]) + command.cooker.extraconfigdata[varname] = value command.cooker.data.setVar(varname, value) def getSetVariable(self, command, params): diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py index a4aaac59f8..620ff9f3d3 100644 --- a/bitbake/lib/bb/cooker.py +++ b/bitbake/lib/bb/cooker.py @@ -358,6 +358,7 @@ class BBCooker: self.databuilder.parseBaseConfiguration() self.data = self.databuilder.data self.data_hash = self.databuilder.data_hash + self.extraconfigdata = {} if consolelog: self.data.setVar("BB_CONSOLELOG", consolelog) diff --git a/bitbake/lib/bb/runqueue.py b/bitbake/lib/bb/runqueue.py index 389df4f1bc..2ad8aad98e 100644 --- a/bitbake/lib/bb/runqueue.py +++ b/bitbake/lib/bb/runqueue.py @@ -1036,6 +1036,7 @@ class RunQueue: } worker.stdin.write(b"" + pickle.dumps(self.cooker.configuration) + b"") + worker.stdin.write(b"" + pickle.dumps(self.cooker.extraconfigdata) + b"") worker.stdin.write(b"" + pickle.dumps(workerdata) + b"") worker.stdin.flush() -- cgit v1.2.3-54-g00ecf