aboutsummaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authorDan Albert <danalbert@google.com>2016-01-26 13:37:44 -0800
committerDan Albert <danalbert@google.com>2016-01-29 15:30:08 -0800
commit73e31b9b79e39bd003b0398e0ed6e111fe757343 (patch)
tree3d014042c3a3155bd39b564b8832663d764fca8b /sources
parent9ec0fcb7ec691bebf3dae16600fafa75ffddafe6 (diff)
downloadndk-73e31b9b79e39bd003b0398e0ed6e111fe757343.tar.gz
Build libc++ with ndk-build instead of bash.
Before this patch we had to maintain two sets of build rules for libc++: build-cxx-stl.sh and Android.mk. This changes the prebuild step from using the shell script to just invoking ndk-build. For one, this means that anyone using LIBCXX_FORCE_REBUILD will actually get a reliable result, as it's the same way we built it. It's also quite a bit faster. It now takes only 45 seconds to build all 8 ABIs, whereas before this patch it took 3 minutes and 15 seconds. Aside from the cost of building everything, we also benefit from dependency checking now since we store the intermediate files in a reliable location, which means that a null build doesn't take long (it still takes some time because we have to run the packaging step). Now that this has been done for libc++, we could also do this for stlport. It may not be worth the effort, however, since that's not being actively worked on. Note that this patch also drops the prebuilt ARM (non-thumb) libraries. There wasn't actually any way to use them, so there's nothing lost here. Change-Id: I8602f0fd3a23a2938cdc5be19d0714d5567ce6fc
Diffstat (limited to 'sources')
-rw-r--r--sources/cxx-stl/llvm-libc++/.gitignore1
-rw-r--r--sources/cxx-stl/llvm-libc++/Android.mk16
-rw-r--r--sources/cxx-stl/llvm-libc++/Application.mk4
-rwxr-xr-xsources/cxx-stl/llvm-libc++/build.py67
4 files changed, 60 insertions, 28 deletions
diff --git a/sources/cxx-stl/llvm-libc++/.gitignore b/sources/cxx-stl/llvm-libc++/.gitignore
index 8f45b0d54..28a55e51c 100644
--- a/sources/cxx-stl/llvm-libc++/.gitignore
+++ b/sources/cxx-stl/llvm-libc++/.gitignore
@@ -1,3 +1,2 @@
libs/
-/repo.prop
/libcxx/test/lit.site.cfg
diff --git a/sources/cxx-stl/llvm-libc++/Android.mk b/sources/cxx-stl/llvm-libc++/Android.mk
index a55b4d8da..ef46ee130 100644
--- a/sources/cxx-stl/llvm-libc++/Android.mk
+++ b/sources/cxx-stl/llvm-libc++/Android.mk
@@ -103,14 +103,6 @@ android_support_c_includes := $(LOCAL_PATH)/../../android/support/include
include $(CLEAR_VARS)
LOCAL_MODULE := c++_static
LOCAL_SRC_FILES := libs/$(TARGET_ARCH_ABI)/lib$(LOCAL_MODULE)$(TARGET_LIB_EXTENSION)
-# For armeabi*, choose thumb mode unless LOCAL_ARM_MODE := arm
-ifneq (,$(filter armeabi%,$(TARGET_ARCH_ABI)))
-ifneq (arm,$(LOCAL_ARM_MODE))
-ifneq (arm,$(TARGET_ARM_MODE))
-LOCAL_SRC_FILES := libs/$(TARGET_ARCH_ABI)/thumb/lib$(LOCAL_MODULE)$(TARGET_LIB_EXTENSION)
-endif
-endif
-endif
LOCAL_EXPORT_C_INCLUDES := $(llvm_libc++_export_includes) $(android_support_c_includes)
LOCAL_EXPORT_CPPFLAGS := $(llvm_libc++_export_cxxflags)
include $(PREBUILT_STATIC_LIBRARY)
@@ -118,14 +110,6 @@ include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := c++_shared
LOCAL_SRC_FILES := libs/$(TARGET_ARCH_ABI)/lib$(LOCAL_MODULE)$(TARGET_SONAME_EXTENSION)
-# For armeabi*, choose thumb mode unless LOCAL_ARM_MODE := arm
-ifneq (,$(filter armeabi%,$(TARGET_ARCH_ABI)))
-ifneq (arm,$(LOCAL_ARM_MODE))
-ifneq (arm,$(TARGET_ARM_MODE))
-LOCAL_SRC_FILES := libs/$(TARGET_ARCH_ABI)/thumb/lib$(LOCAL_MODULE)$(TARGET_SONAME_EXTENSION)
-endif
-endif
-endif
LOCAL_EXPORT_C_INCLUDES := $(llvm_libc++_export_includes) $(android_support_c_includes)
LOCAL_EXPORT_CPPFLAGS := $(llvm_libc++_export_cxxflags)
include $(PREBUILT_SHARED_LIBRARY)
diff --git a/sources/cxx-stl/llvm-libc++/Application.mk b/sources/cxx-stl/llvm-libc++/Application.mk
new file mode 100644
index 000000000..eada7edd8
--- /dev/null
+++ b/sources/cxx-stl/llvm-libc++/Application.mk
@@ -0,0 +1,4 @@
+NDK_TOOLCHAIN_VERSION := clang
+# Even the system STL is too much because it will link libsupc++ for rtti and
+# exceptions.
+APP_STL := none
diff --git a/sources/cxx-stl/llvm-libc++/build.py b/sources/cxx-stl/llvm-libc++/build.py
index df26bba18..270dfb5bc 100755
--- a/sources/cxx-stl/llvm-libc++/build.py
+++ b/sources/cxx-stl/llvm-libc++/build.py
@@ -18,15 +18,18 @@
from __future__ import print_function
import os
+import shutil
import site
+import subprocess
-site.addsitedir(os.path.join(os.path.dirname(__file__), '../../../build/lib'))
+THIS_DIR = os.path.realpath(os.path.dirname(__file__))
+site.addsitedir(os.path.join(THIS_DIR, '../../../build/lib'))
-import build_support
+import build_support # pylint: disable=import-error
class ArgParser(build_support.ArgParser):
- def __init__(self):
+ def __init__(self): # pylint: disable=super-on-old-class
super(ArgParser, self).__init__()
self.add_argument(
@@ -43,18 +46,60 @@ def main(args):
for arch in arches:
abis.extend(build_support.arch_to_abis(arch))
- print('Building libc++ for ABIs: {}'.format(' '.join(abis)))
+ ndk_build = build_support.ndk_path('build/ndk-build')
+ prebuilt_ndk = build_support.android_path('prebuilts/ndk/current')
+ platforms_root = os.path.join(prebuilt_ndk, 'platforms')
+ toolchains_root = os.path.join(prebuilt_ndk, 'toolchains')
+ libcxx_path = build_support.ndk_path('sources/cxx-stl/llvm-libc++')
+ obj_out = os.path.join(args.out_dir, 'libcxx/obj')
+
+ # TODO(danalbert): Stop building to the source directory.
+ # This is historical, and simplifies packaging a bit. We need to pack up
+ # all the source as well as the libraries. If build_support.make_package
+ # were to change to allow a list of directories instead of one directory,
+ # we could make this unnecessary. Will be a follow up CL.
+ lib_out = os.path.join(libcxx_path, 'libs')
- abis_arg = '--abis={}'.format(','.join(abis))
- ndk_dir_arg = '--ndk-dir={}'.format(build_support.ndk_path())
- script = build_support.ndk_path('build/tools/build-cxx-stl.sh')
build_cmd = [
- 'bash', script, '--stl=libc++-libc++abi', abis_arg, ndk_dir_arg,
- build_support.jobs_arg(), build_support.toolchain_path(),
- '--with-debug-info', '--llvm-version=3.6',
+ 'bash', ndk_build, '-C', THIS_DIR, build_support.jobs_arg(), 'V=1',
+ 'APP_ABI=' + ' '.join(abis),
+
+ # Use the prebuilt platforms and toolchains.
+ 'NDK_PLATFORMS_ROOT=' + platforms_root,
+ 'NDK_TOOLCHAINS_ROOT=' + toolchains_root,
+ 'NDK_NEW_TOOLCHAINS_LAYOUT=true',
+
+ # Tell ndk-build where all of our makefiles are and where outputs
+ # should go. The defaults in ndk-build are only valid if we have a
+ # typical ndk-build layout with a jni/{Android,Application}.mk.
+ 'NDK_PROJECT_PATH=null',
+ 'APP_BUILD_SCRIPT=' + os.path.join(THIS_DIR, 'Android.mk'),
+ 'NDK_APPLICATION_MK=' + os.path.join(THIS_DIR, 'Application.mk'),
+ 'NDK_OUT=' + obj_out,
+ 'NDK_LIBS_OUT=' + lib_out,
+
+ # Make sure we don't pick up a cached copy.
+ 'LIBCXX_FORCE_REBUILD=true',
+
+ # Put armeabi-v7a-hard in its own directory.
+ '_NDK_TESTING_ALL_=yes',
]
+ print('Building libc++ for ABIs: {}'.format(', '.join(abis)))
+ subprocess.check_call(build_cmd)
+
+ # The static libraries are installed to NDK_OUT, not NDK_LIB_OUT, so we
+ # need to install them to our package directory.
+ for abi in abis:
+ static_lib_dir = os.path.join(obj_out, 'local', abi)
+ install_dir = os.path.join(lib_out, abi)
+
+ shutil.copy2(os.path.join(static_lib_dir, 'libc++_static.a'),
+ install_dir)
+ shutil.copy2(os.path.join(static_lib_dir, 'libandroid_support.a'),
+ install_dir)
+
+ build_support.make_package('libcxx', libcxx_path, args.dist_dir)
- build_support.build(build_cmd, args)
if __name__ == '__main__':
build_support.run(main, ArgParser)