Merge "Check NDK version in the app build script"
am: 197032faf3
Change-Id: I886a1b1bd45006d00035258a2d1325652a9313f7
diff --git a/android/scripts/build.py b/android/scripts/build.py
index cfee003..a1cc086 100644
--- a/android/scripts/build.py
+++ b/android/scripts/build.py
@@ -24,7 +24,9 @@
import re
import sys
import shutil
+import string
import argparse
+import time
import common
@@ -188,6 +190,51 @@
print "%-30s : %s" % (entry[0], entry[1])
print " "
+# Return NDK version as [<major>,<minor>] or None if cannot be figured out.
+def getNdkVersion (path):
+ if path == None:
+ return None
+
+ propFilePath = os.path.join(path, "source.properties")
+ try:
+ with open(propFilePath) as propFile:
+ for line in propFile:
+ keyValue = map(lambda x: string.strip(x), line.split("="))
+ if keyValue[0] == "Pkg.Revision":
+ versionParts = keyValue[1].split(".")
+ return tuple(map(int, versionParts[0:2]))
+ except:
+ print("Could not read source prop file '%s'" % propFilePath)
+
+ return None
+
+def checkConfig ():
+ HOST_OS_TO_DOWNLOAD_STRING = {
+ "linux-x86_64" : "linux-x86_64",
+ "windows" : "windows-x86",
+ "windows-x86_64" : "windows-x86_64"
+ }
+
+ version = getNdkVersion(common.ANDROID_NDK_PATH)
+ # Note: NDK currently maintains compatibility between minor
+ # versions. Error out only on major version mismatch.
+ if version == None or version[0] != common.ANDROID_NDK_VERSION[0]:
+ print("**** WARNING! Deqp requires NDK version %s" % common.ANDROID_NDK_VERSION_STRING)
+ print("**** NDK Path %s does not appear to have that version." % common.ANDROID_NDK_PATH)
+
+ # Download hint will use the version encored in common.py, not
+ # the latest minor version available
+ versionString = common.ANDROID_NDK_VERSION_STRING
+ if common.ANDROID_NDK_HOST_OS in HOST_OS_TO_DOWNLOAD_STRING:
+ osString = HOST_OS_TO_DOWNLOAD_STRING[common.ANDROID_NDK_HOST_OS]
+ print("**** Please install from https://dl.google.com/android/repository/android-ndk-%s-%s.zip" % (versionString, osString))
+ else:
+ print("**** Please download version", versionString, "from https://developer.android.com/ndk/downloads/index.html")
+
+ return False
+
+ return True
+
if __name__ == "__main__":
nativeBuildTypes = ['Release', 'Debug', 'MinSizeRel', 'RelWithAsserts', 'RelWithDebInfo']
androidBuildTypes = ['debug', 'release']
@@ -199,10 +246,15 @@
parser.add_argument('--dump-config', dest='dumpConfig', action='store_true', help="Print out all configurations variables")
parser.add_argument('--java-api', dest='javaApi', default=common.ANDROID_JAVA_API, help="Set the API signature for the java build.")
parser.add_argument('-p', '--parallel-build', dest='parallelBuild', action="store_true", help="Build native libraries in parallel.")
+ parser.add_argument('--skip-config-check', dest='skipConfigCheck', action="store_true", default=False, help="Skips config check. Warranty void.")
args = parser.parse_args()
if args.dumpConfig:
dumpConfig()
+ if not args.skipConfigCheck and not checkConfig():
+ print "Config check failed, exit"
+ exit(-1)
+
build(buildRoot=os.path.abspath(args.buildRoot), androidBuildType=args.androidBuildType, nativeBuildType=args.nativeBuildType, javaApi=args.javaApi, doParallelBuild=args.parallelBuild)
diff --git a/android/scripts/common.py b/android/scripts/common.py
index 87aad8a..a158367 100644
--- a/android/scripts/common.py
+++ b/android/scripts/common.py
@@ -240,10 +240,16 @@
ANDROID_JAVA_API = "android-22"
NATIVE_LIB_NAME = "libdeqp.so"
+def makeNdkVersionString (version):
+ minorVersionString = (chr(ord('a') + version[1]) if version[1] > 0 else "")
+ return "r%d%s" % (version[0], minorVersionString)
+
+ANDROID_NDK_VERSION = (11,0)
+ANDROID_NDK_VERSION_STRING = makeNdkVersionString(ANDROID_NDK_VERSION)
def selectNDKPath ():
candidates = [
- os.path.expanduser("~/android-ndk-r11"),
- "C:/android/android-ndk-r11",
+ os.path.expanduser("~/android-ndk-" + ANDROID_NDK_VERSION_STRING),
+ "C:/android/android-ndk-" + ANDROID_NDK_VERSION_STRING,
os.environ.get("ANDROID_NDK_PATH", None), # If not defined, return None
]