Bug 1262020 - Move --with-android-ndk, --with-android-toolchain and --with-android-gnu-compiler-version to moz.configure. r=nalexander

This commit is contained in:
Mike Hommey 2016-04-02 11:23:40 +09:00
parent 8bedd96002
commit 6886f13b7d
10 changed files with 98 additions and 101 deletions

View File

@ -11,6 +11,8 @@ 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(_):

View File

@ -5,21 +5,6 @@ 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++)],
@ -38,77 +23,8 @@ 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])
@ -133,8 +49,6 @@ case "$target" in
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"
@ -145,13 +59,9 @@ case "$target" in
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)
;;

View File

@ -89,7 +89,7 @@ elif os == 'Android':
gyp_vars.update(
gtest_target_type='executable',
moz_webrtc_mediacodec=1,
android_toolchain=CONFIG['ANDROID_TOOLCHAIN'],
android_toolchain=CONFIG.get('ANDROID_TOOLCHAIN', ''),
)
flavors = {

View File

@ -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')

View File

@ -301,12 +301,9 @@ def old_configure_options(*options):
'--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',

View File

@ -59,6 +59,17 @@ set_config('HAVE_YASM', have_yasm)
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,
@ -117,6 +128,6 @@ def toolchain_prefix(value, target, host, cross_compiling):
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)

View File

@ -2731,8 +2731,6 @@ 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"

View File

@ -10,6 +10,7 @@ MOZ_AUTOMATION_UPLOAD=0
MOZ_AUTOMATION_UPLOAD_SYMBOLS=0
NO_CACHE=1
NO_NDK=1
. "$topsrcdir/mobile/android/config/mozconfigs/common"

View File

@ -37,10 +37,13 @@ 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}

View File

@ -103,7 +103,6 @@ if test -n "$gonkdir" ; then
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
@ -6996,7 +6995,6 @@ 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)