def main(args): arches = build_support.ALL_ARCHITECTURES if args.arch is not None: arches = [args.arch] abis = [] for arch in arches: abis.extend(build_support.arch_to_abis(arch)) print('Building stlport for ABIs: {}'.format(' '.join(abis))) 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=stlport', abis_arg, ndk_dir_arg, build_support.jobs_arg(), build_support.toolchain_path(), '--with-debug-info', '--llvm-version=3.6', ] build_support.build(build_cmd, args)
def package_host_tools(out_dir, dist_dir, host): packages = [ 'gdb-multiarch-7.11', 'ndk-awk', 'ndk-depends', 'ndk-make', 'ndk-python', 'ndk-stack', 'ndk-yasm', ] files = [ 'ndk-gdb', 'ndk-gdb.py', 'ndk-which', ] if host in ('windows', 'windows64'): packages.append('toolbox') files.append('ndk-gdb.cmd') host_tag = build_support.host_to_tag(host) package_names = [p + '-' + host_tag + '.tar.bz2' for p in packages] for package_name in package_names: package_path = os.path.join(out_dir, package_name) subprocess.check_call(['tar', 'xf', package_path, '-C', out_dir]) for f in files: shutil.copy2(f, os.path.join(out_dir, 'host-tools/bin')) build_support.merge_license_files( os.path.join(out_dir, 'host-tools/NOTICE'), [ build_support.android_path('toolchain/gdb/gdb-7.11/COPYING'), build_support.ndk_path('sources/host-tools/nawk-20071023/NOTICE'), build_support.ndk_path('sources/host-tools/ndk-depends/NOTICE'), build_support.ndk_path('sources/host-tools/make-3.81/COPYING'), build_support.android_path( 'toolchain/python/Python-2.7.5/LICENSE'), build_support.ndk_path('sources/host-tools/ndk-stack/NOTICE'), build_support.ndk_path('sources/host-tools/toolbox/NOTICE'), build_support.android_path('toolchain/yasm/COPYING'), build_support.android_path('toolchain/yasm/BSD.txt'), build_support.android_path('toolchain/yasm/Artistic.txt'), build_support.android_path('toolchain/yasm/GNU_GPL-2.0'), build_support.android_path('toolchain/yasm/GNU_LGPL-2.0'), ]) package_name = 'host-tools-' + host_tag path = os.path.join(out_dir, 'host-tools') build_support.make_package(package_name, path, dist_dir)
def test_ndk(out_dir, args): release = args.release if args.release is None: release = datetime.date.today().strftime('%Y%m%d') # The packaging step extracts all the modules to a known directory for # packaging. This directory is not cleaned up after packaging, so we can # reuse that for testing. test_dir = os.path.join(out_dir, 'android-ndk-{}'.format(release)) test_env = dict(os.environ) test_env['NDK'] = test_dir abis = build_support.ALL_ABIS if args.arch is not None: abis = build_support.arch_to_abis(args.arch) results = {} for abi in abis: cmd = [ 'python', build_support.ndk_path('tests/run-all.py'), '--abi', abi, '--suite', 'build' ] print('Running tests: {}'.format(' '.join(cmd))) result = subprocess.call(cmd, env=test_env) results[abi] = result == 0 print('Results:') for abi, result in results.iteritems(): print('{}: {}'.format(abi, 'PASS' if result else 'FAIL')) return all(results.values())
def main(args): GCC_VERSION = '4.9' toolchains = build_support.ALL_TOOLCHAINS if args.toolchain is not None: toolchains = [args.toolchain] print('Building {} toolchains: {}'.format(args.host, ' '.join(toolchains))) for toolchain in toolchains: toolchain_name = '-'.join([toolchain, GCC_VERSION]) sysroot_arg = '--sysroot={}'.format( build_support.sysroot_path(toolchain)) build_cmd = [ 'bash', 'build-gcc.sh', build_support.toolchain_path(), build_support.ndk_path(), toolchain_name, build_support.jobs_arg(), sysroot_arg, ] if args.host in ('windows', 'windows64'): build_cmd.append('--mingw') if args.host != 'windows': build_cmd.append('--try-64') build_support.build(build_cmd, args)
def main(args): arches = build_support.ALL_ARCHITECTURES if args.arch is not None: arches = [args.arch] abis = [] for arch in arches: abis.extend(build_support.arch_to_abis(arch)) build_dir = os.path.join(args.out_dir, 'gnustl') print('Building libstdc++ for ABIs: {}'.format(' '.join(abis))) abis_arg = '--abis={}'.format(','.join(abis)) ndk_dir_arg = '--ndk-dir={}'.format(build_support.ndk_path()) build_cmd = [ 'bash', 'build-gnu-libstdc++.sh', abis_arg, ndk_dir_arg, build_support.jobs_arg(), build_support.toolchain_path(), '--with-debug-info', '--build-dir={}'.format(build_dir), ] build_support.build(build_cmd, args)
def main(args): GCC_VERSION = "4.9" toolchains = build_support.ALL_TOOLCHAINS if args.toolchain is not None: toolchains = [args.toolchain] print("Building {} toolchains: {}".format(args.host, " ".join(toolchains))) for toolchain in toolchains: toolchain_name = "-".join([toolchain, GCC_VERSION]) sysroot_arg = "--sysroot={}".format(build_support.sysroot_path(toolchain)) build_cmd = [ "bash", "build-gcc.sh", build_support.toolchain_path(), build_support.ndk_path(), toolchain_name, build_support.jobs_arg(), sysroot_arg, ] if args.host in ("windows", "windows64"): build_cmd.append("--mingw") if args.host != "windows": build_cmd.append("--try-64") build_support.build(build_cmd, args)
def main(args): GCC_VERSION = '4.9' toolchains = build_support.ALL_TOOLCHAINS if args.toolchain is not None: toolchains = [args.toolchain] print(f'Building {args.host.value} toolchains: {" ".join(toolchains)}') for toolchain in toolchains: toolchain_name = '-'.join([toolchain, GCC_VERSION]) sysroot_arg = '--sysroot={}'.format( build_support.sysroot_path(toolchain)) build_cmd = [ 'bash', 'build-gcc.sh', build_support.toolchain_path(), build_support.ndk_path(), toolchain_name, build_support.jobs_arg(), sysroot_arg, '--try-64', ] if args.host.is_windows: build_cmd.append('--mingw') build_support.build(build_cmd, args)
def main(args): arches = build_support.ALL_ARCHITECTURES if args.arch is not None: arches = [args.arch] abis = [] for arch in arches: abis.extend(build_support.arch_to_abis(arch)) print('Building libc++ for ABIs: {}'.format(' '.join(abis))) 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', ] build_support.build(build_cmd, args)
def main(args): arches = build_support.ALL_ARCHITECTURES if args.arch is not None: arches = [args.arch] print('Building plaforms: {}'.format(' '.join(arches))) arch_arg = '--arch={}'.format(','.join(arches)) ndk_dir_arg = '--ndk-dir={}'.format(build_support.ndk_path()) build_cmd = [ 'bash', 'gen-platforms.sh', '--fast-copy', arch_arg, ndk_dir_arg, ] if args.host != 'linux': build_cmd.append('--case-insensitive') build_support.build(build_cmd, args)
def main(args): arches = build_support.ALL_ARCHITECTURES if args.arch is not None: arches = [args.arch] print('Building gdbservers: {}'.format(' '.join(arches))) for arch in arches: build_dir = os.path.join(args.out_dir, 'gdbserver', arch) target_triple = dict(zip( build_support.ALL_ARCHITECTURES, GDBSERVER_TARGETS))[arch] build_cmd = [ 'bash', 'build-gdbserver.sh', arch, target_triple, build_support.toolchain_path(), build_support.ndk_path(), '--build-out={}'.format(build_dir), build_support.jobs_arg(), ] build_support.build(build_cmd, args)
def main(args): GCC_VERSION = '4.9' arches = build_support.ALL_ARCHITECTURES if args.arch is not None: arches = [args.arch] print('Building gdbservers: {}'.format(' '.join(arches))) for arch in arches: toolchain = build_support.arch_to_toolchain(arch) toolchain_name = '-'.join([toolchain, GCC_VERSION]) build_cmd = [ 'bash', 'build-gdbserver.sh', build_support.toolchain_path(), build_support.ndk_path(), toolchain_name, build_support.jobs_arg(), ] build_support.build(build_cmd, args)
def main(args): arches = build_support.ALL_ARCHITECTURES if args.arch is not None: arches = [args.arch] print('Building gdbservers: {}'.format(' '.join(arches))) for arch in arches: target_triple = dict( zip(build_support.ALL_ARCHITECTURES, GDBSERVER_TARGETS))[arch] build_cmd = [ 'bash', 'build-gdbserver.sh', arch, target_triple, build_support.toolchain_path(), build_support.ndk_path(), build_support.jobs_arg(), ] build_support.build(build_cmd, args)
def main(args): arches = build_support.ALL_ARCHITECTURES if args.arch is not None: arches = [args.arch] abis = [] for arch in arches: abis.extend(build_support.arch_to_abis(arch)) print("Building libstdc++ for ABIs: {}".format(" ".join(abis))) abis_arg = "--abis={}".format(",".join(abis)) ndk_dir_arg = "--ndk-dir={}".format(build_support.ndk_path()) build_cmd = [ "bash", "build-gnu-libstdc++.sh", abis_arg, ndk_dir_arg, build_support.jobs_arg(), build_support.toolchain_path(), "--with-debug-info", ] build_support.build(build_cmd, args)
def build_system_stl(_out_dir, dist_dir, _args): print('Building system-stl...') path = build_support.ndk_path('sources/cxx-stl/system') build_support.make_package('system-stl', path, dist_dir)
def build_build(_, dist_dir, __): path = build_support.ndk_path('build') build_support.make_package('build', path, dist_dir)
def build_gabixx(_out_dir, dist_dir, _args): print('Building gabi++...') path = build_support.ndk_path('sources/cxx-stl/gabi++') build_support.make_package('gabixx', path, dist_dir)
def build_ndk_helper(_, dist_dir, __): path = build_support.ndk_path('sources/android/ndk_helper') build_support.make_package('ndk_helper', path, dist_dir)
def build_gtest(_, dist_dir, __): path = build_support.ndk_path('sources/third_party/googletest') build_support.make_package('gtest', path, dist_dir)
def build_native_app_glue(_, dist_dir, __): path = build_support.ndk_path('sources/android/native_app_glue') build_support.make_package('native_app_glue', path, dist_dir)
def build_libandroid_support(_out_dir, dist_dir, _args): print('Building libandroid_support...') path = build_support.ndk_path('sources/android/support') build_support.make_package('libandroid_support', path, dist_dir)
def invoke_build(script, args=None): script_path = os.path.join('build/tools', script) _invoke_build(build_support.ndk_path(script_path), args)
def main(args): arches = build_support.ALL_ARCHITECTURES if args.arch is not None: arches = [args.arch] abis = [] for arch in arches: abis.extend(build_support.arch_to_abis(arch)) 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') build_cmd = [ '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) is_arm = abi.startswith('armeabi') if is_arm: shutil.copy2( os.path.join(static_lib_dir, 'libunwind.a'), install_dir) shutil.copy2(os.path.join(static_lib_dir, 'libc++abi.a'), install_dir) shutil.copy2( os.path.join(static_lib_dir, 'libandroid_support.a'), install_dir) shutil.copy2( os.path.join(static_lib_dir, 'libc++_static.a'), install_dir) build_support.make_package('libcxx', libcxx_path, args.dist_dir)
def copy_changelog(out_dir): changelog_path = build_support.ndk_path('CHANGELOG.md') shutil.copy2(changelog_path, out_dir)
def main(args): arches = build_support.ALL_ARCHITECTURES if args.arch is not None: arches = [args.arch] abis = [] for arch in arches: abis.extend(build_support.arch_to_abis(arch)) 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.android_path('external/libcxx') 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') build_cmd = [ '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(libcxx_path, 'Android.mk'), 'NDK_APPLICATION_MK=' + os.path.join(libcxx_path, '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', ] print('Building libc++ for ABIs: {}'.format(', '.join(abis))) print('Running: ' + ' '.join(build_cmd)) 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) is_arm = abi.startswith('armeabi') if is_arm: shutil.copy2(os.path.join(static_lib_dir, 'libunwind.a'), install_dir) shutil.copy2(os.path.join(static_lib_dir, 'libc++abi.a'), install_dir) shutil.copy2(os.path.join(static_lib_dir, 'libandroid_support.a'), install_dir) shutil.copy2(os.path.join(static_lib_dir, 'libc++_static.a'), install_dir) # Create linker scripts for the libraries we use so that we link things # properly even when we're not using ndk-build. The linker will read # the script in place of the library so that we link the unwinder and # other support libraries appropriately. static_libs = ['-lc++_static', '-lc++abi', '-landroid_support'] if is_arm: static_libs.extend(['-lunwind', '-latomic']) make_linker_script(os.path.join(install_dir, 'libc++.a'), static_libs) shared_libs = ['-landroid_support'] if is_arm: shared_libs.extend(['-lunwind', '-latomic']) shared_libs.append('-lc++_shared') make_linker_script(os.path.join(install_dir, 'libc++.so'), shared_libs) build_support.make_package('libc++', libcxx_path, args.dist_dir)
def build_libcxxabi(_out_dir, dist_dir, _args): print('Building libc++abi...') path = build_support.ndk_path('sources/cxx-stl/llvm-libc++abi') build_support.make_package('libcxxabi', path, dist_dir)
def build_cpufeatures(_, dist_dir, __): path = build_support.ndk_path('sources/android/cpufeatures') build_support.make_package('cpufeatures', path, dist_dir)