Changeset 13f4c37 in rtems-source-builder


Ignore:
Timestamp:
Oct 7, 2018, 9:59:45 AM (7 months ago)
Author:
Chris Johns <chrisj@…>
Branches:
master
Children:
c5d84ce
Parents:
8992d20
git-author:
Chris Johns <chrisj@…> (10/07/18 09:59:45)
git-committer:
Chris Johns <chrisj@…> (10/20/18 22:49:02)
Message:

sb: Add support to search for a suitable version of python.

The command python has been removed from upstream python and python2
and python3 is now used. This patch wraps the commands in a shell
script that locates a suitable python to run.

Updates #3537

Location:
source-builder
Files:
10 added
17 edited

Legend:

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

    r8992d20 r13f4c37  
    44# This configuration file configure's, make's and install's gdb.
    55#
     6
     7#
     8# Python
     9#
     10# GDB uses python internally so we need to link to a suitable python
     11# dev kit. The dev kit for python is the header and a library. These
     12# files are versioned where the header file is located in a directory
     13# based on:
     14#
     15#  pythonM.m/Python.h
     16#
     17# where 'M' is the major version number and 'm' is the minor verison
     18# number. The library is:
     19#
     20#  libpythonM.m.a
     21#
     22# The python command is 'pythonM' which means we need to query it for
     23# the minor number.
     24#
     25# The python running the RSB may not be suitable, for example a MSC,
     26# MSYS or Cygwin version on Windows when we want the MinGW python dev
     27# file. A specific version cannot be forced because older versions of
     28# GDB can only link to 'python2'.
     29#
     30# Host support can perform a complex query of the system, for example
     31# Windows and set '%{gdb_python2}' and '%{gdb_python3}' with the full
     32# path to that version's executable.
     33#
     34# A configuration of GDB can set the version required by setting
     35# '%{gdb-python-version}' to the versions command, eg python2.
     36#
     37# The procedure is:
     38#
     39# 1. If the macros '%{gdb_python2}' or '%{gdb_python3}' are present
     40#    use that path they contain. Assume the path is valid.
     41#
     42# 2. Does the version of gdb specify a version of python that must be
     43#    used. Override with '%define gdb-python-version python2'.
     44#
     45# 3. Search for 'python2' and if not found search for 'python3'.
     46#
     47%if %{defined gdb-python2}
     48  %define gdb-enable-python %{gdb_python2}
     49%else
     50  %if %{defined gdb-python3}
     51    %define gdb-enable-python %{gdb_python3}
     52  %else
     53    %if %{defined gdb-python-version}
     54      %define gdb-enable-python %(command -v %{gdb-python-version || true})
     55    %else
     56      %define gdb-enable-python %(command -v python2 || true)
     57      %if %{gdb-enable-python} == %{nil}
     58        %define gdb-enable-python %(command -v python3 || true)
     59      %endif
     60      %if %{gdb-enable-python} == %{nil}
     61          %define gdb-enable-python %(command -v python || true})
     62      %endif
     63    %endif
     64    %if %{gdb-enable-python} == %{nil}
     65      %error "gdb: python: no valid version of python found"
     66    %endif
     67  %endif
     68%endif
     69
     70#
     71# Get the Python's major and minor version from the python
     72# command. The headers and libraries are installed under a major/minor
     73# (mm) version path and name.
     74#
     75# The library file name can vary across the hosts so wildcard the search.
     76#
     77%define gdb-python-ver-mm %(%{gdb-enable-python} --version 2>&1 | sed -e 's/.* //g' | rev | cut -d'.' -f2- | rev)
     78%define gdb-python-ver-header python%{gdb-python-ver-mm}/Python.h
     79%define gdb-python-ver-lib libpython%{gdb-python-ver-mm}.*
     80%if %{host_includes} == %{nil}
     81  %define gdb-host-incs %{nil}
     82%else
     83  %define gdb-host-incs -I '%{host_includes}'
     84%endif
     85%define gdb-python-header-check %(%{_sbdir}/sb/rtems-build-dep -c %{__cc} %{gdb-host-incs} -H %{gdb-python-ver-header})
     86%if %{gdb-python-header-check} == not-found
     87  %error "gdb: python: header file not found: %{gdb-python-ver-header}, please install"
     88%endif
     89#
     90# Too hard to find on MacOS (darwin), the header is good enough.
     91#
     92%ifnos darwin
     93  %if %{host_ldflags} == %{nil}
     94    %define gdb-host-libs %{nil}
     95  %else
     96    %define gdb-host-libs -L '%{host_ldflags}'
     97  %endif
     98  %define gdb-python-lib-check %(%{_sbdir}/sb/rtems-build-dep -c %{__cc} %{gdb-host-libs} -l %{gdb-python-ver-lib})
     99  %if %{gdb-python-lib-check} == not-found
     100    %error "gdb: python: library file not found: %{gdb-python-ver-lib}, please install"
     101  %endif
     102%endif
    6103
    7104#
     
    42139Version:   %{gdb_version}
    43140Release:   %{release}
    44 URL:       http://www.gnu.org/software/gdb/
     141URL:       http://www.gnu.org/software/gdb/
    45142BuildRoot: %{_tmppath}/%{name}-root-%(%{__id_u} -n)
    46143
     
    71168  %define with_python_option --with-python=%{with_python_path}
    72169%else
    73   %define with_python_option --with-python
     170  %if %{defined gdb-enable-python}
     171    %define with_python_option --with-python=%{gdb-enable-python}
     172  %else
     173    %define with_python_option --with-python
     174  %endif
    74175%endif
    75176
  • source-builder/defaults.mc

    r8992d20 r13f4c37  
    6666host_cflags:         none,    convert,  '-O2 -pipe'
    6767host_cxxflags:       none,    convert,  '-O2 -pipe'
     68host_ldflags:        none,    convert,  ''
    6869host_includes:       none,    convert,  ''
    6970build_cflags:        none,    convert,  '-O2 -pipe'
    7071build_cxxflags:      none,    convert,  '-O2 -pipe'
     72build_ldflags:       none,    convert,  ''
    7173build_includes:      none,    convert,  ''
    7274
     
    203205SB_HOST_CFLAGS="%{host_cflags} %{host_includes}"
    204206SB_HOST_CXXFLAGS="%{host_cxxflags} %{host_includes}"
    205 SB_HOST_LDFLAGS="%{?host_ldflags:%{host_ldflags}} %{?_tmproot:-L%{_tmproot}/${SB_PREFIX_CLEAN}/lib}"
     207SB_HOST_LDFLAGS="%{host_ldflags} %{?_tmproot:-L%{_tmproot}/${SB_PREFIX_CLEAN}/lib}"
    206208SB_BUILD_CFLAGS="%{build_cflags} %{?_tmproot:-I%{_tmproot}/${SB_PREFIX_CLEAN}/include}"
    207209SB_BUILD_CXXFLAGS="%{build_cxxflags} %{?_tmproot:-I%{_tmproot}/${SB_PREFIX_CLEAN}/include}"
    208 SB_BUILD_LDFLAGS="%{?build_ldflags:%{build_ldflags}} %{?_tmproot:-L%{_tmproot}/${SB_PREFIX_CLEAN}/lib}"
     210SB_BUILD_LDFLAGS="%{build_ldflags} %{?_tmproot:-L%{_tmproot}/${SB_PREFIX_CLEAN}/lib}"
    209211SB_CFLAGS="${SB_BUILD_CFLAGS} %{build_includes}"
    210212SB_CXXFLAGS="${SB_BUILD_CXXFLAGS} %{build_includes}"
  • source-builder/pkg-config

    r8992d20 r13f4c37  
    1 #! /usr/bin/env python
     1#! /bin/sh
    22#
    33# RTEMS Tools Project (http://www.rtems.org/)
    4 # Copyright 2014-2016 Chris Johns (chrisj@rtems.org)
     4# Copyright 2018 Chris Johns (chrisj@rtems.org)
    55# All rights reserved.
    66#
    77# This file is part of the RTEMS Tools package in 'rtems-tools'.
    88#
    9 # Redistribution and use in source and binary forms, with or without
    10 # modification, are permitted provided that the following conditions are met:
     9# Permission to use, copy, modify, and/or distribute this software for any
     10# purpose with or without fee is hereby granted, provided that the above
     11# copyright notice and this permission notice appear in all copies.
    1112#
    12 # 1. Redistributions of source code must retain the above copyright notice,
    13 # this list of conditions and the following disclaimer.
     13# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
     14# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
     15# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
     16# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
     17# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
     18# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
     19# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
    1420#
    15 # 2. Redistributions in binary form must reproduce the above copyright notice,
    16 # this list of conditions and the following disclaimer in the documentation
    17 # and/or other materials provided with the distribution.
    18 #
    19 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    20 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    21 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    22 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
    23 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    24 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    25 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    26 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    27 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    28 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    29 # POSSIBILITY OF SUCH DAMAGE.
    30 #
    31 
    32 from __future__ import print_function
    33 
    34 import os
    35 import sys
    36 
    37 base = os.path.dirname(sys.argv[0])
    38 sys.path.insert(0, base + '/sb')
    39 
    40 try:
    41     import argparse
    42 except:
    43     sys.path.insert(0, base + '/sb/imports')
    44     try:
    45         import argparse
    46     except:
    47         print("Incorrect Source Builder installation", file = sys.stderr)
    48         sys.exit(1)
    49 
    50 try:
    51     import pkgconfig
    52 except ImportError:
    53     print("Incorrect Source Builder installation", file = sys.stderr)
    54     sys.exit(1)
    55 
    56 #
    57 # Make trace true to get a file of what happens and what is being asked.
    58 #
    59 trace = True
    60 trace_stdout = False
    61 logfile = 'pkg-config.log'
    62 out = None
    63 srcfd = None
    64 
    65 #
    66 # Write all the package source parsed to a single file.
    67 #
    68 trace_src = True
    69 if trace_src:
    70     srcfd = open('pkg-src.txt', 'w')
    71 
    72 def src(text):
    73     if srcfd:
    74         srcfd.writelines(text)
    75 
    76 def log(s, lf = True):
    77     global trace, logfile, out
    78     if trace:
    79         if out is None:
    80             if logfile:
    81                 out = open(logfile, 'a')
    82             else:
    83                 out = sys.stdout
    84         if lf:
    85             if out != sys.stdout and trace_stdout:
    86                 print(s)
    87             print(s, file = out)
    88         else:
    89             if out != sys.stdout and trace_stdout:
    90                 print(s, end = '')
    91                 sys.stdout.flush()
    92             print(s, end = '', file = out)
    93 
    94 def run(argv):
    95 
    96     class version_action(argparse.Action):
    97         def __call__(self, parser, namespace, values, option_string = None):
    98             parts = values[0].strip().split('.')
    99             for p in parts:
    100                 if not p.isdigit():
    101                     raise error('invalid version value: %s' % (values))
    102             setattr(namespace, self.dest, '.'.join(parts))
    103 
    104     ec = 0
    105 
    106     opts = argparse.ArgumentParser(prog = 'pkg-config', description = 'Package Configuration.')
    107     opts.add_argument('libraries', metavar='lib', type = str,  help = 'a library', nargs = '*')
    108     opts.add_argument('--modversion', dest = 'modversion', action = 'store', default = None,
    109                       help = 'Requests that the version information of the libraries.')
    110     opts.add_argument('--print-errors', dest = 'print_errors', action = 'store_true',
    111                       default = False,
    112                       help = 'Print any errors.')
    113     opts.add_argument('--short-errors', dest = 'short_errors', action = 'store_true',
    114                       default = False,
    115                       help = 'Make error messages short.')
    116     opts.add_argument('--silence-errors', dest = 'silence_errors', action = 'store_true',
    117                       default = False,
    118                       help = 'Do not print any errors.')
    119     opts.add_argument('--errors-to-stdout', dest = 'errors_to_stdout', action = 'store_true',
    120                       default = False,
    121                       help = 'Print errors to stdout rather than stderr.')
    122     opts.add_argument('--cflags', dest = 'cflags', action = 'store_true',
    123                       default = False,
    124                       help = 'This prints pre-processor and compile flags required to' \
    125                              ' compile the package(s)')
    126     opts.add_argument('--libs', dest = 'libs', action = 'store_true',
    127                       default = False,
    128                       help = 'This option is identical to "--cflags", only it prints the' \
    129                              ' link flags.')
    130     opts.add_argument('--libs-only-L', dest = 'libs_only_L', action = 'store_true',
    131                       default = False,
    132                       help = 'This prints the -L/-R part of "--libs".')
    133     opts.add_argument('--libs-only-l', dest = 'libs_only_l', action = 'store_true',
    134                       default = False,
    135                       help = 'This prints the -l part of "--libs".')
    136     opts.add_argument('--variable', dest = 'variable', action = 'store',
    137                       nargs = 1, default = None,
    138                       help = 'This returns the value of a variable.')
    139     opts.add_argument('--define-variable', dest = 'define_variable', action = 'store',
    140                       nargs = 1, default = None,
    141                       help = 'This sets a global value for a variable')
    142     opts.add_argument('--uninstalled', dest = 'uninstalled', action = 'store_true',
    143                       default = False,
    144                       help = 'Ignored')
    145     opts.add_argument('--atleast-pkgconfig-version', dest = 'atleast_pkgconfig_version',
    146                       action = 'store', nargs = 1, default = None,
    147                       help = 'Check the version of package config. Always ok.')
    148     opts.add_argument('--exists', dest = 'exists', action = 'store_true',
    149                       default = False,
    150                       help = 'Test if a library is present')
    151     opts.add_argument('--atleast-version', dest = 'atleast_version',
    152                       action = version_action, nargs = 1, default = None,
    153                       help = 'The package is at least this version.')
    154     opts.add_argument('--exact-version', dest = 'exact_version', action = version_action,
    155                        nargs = 1, default = None,
    156                         help = 'The package is the exact version.')
    157     opts.add_argument('--max-version', dest = 'max_version', action = version_action,
    158                       nargs = 1, default = None,
    159                       help = 'The package is no later than this version.')
    160     opts.add_argument('--msvc-syntax', dest = 'msvc_syntax', action = 'store_true',
    161                       default = False,
    162                       help = 'Ignored')
    163     opts.add_argument('--dont-define-prefix', dest = 'dont_define_prefix', action = 'store_true',
    164                       default = False,
    165                       help = 'Ignored')
    166     opts.add_argument('--prefix-variable', dest = 'prefix', action = 'store',
    167                       nargs = 1, default = pkgconfig.default_prefix(),
    168                       help = 'Define the prefix.')
    169     opts.add_argument('--static', dest = 'static', action = 'store_true',
    170                       default = False,
    171                       help = 'Output libraries suitable for static linking')
    172     opts.add_argument('--dump', dest = 'dump', action = 'store_true',
    173                       default = False,
    174                       help = 'Dump the package if one is found.')
    175 
    176     args = opts.parse_args(argv[1:])
    177 
    178     if (args.exists and (args.exact_version or args.max_version)) or \
    179             (args.exact_version and (args.exists or args.max_version)) or \
    180             (args.max_version and (args.exists or args.exact_version)):
    181         raise error('only one of --exists, --exact-version, or --max-version')
    182 
    183     if args.dont_define_prefix:
    184         args.prefix = pkgconfig.default_prefix(False)
    185 
    186     exists = False
    187 
    188     ec = 1
    189 
    190     if args.atleast_pkgconfig_version:
    191         ec = 0
    192     else:
    193         ec, pkg, flags = pkgconfig.check_package(args.libraries, args, log, src)
    194         if ec == 0:
    195             if args.cflags:
    196                 if len(flags['cflags']):
    197                     print(flags['cflags'])
    198                     log('cflags: %s' % (flags['cflags']))
    199                 else:
    200                     log('cflags: empty')
    201             if args.libs:
    202                 if len(flags['libs']):
    203                     print(flags['libs'])
    204                     log('libs: %s' % (flags['libs']))
    205                 else:
    206                     log('libs: empty')
    207 
    208     #pkgconfig.package.dump_loaded()
    209 
    210     return ec
    211 
    212 try:
    213     log('-' * 40)
    214     log('pkg-config', lf = False)
    215     for a in sys.argv[1:]:
    216         log(' "%s"' % (a), lf = False)
    217     log('')
    218     ec = run(sys.argv)
    219     log('ec = %d' % (ec))
    220 except ImportError:
    221     print("incorrect package config installation", file = sys.stderr)
    222     sys.exit(1)
    223 except pkgconfig.error as e:
    224     print('error: %s' % (e), file = sys.stderr)
    225     sys.exit(1)
    226 sys.exit(ec)
     21set -e
     22base=$(dirname $0)
     23PYTHON_CMD=${base}/sb/cmd-pkg-config.py
     24if test -f ${base}/sb/python-wrapper.sh; then
     25  . ${base}/sb/python-wrapper.sh
     26fi
     27echo "error: python wrapper not found"
  • source-builder/sb-bootstrap

    r8992d20 r13f4c37  
    1 #! /usr/bin/env python
     1#! /bin/sh
    22#
    33# RTEMS Tools Project (http://www.rtems.org/)
    4 # Copyright 2013 Chris Johns (chrisj@rtems.org)
     4# Copyright 2018 Chris Johns (chrisj@rtems.org)
    55# All rights reserved.
    66#
     
    1818# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
    1919# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
    20 
    21 from __future__ import print_function
    22 
    23 import sys, os
    24 base = os.path.dirname(sys.argv[0])
    25 sys.path.insert(0, base + '/sb')
    26 try:
    27     import bootstrap
    28     bootstrap.run(sys.argv)
    29 except ImportError:
    30     print("Incorrect Source Builder installation", file = sys.stderr)
    31     sys.exit(1)
     20#
     21set -e
     22base=$(dirname $0)
     23PYTHON_CMD=${base}/sb/cmd-bootstrap.py
     24if test -f ${base}/sb/python-wrapper.sh; then
     25  . ${base}/sb/python-wrapper.sh
     26fi
     27echo "error: python wrapper not found"
  • source-builder/sb-builder

    r8992d20 r13f4c37  
    1 #! /usr/bin/env python
     1#! /bin/sh
    22#
    33# RTEMS Tools Project (http://www.rtems.org/)
    4 # Copyright 2010-2012 Chris Johns (chrisj@rtems.org)
     4# Copyright 2018 Chris Johns (chrisj@rtems.org)
    55# All rights reserved.
    66#
     
    1818# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
    1919# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
    20 
    21 from __future__ import print_function
    22 
    23 import sys, os
    24 base = os.path.dirname(sys.argv[0])
    25 sys.path.insert(0, base + '/sb')
    26 try:
    27     import build
    28     build.run(sys.argv)
    29 except ImportError:
    30     print("Incorrect Source Builder installation", file = sys.stderr)
    31     sys.exit(1)
     20#
     21set -e
     22base=$(dirname $0)
     23PYTHON_CMD=${base}/sb/cmd-builder.py
     24if test -f ${base}/sb/python-wrapper.sh; then
     25  . ${base}/sb/python-wrapper.sh
     26fi
     27echo "error: python wrapper not found"
  • source-builder/sb-check

    r8992d20 r13f4c37  
    1 #! /usr/bin/env python
     1#! /bin/sh
    22#
    33# RTEMS Tools Project (http://www.rtems.org/)
    4 # Copyright 2010-2012 Chris Johns (chrisj@rtems.org)
     4# Copyright 2018 Chris Johns (chrisj@rtems.org)
    55# All rights reserved.
    66#
     
    1818# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
    1919# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
    20 
    21 from __future__ import print_function
    22 
    23 import sys, os
    24 base = os.path.dirname(sys.argv[0])
    25 sys.path.insert(0, base + '/sb')
    26 try:
    27     import check
    28     check.run()
    29 except ImportError:
    30     print("Incorrect Source Builder installation", file = sys.stderr)
    31     sys.exit(1)
     20#
     21set -e
     22base=$(dirname $0)
     23PYTHON_CMD=${base}/sb/cmd-check.py
     24if test -f ${base}/sb/python-wrapper.sh; then
     25  . ${base}/sb/python-wrapper.sh
     26fi
     27echo "error: python wrapper not found"
  • source-builder/sb-defaults

    r8992d20 r13f4c37  
    1 #! /usr/bin/env python
     1#! /bin/sh
    22#
    33# RTEMS Tools Project (http://www.rtems.org/)
    4 # Copyright 2010-2013 Chris Johns (chrisj@rtems.org)
     4# Copyright 2018 Chris Johns (chrisj@rtems.org)
    55# All rights reserved.
    66#
     
    1818# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
    1919# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
    20 
    21 from __future__ import print_function
    22 
    23 import sys, os
    24 base = os.path.dirname(sys.argv[0])
    25 sys.path.insert(0, base + '/sb')
    26 try:
    27     import options
    28     options.run(sys.argv)
    29 except ImportError:
    30     print("Incorrect Source Builder installation", file = sys.stderr)
    31     sys.exit(1)
     20#
     21set -e
     22base=$(dirname $0)
     23PYTHON_CMD=${base}/sb/cmd-defaults.py
     24if test -f ${base}/sb/python-wrapper.sh; then
     25  . ${base}/sb/python-wrapper.sh
     26fi
     27echo "error: python wrapper not found"
  • source-builder/sb-reports

    r8992d20 r13f4c37  
    1 #! /usr/bin/env python
     1#! /bin/sh
    22#
    33# RTEMS Tools Project (http://www.rtems.org/)
    4 # Copyright 2010-2013 Chris Johns (chrisj@rtems.org)
     4# Copyright 2018 Chris Johns (chrisj@rtems.org)
    55# All rights reserved.
    66#
     
    1818# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
    1919# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
    20 
    21 from __future__ import print_function
    22 
    23 import sys, os
    24 base = os.path.dirname(sys.argv[0])
    25 sys.path.insert(0, base + '/sb')
    26 try:
    27     import reports
    28     reports.run(sys.argv)
    29 except ImportError:
    30     print("Incorrect Source Builder installation", file = sys.stderr)
    31     sys.exit(1)
     20#
     21set -e
     22base=$(dirname $0)
     23PYTHON_CMD=${base}/sb/cmd-reports.py
     24if test -f ${base}/sb/python-wrapper.sh; then
     25  . ${base}/sb/python-wrapper.sh
     26fi
     27echo "error: python wrapper not found"
  • source-builder/sb-rtems-config

    r8992d20 r13f4c37  
    1 #! /usr/bin/env python
     1#! /bin/sh
    22#
    33# RTEMS Tools Project (http://www.rtems.org/)
    4 # Copyright 2010-2012 Chris Johns (chrisj@rtems.org)
     4# Copyright 2018 Chris Johns (chrisj@rtems.org)
    55# All rights reserved.
    66#
     
    1818# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
    1919# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
    20 
    21 from __future__ import print_function
    22 
    23 import sys, os
    24 base = os.path.dirname(sys.argv[0])
    25 sys.path.insert(0, base + '/sb')
    26 try:
    27     import rtemsconfig
    28     rtemsconfig.run(sys.argv)
    29 except ImportError:
    30     print("Incorrect Source Builder installation", file = sys.stderr)
    31     sys.exit(1)
     20#
     21set -e
     22base=$(dirname $0)
     23PYTHON_CMD=${base}/sb/cmd-rtems-config.py
     24if test -f ${base}/sb/python-wrapper.sh; then
     25  . ${base}/sb/python-wrapper.sh
     26fi
     27echo "error: python wrapper not found"
  • source-builder/sb-set-builder

    r8992d20 r13f4c37  
    1 #! /usr/bin/env python
     1#! /bin/sh
    22#
    33# RTEMS Tools Project (http://www.rtems.org/)
    4 # Copyright 2010-2012 Chris Johns (chrisj@rtems.org)
     4# Copyright 2018 Chris Johns (chrisj@rtems.org)
    55# All rights reserved.
    66#
     
    1818# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
    1919# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
    20 
    21 from __future__ import print_function
    22 
    23 import sys, os
    24 base = os.path.dirname(sys.argv[0])
    25 sys.path.insert(0, base + '/sb')
    26 
    27 try:
    28     import setbuilder
    29     setbuilder.run()
    30 except ImportError:
    31     print("Incorrect Source Builder installation", file = sys.stderr)
    32     sys.exit(1)
     20#
     21set -e
     22base=$(dirname $0)
     23PYTHON_CMD=${base}/sb/cmd-set-builder.py
     24if test -f ${base}/sb/python-wrapper.sh; then
     25  . ${base}/sb/python-wrapper.sh
     26fi
     27echo "error: python wrapper not found"
  • source-builder/sb/build.py

    r8992d20 r13f4c37  
    7070
    7171    def append(self, text):
     72        is_str = False
    7273        if type(text) is str:
     74            is_str = True
     75        try:
     76            if type(text) is unicode:
     77                is_str = True
     78        except:
     79            pass
     80        if is_str:
    7381            text = text.splitlines()
    7482        if not log.quiet:
  • source-builder/sb/config.py

    r8992d20 r13f4c37  
    558558                    colon = m.find(':')
    559559                    if colon < 8:
    560                         log.warning('malformed expand macro, no colon found')
     560                        log.warning(self._name_line_msg('malformed expand macro, no colon found'))
    561561                    else:
    562562                        e = self._expand(m[colon + 1:-1].strip())
     
    577577                elif m.startswith('%{echo'):
    578578                    if not m.endswith('}'):
    579                         log.warning("malformed conditional macro '%s'" % (m))
     579                        log.warning(self._name_line_msg("malformed conditional macro '%s'" % (m)))
    580580                        mn = None
    581581                    else:
     
    649649                    if colon < 0:
    650650                        if not m.endswith('}'):
    651                             log.warning("malformed conditional macro '%s'" % (m))
     651                            log.warning(self._name_line_msg("malformed conditional macro '%s'" % (m)))
    652652                            mn = None
    653653                        else:
     
    691691    def _disable(self, config, ls):
    692692        if len(ls) != 2:
    693             log.warning('invalid disable statement')
     693            log.warning(self._name_line_msg('invalid disable statement'))
    694694        else:
    695695            if ls[1] == 'select':
     
    698698                                                                     ls[1]))
    699699            else:
    700                 log.warning('invalid disable statement: %s' % (ls[1]))
     700                log.warning(self._name_line_msg('invalid disable statement: %s' % (ls[1])))
    701701
    702702    def _select(self, config, ls):
    703703        if len(ls) != 2:
    704             log.warning('invalid select statement')
     704            log.warning(self._name_line_msg('invalid select statement'))
    705705        else:
    706706            r = self.macros.set_read_map(ls[1])
     
    717717    def _define(self, config, ls):
    718718        if len(ls) <= 1:
    719             log.warning('invalid macro definition')
     719            log.warning(self._name_line_msg('invalid macro definition'))
    720720        else:
    721721            d = self._label(ls[1])
     
    728728                        self.macros[d] = ' '.join([f.strip() for f in ls[2:]])
    729729                else:
    730                     log.warning("macro '%s' already defined" % (d))
     730                    log.warning(self._name_line_msg("macro '%s' already defined" % (d)))
    731731            else:
    732732                if len(ls) == 2:
     
    737737    def _undefine(self, config, ls):
    738738        if len(ls) <= 1:
    739             log.warning('invalid macro definition')
     739            log.warning(self._name_line_msg('invalid macro definition'))
    740740        else:
    741741            mn = self._label(ls[1])
     
    842842                log.trace('config: %s: %3d: _if[%i]: next OP found at %i' % (self.name, self.lc,
    843843                                                                             self.if_depth,
    844                 i))
     844                                                                             i))
    845845            ls = cls[:i]
    846846            if len(ls) == 0:
     
    965965                    break
    966966        return self._ifs(config, ls, '%ifos', isos, isvalid, dir, info)
     967
     968    def _ifnos(self, config, ls, isvalid, dir, info):
     969        isnos = True
     970        if isvalid:
     971            os = self.define('_os')
     972            for l in ls:
     973                if l in os:
     974                    isnos = False
     975                    break
     976        return self._ifs(config, ls, '%ifnos', isnos, isvalid, dir, info)
    967977
    968978    def _ifarch(self, config, positive, ls, isvalid, dir, info):
     
    10641074                    if len(d):
    10651075                        return ('data', d)
     1076                elif ls[0] == '%ifnos':
     1077                    d = self._ifnos(config, ls, isvalid, dir, info)
     1078                    if len(d):
     1079                        return ('data', d)
    10661080                elif ls[0] == '%ifarch':
    10671081                    d = self._ifarch(config, True, ls, isvalid, dir, info)
     
    10751089                    if roc:
    10761090                        return ('control', '%endif', '%endif')
    1077                     log.warning("unexpected '" + ls[0] + "'")
     1091                    log.warning(self._name_line_msg("unexpected '" + ls[0] + "'"))
    10781092                elif ls[0] == '%else':
    10791093                    if roc:
    10801094                        return ('control', '%else', '%else')
    1081                     log.warning("unexpected '" + ls[0] + "'")
     1095                    log.warning(self._name_line_msg("unexpected '" + ls[0] + "'"))
    10821096                elif ls[0].startswith('%defattr'):
    10831097                    return ('data', [l])
     
    11041118                                          (self.name, self.lc, ls[0].strip()))
    11051119                                return ('directive', ls[0].strip(), ls[1:])
    1106                         log.warning("unknown directive: '" + ls[0] + "'")
     1120                        log.warning(self._name_line_msg("unknown directive: '" + ls[0] + "'"))
    11071121                        return ('data', [lo])
    11081122            else:
     
    11251139            else:
    11261140                if results[2][0].strip() != '-n':
    1127                     log.warning("unknown directive option: '%s'" % (' '.join(results[2])))
     1141                    log.warning(self._name_line_msg("unknown directive option: '%s'" % (' '.join(results[2]))))
    11281142                _package = results[2][1].strip()
    11291143            self._set_package(_package)
     
    11471161            elif l.startswith('%warning'):
    11481162                l = self._expand(l)
    1149                 log.warning(l[9:])
     1163                log.warning(self._name_line_msg(l[9:]))
    11501164            if not directive:
    11511165                l = self._expand(l)
     
    11621176                    self._info_append(info, info_data)
    11631177                else:
    1164                     log.warning("invalid format: '%s'" % (info_data[:-1]))
     1178                    log.warning(self._name_line_msg("invalid format: '%s'" % (info_data[:-1])))
    11651179            else:
    11661180                l = self._expand(l)
     
    12761290                    if r[1] == '%end':
    12771291                        break
    1278                     log.warning("unexpected '%s'" % (r[1]))
     1292                    log.warning(self._name_line_msg("unexpected '%s'" % (r[1])))
    12791293                elif r[0] == 'directive':
    12801294                    if r[1] == '%include':
  • source-builder/sb/freebsd.py

    r8992d20 r13f4c37  
    5858        '_host_alias':      ('none',    'none',     '%{nil}'),
    5959        '_host_arch':       ('none',    'none',     cpu),
     60        'host_includes':    ('none',    'convert',  '-I%{_usr}/include'),
     61        'host_ldflags':     ('none',    'convert',  '-L%{_usr}/lib'),
    6062        '_usr':             ('dir',     'required', '/usr/local'),
    6163        '_var':             ('dir',     'optional', '/usr/local/var'),
     
    6870        '__make':           ('exe',     'required', 'gmake'),
    6971        '__patch_opts':     ('none',     'none',    '-E')
    70         }
     72    }
    7173
    7274    defines['_build']        = defines['_host']
     
    111113        # Fix the mess iconv is on FreeBSD 10.0.
    112114        #
    113         defines['iconv_includes'] = ('none', 'none', '-I/usr/local/include -L/usr/local/lib')
     115        defines['iconv_includes'] = ('none', 'none', '%{_host_includes} %{_host_ldflags}')
    114116
    115117        #
  • source-builder/sb/macros.py

    r8992d20 r13f4c37  
    5454            return self.keys
    5555
    56     def _unicode_to_str(self, us):
     56    @staticmethod
     57    def _unicode_to_str(us):
    5758        try:
    5859            if type(us) == unicode:
     
    175176            raise TypeError('bad value tuple (attrib field): %s' % (value[1]))
    176177        if value[1] == 'convert':
    177             value = self.expand(value)
     178            value = (value[0], value[1], self.expand(value[2]))
    178179        self.macros[self.write_map][self.key_filter(key)] = value
    179180
     
    182183
    183184    def __contains__(self, key):
    184         return self.has_key(key)
     185        return self.has_key(self._unicode_to_str(key))
    185186
    186187    def __len__(self):
     
    202203
    203204    def has_key(self, key):
     205        key = self._unicode_to_str(key)
    204206        if type(key) is not str:
    205207            raise TypeError('bad key type (want str): %s' % (type(key)))
     
    453455    def expand(self, _str):
    454456        """Simple basic expander of config file macros."""
     457        _str = self._unicode_to_str(_str)
    455458        expanded = True
    456459        while expanded:
  • source-builder/sb/options.py

    r8992d20 r13f4c37  
    603603
    604604    #
     605    # Adjust the args to remove the wrapper.
     606    #
     607    args = args[1:]
     608
     609    #
    605610    # The path to this command.
    606611    #
    607     command_path = path.dirname(args[0])
     612    command_path = path.dirname(path.abspath(args[0]))
    608613    if len(command_path) == 0:
    609614        command_path = '.'
  • source-builder/sb/path.py

    r8992d20 r13f4c37  
    3131import stat
    3232import string
     33import sys
    3334
    3435import error
    3536
     37windows_posix = sys.platform == 'msys'
    3638windows = os.name == 'nt'
     39
    3740win_maxpath = 254
    3841
     
    5558
    5659def shell(path):
     60    if isinstance(path, bytes):
     61        path = path.decode('ascii')
    5762    if path is not None:
    58         if windows:
    59             path = path.encode('ascii', 'ignore')
     63        if windows or windows_posix:
     64            path = path.encode('ascii', 'ignore').decode('ascii')
    6065            if path.startswith('\\\\?\\'):
    6166                path = path[4:]
    6267            if len(path) > 1 and path[1] == ':':
    63                 path = '/%s%s' % (path[0], path[2:])
     68                path = '/%s%s' % (path[0].lower(), path[2:])
    6469            path = path.replace('\\', '/')
    6570        while '//' in path:
  • source-builder/sb/windows.py

    r8992d20 r13f4c37  
    11#
    22# RTEMS Tools Project (http://www.rtems.org/)
    3 # Copyright 2010-2013 Chris Johns (chrisj@rtems.org)
     3# Copyright 2010-2018 Chris Johns (chrisj@rtems.org)
    44# All rights reserved.
    55#
     
    2222#
    2323
    24 import error
    25 import pprint
    2624import os
    2725import sys
    2826
     27import error
    2928import execute
     29import path
    3030
    3131def load():
     
    147147    #  7. W64/Python3 - gdb-7.9 needs python2.
    148148    #
    149     if sys.platform == 'win32' and 'MSC' in sys.version:
    150         raise error.general('python.org Pythons are built with MSC and cannot be linked with GDB')
    151 
     149    # Find a suitable python2 and python3.
     150    #
     151    for p in os.environ['PATH'].split(os.pathsep):
     152        sh = os.path.join(p, 'sh.exe')
     153        if os.path.exists(sh) and os.path.isfile(sh):
     154            break
     155        sh = None
     156    if sh is None:
     157        raise error.general('cannot find a shell (sh.exe) in the PATH')
    152158    #
    153159    # Search the MSYS2 install tree for a suitable python.
    154160    #
    155     if sys.platform == 'msys':
     161    if sys.platform == 'msys' or True:
    156162        e = execute.capture_execution()
    157163        exit_code, proc, output = e.shell("sh -c mount")
     
    167173        if install_point[1] != ':':
    168174            raise error.general('invalid MSYS root mount point: %s' % install_point)
    169         install_point = '/%s%s' % (install_point[0], install_point[2:])
    170         bin = '/mingw%s/bin' % (machsize)
    171         bin_list = os.listdir(bin)
    172         exe = None
    173         for python in ['python2.exe']:
    174             for f in bin_list:
    175                 if f == python:
    176                     exe = install_point + os.path.join(bin, f)
    177                     break;
    178             if exe is not None:
    179                 break
    180         if exe is None:
    181             raise error.general('no valid python found; you need a mingw%s python2 installed' % (machsize))
    182         defines['with_python_path'] = exe
    183 
     175        install_point = path.shell(install_point)
     176        mingw = path.join(install_point, 'mingw%s' % (machsize))
     177        if not path.exists(mingw) or not path.isdir(mingw):
     178            raise error.general('cannot find MinGW install: %s' % (path.host(mingw)))
     179        for version in ['2', '3']:
     180            python = 'python%s' % (version)
     181            exe = path.join(mingw, 'bin', '%s.exe' % (python))
     182            if not path.exists(exe) or not path.isdir(exe):
     183                defines['gdb_python%s' % (version)] = exe
     184                header = path.join(mingw, python)
    184185
    185186    return defines
    186187
    187188if __name__ == '__main__':
     189    import pprint
    188190    pprint.pprint(load())
Note: See TracChangeset for help on using the changeset viewer.