Changeset 8922c8b in rtems-source-builder


Ignore:
Timestamp:
07/08/19 12:44:02 (5 years ago)
Author:
Chris Johns <chrisj@…>
Branches:
5, master
Children:
8db33fb
Parents:
c799e04
git-author:
Chris Johns <chrisj@…> (07/08/19 12:44:02)
git-committer:
Chris Johns <chrisj@…> (07/21/19 11:09:34)
Message:

sb/config: Fix GDB probes when using python-config.

  • Fix the config file handling of shell calls where the shell command has nesting braces.
  • Fix the bool check to support a '!' next to the check value.
Location:
source-builder
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • source-builder/config/gdb-common-1.cfg

    rc799e04 r8922c8b  
    109109  %endif
    110110  %if %{gdb-python-config} != %{nil}
    111     %define gdb-python-config-libs -l '%(%{gdb-python-config} --ldflags)'
    112     %define gdb-python-lib-check %(%{_sbdir}/sb/rtems-build-dep -c %{__cc} %{gdb-host-libs} %{gdb-python-config-libs})
     111    %define gdb-python-lib-filter awk 'BEGIN{FS=" "}/python/{for(i=1;i<NF;++i)if(match($i,".*python.*")) print "lib"substr($i,3)"*";}'
     112    %define gdb-python-config-libs %(%{gdb-python-config} --ldflags | %{gdb-python-lib-filter})
     113    %define gdb-python-lib-check %(%{_sbdir}/sb/rtems-build-dep -c %{__cc} %{gdb-host-libs} -l %{gdb-python-config-libs})
    113114  %else
    114115    %define gdb-python-lib-check %(%{_sbdir}/sb/rtems-build-dep -c %{__cc} %{gdb-host-libs} -l %{gdb-python-ver-lib})
  • source-builder/sb/config.py

    rc799e04 r8922c8b  
    5050
    5151def _check_bool(value):
     52    istrue = None
    5253    if value.isdigit():
    5354        if int(value) == 0:
     
    5657            istrue = True
    5758    else:
    58         istrue = None
     59        if type(value) is str and len(value) == 2 and value[0] == '!':
     60            istrue = _check_bool(value[1])
     61            if type(istrue) is bool:
     62                istrue = not istrue
    5963    return istrue
    6064
     
    417421
    418422    def _shell(self, line):
    419         sl = self.sf.findall(line)
    420         if len(sl):
    421             e = execute.capture_execution()
    422             for s in sl:
     423        #
     424        # Parse the line and handle nesting '()' pairs.
     425        #
     426        def _exec(shell_macro):
     427            output = ''
     428            if len(shell_macro) > 3:
     429                e = execute.capture_execution()
    423430                if options.host_windows:
    424                     cmd = '%s -c "%s"' % (self.macros.expand('%{__sh}'), s[2:-1])
    425                 else:
    426                     cmd = s[2:-1]
     431                    cmd = '%s -c "%s"' % (self.macros.expand('%{__sh}'), shell_macro[2:-1])
     432                else:
     433                    cmd = shell_macro[2:-1]
    427434                exit_code, proc, output = e.shell(cmd)
    428435                log.trace('shell-output: %d %s' % (exit_code, output))
    429                 if exit_code == 0:
    430                     line = line.replace(s, output)
    431                 else:
    432                     raise error.general('shell macro failed: %s:%d: %s' % (s, exit_code, output))
     436                if exit_code != 0:
     437                    raise error.general('shell macro failed: %s: %d: %s' % (cmd,
     438                                                                            exit_code,
     439                                                                            output))
     440            return output
     441
     442        updating = True
     443        while updating:
     444            updating = False
     445            pos = line.find('%(')
     446            if pos >= 0:
     447                braces = 0
     448                for p in range(pos + 2, len(line)):
     449                    if line[p] == '(':
     450                        braces += 1
     451                    elif line[p] == ')':
     452                        if braces > 0:
     453                            braces -= 1
     454                        else:
     455                            line = line[:pos] + _exec(line[pos:p + 1]) + line[p + 1:]
     456                            updating = True
     457                            break
    433458        return line
    434459
Note: See TracChangeset for help on using the changeset viewer.