tree: db391be5c8ef6cfc46eb5c6e58f70bd15a72287c [path history] [tgz]
  1. android_trampolines/
  2. linux_amd64_trampolines/
  3. mac_trampolines/
  4. BUILD.bazel
  5. clang_layering_check.bzl
  6. clang_linux_amd64_toolchain_config.bzl
  7. download_clang_linux_amd64.bzl
  8. download_mac_toolchain.bzl
  9. download_ndk_linux_amd64.bzl
  10. download_toolchains.bzl
  11. mac_toolchain_config.bzl
  12. ndk.BUILD
  13. ndk_linux_arm64_toolchain_config.bzl
  14. README.md
  15. utils.bzl
toolchain/README.md

Hermetic Android NDK C++ toolchain

This directory defines a hermetic C++ toolchain suite to compile with the Android NDK.

Motivation

Bazel has a built-in android_ndk_repository rule, which generates C++ toolchains based on a local NDK installation provided via the ANDROID_NDK_HOME environment variable. However, this rule breaks hermeticity, and requires the user to provide an NDK installation.

This directory provides a download_android_ndk repository rule, which downloads the Android NDK under external/ndk_linux_amd64, and a C++ toolchain suite that targets 32- and 64-bit ARM.

Design

The C++ toolchain suite is based on the C++ toolchain generated by the android_ndk_repository rule.

Steps taken:

  • Build SkCMS with the android_ndk_repository rule at this revision.
  • Inspect the contents of bazel-skcms/external/androidndk/BUILD.bazel and bazel-skcms/external/androidndk/cc_toolchain_config.bzl, which are generated by said rule.
  • Extract the useful parts into the C++ toolchain defined in this directory.

Trampoline scripts

The cc_common.create_cc_toolchain_config_info function expects tool paths to point to files under the directory in which it is invoked. This means we cannot directly reference tools under external/ndk_linux_amd64. The solution is to use “trampoline” scripts that pass through any command-line arguments to the NDK binaries under external/android_sdk.