mirror of
https://git.rtems.org/rtems-source-builder
synced 2024-10-09 07:15:10 +08:00
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
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# RTEMS Tools Project (http://www.rtems.org/)
|
||||
# Copyright 2010-2013 Chris Johns (chrisj@rtems.org)
|
||||
# Copyright 2010-2018 Chris Johns (chrisj@rtems.org)
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is part of the RTEMS Tools package in 'rtems-tools'.
|
||||
@@ -21,12 +21,12 @@
|
||||
# Windows specific support and overrides.
|
||||
#
|
||||
|
||||
import error
|
||||
import pprint
|
||||
import os
|
||||
import sys
|
||||
|
||||
import error
|
||||
import execute
|
||||
import path
|
||||
|
||||
def load():
|
||||
# Default to the native Windows Python.
|
||||
@@ -146,13 +146,19 @@ def load():
|
||||
# 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')
|
||||
|
||||
# Find a suitable python2 and python3.
|
||||
#
|
||||
for p in os.environ['PATH'].split(os.pathsep):
|
||||
sh = os.path.join(p, 'sh.exe')
|
||||
if os.path.exists(sh) and os.path.isfile(sh):
|
||||
break
|
||||
sh = None
|
||||
if sh is None:
|
||||
raise error.general('cannot find a shell (sh.exe) in the PATH')
|
||||
#
|
||||
# Search the MSYS2 install tree for a suitable python.
|
||||
#
|
||||
if sys.platform == 'msys':
|
||||
if sys.platform == 'msys' or True:
|
||||
e = execute.capture_execution()
|
||||
exit_code, proc, output = e.shell("sh -c mount")
|
||||
if exit_code != 0:
|
||||
@@ -166,23 +172,19 @@ def load():
|
||||
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
|
||||
|
||||
install_point = path.shell(install_point)
|
||||
mingw = path.join(install_point, 'mingw%s' % (machsize))
|
||||
if not path.exists(mingw) or not path.isdir(mingw):
|
||||
raise error.general('cannot find MinGW install: %s' % (path.host(mingw)))
|
||||
for version in ['2', '3']:
|
||||
python = 'python%s' % (version)
|
||||
exe = path.join(mingw, 'bin', '%s.exe' % (python))
|
||||
if not path.exists(exe) or not path.isdir(exe):
|
||||
defines['gdb_python%s' % (version)] = exe
|
||||
header = path.join(mingw, python)
|
||||
|
||||
return defines
|
||||
|
||||
if __name__ == '__main__':
|
||||
import pprint
|
||||
pprint.pprint(load())
|
||||
|
Reference in New Issue
Block a user