source: rtems-source-builder/source-builder/sb/shell.py @ 158ad68

4.11
Last change on this file since 158ad68 was 158ad68, checked in by Chris Johns <chrisj@…>, on 10/03/20 at 11:53:04

sb: Back port the RTEMS 5 and 6 RSB engine.

  • Build GDb first as we do for RTEMS 5 and later
  • Update GDB to 9.1 for all archs expect SPARC. The SIS patches only apply to 7.9. Disable Python for SPARC

Closes #4111

  • Property mode set to 100644
File size: 2.6 KB
Line 
1#
2# RTEMS Tools Project (http://www.rtems.org/)
3# Copyright 2019 Chris Johns (chrisj@rtems.org)
4# All rights reserved.
5#
6# This file is part of the RTEMS Tools package in 'rtems-tools'.
7#
8# Permission to use, copy, modify, and/or distribute this software for any
9# purpose with or without fee is hereby granted, provided that the above
10# copyright notice and this permission notice appear in all copies.
11#
12# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19
20#
21# This code builds a package compiler tool suite given a tool set. A tool
22# set lists the various tools. These are specific tool configurations.
23#
24
25from __future__ import print_function
26
27try:
28    from . import error
29    from . import execute
30    from . import log
31    from . import options
32except KeyboardInterrupt:
33    print('abort: user terminated', file = sys.stderr)
34    sys.exit(1)
35except:
36    raise
37
38def expand(macros, line):
39    #
40    # Parse the line and handle nesting '()' pairs.
41    #
42    def _exec(shell_macro):
43        output = ''
44        if len(shell_macro) > 3:
45            e = execute.capture_execution()
46            if options.host_windows:
47                cmd = '%s -c "%s"' % (macros.expand('%{__sh}'), shell_macro[2:-1])
48            else:
49                cmd = shell_macro[2:-1]
50            exit_code, proc, output = e.shell(cmd)
51            log.trace('shell-output: %d %s' % (exit_code, output))
52            if exit_code != 0:
53                raise error.general('shell macro failed: %s: %d: %s' % (cmd,
54                                                                        exit_code,
55                                                                        output))
56        return output
57
58    updating = True
59    while updating:
60        updating = False
61        pos = line.find('%(')
62        if pos >= 0:
63            braces = 0
64            for p in range(pos + 2, len(line)):
65                if line[p] == '(':
66                    braces += 1
67                elif line[p] == ')':
68                    if braces > 0:
69                        braces -= 1
70                    else:
71                        line = line[:pos] + _exec(line[pos:p + 1]) + line[p + 1:]
72                        updating = True
73                        break
74    return line
Note: See TracBrowser for help on using the repository browser.