diff --git a/Dockerfile b/Dockerfile index da01f91c7..ef18d3329 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,8 +30,4 @@ ENV PATH ${PATH}:/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/b RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain none ENV PATH ${PATH}:/root/.cargo/bin -COPY jni/deltachat-core-rust/rust-toolchain ${ANDROID_HOME} -RUN rustup default `cat ${ANDROID_HOME}/rust-toolchain` \ -&& rustup target add armv7-linux-androideabi aarch64-linux-android i686-linux-android x86_64-linux-android - COPY docker/cargo-config /root/.cargo/config diff --git a/README.md b/README.md index 6aa73e5ec..0cfbb150f 100644 --- a/README.md +++ b/README.md @@ -40,8 +40,9 @@ Then, run the image: podman run -it -v $(pwd):/home/app -w /home/app localhost/deltachat-android ``` -Within the container, build the native library first: +Within the container, install toolchains and build the native library: ``` +root@6012dcb974fe:/home/app# scripts/install-toolchains.sh root@6012dcb974fe:/home/app# ./ndk-make.sh ``` diff --git a/ndk-make.sh b/ndk-make.sh index 7042e77cd..481b7a4ce 100755 --- a/ndk-make.sh +++ b/ndk-make.sh @@ -5,9 +5,8 @@ echo "starting time: `date`" cd jni/deltachat-core-rust # to setup the toolchains (from https://medium.com/visly/rust-on-android-19f34a2fb43 ) -# run the following in `jni/deltachat-core-rust`: -# $ rustup target add armv7-linux-androideabi aarch64-linux-android i686-linux-android x86_64-linux-android --toolchain `cat rust-toolchain` -# +# run `scripts/install-toolchains.sh`. +# # Currently ndk20b is minimum required version # (newer versions will likely work, however, are not tested and not used in offial releases, # in general, changes on the ndk-version should be done with care) diff --git a/scripts/install-toolchains.sh b/scripts/install-toolchains.sh new file mode 100755 index 000000000..07e125c26 --- /dev/null +++ b/scripts/install-toolchains.sh @@ -0,0 +1,9 @@ +#!/bin/sh +# +# Installs Rust cross-compilation toolchains for all supported architectures. +# +set -e +TARGETS="armv7-linux-androideabi aarch64-linux-android i686-linux-android x86_64-linux-android" +TOOLCHAIN="$(cat jni/deltachat-core-rust/rust-toolchain)" +rustup install "$TOOLCHAIN" +rustup target add $TARGETS --toolchain "$TOOLCHAIN"