increase dvbapp PR.
[vuplus_openembedded] / recipes / addons / devshell.bb
1 DESCRIPTION = "Runs a shell in an environment as emitted by BitBake to execute tasks"
2 LICENSE = "GPL"
3 PR = "r3"
4
5 inherit autotools pkgconfig
6
7 do_configure() {
8         :
9 }
10
11 def devshell_emit_env(o, d, all=False, funcwhitelist=None):
12     """Emits all items in the data store in a format such that it can be sourced by a shell."""
13
14     env = bb.data.keys(d)
15
16     for e in env:
17         if bb.data.getVarFlag(e, "func", d):
18             continue
19         bb.data.emit_var(e, o, d, all) and o.write('\n')
20
21     for e in env:
22         if not bb.data.getVarFlag(e, "func", d):
23             continue
24         if not funcwhitelist:
25             bb.data.emit_var(e, o, d) and o.write('\n')
26             continue
27         for i in funcwhitelist:
28             if e.startswith(i):
29                 bb.data.emit_var(e, o, d) and o.write('\n')
30                 break
31
32 python do_compile() {
33         import os
34         import os.path
35
36         workdir = bb.data.getVar('WORKDIR', d, 1)
37         shellfile = os.path.join(workdir, bb.data.expand("${TARGET_PREFIX}${DISTRO}-${MACHINE}-devshell", d))
38
39         f = open(shellfile, "w")
40
41         # emit variables and shell functions
42         devshell_emit_env(f, d, False, ["die", "oe", "autotools_do_configure"])
43
44         f.close()
45 }
46
47 do_install() {
48         :
49 }
50
51 do_stage() {
52         :
53 }
54
55 do_deploy() {
56         shellfile="${TARGET_PREFIX}${DISTRO}-${MACHINE}-devshell"
57
58         cd ${WORKDIR}
59
60         cp $shellfile tmpfile
61         echo "#!/bin/bash --rcfile" > $shellfile
62         sed -e "s:${S}:.:g" -e "s:exit 1:true:" tmpfile >> $shellfile
63
64         echo "export PS1='[OE::${TARGET_PREFIX}${DISTRO}-${MACHINE}]:\w\$ '" >> $shellfile
65         echo "alias ./configure=oe_runconf" >> $shellfile
66         echo "alias make=oe_runmake" >> $shellfile
67
68         mkdir -p ${DEPLOY_DIR}/addons
69         install -m 755 $shellfile ${DEPLOY_DIR}/addons
70 }
71
72 addtask deploy after do_install before do_package