summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2016-03-08 22:23:01 +1100
committerChris Johns <chrisj@rtems.org>2016-03-08 22:26:28 +1100
commit7309d94031e830543eb23c3dd70c9ca4164c59af (patch)
tree4747a2cfe01d4ef03b88fe66083f867d09f81a7e
parentsb: Report platform import errors. (diff)
downloadrtems-source-builder-7309d94031e830543eb23c3dd70c9ca4164c59af.tar.bz2
sb: Add support to GDB to select a specific Python.
Detect a suitable Python version on Windows. Update #2619.
-rw-r--r--source-builder/config/gdb-7-1.cfg12
-rw-r--r--source-builder/sb/windows.py51
2 files changed, 62 insertions, 1 deletions
diff --git a/source-builder/config/gdb-7-1.cfg b/source-builder/config/gdb-7-1.cfg
index 90a1f5a..0fef5b3 100644
--- a/source-builder/config/gdb-7-1.cfg
+++ b/source-builder/config/gdb-7-1.cfg
@@ -60,6 +60,16 @@ BuildRoot: %{_tmppath}/%{name}-root-%(%{__id_u} -n)
%endif
#
+# The --with-python option is either the default which is auto or the path to
+# the specific python to be used.
+#
+%if %{defined with_python_path}
+ %define with_python_option --with-python=%{with_python_path}
+%else
+ %define with_python_option --with-python
+%endif
+
+#
#
# Prepare the source code.
#
@@ -104,7 +114,7 @@ BuildRoot: %{_tmppath}/%{name}-root-%(%{__id_u} -n)
%{?gdb-sim-options:%{gdb-sim-options}} \
--without-zlib \
--with-expat \
- %{!?without_python:--with-python} \
+ %{!?without_python:%{with_python_option}} \
--prefix=%{_prefix} --bindir=%{_bindir} \
--exec-prefix=%{_exec_prefix} \
--includedir=%{_includedir} --libdir=%{_libdir} \
diff --git a/source-builder/sb/windows.py b/source-builder/sb/windows.py
index f613da2..5e732b5 100644
--- a/source-builder/sb/windows.py
+++ b/source-builder/sb/windows.py
@@ -24,6 +24,7 @@
import error
import pprint
import os
+import sys
import execute
@@ -125,6 +126,56 @@ def load():
'_buildshell': ('exe', 'required', '%{__sh}'),
'___setup_shell': ('exe', 'required', '%{__sh}')
}
+
+ #
+ # Locate a suitable python to use with GDB. Python Windows is more
+ # complicated than most hosts. There are 7 possible pythons on Windows and
+ # we can use only 4 which are split on machine size. The types are:
+ #
+ # 1. Python27 - python.org, cannot use cause built with MSVC.
+ # 2. Python35 - python.org, cannot use cause built with MSVC.
+ # 3. MSYS/Python - MSYS2, cannot use cause it is a MSYS executable.
+ # 4. W64/Python2 - Ok if machsize is 64
+ # 5. W64/Python3 - gdb-7.9 needs python2.
+ # 6. W64/Python2 - Ok if machsize is 32
+ # 7. W64/Python3 - gdb-7.9 needs python2.
+ #
+ if sys.platform == 'win32' and 'MSC' in sys.version:
+ raise error.general('python.org Pythons are built with MSC and cannot be linked with GDB')
+
+ #
+ # Search the MSYS2 install tree for a suitable python.
+ #
+ if sys.platform == 'msys':
+ e = execute.capture_execution()
+ exit_code, proc, output = e.shell("sh -c mount")
+ if exit_code != 0:
+ raise error.general('cannot get MSYS mount points')
+ install_point = None
+ for l in output.split('\n'):
+ if ' on / ' in l:
+ install_point = l.split()[0]
+ break
+ if install_point is None:
+ raise error.general('cannot locate MSYS root mount point')
+ if install_point[1] != ':':
+ raise error.general('invalid MSYS root mount point: %s' % install_point)
+ install_point = '/%s%s' % (install_point[0], install_point[2:])
+ bin = '/mingw%s/bin' % (machsize)
+ bin_list = os.listdir(bin)
+ exe = None
+ for python in ['python2.exe']:
+ for f in bin_list:
+ if f == python:
+ exe = install_point + os.path.join(bin, f)
+ break;
+ if exe is not None:
+ break
+ if exe is None:
+ raise error.general('no valid python found; you need a mingw%s python2 installed' % (machsize))
+ defines['with_python_path'] = exe
+
+
return defines
if __name__ == '__main__':