Update build/test and status documentation to reflect Android

BUG=crashpad:30

Change-Id: I0170e95e43146f6a2af6b6753c5197794bd83817
Reviewed-on: https://chromium-review.googlesource.com/406307
Reviewed-by: Robert Sesek <rsesek@chromium.org>
This commit is contained in:
Mark Mentovai 2016-11-01 14:06:13 -04:00
parent fd751f4708
commit e7bd798af4
2 changed files with 108 additions and 1 deletions

View File

@ -104,6 +104,80 @@ Ninja is part of the
https://dev.chromium.org/developers/how-tos/depottools[depot_tools]. Theres no
need to install it separately.
=== Android
Crashpads Android port is in its early stages. This build relies on
cross-compilation. Its possible to develop Crashpad for Android on any platform
that the https://developer.android.com/ndk/[Android NDK (Native Development
Kit)] runs on.
If its not already present on your system,
https://developer.android.com/ndk/downloads/[download the NDK package for your
system] and expand it to a suitable location. These instructions assume that
its been expanded to `~/android-ndk-r13`.
To build Crashpad, portions of the NDK must be reassembled into a
https://developer.android.com/ndk/guides/standalone_toolchain.html[standalone
toolchain]. This is a repackaged subset of the NDK suitable for cross-compiling
for a single Android architecture (such as `arm`, `arm64`, `x86`, and `x86_64`)
targeting a specific
https://source.android.com/source/build-numbers.html[Android API level]. The
standalone toolchain only needs to be built from the NDK one time for each set
of options desired. To build a standalone toolchain targeting 64-bit ARM and API
level 21 (Android 5.0 “Lollipop”), run:
[subs="verbatim,quotes"]
----
$ *cd ~*
$ *python android-ndk-r13/build/tools/make_standalone_toolchain.py \
--arch=arm64 --api=21 --install-dir=android-ndk-r13_arm64_api21*
----
Note that Chrome uses Android API level 21 for 64-bit platforms and 16 for
32-bit platforms. See Chromes
https://chromium.googlesource.com/chromium/src/+/master/build/config/android/config.gni[`build/config/android/config.gni`]
which sets `_android_api_level` and `_android64_api_level`.
To configure a Crashpad build for Android using this standalone toolchain,
set several environment variables directing the build to the standalone
toolchain, along with GYP options to identify an Android build. This must be
done after any `gclient sync`, or instead of any `gclient runhooks` operation.
The environment variables only need to be set for this `gyp_crashpad.py`
invocation, and need not be permanent.
[subs="verbatim,quotes"]
----
$ *cd \~/crashpad/crashpad*
$ *CC_target=\~/android-ndk-r13_arm64_api21/bin/clang \
CXX_target=\~/android-ndk-r13_arm64_api21/bin/clang++ \
AR_target=\~/android-ndk-r13_arm64_api21/bin/aarch64-linux-android-ar \
NM_target=\~/android-ndk-r13_arm64_api21/bin/aarch64-linux-android-nm \
READELF_target=~/android-ndk-r13_arm64_api21/bin/aarch64-linux-android-readelf \
python build/gyp_crashpad.py \
-DOS=android -Dtarget_arch=arm64 -Dclang=1 \
--generator-output=out_android_arm64_api21 -f ninja-android*
----
Target “triplets” to use for `ar`, `nm`, and `readelf` are:
[width="40%",cols="1,3",frame="topbot"]
|===
|`arm` |`arm-linux-androideabi`
|`arm64` |`aarch64-linux-android`
|`x86` |`i686-linux-android`
|`x86_64` |`x86_64-linux-android`
|===
The port is incomplete, but targets known to be working include `crashpad_util`,
`crashpad_test`, and `crashpad_test_test`. This list will grow over time. To
build, direct `ninja` to the specific `out` directory chosen by
`--generator-output` above.
[subs="verbatim,quotes"]
----
$ *ninja -C out_android_arm64_api21/out/Debug crashpad_test_test*
----
== Testing
Crashpad uses https://github.com/google/googletest/[Google Test] as its
@ -130,6 +204,39 @@ $ *cd ~/crashpad/crashpad*
$ *python build/run_tests.py Debug*
----
=== Android
To test on Android, use
https://developer.android.com/studio/command-line/adb.html[ADB (Android Debug
Bridge)] to `adb push` test executables and test data to a device or emulator,
then use `adb shell` to get a shell to run the test executables from. ADB is
part of the https://developer.android.com/sdk/[Android SDK]. Note that it is
sufficient to install just the command-line tools. The entire Android Studio IDE
is not necessary to obtain ADB.
This example runs `crashpad_test_test` on a device. This test executable has a
run-time dependency on a second executable and a test data file, which are also
transferred to the device prior to running the test.
[subs="verbatim,quotes"]
----
$ *cd ~/crashpad/crashpad*
$ *adb push out_android_arm64_api21/out/Debug/crashpad_test_test /data/local/tmp/*
[100%] /data/local/tmp/crashpad_test_test
$ *adb push \
out_android_arm64_api21/out/Debug/crashpad_test_test_multiprocess_exec_test_child \
/data/local/tmp/*
[100%] /data/local/tmp/crashpad_test_test_multiprocess_exec_test_child
$ *adb shell mkdir -p /data/local/tmp/crashpad_test_data_root/test*
$ *adb push test/paths_test_data_root.txt \
/data/local/tmp/crashpad_test_data_root/test/*
[100%] /data/local/tmp/crashpad_test_data_root/test/paths_test_data_root.txt
$ *adb shell*
device:/ $ *cd /data/local/tmp*
device:/data/local/tmp $ *CRASHPAD_TEST_DATA_ROOT=crashpad_test_data_root \
./crashpad_test_test*
----
== Contributing
Crashpads contribution process is very similar to

View File

@ -31,7 +31,7 @@ https://chromium.googlesource.com/chromium/src/\+/cfa5b01bb1d06bf96967bd37e21a44
Initial work on a Crashpad client for
https://crashpad.chromium.org/bug/30[Android] has begun. This is currently in
the design phase.
the early implementation phase.
== Future