Bug 1397764 - Part 1. Move STLPORT_CPPFLAGS to moz.configure. r=chmanchester draft
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Fri, 29 Sep 2017 16:45:44 +0900
changeset 675908 5568627368fbf2dce02904918e50a241713d0a85
parent 672296 e6c32278f32cd5f7d159627b2157396b62d0c4a9
child 675909 50e848dabe8ff6fd2ef1886f6fcff1fa50ff5364
push id83297
push userbmo:m_kato@ga2.so-net.ne.jp
push dateFri, 06 Oct 2017 07:24:10 +0000
reviewerschmanchester
bugs1397764
milestone58.0a1
Bug 1397764 - Part 1. Move STLPORT_CPPFLAGS to moz.configure. r=chmanchester To build sytlo, we have to set compiler flags via BINDGEN_CFLAGS. Since we pass stlport flags to clang, I would like to move STLPORT_CPPFLAGS to moz.configure. MozReview-Commit-ID: 26jvUqUvwTY
build/autoconf/android.m4
build/moz.configure/android-ndk.configure
--- a/build/autoconf/android.m4
+++ b/build/autoconf/android.m4
@@ -5,17 +5,17 @@ dnl file, You can obtain one at http://m
 AC_DEFUN([MOZ_ANDROID_NDK],
 [
 
 case "$target" in
 *-android*|*-linuxandroid*)
     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"
+    CXXFLAGS="-fno-short-enums -fno-exceptions $CXXFLAGS $stlport_cppflags"
     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.)
     LDFLAGS="-L$android_platform/usr/lib -Wl,-rpath-link=$android_platform/usr/lib --sysroot=$android_platform -Wl,--allow-shlib-undefined $LDFLAGS"
     ANDROID_PLATFORM="${android_platform}"
 
@@ -52,63 +52,37 @@ if test "$OS_TARGET" = "Android"; then
     AC_SUBST(ANDROID_CPU_ARCH)
 fi
 ])
 
 AC_DEFUN([MOZ_ANDROID_STLPORT],
 [
 
 if test "$OS_TARGET" = "Android"; then
-    if test -z "$STLPORT_CPPFLAGS$STLPORT_LIBS"; then
+    if test -z "$STLPORT_LIBS"; then
         # android-ndk-r8b and later
-        ndk_base="$android_ndk/sources/cxx-stl"
-        cxx_base="$ndk_base/llvm-libc++"
-        cxx_libs="$cxx_base/libs/$ANDROID_CPU_ARCH"
+        cxx_libs="$android_ndk/sources/cxx-stl/llvm-libc++/libs/$ANDROID_CPU_ARCH"
         # NDK r12 removed the arm/thumb library split and just made
         # everything thumb by default.  Attempt to compensate.
         if test "$MOZ_THUMB2" = 1 -a -d "$cxx_libs/thumb"; then
             cxx_libs="$cxx_libs/thumb"
         fi
-        cxx_include="$cxx_base/libcxx/include"
-        cxxabi_base="$ndk_base/llvm-libc++abi"
-        cxxabi_include="$cxxabi_base/libcxxabi/include"
 
         if ! test -e "$cxx_libs/libc++_static.a"; then
             AC_MSG_ERROR([Couldn't find path to llvm-libc++ in the android ndk])
         fi
 
-        if ! test -e "$cxx_include"; then
-            # NDK r13 removes the inner "libcxx" directory.
-            cxx_include="$cxx_base/include"
-            if ! test -e "$cxx_include"; then
-                AC_MSG_ERROR([Couldn't find path to libc++ includes in the android ndk])
-            fi
-        fi
-
-        if ! test -e "$cxxabi_include"; then
-            # NDK r13 removes the inner "libcxxabi" directory.
-            cxxabi_include="$cxxabi_base/include"
-            if ! test -e "$cxxabi_include"; then
-                AC_MSG_ERROR([Couldn't find path to libc++abi includes in the android ndk])
-            fi
-        fi
-
         STLPORT_LIBS="-L$cxx_libs -lc++_static"
         # NDK r12 split the libc++ runtime libraries into pieces.
         for lib in c++abi unwind android_support; do
             if test -e "$cxx_libs/lib${lib}.a"; then
                  STLPORT_LIBS="$STLPORT_LIBS -l${lib}"
             fi
         done
-        # Add android/support/include/ for prototyping long double math
-        # functions, locale-specific C library functions, multibyte support,
-        # etc.
-        STLPORT_CPPFLAGS="-I$cxx_include -I$android_ndk/sources/android/support/include -I$cxxabi_include"
     fi
-    CXXFLAGS="$CXXFLAGS $STLPORT_CPPFLAGS"
 fi
 AC_SUBST([STLPORT_LIBS])
 
 ])
 
 
 AC_DEFUN([concat],[$1$2$3$4])
 
--- a/build/moz.configure/android-ndk.configure
+++ b/build/moz.configure/android-ndk.configure
@@ -181,8 +181,48 @@ def android_toolchain_prefix(target, too
         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')
+
+option(env='STLPORT_CPPFLAGS',
+       nargs=1,
+       help='Options compiler should pass for standard C++ library')
+
+@depends('STLPORT_CPPFLAGS', ndk)
+@imports(_from='os.path', _import='isdir')
+def stlport_cppflags(value, ndk):
+    if value and len(value):
+        return value
+    if not ndk:
+        return
+
+    ndk_base = os.path.join(ndk, 'sources', 'cxx-stl')
+    cxx_base = os.path.join(ndk_base, 'llvm-libc++')
+    cxx_include = os.path.join(cxx_base, 'libcxx', 'include')
+    cxxabi_base = os.path.join(ndk_base, 'llvm-libc++abi')
+    cxxabi_include = os.path.join(cxxabi_base, 'libcxxabi', 'include')
+
+    if not isdir(cxx_include):
+        # NDK r13 removes the inner "libcxx" directory.
+        cxx_include = os.path.join(cxx_base, 'include')
+        if not isdir(cxx_include):
+            die("Couldn't find path to libc++ includes in the android ndk")
+
+    if not isdir(cxxabi_include):
+        # NDK r13 removes the inner "libcxxabi" directory.
+        cxxabi_include = os.path.join(cxxabi_base, 'include')
+        if not isdir(cxxabi_include):
+            die("Couldn't find path to libc++abi includes in the android ndk")
+
+    # Add android/support/include/ for prototyping long double math
+    # functions, locale-specific C library functions, multibyte support,
+    # etc.
+    return "-I%s -I%s -I%s" % (cxx_include,
+                               os.path.join(ndk, 'sources', 'android',
+                                            'support', 'include'),
+                               cxxabi_include)
+
+add_old_configure_assignment('stlport_cppflags', stlport_cppflags)