diff options
author | Chris Johns <chrisj@rtems.org> | 2018-10-07 20:59:45 +1100 |
---|---|---|
committer | Chris Johns <chrisj@rtems.org> | 2018-10-21 09:49:02 +1100 |
commit | 13f4c379997b53b204d8534d198da2fa35dd5630 (patch) | |
tree | f7591495c8f2165af7bbb20d4eaf743d3d034416 /source-builder/config | |
parent | rtems-tools-5-1.cfg: Bump to latest (diff) | |
download | rtems-source-builder-13f4c379997b53b204d8534d198da2fa35dd5630.tar.bz2 |
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
Diffstat (limited to 'source-builder/config')
-rw-r--r-- | source-builder/config/gdb-common-1.cfg | 105 |
1 files changed, 103 insertions, 2 deletions
diff --git a/source-builder/config/gdb-common-1.cfg b/source-builder/config/gdb-common-1.cfg index fe4dbaf..30fdf90 100644 --- a/source-builder/config/gdb-common-1.cfg +++ b/source-builder/config/gdb-common-1.cfg @@ -5,6 +5,103 @@ # # +# Python +# +# GDB uses python internally so we need to link to a suitable python +# dev kit. The dev kit for python is the header and a library. These +# files are versioned where the header file is located in a directory +# based on: +# +# pythonM.m/Python.h +# +# where 'M' is the major version number and 'm' is the minor verison +# number. The library is: +# +# libpythonM.m.a +# +# The python command is 'pythonM' which means we need to query it for +# the minor number. +# +# The python running the RSB may not be suitable, for example a MSC, +# MSYS or Cygwin version on Windows when we want the MinGW python dev +# file. A specific version cannot be forced because older versions of +# GDB can only link to 'python2'. +# +# Host support can perform a complex query of the system, for example +# Windows and set '%{gdb_python2}' and '%{gdb_python3}' with the full +# path to that version's executable. +# +# A configuration of GDB can set the version required by setting +# '%{gdb-python-version}' to the versions command, eg python2. +# +# The procedure is: +# +# 1. If the macros '%{gdb_python2}' or '%{gdb_python3}' are present +# use that path they contain. Assume the path is valid. +# +# 2. Does the version of gdb specify a version of python that must be +# used. Override with '%define gdb-python-version python2'. +# +# 3. Search for 'python2' and if not found search for 'python3'. +# +%if %{defined gdb-python2} + %define gdb-enable-python %{gdb_python2} +%else + %if %{defined gdb-python3} + %define gdb-enable-python %{gdb_python3} + %else + %if %{defined gdb-python-version} + %define gdb-enable-python %(command -v %{gdb-python-version || true}) + %else + %define gdb-enable-python %(command -v python2 || true) + %if %{gdb-enable-python} == %{nil} + %define gdb-enable-python %(command -v python3 || true) + %endif + %if %{gdb-enable-python} == %{nil} + %define gdb-enable-python %(command -v python || true}) + %endif + %endif + %if %{gdb-enable-python} == %{nil} + %error "gdb: python: no valid version of python found" + %endif + %endif +%endif + +# +# Get the Python's major and minor version from the python +# command. The headers and libraries are installed under a major/minor +# (mm) version path and name. +# +# The library file name can vary across the hosts so wildcard the search. +# +%define gdb-python-ver-mm %(%{gdb-enable-python} --version 2>&1 | sed -e 's/.* //g' | rev | cut -d'.' -f2- | rev) +%define gdb-python-ver-header python%{gdb-python-ver-mm}/Python.h +%define gdb-python-ver-lib libpython%{gdb-python-ver-mm}.* +%if %{host_includes} == %{nil} + %define gdb-host-incs %{nil} +%else + %define gdb-host-incs -I '%{host_includes}' +%endif +%define gdb-python-header-check %(%{_sbdir}/sb/rtems-build-dep -c %{__cc} %{gdb-host-incs} -H %{gdb-python-ver-header}) +%if %{gdb-python-header-check} == not-found + %error "gdb: python: header file not found: %{gdb-python-ver-header}, please install" +%endif +# +# Too hard to find on MacOS (darwin), the header is good enough. +# +%ifnos darwin + %if %{host_ldflags} == %{nil} + %define gdb-host-libs %{nil} + %else + %define gdb-host-libs -L '%{host_ldflags}' + %endif + %define gdb-python-lib-check %(%{_sbdir}/sb/rtems-build-dep -c %{__cc} %{gdb-host-libs} -l %{gdb-python-ver-lib}) + %if %{gdb-python-lib-check} == not-found + %error "gdb: python: library file not found: %{gdb-python-ver-lib}, please install" + %endif +%endif + +# # See if the simulator has been disabled for Windows. # # Build using the system's readline, it is in better shape @@ -41,7 +138,7 @@ Name: %{_target}-gdb-%{gdb_version}-%{_host}-%{release} Summary: GDB v%{gdb_version} for target %{_target} on host %{_host} Version: %{gdb_version} Release: %{release} -URL: http://www.gnu.org/software/gdb/ +URL: http://www.gnu.org/software/gdb/ BuildRoot: %{_tmppath}/%{name}-root-%(%{__id_u} -n) # @@ -70,7 +167,11 @@ BuildRoot: %{_tmppath}/%{name}-root-%(%{__id_u} -n) %if %{defined with_python_path} %define with_python_option --with-python=%{with_python_path} %else - %define with_python_option --with-python + %if %{defined gdb-enable-python} + %define with_python_option --with-python=%{gdb-enable-python} + %else + %define with_python_option --with-python + %endif %endif # |