summaryrefslogtreecommitdiffstats
path: root/meta/classes/terminal.bbclass
diff options
context:
space:
mode:
authorChris Larson <chris_larson@mentor.com>2011-03-29 19:53:19 (GMT)
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-08-10 12:33:07 (GMT)
commit057cc1e8162017b63a334953eb0998863e6b640f (patch)
treefb42e2631b26c3757fe7774bfba07e8f5bf34c9c /meta/classes/terminal.bbclass
parent94faa71d5c1b25510219ee04c831daa9f242b883 (diff)
downloadpoky-057cc1e8162017b63a334953eb0998863e6b640f.tar.gz
Rework how the devshell functions
In the new implementation, each known terminal is defined as a class in oe.terminal, as a subclass of bb.process.Popen. terminal.bbclass wraps this functionality, providing the metadata pieces. It obeys the OE_TERMINAL variable, which is a 'choice' typed variable. This variable may be 'auto', 'none', or any of the names of the defined terminals. When using 'auto', or requesting an unsupported terminal, we attempt to spawn them in priority order until we get one that's available on this system (and in the case of the X terminals, has DISPLAY defined). The 'none' value is used when we're doing things like automated builds, and want to ensure that no terminal is *ever* spawned, under any circumstances. Current available terminals: gnome konsole xterm rxvt screen (From OE-Core rev: 69f77f80965fa06a057837f8f49eda06855c4086) Signed-off-by: Chris Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/terminal.bbclass')
-rw-r--r--meta/classes/terminal.bbclass40
1 files changed, 40 insertions, 0 deletions
diff --git a/meta/classes/terminal.bbclass b/meta/classes/terminal.bbclass
new file mode 100644
index 0000000..4123046
--- /dev/null
+++ b/meta/classes/terminal.bbclass
@@ -0,0 +1,40 @@
1OE_TERMINAL ?= 'auto'
2OE_TERMINAL[type] = 'choice'
3OE_TERMINAL[choices] = 'auto none \
4 ${@" ".join(o.name \
5 for o in oe.terminal.prioritized())}'
6
7OE_TERMINAL_EXPORTS = 'XAUTHORITY SHELL DBUS_SESSION_BUS_ADDRESS DISPLAY EXTRA_OEMAKE'
8OE_TERMINAL_EXPORTS[type] = 'list'
9
10XAUTHORITY ?= "${HOME}/.Xauthority"
11SHELL ?= "bash"
12
13
14def 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))