Update Dockerfile to build Rust core

This commit is contained in:
Alexander Krotov 2020-03-13 22:20:38 +03:00
parent 3dac8d8fa0
commit aee9324a83
3 changed files with 81 additions and 26 deletions

View file

@ -1,25 +1,36 @@
FROM ubuntu:17.04 FROM ubuntu:18.04
RUN dpkg --add-architecture i386 && \ # Install Android Studio requirements
apt-get update -y && \ # See https://developer.android.com/studio/install#linux
apt-get install -y software-properties-common && \ RUN apt-get update -y \
apt-get update -y && \ && apt-get install -y --no-install-recommends \
apt-get install -y libc6:i386=2.24-9ubuntu2.2 libncurses5:i386=6.0+20160625-1ubuntu1 libstdc++6:i386=6.3.0-12ubuntu2 lib32z1=1:1.2.11.dfsg-0ubuntu1 wget openjdk-8-jdk=8u131-b11-2ubuntu1.17.04.3 git unzip && \ wget \
rm -rf /var/lib/apt/lists/* && \ curl \
apt-get autoremove -y && \ unzip \
apt-get clean openjdk-11-jre \
file \
build-essential \
&& rm -rf /var/lib/apt/lists/*
ENV ANDROID_SDK_FILENAME android-sdk_r24.4.1-linux.tgz ENV ANDROID_HOME /android-sdk
ENV ANDROID_SDK_URL https://dl.google.com/android/${ANDROID_SDK_FILENAME}
ENV ANDROID_API_LEVELS android-27 WORKDIR /android-sdk
ENV ANDROID_BUILD_TOOLS_VERSION 27.0.1 RUN wget -q https://dl.google.com/android/repository/commandlinetools-linux-6200805_latest.zip && \
ENV ANDROID_HOME /usr/local/android-sdk-linux unzip commandlinetools-linux-6200805_latest.zip && \
ENV PATH ${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools rm commandlinetools-linux-6200805_latest.zip
RUN cd /usr/local/ && \
wget -q ${ANDROID_SDK_URL} && \ RUN yes | ${ANDROID_HOME}/tools/bin/sdkmanager --sdk_root=${ANDROID_HOME} --licenses
tar -xzf ${ANDROID_SDK_FILENAME} && \
rm ${ANDROID_SDK_FILENAME} ENV PATH ${PATH}:/android-sdk/tools/bin
RUN echo y | android update sdk --no-ui -a --filter ${ANDROID_API_LEVELS}
RUN echo y | android update sdk --no-ui -a --filter extra-android-m2repository,extra-android-support,extra-google-google_play_services,extra-google-m2repository # Install NDK manually. Other SDK parts are installed automatically by gradle.
RUN echo y | android update sdk --no-ui -a --filter tools,platform-tools,build-tools-${ANDROID_BUILD_TOOLS_VERSION} RUN sdkmanager --sdk_root=${ANDROID_HOME} ndk-bundle
RUN rm -rf ${ANDROID_HOME}/tools && unzip ${ANDROID_HOME}/temp/*.zip -d ${ANDROID_HOME}
ENV PATH ${PATH}:/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/:/android-sdk/ndk-bundle/
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain none
ENV PATH ${PATH}:/root/.cargo/bin
RUN rustup default nightly-2019-11-06 \
&& rustup target add armv7-linux-androideabi aarch64-linux-android i686-linux-android x86_64-linux-android
COPY docker/cargo-config /root/.cargo/config

View file

@ -12,7 +12,7 @@ For the core library and other common info, please refer to the
<img alt="Screenshot Chat List" src="docs/images/2019-01-chatlist.png" width="298" /> <img alt="Screenshot Chat View" src="docs/images/2019-01-chat.png" width="298" /> <img alt="Screenshot Chat List" src="docs/images/2019-01-chatlist.png" width="298" /> <img alt="Screenshot Chat View" src="docs/images/2019-01-chat.png" width="298" />
# Build # Check Out Repository
When checking out _deltachat-android_, make sure also to check out the When checking out _deltachat-android_, make sure also to check out the
subproject _deltachat-core-rust_: subproject _deltachat-core-rust_:
@ -22,8 +22,44 @@ subproject _deltachat-core-rust_:
or later by `git submodule update --init --recursive`. If you do this in your or later by `git submodule update --init --recursive`. If you do this in your
home directory, this results in the folder `~/deltachat-android` which is just fine. home directory, this results in the folder `~/deltachat-android` which is just fine.
Then, open `ndk-make.sh` in an editor and follow the instructions # Build Using Dockerfile
to set up a rust build environment. This is needed only once.
If you only want to build an APK, the easiest way is to use
provided `Dockerfile` with [Docker](https://www.docker.com/) or
[Podman](https://podman.io/). Podman is a drop-in replacement for Docker
that does not require root privileges. It is used in the following
example.
First, build the image `deltachat-android` by running
```
podman build . -t deltachat-android
```
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:
```
root@6012dcb974fe:/home/app# ./ndk-make.sh
```
Then, [build an APK](https://developer.android.com/studio/build/building-cmdline):
```
root@6012dcb974fe:/home/app# ./gradlew assembleDebug
```
If you don't want to use Docker or Podman, proceed to the next section.
# Install Build Environment
To setup build environment manually, you can read the `Dockerfile`
and mimic what it does.
First, you need to setup Android SDK and Android NDK. Then, open
`ndk-make.sh` in an editor and follow the instructions to set up a rust
build environment. This is needed only once.
After that, call `./ndk-make.sh` in the root directory to build core-rust. After that, call `./ndk-make.sh` in the root directory to build core-rust.
Afterwards run the project in Android Studio. The project requires API 25. Afterwards run the project in Android Studio. The project requires API 25.

8
docker/cargo-config Normal file
View file

@ -0,0 +1,8 @@
[target.armv7-linux-androideabi]
linker = "/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi16-clang"
[target.aarch64-linux-android]
linker = "/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang"
[target.i686-linux-android]
linker = "/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android16-clang"
[target.x86_64-linux-android]
linker = "/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android21-clang"