summaryrefslogtreecommitdiffstats
path: root/bitbake/bin/bitbake-runtask
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@linux.intel.com>2010-08-16 16:37:29 +0100
committerRichard Purdie <rpurdie@linux.intel.com>2010-08-19 22:36:25 +0100
commitb6bfe1420517aa5aa190e17dca40ea70f09effd9 (patch)
tree2591a26f18290e8d929517df71f24645394c57fb /bitbake/bin/bitbake-runtask
parenta45e1d54e19d4cd728e90df929b212e41ef70d4b (diff)
downloadpoky-b6bfe1420517aa5aa190e17dca40ea70f09effd9.tar.gz
bitbake: Switch to use subprocess for forking tasks and FAKEROOTENV to run shell and python under a fakeroot environment
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'bitbake/bin/bitbake-runtask')
-rwxr-xr-xbitbake/bin/bitbake-runtask77
1 files changed, 77 insertions, 0 deletions
diff --git a/bitbake/bin/bitbake-runtask b/bitbake/bin/bitbake-runtask
new file mode 100755
index 0000000000..417f3949cd
--- /dev/null
+++ b/bitbake/bin/bitbake-runtask
@@ -0,0 +1,77 @@
1#!/usr/bin/env python
2
3import os
4import sys
5import warnings
6sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), 'lib'))
7
8class BBConfiguration(object):
9 """
10 Manages build options and configurations for one run
11 """
12
13 def __init__(self):
14 setattr(self, "data", {})
15 setattr(self, "file", [])
16 setattr(self, "cmd", None)
17
18_warnings_showwarning = warnings.showwarning
19def _showwarning(message, category, filename, lineno, file=None, line=None):
20 """Display python warning messages using bb.msg"""
21 if file is not None:
22 if _warnings_showwarning is not None:
23 _warnings_showwarning(message, category, filename, lineno, file, line)
24 else:
25 s = warnings.formatwarning(message, category, filename, lineno)
26 s = s.split("\n")[0]
27 bb.msg.warn(None, s)
28
29warnings.showwarning = _showwarning
30warnings.simplefilter("ignore", DeprecationWarning)
31
32import bb.event
33
34# Need to map our I/O correctly. Currently stdout is a pipe to
35# the server expecting events. We save this and map stdout to stderr.
36
37eventfd = os.dup(sys.stdout.fileno())
38bb.event.worker_pipe = os.fdopen(eventfd, 'w', 0)
39# Replace those fds with our own
40os.dup2(sys.stderr.fileno(), sys.stdout.fileno())
41
42# Save out the PID so that the event can include it the
43# events
44bb.event.worker_pid = os.getpid()
45bb.event.usestdout = False
46
47
48import bb.cooker
49
50cooker = bb.cooker.BBCooker(BBConfiguration(), None)
51buildfile = sys.argv[1]
52taskname = sys.argv[2]
53
54cooker.parseConfiguration()
55
56cooker.bb_cache = bb.cache.init(cooker)
57cooker.status = bb.cache.CacheData()
58
59(fn, cls) = cooker.bb_cache.virtualfn2realfn(buildfile)
60buildfile = cooker.matchFile(fn)
61fn = cooker.bb_cache.realfn2virtual(buildfile, cls)
62
63cooker.buildSetVars()
64
65# Load data into the cache for fn and parse the loaded cache data
66the_data = cooker.bb_cache.loadDataFull(fn, cooker.get_file_appends(fn), cooker.configuration.data)
67cooker.bb_cache.setData(fn, buildfile, the_data)
68cooker.bb_cache.handle_data(fn, cooker.status)
69
70if taskname.endswith("_setscene"):
71 the_data.setVarFlag(taskname, "quieterrors", "1")
72
73ret = 0
74if sys.argv[3] != "True":
75 ret = bb.build.exec_task(taskname, the_data)
76sys.exit(ret)
77