summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
diff options
context:
space:
mode:
authorLaurentiu Palcu <laurentiu.palcu@intel.com>2014-02-03 13:33:07 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-02-09 10:01:38 +0000
commit095bb006c3dbbfbdfa05f13d8d7b50e2a5ab2af0 (patch)
treeab86def4170d8a2d78712b898a2844ba61db0296 /bitbake/lib
parent5232ba83fda1b9c0f275e51037e4a51aaf4094ea (diff)
downloadpoky-095bb006c3dbbfbdfa05f13d8d7b50e2a5ab2af0.tar.gz
bitbake: bitbake: build.py: create separate function for shell trap creation code
Currently, the shell trap code was created in exec_func_shell(). Split the function so that we can create the code separately. Also, some whitespaces were automatically deleted by my editor. Since this is not necessarily a bad thing, leave these changes too. (Bitbake rev: c712e622d20c61a07c9c172b60e9dc6beae14197) Signed-off-by: Laurentiu Palcu <laurentiu.palcu@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rw-r--r--bitbake/lib/bb/build.py37
1 files changed, 20 insertions, 17 deletions
diff --git a/bitbake/lib/bb/build.py b/bitbake/lib/bb/build.py
index 3aa63758c1..692b91ec1b 100644
--- a/bitbake/lib/bb/build.py
+++ b/bitbake/lib/bb/build.py
@@ -254,19 +254,8 @@ def exec_func_python(func, d, runfile, cwd=None):
254 except OSError: 254 except OSError:
255 pass 255 pass
256 256
257def exec_func_shell(func, d, runfile, cwd=None): 257def shell_trap_code():
258 """Execute a shell function from the metadata 258 return '''#!/bin/sh\n
259
260 Note on directory behavior. The 'dirs' varflag should contain a list
261 of the directories you need created prior to execution. The last
262 item in the list is where we will chdir/cd to.
263 """
264
265 # Don't let the emitted shell script override PWD
266 d.delVarFlag('PWD', 'export')
267
268 with open(runfile, 'w') as script:
269 script.write('''#!/bin/sh\n
270# Emit a useful diagnostic if something fails: 259# Emit a useful diagnostic if something fails:
271bb_exit_handler() { 260bb_exit_handler() {
272 ret=$? 261 ret=$?
@@ -282,7 +271,21 @@ bb_exit_handler() {
282} 271}
283trap 'bb_exit_handler' 0 272trap 'bb_exit_handler' 0
284set -e 273set -e
285''') 274'''
275
276def exec_func_shell(func, d, runfile, cwd=None):
277 """Execute a shell function from the metadata
278
279 Note on directory behavior. The 'dirs' varflag should contain a list
280 of the directories you need created prior to execution. The last
281 item in the list is where we will chdir/cd to.
282 """
283
284 # Don't let the emitted shell script override PWD
285 d.delVarFlag('PWD', 'export')
286
287 with open(runfile, 'w') as script:
288 script.write(shell_trap_code())
286 289
287 bb.data.emit_func(func, script, d) 290 bb.data.emit_func(func, script, d)
288 291
@@ -473,12 +476,12 @@ def _exec_task(fn, task, d, quieterr):
473 return 0 476 return 0
474 477
475def exec_task(fn, task, d, profile = False): 478def exec_task(fn, task, d, profile = False):
476 try: 479 try:
477 quieterr = False 480 quieterr = False
478 if d.getVarFlag(task, "quieterrors") is not None: 481 if d.getVarFlag(task, "quieterrors") is not None:
479 quieterr = True 482 quieterr = True
480 483
481 if profile: 484 if profile:
482 profname = "profile-%s.log" % (d.getVar("PN", True) + "-" + task) 485 profname = "profile-%s.log" % (d.getVar("PN", True) + "-" + task)
483 try: 486 try:
484 import cProfile as profile 487 import cProfile as profile
@@ -576,7 +579,7 @@ def make_stamp(task, d, file_name = None):
576 if name.endswith('.taint'): 579 if name.endswith('.taint'):
577 continue 580 continue
578 os.unlink(name) 581 os.unlink(name)
579 582
580 stamp = stamp_internal(task, d, file_name) 583 stamp = stamp_internal(task, d, file_name)
581 # Remove the file and recreate to force timestamp 584 # Remove the file and recreate to force timestamp
582 # change on broken NFS filesystems 585 # change on broken NFS filesystems