summaryrefslogtreecommitdiffstats
path: root/scons
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2015-04-12 17:47:06 (GMT)
committerTobias Markmann <tm@ayena.de>2015-04-13 20:02:54 (GMT)
commit908b442c7b5e74c9d557a1468b321ef4255e402e (patch)
treeac4be393b4645252e9875d46f8d09f31d0167451 /scons
parent6a2e6d58233cbf40b34f962f2b2f9b1589969e13 (diff)
downloadswift-908b442c7b5e74c9d557a1468b321ef4255e402e.zip
swift-908b442c7b5e74c9d557a1468b321ef4255e402e.tar.bz2
Improve python flexibility for SCons build system
This adds support for running ./scons out of the box on Arch Linux. Test-Information: Tested on OS X 10.9.5 and Manjaro Linux (Arch-based). Change-Id: I53c4d537571a40352797c9176582b6fd93a75227
Diffstat (limited to 'scons')
-rwxr-xr-xscons24
1 files changed, 22 insertions, 2 deletions
diff --git a/scons b/scons
index 938c2d1..32bdf6c 100755
--- a/scons
+++ b/scons
@@ -1,3 +1,23 @@
-#!/bin/sh
+#!/usr/bin/env bash
-`dirname $0`/3rdParty/SCons/scons.py $@
+# This script checks various names for the Python interpreter for their existance and version.
+# The latest valid version is used to run the SCons build tool, which requires python2.
+# This is needed because some distributions ship Pyhton3 and others Python2 their 'python'.
+
+function is_supported_python
+{
+ local exe=$1
+ $exe -c 'import sys; (major, minor, a, b, c) = sys.version_info; python_version = (major, minor); exit(not ((2, 4) <= python_version <= (2, 7)))' 2>/dev/null
+}
+
+declare -a supported_python_versions=(python python2.7 python2.6 python2.5 python2.4)
+
+for exe in ${supported_python_versions[*]}; do
+ if is_supported_python "$exe"; then
+ exec $exe `dirname $0`/3rdParty/SCons/scons.py "$@"
+ exit
+ fi
+done
+
+echo "No suitable Python interpreter found! Swift build system supports Python 2.4 to Python 2.7.!!!" >&2
+exit 1 \ No newline at end of file