Bug 1276927: Build B2G with Android build scripts where possible, r=glandium draft
authorThomas Zimmermann <tdz@users.sourceforge.net>
Wed, 15 Jun 2016 16:10:45 +0100
changeset 378347 6d248fd01c0d9477f0cc9b19839cd79ad2b22fa5
parent 378346 898628364ba7143aed07bfc455fab5571c61c193
child 523509 5bf0c6f307325d128682e29a7bbab275eedc2268
push id20985
push usertdz@users.sourceforge.net
push dateThu, 16 Jun 2016 07:41:33 +0000
reviewersglandium
bugs1276927
milestone50.0a1
Bug 1276927: Build B2G with Android build scripts where possible, r=glandium This patch adds support for configuring Gonk/B2G with Android-specific build scripts. This removes duplicated code and simplifies maintenance of B2G. The B2G builds will now use libc++ for Gecko; instead of the obsolete STLport. A side-effect of this patch is the removal of any compile-time dependency on B2G's bionic library. MozReview-Commit-ID: 7V6BmC7jlrs
b2g/moz.configure
build/autoconf/android.m4
build/moz.configure/init.configure
build/moz.configure/toolchain.configure
old-configure.in
--- a/b2g/moz.configure
+++ b/b2g/moz.configure
@@ -1,23 +1,21 @@
 # -*- 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/.
 
 option('--with-gonk', nargs=1, help='Path to the gonk base directory')
 
-@depends_if('--with-gonk')
-def gonkdir(value):
+@depends_if('--with-gonk', '--help')
+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
@@ -65,17 +65,17 @@ case "$target" in
     ;;
 esac
 
 ])
 
 AC_DEFUN([MOZ_ANDROID_CPU_ARCH],
 [
 
-if test "$OS_TARGET" = "Android" -a -z "$gonkdir"; then
+if test "$OS_TARGET" = "Android"; then
     case "${CPU_ARCH}-${MOZ_ARCH}" in
     arm-armv7*)
         ANDROID_CPU_ARCH=armeabi-v7a
         ;;
     arm-*)
         ANDROID_CPU_ARCH=armeabi
         ;;
     x86-*)
@@ -88,17 +88,17 @@ if test "$OS_TARGET" = "Android" -a -z "
 
     AC_SUBST(ANDROID_CPU_ARCH)
 fi
 ])
 
 AC_DEFUN([MOZ_ANDROID_STLPORT],
 [
 
-if test "$OS_TARGET" = "Android" -a -z "$gonkdir"; then
+if test "$OS_TARGET" = "Android"; then
     cpu_arch_dir="$ANDROID_CPU_ARCH"
     if test "$MOZ_THUMB2" = 1; then
         cpu_arch_dir="$cpu_arch_dir/thumb"
     fi
 
     if test -z "$STLPORT_CPPFLAGS$STLPORT_LIBS"; then
         case "$android_cxx_stl" in
         libstdc++)
--- a/build/moz.configure/init.configure
+++ b/build/moz.configure/init.configure
@@ -788,9 +788,19 @@ def js_option(*args, **kwargs):
 
     add_old_configure_arg(js_option)
 
 
 include('pkg.configure')
 # Make this assignment here rather than in pkg.configure to avoid
 # requiring this file in unit tests.
 add_old_configure_assignment('PKG_CONFIG', pkg_config)
+
+# Bug 1278542: This function is a workaround to resolve
+# |android_ndk_include|'s dependency on 'gonkdir.' The
+# actual implementation is located in b2g/moz.configure.
+# Remove this function as soon as 'android_ndk_include'
+# depends on 'target.'
+@depends('--help')
+def gonkdir(_):
+    return None
+
 include(include_project_configure)
--- a/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -54,19 +54,19 @@ def have_yasm(value):
 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'):
+@depends('--disable-compile-environment', build_project, gonkdir, '--help')
+def android_ndk_include(compile_env, build_project, gonkdir, _):
+    if compile_env and (gonkdir or build_project in ('mobile/android', 'js')):
         return 'android-ndk.configure'
 
 include(android_ndk_include)
 
 
 # MacOS deployment target version
 # ==============================================================
 # This needs to happen before any compilation test is done.
--- a/old-configure.in
+++ b/old-configure.in
@@ -90,34 +90,33 @@ dnl ====================================
 _topsrcdir=`cd \`dirname $0\`; pwd -W 2>/dev/null || pwd -P`
 _objdir=`pwd -P`
 
 MOZ_BUILD_ROOT=`pwd -W 2>/dev/null || pwd -P`
 DIST="$MOZ_BUILD_ROOT/dist"
 
 MOZ_DEFAULT_COMPILER
 
+if test "$COMPILE_ENVIRONMENT"; then
+    MOZ_ANDROID_NDK
+fi # COMPILE_ENVIRONMENT
+
 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"
     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])
