diff options
Diffstat (limited to 'bitbake/bin/bitbake-worker')
-rwxr-xr-x | bitbake/bin/bitbake-worker | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/bitbake/bin/bitbake-worker b/bitbake/bin/bitbake-worker index d1ff5b36c5..c7992f7e82 100755 --- a/bitbake/bin/bitbake-worker +++ b/bitbake/bin/bitbake-worker | |||
@@ -12,10 +12,18 @@ import errno | |||
12 | import signal | 12 | import signal |
13 | 13 | ||
14 | # Users shouldn't be running this code directly | 14 | # Users shouldn't be running this code directly |
15 | if len(sys.argv) != 2 or sys.argv[1] != "decafbad": | 15 | if len(sys.argv) != 2 or not sys.argv[1].startswith("decafbad"): |
16 | print("bitbake-worker is meant for internal execution by bitbake itself, please don't use it standalone.") | 16 | print("bitbake-worker is meant for internal execution by bitbake itself, please don't use it standalone.") |
17 | sys.exit(1) | 17 | sys.exit(1) |
18 | 18 | ||
19 | profiling = False | ||
20 | if sys.argv[1] == "decafbadbad": | ||
21 | profiling = True | ||
22 | try: | ||
23 | import cProfile as profile | ||
24 | except: | ||
25 | import profile | ||
26 | |||
19 | logger = logging.getLogger("BitBake") | 27 | logger = logging.getLogger("BitBake") |
20 | 28 | ||
21 | try: | 29 | try: |
@@ -134,6 +142,7 @@ def fork_off_task(cfg, data, workerdata, fn, task, taskname, appends, taskdepdat | |||
134 | bb.msg.fatal("RunQueue", "fork failed: %d (%s)" % (e.errno, e.strerror)) | 142 | bb.msg.fatal("RunQueue", "fork failed: %d (%s)" % (e.errno, e.strerror)) |
135 | 143 | ||
136 | if pid == 0: | 144 | if pid == 0: |
145 | def child(): | ||
137 | global worker_pipe | 146 | global worker_pipe |
138 | pipein.close() | 147 | pipein.close() |
139 | 148 | ||
@@ -185,10 +194,20 @@ def fork_off_task(cfg, data, workerdata, fn, task, taskname, appends, taskdepdat | |||
185 | os._exit(1) | 194 | os._exit(1) |
186 | try: | 195 | try: |
187 | if not cfg.dry_run: | 196 | if not cfg.dry_run: |
188 | ret = bb.build.exec_task(fn, taskname, the_data, cfg.profile) | 197 | return bb.build.exec_task(fn, taskname, the_data, cfg.profile) |
189 | os._exit(ret) | ||
190 | except: | 198 | except: |
191 | os._exit(1) | 199 | os._exit(1) |
200 | if not profiling: | ||
201 | os._exit(child()) | ||
202 | else: | ||
203 | profname = "profile-%s.log" % (fn.replace("/", "-") + "-" + taskname) | ||
204 | prof = profile.Profile() | ||
205 | try: | ||
206 | ret = profile.Profile.runcall(prof, child) | ||
207 | finally: | ||
208 | prof.dump_stats(profname) | ||
209 | bb.utils.process_profilelog(profname) | ||
210 | os._exit(ret) | ||
192 | else: | 211 | else: |
193 | for key, value in envbackup.iteritems(): | 212 | for key, value in envbackup.iteritems(): |
194 | if value is None: | 213 | if value is None: |
@@ -363,7 +382,16 @@ class BitbakeWorker(object): | |||
363 | 382 | ||
364 | try: | 383 | try: |
365 | worker = BitbakeWorker(sys.stdin) | 384 | worker = BitbakeWorker(sys.stdin) |
366 | worker.serve() | 385 | if not profiling: |
386 | worker.serve() | ||
387 | else: | ||
388 | profname = "profile-worker.log" | ||
389 | prof = profile.Profile() | ||
390 | try: | ||
391 | profile.Profile.runcall(prof, worker.serve) | ||
392 | finally: | ||
393 | prof.dump_stats(profname) | ||
394 | bb.utils.process_profilelog(profname) | ||
367 | except BaseException as e: | 395 | except BaseException as e: |
368 | if not normalexit: | 396 | if not normalexit: |
369 | import traceback | 397 | import traceback |