mirror of
https://fuchsia.googlesource.com/third_party/pigweed.googlesource.com/pigweed/pigweed
synced 2024-09-20 05:41:06 +00:00
aa00a15beb
The default Pigweed pw_toolchain defines the `ar`, `cc`, and `cxx` tools in the base toolchain definition, and builds more customization on top. For Android, since those paths are defined based on build args and toolchain defaults such as `current_cpu` and `api_level`, instead provide "pw_generate_android_toolchain" that defines them last before calling "generate_toolchain". Otherwise arrange matters such that defining Android targets feels as close to the other Pigweed targets as possible. Change-Id: Ic28b62f18c2600cea9c9890389672604e9741773 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/55340 Commit-Queue: Scott James Remnant <keybuk@google.com> Reviewed-by: Anthony DiGirolamo <tonymd@google.com>
100 lines
3.1 KiB
ReStructuredText
100 lines
3.1 KiB
ReStructuredText
.. _module-pw_android_toolchain:
|
|
|
|
--------------------
|
|
pw_android_toolchain
|
|
--------------------
|
|
Android toolchains differ from ``pw_toolchain`` in that the latter defines the
|
|
tool names and paths at the lowest level, with customisation added at higher
|
|
levels, while in ``pw_android_toolchain`` the tool names and paths are derived
|
|
from build args and defaults so are defined last by calling
|
|
``pw_generate_android_toolchain``.
|
|
|
|
Setup
|
|
=====
|
|
You must first download and unpack a copy of the `Android NDK`_ and let Pigweed
|
|
know where that is located using the ``pw_android_toolchain_NDK_PATH`` build
|
|
arg.
|
|
|
|
.. _Android NDK: https://developer.android.com/ndk
|
|
|
|
You can set Pigweed build options using ``gn args out``.
|
|
|
|
Toolchains
|
|
==========
|
|
``pw_android_toolchain`` provides GN toolchains that may be used to build
|
|
Pigweed against an Android NDK. The following toolchains are defined:
|
|
|
|
- arm_android_debug
|
|
- arm_android_size_optimized
|
|
- arm_android_speed_optimized
|
|
- arm64_android_debug
|
|
- arm64_android_size_optimized
|
|
- arm64_android_speed_optimized
|
|
- x64_android_debug
|
|
- x64_android_size_optimized
|
|
- x64_android_speed_optimized
|
|
- x86_android_debug
|
|
- x86_android_size_optimized
|
|
- x86_android_speed_optimized
|
|
|
|
.. note::
|
|
The documentation for this module is currently incomplete.
|
|
|
|
Defining Toolchains
|
|
===================
|
|
Defining Android NDK toolchains is similar to ``pw_toolchain`` except that
|
|
instead of using ``generate_toolchain`` use ``pw_generate_android_toolchain``,
|
|
and ensure that ``current_cpu`` is set in the toolchain ``defaults``.
|
|
|
|
For example:
|
|
|
|
.. code::
|
|
|
|
import("//build_overrides/pigweed.gni")
|
|
|
|
import("$dir_pw_android_toolchain/toolchains.gni")
|
|
import("$dir_pw_android_toolchain/generate_toolchain.gni")
|
|
|
|
my_target_scope = {
|
|
# Use Pigweed's Android toolchain as a base.
|
|
_toolchain_base = pw_toolchain_android.debug
|
|
|
|
# Forward everything except the defaults scope from that toolchain.
|
|
forward_variables_from(_toolchain_base, "*", [ "defaults" ])
|
|
|
|
defaults = {
|
|
# Forward everything from the base toolchain's defaults.
|
|
forward_variables_from(_toolchain_base.defaults, "*")
|
|
|
|
# Build for 64-bit AArch64 Android devices.
|
|
current_cpu = "arm64"
|
|
|
|
# Extend with custom build arguments for the target.
|
|
pw_log_BACKEND = dir_pw_log_tokenized
|
|
}
|
|
}
|
|
|
|
# Create the actual GN toolchain from the scope.
|
|
pw_generate_android_toolchain("my_target") {
|
|
forward_variables_from(my_target_scope, "*")
|
|
}
|
|
|
|
Since Android NDKs contain toolchains for all supported targets, as a
|
|
convenience, ``pw_generate_android_toolchains`` does not require that
|
|
``current_cpu`` is set. If any toolchain scope in the list does not set it, a
|
|
toolchain for each supported target will be generated.
|
|
|
|
.. code::
|
|
|
|
# Generate arm_*, arm64_*, x64_*, and x86_* for each scope in the list.
|
|
pw_generate_android_toolchains("target_toolchains) {
|
|
toolchains = pw_toolchain_android_list
|
|
}
|
|
|
|
Customization
|
|
-------------
|
|
The Android SDK target version defaults to the value of the
|
|
``pw_android_toolchain_API_LEVEL`` build arg. You can override this on global
|
|
level, or on a per-toolchain level by setting ``api_level`` in the toolchain
|
|
defaults.
|