aboutsummaryrefslogtreecommitdiff
path: root/ndk-gdb.py
diff options
context:
space:
mode:
authorRay Donnelly <mingw.android@gmail.com>2013-08-11 00:41:26 +0100
committerRay Donnelly <mingw.android@gmail.com>2013-08-11 00:41:29 +0100
commit9855fa06afb1c0707a8d30a0846eca6ca65031f1 (patch)
tree92ab6fc9e6a96a9b47d621b56a65b04693f8e9ea /ndk-gdb.py
parent0a9da1b9be8ebe50c7772249fa4e2baaaf4372b5 (diff)
downloadndk-9855fa06afb1c0707a8d30a0846eca6ca65031f1.tar.gz
ndk-gdb.py: Fix ndk_bin_path determination
It wasn't correct on 64bit. This meant that the gnumake found on those systems tended to be the system one. Now, sys.executable is used and if that fails, some more exhaustive checks of platform.platform() and sys.maxsize are used (in-case the user uses their own Python - note if this happens, arch differences between that Python and the NDK could still cause the system make to be used, but this is a small corner case that will usually work ok ..)
Diffstat (limited to 'ndk-gdb.py')
-rwxr-xr-xndk-gdb.py42
1 files changed, 33 insertions, 9 deletions
diff --git a/ndk-gdb.py b/ndk-gdb.py
index 82a833967..5f3b35b31 100755
--- a/ndk-gdb.py
+++ b/ndk-gdb.py
@@ -28,7 +28,7 @@ r'''
adb install && <start-application-on-device>
'''
-import sys, os, argparse, subprocess, types
+import sys, os, platform, argparse, subprocess, types
import xml.etree.cElementTree as ElementTree
import shutil, time
from threading import Thread
@@ -51,15 +51,39 @@ def find_program(program, extra_paths = []):
return True, full
return False, None
-# Return the prebuilt bin path for the host os.
def ndk_bin_path(ndk):
- if sys.platform.startswith('linux'):
- return ndk+os.sep+'prebuilt/linux-x86/bin'
- elif sys.platform.startswith('darwin'):
- return ndk+os.sep+'prebuilt/darwin-x86/bin'
- elif sys.platform.startswith('win'):
- return ndk+os.sep+'prebuilt/windows/bin'
- return ndk+os.sep+'prebuilt/UNKNOWN/bin'
+ '''
+ Return the prebuilt bin path for the host OS.
+
+ If Python executable is the NDK-prebuilt one (it should be)
+ then use the location of the executable as the first guess.
+ We take the grand-parent foldername and then ensure that it
+ starts with one of 'linux', 'darwin' or 'windows'.
+
+ If this is not the case, then we're using some other Python
+ and fall-back to using platform.platform() and sys.maxsize.
+ '''
+
+ try:
+ ndk_host = os.path.basename(
+ os.path.dirname(
+ os.path.dirname(sys.executable)))
+ except:
+ ndk_host = ''
+ # NDK-prebuilt Python?
+ if (not ndk_host.startswith('linux') and
+ not ndk_host.startswith('darwin') and
+ not ndk_host.startswith('windows')):
+ is64bit = True if sys.maxsize > 2**32 else False
+ if platform.platform().startswith('Linux'):
+ ndk_host = 'linux%s' % ('-x86_64' if is64bit else '-x86')
+ elif platform.platform().startswith('Darwin'):
+ ndk_host = 'darwin%s' % ('-x86_64' if is64bit else '-x86')
+ elif platform.platform().startswith('Windows'):
+ ndk_host = 'windows%s' % ('-x86_64' if is64bit else '')
+ else:
+ ndk_host = 'UNKNOWN'
+ return ndk+os.sep+'prebuilt'+os.sep+ndk_host+os.sep+'bin'
VERBOSE = False
PROJECT = None