1 # -*- coding: utf-8 -*-
9 def __init__ (self, libName, apiVersion, abiVersion):
10 self.libName = libName
11 self.apiVersion = apiVersion
12 self.abiVersion = abiVersion
15 if sys.platform.startswith('linux'):
20 def getCfg (variants):
21 platform = getPlatform()
22 if platform in variants:
23 return variants[platform]
24 elif 'other' in variants:
25 return variants['other']
27 raise Exception("No configuration for '%s'" % platform)
29 def isExecutable (path):
30 return os.path.isfile(path) and os.access(path, os.X_OK)
33 for path in os.environ['PATH'].split(os.pathsep):
34 path = path.strip('"')
35 fullPath = os.path.join(path, binName)
36 if isExecutable(fullPath):
41 def isBinaryInPath (binName):
42 return which(binName) != None
44 def selectBin (basePaths, relBinPath):
45 for basePath in basePaths:
46 fullPath = os.path.normpath(os.path.join(basePath, relBinPath))
47 if isExecutable(fullPath):
49 return which(os.path.basename(relBinPath))
56 return '"%s"' % s.replace('\\', '\\\\').replace('"', '\"').replace('$', '\$').replace('`', '\`')
58 def execute (commandLine):
59 args = shlex.split(commandLine)
60 retcode = subprocess.call(args)
62 raise Exception("Failed to execute '%s', got %d" % (commandLine, retcode))
65 retcode = subprocess.call(args)
67 raise Exception("Failed to execute '%s', got %d" % (str(args), retcode))
70 ANDROID_DIR = os.path.realpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))
74 # library name API ABI
75 # NativeLib("testercore_legacy", 5, "armeabi-v7a"), # Pre-gingerbread
76 # NativeLib("testercore_legacy", 5, "armeabi"), # ARM v5 ABI / pre-gingerbread
77 NativeLib("testercore", 9, "armeabi-v7a"), # ARM v7a ABI
78 # NativeLib("testercore", 9, "x86"), # x86
80 ANDROID_JAVA_API = "android-10"
83 ANDROID_NDK_HOST_OS = getCfg({
85 'darwin': "darwin-x86",
88 ANDROID_NDK_PATH = getCfg({
89 'win32': "C:/android/android-ndk-r9d",
90 'darwin': os.path.expanduser("~/android-ndk-r9d"),
91 'linux': os.path.expanduser("~/android-ndk-r9d")
93 ANDROID_NDK_TOOLCHAIN_VERSION = "clang-r9d" # Toolchain file is selected based on this
95 def getWin32Generator ():
96 if which("jom.exe") != None:
97 return "NMake Makefiles JOM"
99 return "NMake Makefiles"
101 # Native code build settings
102 CMAKE_GENERATOR = getCfg({
103 'win32': getWin32Generator(),
104 'darwin': "Unix Makefiles",
105 'linux': "Unix Makefiles"
108 'win32': "cmake --build .",
109 'darwin': "cmake --build . -- -j 4",
110 'linux': "cmake --build . -- -j 4"
114 ANDROID_SDK_PATHS = [
115 "C:/android/android-sdk-windows",
116 os.path.expanduser("~/android-sdk-mac_x86"),
117 os.path.expanduser("~/android-sdk-linux")
119 ANDROID_BIN = getCfg({
120 'win32': selectBin(ANDROID_SDK_PATHS, "tools/android.bat"),
121 'other': selectBin(ANDROID_SDK_PATHS, "tools/android"),
124 'win32': selectBin(ANDROID_SDK_PATHS, "platform-tools/adb.exe"),
125 'other': selectBin(ANDROID_SDK_PATHS, "platform-tools/adb"),
127 ZIPALIGN_BIN = getCfg({
128 'win32': selectBin(ANDROID_SDK_PATHS, "tools/zipalign.exe"),
129 'other': selectBin(ANDROID_SDK_PATHS, "tools/zipalign"),
131 JARSIGNER_BIN = "jarsigner"
135 "C:/android/apache-ant-1.8.4",
136 "C:/android/apache-ant-1.9.2",
137 "C:/android/apache-ant-1.9.3",
138 "C:/android/apache-ant-1.9.4",
141 'win32': selectBin(ANT_PATHS, "bin/ant.bat"),
142 'other': selectBin(ANT_PATHS, "bin/ant")