Bug 1262020 - Move --with-android-ndk, --with-android-toolchain and --with-android-gnu-compiler-version to moz.configure. r=nalexander
--- a/b2g/moz.configure
+++ b/b2g/moz.configure
@@ -6,16 +6,18 @@
option('--with-gonk', nargs=1, help='Path to the gonk base directory')
@depends_if('--with-gonk')
def gonkdir(value):
return value[0]
add_old_configure_assignment('gonkdir', gonkdir)
+set_config('ANDROID_NDK',
+ depends_if(gonkdir)(lambda x: os.path.join(x, 'ndk')))
@depends_if('--with-gonk')
def gonk_toolkit(_):
return 'cairo-gonk'
imply_option('--enable-default-toolkit', gonk_toolkit)
--- a/build/autoconf/android.m4
+++ b/build/autoconf/android.m4
@@ -1,30 +1,15 @@
dnl This Source Code Form is subject to the terms of the Mozilla Public
dnl License, v. 2.0. If a copy of the MPL was not distributed with this
dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
AC_DEFUN([MOZ_ANDROID_NDK],
[
-MOZ_ARG_WITH_STRING(android-ndk,
-[ --with-android-ndk=DIR
- location where the Android NDK can be found],
- android_ndk=$withval)
-
-MOZ_ARG_WITH_STRING(android-toolchain,
-[ --with-android-toolchain=DIR
- location of the Android toolchain],
- android_toolchain=$withval)
-
-MOZ_ARG_WITH_STRING(android-gnu-compiler-version,
-[ --with-android-gnu-compiler-version=VER
- gnu compiler version to use],
- android_gnu_compiler_version=$withval)
-
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=mozstlport)
define([MIN_ANDROID_VERSION], [9])
android_version=MIN_ANDROID_VERSION
@@ -34,86 +19,17 @@ MOZ_ARG_WITH_STRING(android-version,
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
-arm-*linux*-android*|*-linuxandroid*)
- android_tool_prefix="arm-linux-androideabi"
- ;;
-i?86-*android*)
- android_tool_prefix="i686-linux-android"
- ;;
-mipsel-*android*)
- android_tool_prefix="mipsel-linux-android"
- ;;
-*)
- android_tool_prefix="$target_os"
- ;;
-esac
-
-case "$target" in
*-android*|*-linuxandroid*)
- if test -z "$android_ndk" ; then
- AC_MSG_ERROR([You must specify --with-android-ndk=/path/to/ndk when targeting Android.])
- fi
-
- if test -z "$android_toolchain" ; then
- AC_MSG_CHECKING([for android toolchain directory])
-
- kernel_name=`uname -s | tr "[[:upper:]]" "[[:lower:]]"`
-
- for version in $android_gnu_compiler_version 4.9 4.8 4.7; do
- case "$target_cpu" in
- arm)
- target_name=arm-linux-androideabi-$version
- ;;
- i?86)
- target_name=x86-$version
- ;;
- mipsel)
- target_name=mipsel-linux-android-$version
- ;;
- *)
- AC_MSG_ERROR([target cpu is not supported])
- ;;
- esac
- case "$host_cpu" in
- i*86)
- android_toolchain="$android_ndk"/toolchains/$target_name/prebuilt/$kernel_name-x86
- ;;
- x86_64)
- android_toolchain="$android_ndk"/toolchains/$target_name/prebuilt/$kernel_name-x86_64
- if ! test -d "$android_toolchain" ; then
- android_toolchain="$android_ndk"/toolchains/$target_name/prebuilt/$kernel_name-x86
- fi
- ;;
- *)
- AC_MSG_ERROR([No known toolchain for your host cpu])
- ;;
- esac
- if test -d "$android_toolchain" ; then
- android_gnu_compiler_version=$version
- break
- elif test -n "$android_gnu_compiler_version" ; then
- AC_MSG_ERROR([not found. Your --with-android-gnu-compiler-version may be wrong.])
- fi
- done
-
- if test -z "$android_gnu_compiler_version" ; then
- AC_MSG_ERROR([not found. You have to specify --with-android-toolchain=/path/to/ndk/toolchain.])
- else
- AC_MSG_RESULT([$android_toolchain])
- fi
- NSPR_CONFIGURE_ARGS="$NSPR_CONFIGURE_ARGS --with-android-toolchain=$android_toolchain"
- fi
-
NSPR_CONFIGURE_ARGS="$NSPR_CONFIGURE_ARGS --with-android-version=$android_version"
AC_MSG_CHECKING([for android platform directory])
case "$target_cpu" in
arm)
target_name=arm
;;
@@ -128,35 +44,29 @@ case "$target" in
android_platform="$android_ndk"/platforms/android-"$android_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
- TOOLCHAIN_PREFIX="$android_toolchain/bin/$android_tool_prefix-"
-
CPPFLAGS="-idirafter $android_platform/usr/include $CPPFLAGS"
CFLAGS="-mandroid -fno-short-enums -fno-exceptions $CFLAGS"
CXXFLAGS="-mandroid -fno-short-enums -fno-exceptions $CXXFLAGS"
ASFLAGS="-idirafter $android_platform/usr/include -DANDROID $ASFLAGS"
dnl Add -llog by default, since we use it all over the place.
dnl Add --allow-shlib-undefined, because libGLESv2 links to an
dnl undefined symbol (present on the hardware, just not in the
dnl NDK.)
LDFLAGS="-mandroid -L$android_platform/usr/lib -Wl,-rpath-link=$android_platform/usr/lib --sysroot=$android_platform -llog -Wl,--allow-shlib-undefined $LDFLAGS"
- ANDROID_NDK="${android_ndk}"
- ANDROID_TOOLCHAIN="${android_toolchain}"
ANDROID_PLATFORM="${android_platform}"
AC_DEFINE(ANDROID)
- AC_SUBST(ANDROID_NDK)
- AC_SUBST(ANDROID_TOOLCHAIN)
AC_SUBST(ANDROID_PLATFORM)
;;
esac
])
AC_DEFUN([MOZ_ANDROID_CPU_ARCH],
--- a/build/gyp.mozbuild
+++ b/build/gyp.mozbuild
@@ -84,17 +84,17 @@ elif os == 'Android':
gyp_vars['moz_widget_toolkit_gonk'] = 1
gyp_vars['opus_complexity'] = 1
if int(CONFIG['ANDROID_VERSION']) >= 18:
gyp_vars['moz_webrtc_omx'] = 1
else:
gyp_vars.update(
gtest_target_type='executable',
moz_webrtc_mediacodec=1,
- android_toolchain=CONFIG['ANDROID_TOOLCHAIN'],
+ android_toolchain=CONFIG.get('ANDROID_TOOLCHAIN', ''),
)
flavors = {
'WINNT': 'win',
'Android': 'linux' if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk' else 'android',
'Linux': 'linux',
'Darwin': 'mac' if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa' else 'ios',
'SunOS': 'solaris',
new file mode 100644
--- /dev/null
+++ b/build/moz.configure/android-ndk.configure
@@ -0,0 +1,77 @@
+# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+
+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('--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, 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:
+ return toolchain[0]
+ else:
+ if target.cpu == 'arm' and target.endianness == 'little':
+ target_base = 'arm-linux-androideabi'
+ elif target.cpu == 'x86':
+ target_base = 'x86'
+ elif target.cpu == 'mips' and target.endianness == 'little':
+ target_base = 'mipsel-linux-android'
+ else:
+ die('Target cpu is not supported.')
+
+ toolchain_format = '%s/toolchains/%s-%s/prebuilt/%s-%s'
+
+ for version in gnu_compiler_version or ['4.9', '4.8', '4.7']:
+ toolchain = toolchain_format % (ndk, target_base, version,
+ host.kernel.lower(), host.cpu)
+ log.debug('Trying %s' % quote(toolchain))
+ if not os.path.isdir(toolchain) and host.cpu == 'x86_64':
+ toolchain = toolchain_format % (ndk, target_base, version,
+ host.kernel.lower(), 'x86')
+ log.debug('Trying %s' % quote(toolchain))
+ if os.path.isdir(toolchain):
+ return toolchain
+ else:
+ if gnu_compiler_version:
+ die('Your --with-android-gnu-compiler-version may be wrong')
+ die('You have to specify --with-android-toolchain='
+ '/path/to/ndk/toolchain.')
+
+set_config('ANDROID_TOOLCHAIN', android_toolchain)
+
+@depends(target, android_toolchain)
+def android_toolchain_prefix(target, toolchain):
+ if toolchain:
+ if target.cpu == 'x86':
+ # Ideally, the --target should just have the right x86 variant
+ # in the first place.
+ return '%s/bin/i686-linux-android-' % toolchain
+ return '%s/bin/%s-' % (toolchain, target.toolchain)
+
+imply_option('--with-toolchain-prefix', android_toolchain_prefix,
+ reason='--with-android-ndk')
--- a/build/moz.configure/old.configure
+++ b/build/moz.configure/old.configure
@@ -296,22 +296,19 @@ def old_configure_options(*options):
'--enable-webspeechtestbackend',
'--enable-xul',
'--enable-zipwriter',
'--no-create',
'--prefix',
'--with-adjust-sdk-keyfile',
'--with-android-cxx-stl',
'--with-android-distribution-directory',
- '--with-android-gnu-compiler-version',
'--with-android-max-sdk',
'--with-android-min-sdk',
- '--with-android-ndk',
'--with-android-sdk',
- '--with-android-toolchain',
'--with-android-version',
'--with-app-basename',
'--with-app-name',
'--with-arch',
'--with-bing-api-keyfile',
'--with-branding',
'--with-crashreporter-enable-percent',
'--with-cross-lib',
--- a/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -54,16 +54,27 @@ def have_yasm(value):
if value:
return True
set_config('HAVE_YASM', have_yasm)
# Until the YASM variable is not necessary in old-configure.
add_old_configure_assignment('YASM', have_yasm)
+# Android NDK
+# ==============================================================
+
+@depends('--disable-compile-environment', build_project, '--help')
+def android_ndk_include(compile_env, build_project, _):
+ if compile_env and build_project in ('mobile/android', 'js'):
+ return 'android-ndk.configure'
+
+include(android_ndk_include)
+
+
# Compiler wrappers
# ==============================================================
js_option('--with-compiler-wrapper', env='COMPILER_WRAPPER', nargs=1,
help='Enable compiling with wrappers such as distcc and ccache')
js_option('--with-ccache', env='CCACHE', nargs='?',
help='Enable compiling with ccache')
@@ -112,11 +123,11 @@ js_option('--with-toolchain-prefix', env
def toolchain_prefix(value, target, host, cross_compiling):
if value:
return value[0]
# Special case x86-64 <-> x86 cross compiling until we have the right tests
# in moz.configure land.
if cross_compiling and not all(i.cpu in ('x86_64', 'x86')
for i in (target, host)):
return '%s-' % target.toolchain
- return ''
+set_config('TOOLCHAIN_PREFIX', toolchain_prefix)
add_old_configure_assignment('TOOLCHAIN_PREFIX', toolchain_prefix)
--- a/js/src/old-configure.in
+++ b/js/src/old-configure.in
@@ -2728,18 +2728,16 @@ dnl ====================================
MOZ_CHECK_ALLOCATOR
AC_CHECK_FUNCS(setlocale localeconv)
AC_SUBST(MOZILLA_VERSION)
AC_SUBST(ac_configure_args)
-AC_SUBST(TOOLCHAIN_PREFIX)
-
if test -n "$JS_STANDALONE"; then
MOZ_APP_NAME="mozjs"
MOZ_APP_VERSION="$MOZILLA_SYMBOLVERSION"
JS_LIBRARY_NAME="mozjs-$MOZILLA_SYMBOLVERSION"
else
JS_LIBRARY_NAME="mozjs"
fi
JS_CONFIG_LIBS="$NSPR_LIBS $LIBS"
--- a/mobile/android/config/mozconfigs/android-api-15-frontend/nightly
+++ b/mobile/android/config/mozconfigs/android-api-15-frontend/nightly
@@ -5,16 +5,17 @@ MOZ_AUTOMATION_L10N_CHECK=0
MOZ_AUTOMATION_PACKAGE=0
MOZ_AUTOMATION_PACKAGE_TESTS=0
MOZ_AUTOMATION_SDK=0
MOZ_AUTOMATION_UPDATE_PACKAGING=0
MOZ_AUTOMATION_UPLOAD=0
MOZ_AUTOMATION_UPLOAD_SYMBOLS=0
NO_CACHE=1
+NO_NDK=1
. "$topsrcdir/mobile/android/config/mozconfigs/common"
ac_add_options --with-gradle="$topsrcdir/gradle/bin/gradle"
export GRADLE_MAVEN_REPOSITORY="file://$topsrcdir/jcentral"
ac_add_options --disable-compile-environment
ac_add_options --disable-tests
--- a/mobile/android/config/mozconfigs/common
+++ b/mobile/android/config/mozconfigs/common
@@ -32,20 +32,23 @@ MOZ_SZIP_FLAGS="-D auto -f auto"
ac_add_options --enable-elf-hack
ANDROID_NDK_VERSION="r10e"
ANDROID_NDK_VERSION_32BIT="r8c"
# Build Fennec
ac_add_options --enable-application=mobile/android
-ac_add_options --with-android-ndk="$topsrcdir/android-ndk"
ac_add_options --with-android-sdk="$topsrcdir/android-sdk-linux"
-ac_add_options --with-android-gnu-compiler-version=4.9
+if [ -z "$NO_NDK" ]; then
+ ac_add_options --with-android-ndk="$topsrcdir/android-ndk"
+ ac_add_options --with-android-gnu-compiler-version=4.9
+fi
+
ac_add_options --with-android-version=9
ac_add_options --with-system-zlib
ac_add_options --enable-update-channel=${MOZ_UPDATE_CHANNEL}
# Treat warnings as errors (modulo ALLOW_COMPILER_WARNINGS).
ac_add_options --enable-warnings-as-errors
ac_add_options --with-mozilla-api-keyfile=/builds/mozilla-fennec-geoloc-api.key
--- a/old-configure.in
+++ b/old-configure.in
@@ -98,17 +98,16 @@ MOZ_DEFAULT_COMPILER
if test -n "$gonkdir" ; then
dnl export for js/src/configure. We can't pass the option down normally,
dnl because it's a `--enable-project=b2g`-only option.
export gonkdir
kernel_name=`uname -s | tr "[[:upper:]]" "[[:lower:]]"`
android_source="$gonkdir"
ANDROID_SOURCE="$android_source"
- ANDROID_NDK="${ANDROID_SOURCE}/ndk"
dnl Default to ICS
ANDROID_VERSION=15
if test -n "${PLATFORM_SDK_VERSION}"; then
ANDROID_VERSION="${PLATFORM_SDK_VERSION}"
fi
if ! test -e "$gonkdir/ndk/sources/cxx-stl/stlport/src/iostream.cpp"; then
AC_MSG_ERROR([Couldn't find path to stlport sources in the gonk tree])
@@ -6991,17 +6990,16 @@ AC_SUBST(WARNINGS_AS_ERRORS)
AC_SUBST_SET(MOZ_EXTENSIONS)
AC_SUBST(LIBICONV)
AC_SUBST(MOZ_PLACES)
AC_SUBST(MOZ_SOCIAL)
AC_SUBST(MOZ_TOOLKIT_SEARCH)
AC_SUBST(MOZ_FEEDS)
AC_SUBST(NS_PRINTING)
AC_SUBST(MOZ_HELP_VIEWER)
-AC_SUBST(TOOLCHAIN_PREFIX)
AC_SUBST(JAVA)
AC_SUBST(JAVAC)
AC_SUBST(JAVAH)
AC_SUBST(JAR)
AC_SUBST(JARSIGNER)
AC_SUBST(KEYTOOL)