-    fi
-    STLPORT_CPPFLAGS="-I$_topsrcdir/build/stlport/stlport -I$gonkdir/ndk/sources/cxx-stl/system/include"
-
     case "$ANDROID_VERSION" in
     15)
         GONK_INCLUDES="-I$gonkdir/frameworks/base/opengl/include -I$gonkdir/frameworks/base/native/include -I$gonkdir/frameworks/base/include -I$gonkdir/frameworks/base/services/camera -I$gonkdir/frameworks/base/include/media/ -I$gonkdir/frameworks/base/include/media/stagefright -I$gonkdir/frameworks/base/include/media/stagefright/openmax -I$gonkdir/frameworks/base/media/libstagefright/rtsp -I$gonkdir/frameworks/base/media/libstagefright/include -I$gonkdir/external/dbus -I$gonkdir/external/bluetooth/bluez/lib -I$gonkdir/dalvik/libnativehelper/include/nativehelper"
         MOZ_B2G_BT=1
         MOZ_B2G_BT_BLUEZ=1
         MOZ_NFC=1
         MOZ_B2G_CAMERA=1
         MOZ_OMX_DECODER=1
@@ -178,36 +177,30 @@ if test -n "$gonkdir" ; then
         fi
         MOZ_NFC=1
         MOZ_RTSP=1
         ;;
     *)
         AC_MSG_ERROR([Unsupported platform version: $ANDROID_VERSION])
         ;;
     esac
-    CPPFLAGS="-DANDROID $TARGET_C_INCLUDES -I$gonkdir/system -I$gonkdir/system/core/include -isystem $gonkdir/bionic -I$gonkdir/hardware/libhardware/include -I$gonkdir/external/valgrind/fxos-include $GONK_INCLUDES $CPPFLAGS"
-    CFLAGS="-fno-short-enums -fno-exceptions $CFLAGS"
-    CXXFLAGS="-fno-short-enums -fno-exceptions $CXXFLAGS $STLPORT_CPPFLAGS"
+
+    CPPFLAGS="-I$gonkdir/system -I$gonkdir/system/core/include -I$gonkdir/hardware/libhardware/include -I$gonkdir/external/valgrind/fxos-include $GONK_INCLUDES $CPPFLAGS"
+    LDFLAGS="-L$gonkdir/out/target/product/$GONK_PRODUCT/obj/lib -Wl,-rpath-link=$gonkdir/out/target/product/$GONK_PRODUCT/obj/lib $LDFLAGS"
     dnl Add -llog by default, since we use it all over the place.
     LIBS="$LIBS -llog"
 
-    LDFLAGS="-L$gonkdir/out/target/product/$GONK_PRODUCT/obj/lib -Wl,-rpath-link=$gonkdir/out/target/product/$GONK_PRODUCT/obj/lib --sysroot=$gonkdir/out/target/product/$GONK_PRODUCT/obj/ $LDFLAGS"
-
     AC_DEFINE(ANDROID)
     AC_DEFINE_UNQUOTED(ANDROID_VERSION, $ANDROID_VERSION)
     AC_SUBST(ANDROID_VERSION)
     AC_DEFINE(HAVE_SYS_UIO_H)
     AC_DEFINE(HAVE_PTHREADS)
     direct_nspr_config=1
-    android_cxx_stl=mozstlport
+
 else
-    if test "$COMPILE_ENVIRONMENT"; then
-        MOZ_ANDROID_NDK
-    fi # COMPILE_ENVIRONMENT
-
     case "$target" in
     *-android*|*-linuxandroid*)
         ZLIB_DIR=yes
         AC_DEFINE(ANDROID)
         ;;
     *-linux*)
         AC_PATH_PROG(OBJCOPY,objcopy)
         ;;