-
Notifications
You must be signed in to change notification settings - Fork 379
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve support for different Android versions.
We provide the following arguments to configure the Android version: - `ANDROID_NDK` - `ANDROID_SDK` (note that this is dependent on `ANDROID_VERSION) - `ANDROID_VERSION` - `ANDROID_SYSTEM_COMPLETE`: do a complete Android build Next, we've improved the removal of unittests during the build process, to ensure fast builds while maintaining compatibility with various newer Android versions. To do this, we've implemented a Python library and a script. The Python library contains a complete parser (correctly parses all valid input) for Soong blueprint files, using an LALR grammar, and a rudimentary parser for Makefiles. The Soong parser removes any `gtest` dependencies, as well as any subdirectories or scope names containing `test`. For example: ``` cc_library { name: "lib", srcs: ["lib.cc",], } cc_test { name: "test", defaults: ["target"], srcs: ["test.cc"], } ``` Will become: ``` cc_library { name: "lib", srcs: ["lib.cc",], } ``` The Makefile parser first splits the file based on conditional directives (`ifeq`, `endif`, etc.) to ensure any subsequent processing doesn't lead to unbalanced directives. Next, we split the text within each directive based on comment sections used in the Android source tree. For example: ``` test_tags := tests include $(call subdir,$(LOCAL_PATH)) c_flags := \ -g \ -Wall ``` We can therefore remove the `Benchmarks` and `Unit tests` sections without removing the `Other section`. The Python library is reasonably performant (it adds no noticeable overhead to the build process) and is compact (in total, < 60KB). Also, it is much more resilient than a series of `sed` scripts. Finally, extensive unittests have been added for the Python library, for both code linting (`flake8`) and unittests (via `tox`). Since we cannot assume the presence of Python on the host machine, the tests can be optionally enabled via the `--python` flag (or `PYTHON` environment variable, to hook into the git hooks), and custom overrides for the `flake8` and `tox` commands are provided (since the user may wish to specify a specific Python version, such as `python3.7 -m flake8`).
- Loading branch information
1 parent
79eeb91
commit 75870b7
Showing
37 changed files
with
3,512 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"description": "support different Android NDK, API, and Android versions using Docker build args.", | ||
"type": "added" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# don't copy any of the python artifacts to the docker context | ||
__pycache__/ | ||
.pytest_cache/ | ||
*.py[cod] | ||
*$py.class | ||
**/*.egg-info/ | ||
*.egg | ||
.tox | ||
|
||
# also skip our test suite | ||
android/tests/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
FROM ubuntu:20.04 | ||
ARG DEBIAN_FRONTEND=noninteractive | ||
|
||
COPY common.sh lib.sh / | ||
RUN /common.sh | ||
|
||
COPY cmake.sh / | ||
RUN /cmake.sh | ||
|
||
COPY xargo.sh / | ||
RUN /xargo.sh | ||
|
||
COPY qemu.sh / | ||
RUN /qemu.sh aarch64 | ||
|
||
ARG ANDROID_NDK=r21d | ||
ARG ANDROID_SDK=28 | ||
ARG ANDROID_VERSION=9.0.0_r1 | ||
ARG ANDROID_SYSTEM_COMPLETE=0 | ||
|
||
COPY android-ndk.sh / | ||
RUN /android-ndk.sh arm64 | ||
ENV PATH=$PATH:/android-ndk/bin | ||
|
||
COPY android-system.sh remove_android_tests.py / | ||
RUN /android-system.sh arm64 | ||
|
||
COPY android-symlink.sh / | ||
RUN /android-symlink.sh aarch64 aarch64-linux-android | ||
|
||
COPY android-runner / | ||
|
||
# Libz is distributed in the android ndk, but for some unknown reason it is not | ||
# found in the build process of some crates, so we explicit set the DEP_Z_ROOT | ||
ENV CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=aarch64-linux-android-gcc \ | ||
CARGO_TARGET_AARCH64_LINUX_ANDROID_RUNNER="/android-runner aarch64" \ | ||
AR_aarch64_linux_android=aarch64-linux-android-ar \ | ||
AS_aarch64_linux_android=aarch64-linux-android-as \ | ||
CC_aarch64_linux_android=aarch64-linux-android-gcc \ | ||
CXX_aarch64_linux_android=aarch64-linux-android-g++ \ | ||
LD_aarch64_linux_android=aarch64-linux-android-ld \ | ||
NM_aarch64_linux_android=aarch64-linux-android-nm \ | ||
OBJCOPY_aarch64_linux_android=aarch64-linux-android-objcopy \ | ||
OBJDUMP_aarch64_linux_android=aarch64-linux-android-objdump \ | ||
RANLIB_aarch64_linux_android=aarch64-linux-android-ranlib \ | ||
READELF_aarch64_linux_android=aarch64-linux-android-readelf \ | ||
SIZE_aarch64_linux_android=aarch64-linux-android-size \ | ||
STRINGS_aarch64_linux_android=aarch64-linux-android-strings \ | ||
STRIP_aarch64_linux_android=aarch64-linux-android-strip \ | ||
BINDGEN_EXTRA_CLANG_ARGS_aarch64_linux_android="--sysroot=/android-ndk/sysroot" \ | ||
DEP_Z_INCLUDE=/android-ndk/sysroot/usr/include/ \ | ||
RUST_TEST_THREADS=1 \ | ||
HOME=/tmp/ \ | ||
TMPDIR=/tmp/ \ | ||
ANDROID_DATA=/ \ | ||
ANDROID_DNS_MODE=local \ | ||
ANDROID_ROOT=/system |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.