adapt build script for M1/M2 hosts (#2433)

* adapt build script for M1/M2 hosts

* GUI way to set up build environment, update NDK information

* more precice warning message
This commit is contained in:
bjoern 2022-12-04 02:01:04 +01:00 committed by GitHub
parent d1b3124ab0
commit f2e1503b52
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 12 deletions

View file

@ -98,11 +98,19 @@ See https://wiki.archlinux.org/index.php/Podman#Rootless_Podman for more informa
# <a name="install-build-environment"></a>Install Build Environment (without Docker or Podman)
To setup build environment manually, you can read the `Dockerfile`
and mimic what it does.
To setup build environment manually:
- _Either_, in Android Studio, go to "Tools / SDK Manager / SDK Tools", enable "Show Package Details",
select "CMake" and the desired NDK, hit "Apply".
- _Or_ read `Dockerfile` and mimic what it does.
First, you need to setup Android SDK and Android NDK. Configure
`ANDROID_NDK_ROOT` environment variable to point to the Android NDK
Currently ndk20b is the minimum required version.
Newer versions will likely work, however, changes on the ndk-version should be
done with care. Too new versions do not support abi16 and cannot be used to target Android 4.3 or lower.
Then, in both cases, install Rust using [rustup](https://rustup.rs/)
and Rust toolchains for cross-compilation by executing `scripts/install-toolchains.sh`.
Then, configure `ANDROID_NDK_ROOT` environment variable to point to the Android NDK
installation directory e.g. by adding this to your `.bashrc`:
```bash
@ -110,14 +118,6 @@ export ANDROID_NDK_ROOT=${HOME}/Android/Sdk/ndk/[version] # (or whereever your N
export PATH=${PATH}:${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/linux-x86_64/bin/:${ANDROID_NDK_ROOT}
```
Currently ndk20b is the minimum required version.
Newer versions will likely work, however, are not tested and not used
in official releases, in general, changes on the ndk-version should be
done with care.
Then, install Rust using [rustup](https://rustup.rs/). Install Rust
toolchains for cross-compilation by executing `scripts/install-toolchains.sh`.
After that, call `scripts/ndk-make.sh` in the root directory to build core-rust.
Afterwards run the project in Android Studio. The project requires API 25.

View file

@ -46,6 +46,13 @@ echo Setting CARGO_TARGET environment variables.
if test -z "$NDK_HOST_TAG"; then
KERNEL="$(uname -s | tr '[:upper:]' '[:lower:]')"
ARCH="$(uname -m)"
if test "$ARCH" == "arm64" && ! test -f "$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/$KERNEL-$ARCH/bin/aarch64-linux-android21-clang"; then
echo "arm64 host is not supported by $ANDROID_NDK_ROOT; trying to use x86_64, in case the host has a binary translation such as Rosetta or QEMU installed."
echo "(Newer NDK may support arm64 host but may lack support for Android4/ABI16)"
ARCH="x86_64"
fi
NDK_HOST_TAG="$KERNEL-$ARCH"
fi