diff options
Diffstat (limited to 'meta/classes')
-rw-r--r-- | meta/classes/devshell.bbclass | 24 | ||||
-rw-r--r-- | meta/classes/terminal.bbclass | 40 |
2 files changed, 46 insertions, 18 deletions
diff --git a/meta/classes/devshell.bbclass b/meta/classes/devshell.bbclass index 5f262f426e..ddb6e55303 100644 --- a/meta/classes/devshell.bbclass +++ b/meta/classes/devshell.bbclass | |||
@@ -1,22 +1,10 @@ | |||
1 | do_devshell[dirs] = "${S}" | 1 | inherit terminal |
2 | do_devshell[nostamp] = "1" | ||
3 | 2 | ||
4 | XAUTHORITY ?= "${HOME}/.Xauthority" | 3 | python do_devshell () { |
5 | 4 | oe_terminal(d.getVar('SHELL', True), 'OpenEmbedded Developer Shell', d) | |
6 | devshell_do_devshell() { | ||
7 | export DISPLAY='${DISPLAY}' | ||
8 | export DBUS_SESSION_BUS_ADDRESS='${DBUS_SESSION_BUS_ADDRESS}' | ||
9 | export XAUTHORITY='${XAUTHORITY}' | ||
10 | export TERMWINDOWTITLE="Bitbake Developer Shell" | ||
11 | export EXTRA_OEMAKE='${EXTRA_OEMAKE}' | ||
12 | export SHELLCMDS="bash" | ||
13 | ${TERMCMDRUN} | ||
14 | if [ $? -ne 0 ]; then | ||
15 | echo "Fatal: '${TERMCMD}' not found. Check TERMCMD variable." | ||
16 | exit 1 | ||
17 | fi | ||
18 | } | 5 | } |
19 | addtask devshell after do_patch | ||
20 | 6 | ||
21 | EXPORT_FUNCTIONS do_devshell | 7 | addtask devshell after do_patch |
22 | 8 | ||
9 | do_devshell[dirs] = "${S}" | ||
10 | do_devshell[nostamp] = "1" | ||
diff --git a/meta/classes/terminal.bbclass b/meta/classes/terminal.bbclass new file mode 100644 index 0000000000..41230466c4 --- /dev/null +++ b/meta/classes/terminal.bbclass | |||
@@ -0,0 +1,40 @@ | |||
1 | OE_TERMINAL ?= 'auto' | ||
2 | OE_TERMINAL[type] = 'choice' | ||
3 | OE_TERMINAL[choices] = 'auto none \ | ||
4 | ${@" ".join(o.name \ | ||
5 | for o in oe.terminal.prioritized())}' | ||
6 | |||
7 | OE_TERMINAL_EXPORTS = 'XAUTHORITY SHELL DBUS_SESSION_BUS_ADDRESS DISPLAY EXTRA_OEMAKE' | ||
8 | OE_TERMINAL_EXPORTS[type] = 'list' | ||
9 | |||
10 | XAUTHORITY ?= "${HOME}/.Xauthority" | ||
11 | SHELL ?= "bash" | ||
12 | |||
13 | |||
14 | def oe_terminal(command, title, d): | ||
15 | import oe.data | ||
16 | import oe.terminal | ||
17 | |||
18 | terminal = oe.data.typed_value('OE_TERMINAL', d).lower() | ||
19 | if terminal == 'none': | ||
20 | bb.fatal('Devshell usage disabled with OE_TERMINAL') | ||
21 | elif terminal != 'auto': | ||
22 | try: | ||
23 | oe.terminal.spawn(terminal, command, title) | ||
24 | return | ||
25 | except oe.terminal.UnsupportedTerminal: | ||
26 | bb.warn('Unsupported terminal "%s", defaulting to "auto"' % | ||
27 | terminal) | ||
28 | except oe.terminal.ExecutionError as exc: | ||
29 | bb.fatal('Unable to spawn terminal %s: %s' % (terminal, exc)) | ||
30 | |||
31 | env = dict(os.environ) | ||
32 | for export in oe.data.typed_value('OE_TERMINAL_EXPORTS', d): | ||
33 | env[export] = d.getVar(export, True) | ||
34 | |||
35 | try: | ||
36 | oe.terminal.spawn_preferred(command, title, env) | ||
37 | except oe.terminal.NoSupportedTerminals: | ||
38 | bb.fatal('No valid terminal found, unable to open devshell') | ||
39 | except oe.terminal.ExecutionError as exc: | ||
40 | bb.fatal('Unable to spawn terminal %s: %s' % (terminal, exc)) | ||