Bug 1269517 - Move android_platform to python configure. r=glandium
authorChris Manchester <cmanchester@mozilla.com>
Tue, 26 Jul 2016 15:27:19 -0700
changeset 348904 cd2ca7c770fd94e67af3f4f97ceab20a373eb29c
parent 348903 de64f009410311eda93f4ac9358f44f1bc327fbe
child 348905 2081a003f2d83f456ae6a8d1bfa77157508960b7
push id1230
push userjlund@mozilla.com
push dateMon, 31 Oct 2016 18:13:35 +0000
treeherdermozilla-release@5e06e3766db2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs1269517
milestone50.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1269517 - Move android_platform to python configure. r=glandium MozReview-Commit-ID: 30bVQUc8hGb
build/autoconf/android.m4
build/moz.configure/android-ndk.configure
build/moz.configure/old.configure
--- a/build/autoconf/android.m4
+++ b/build/autoconf/android.m4
@@ -6,69 +6,19 @@ AC_DEFUN([MOZ_ANDROID_NDK],
 [
 
 MOZ_ARG_WITH_STRING(android-cxx-stl,
 [  --with-android-cxx-stl=VALUE
                           use the specified C++ STL (stlport, libstdc++, libc++)],
     android_cxx_stl=$withval,
     android_cxx_stl=libc++)
 
-define([MIN_ANDROID_VERSION], [9])
-android_version=MIN_ANDROID_VERSION
-
-MOZ_ARG_WITH_STRING(android-version,
-[  --with-android-version=VER
-                          android platform version, default] MIN_ANDROID_VERSION,
-    android_version=$withval)
-
-if test $android_version -lt MIN_ANDROID_VERSION ; then
-    AC_MSG_ERROR([--with-android-version must be at least MIN_ANDROID_VERSION.])
-fi
-
 case "$target" in
 *-android*|*-linuxandroid*)
-    AC_MSG_CHECKING([for android platform directory])
-
-    case "$target_cpu" in
-    arm)
-        target_name=arm
-        ;;
-    i?86)
-        target_name=x86
-        ;;
-    mipsel)
-        target_name=mips
-        ;;
-    esac
-
-    dnl Not all Android releases have their own platform release. We use
-    dnl the next lower platform version in these cases.
-    case $android_version in
-    11|10)
-        android_platform_version=9
-        ;;
-    20)
-        android_platform_version=19
-        ;;
-    22)
-        android_platform_version=21
-        ;;
-    *)
-        android_platform_version=$android_version
-        ;;
-    esac
-
-    android_platform="$android_ndk"/platforms/android-"$android_platform_version"/arch-"$target_name"
-
-    if test -d "$android_platform" ; then
-        AC_MSG_RESULT([$android_platform])
-    else
-        AC_MSG_ERROR([not found. Please check your NDK. With the current configuration, it should be in $android_platform])
-    fi
-
+    dnl $android_platform will be set for us by Python configure.
     CPPFLAGS="-idirafter $android_platform/usr/include $CPPFLAGS"
     CFLAGS="-fno-short-enums -fno-exceptions $CFLAGS"
     CXXFLAGS="-fno-short-enums -fno-exceptions $CXXFLAGS"
     ASFLAGS="-idirafter $android_platform/usr/include -DANDROID $ASFLAGS"
 
     dnl Add --allow-shlib-undefined, because libGLESv2 links to an
     dnl undefined symbol (present on the hardware, just not in the
     dnl NDK.)
--- a/build/moz.configure/android-ndk.configure
+++ b/build/moz.configure/android-ndk.configure
@@ -9,27 +9,87 @@ js_option('--with-android-ndk', nargs=1,
           help='location where the Android NDK can be found')
 
 js_option('--with-android-toolchain', nargs=1,
           help='location of the Android toolchain')
 
 js_option('--with-android-gnu-compiler-version', nargs=1,
           help='GNU compiler version to use')
 
+@depends('--help')
+def min_android_version(_):
+    return '9'
+
+js_option('--with-android-version',
+          nargs=1,
+          help='android platform version',
+          default=min_android_version)
+
+@depends('--with-android-version', min_android_version)
+@imports(_from='__builtin__', _import='ValueError')
+def android_version(value, min_version):
+    if not value:
+        # Someone has passed --without-android-version.
+        die('--with-android-version cannot be disabled.')
+
+    try:
+        version = int(value[0])
+    except ValueError:
+        die('--with-android-version expects an integer value')
+
+    if version < int(min_version):
+        die('--with-android-version must be at least %s (got %s)',
+            min_version, value[0])
+
+    return version
+
 @depends('--with-android-ndk', build_project)
 def ndk(value, build_project):
     if build_project == 'mobile/android' and not value:
         die('You must specify --with-android-ndk=/path/to/ndk when '
             'building mobile/android')
     if value:
         return value[0]
 
 set_config('ANDROID_NDK', ndk)
 add_old_configure_assignment('android_ndk', ndk)
 
+@depends(target, android_version, ndk)
+@checking('for android platform directory')
+def android_platform(target, android_version, ndk):
+    if target.os != 'Android':
+        return
+
+    if 'mips' in target.cpu:
+        target_dir_name = 'mips'
+    else:
+        target_dir_name = target.cpu
+
+    # Not all Android releases have their own platform release. We use
+    # the next lower platform version in these cases.
+    if android_version in (11, 10):
+        platform_version = 9
+    elif android_version in (20, 22):
+        platform_version = android_version - 1
+    else:
+        platform_version = android_version
+
+    platform_dir = os.path.join(ndk,
+                                'platforms',
+                                'android-%s' % platform_version,
+                                'arch-%s' % target_dir_name)
+
+    if not os.path.isdir(platform_dir):
+        die("Android platform directory not found. With the current "
+            "configuration, it should be in %s" % platform_dir)
+
+    return platform_dir
+
+add_old_configure_assignment('android_platform', android_platform)
+
 @depends(target, host, ndk, '--with-android-toolchain',
          '--with-android-gnu-compiler-version')
 @checking('for the Android toolchain directory', lambda x: x or 'not found')
 @imports(_from='mozbuild.shellutil', _import='quote')
 def android_toolchain(target, host, ndk, toolchain, gnu_compiler_version):
     if not ndk:
         return
     if toolchain:
--- a/build/moz.configure/old.configure
+++ b/build/moz.configure/old.configure
@@ -267,17 +267,16 @@ def old_configure_options(*options):
     '--no-create',
     '--prefix',
     '--with-adjust-sdk-keyfile',
     '--with-android-cxx-stl',
     '--with-android-distribution-directory',
     '--with-android-max-sdk',
     '--with-android-min-sdk',
     '--with-android-sdk',
-    '--with-android-version',
     '--with-app-basename',
     '--with-app-name',
     '--with-arch',
     '--with-bing-api-keyfile',
     '--with-branding',
     '--with-crashreporter-enable-percent',
     '--with-cross-lib',
     '--with-debug-label',