Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Commit

Permalink
Merge pull request #10 from wireapp/add-64bit-builds
Browse files Browse the repository at this point in the history
Add 64bit builds
  • Loading branch information
marcoconti83 authored Aug 7, 2019
2 parents a6b7522 + 3e856c2 commit 24fb746
Show file tree
Hide file tree
Showing 10 changed files with 241 additions and 156 deletions.
8 changes: 6 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
android/jni/*.so
android/jni/include
android/jni/x86
android/jni/x86_64
android/jni/arm64-v8a
android/jni/armeabi-v7a
bin/
gen/
libs/
obj/
build/
dist/
local.properties
output/
local.properties
96 changes: 96 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
FROM rust

USER root

ENV PATH $PATH:/usr/local/sbin:/usr/sbin:/sbin

####### BASE TOOLS #######
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install -qqy --no-install-recommends \
git \
wget \
build-essential \
gcc \
software-properties-common \
unzip \
clang \
vim \
pkg-config \
strace \
less \
g++-multilib \
libc6-dev-i386 \
sudo \
openjdk-8-jdk-headless \
openjdk-8-jre-headless

ENV JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64

######## ANDROID #########

RUN wget https://dl.google.com/android/android-sdk_r24.4.1-linux.tgz
RUN mv android-sdk_r24.4.1-linux.tgz /opt/
RUN cd /opt && tar xzvf ./android-sdk_r24.4.1-linux.tgz
ENV ANDROID_HOME /opt/android-sdk-linux
ENV PATH $ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$PATH
RUN echo y | android update sdk --no-ui --all --filter tools
RUN echo y | android update sdk --no-ui --all --filter platform-tools
RUN echo y | android update sdk --no-ui --all --filter android-27
RUN echo y | android update sdk --no-ui --all --filter build-tools-27.0.3
RUN echo y | android update sdk --no-ui --all --filter extra-android-m2repository
RUN echo y | android update sdk --no-ui --all --filter extra-google-m2repository
RUN echo y | android update sdk --no-ui --all --filter extra-google-google_play_services
RUN echo y | android update sdk --no-ui --all --filter addon-google_apis-google-23

ENV ANDROID_NDK_HOME /opt/android-ndk
ENV ANDROID_NDK_VERSION r20
RUN mkdir /opt/android-ndk-tmp && \
cd /opt/android-ndk-tmp && \
wget -q https://dl.google.com/android/repository/android-ndk-${ANDROID_NDK_VERSION}-linux-x86_64.zip && \
# uncompress
unzip -q android-ndk-${ANDROID_NDK_VERSION}-linux-x86_64.zip && \
# move to its final location
mv ./android-ndk-${ANDROID_NDK_VERSION} ${ANDROID_NDK_HOME} && \
# remove temp dir
cd ${ANDROID_NDK_HOME} && \
rm -rf /opt/android-ndk-tmp

# add to PATH
ENV PATH ${PATH}:${ANDROID_NDK_HOME}

# # Install gradle
# RUN apt-get install -y unzip
# #ADD https://services.gradle.org/distributions/gradle-2.14.1-bin.zip /opt/
# ADD gradle-2.14.1-bin.zip /opt/
# RUN unzip /opt/gradle-2.14.1-bin.zip -d /opt
# ENV GRADLE_HOME /opt/gradle-2.14.1
# ENV PATH $GRADLE_HOME/bin:$PATH

######### RUST ############
RUN useradd rust -m
USER rust

RUN rustup install 1.36.0
RUN rustup default 1.36.0
RUN rustup target add armv7-linux-androideabi
RUN rustup target add i686-linux-android
RUN rustup target add aarch64-linux-android
RUN rustup target add x86_64-linux-android

ENV RUST_HOME ~/.rust

ENV PKG_CONFIG_PATH=/home/rust/cryptobox-jni/android/build/libsodium-android-armv7-a/lib/pkgconfig

######### ADDITIONAL TOOLS ############
USER root
RUN apt-get install -qqy --no-install-recommends \
zip
USER rust

######### Build ##############
WORKDIR /home/rust
COPY --chown=rust . cryptobox-jni
WORKDIR cryptobox-jni/android
RUN make dist || echo "FAILED TO BUILD!!"

109 changes: 10 additions & 99 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,113 +12,24 @@ JNI bindings for the [cryptobox](https://github.com/wireapp/cryptobox) with supp

## Building

### Host Architecture
There is a Docker file that create an image to cross compile on all necessary platforms. You need to have Docker running on your machine.

Besides common OS-specific development tooling, the following prerequisites
are needed to build for the host architecture:
Run `./docker-build.sh` to start the build. It will download Android SDK and NDK, so it will take a while.

* A Rust compiler (1.16.0).
* A Java compiler (1.6 or later).
Once the script is completed, you will find the result of the compilation copied to the `output/` folder.

With that in place
### Publishing

make dist

will leave a tarball in the `dist` directory containing all the binaries for
your host architecture in the form of shared libraries, as well as a `.jar`
file and the corresponding `javadoc` output.

### Android

Besides common OS-specific development tooling, the following prerequisites
are needed to build for Android:

* The [Android SDK](http://developer.android.com/sdk/index.html) (The Android Studio IDE is not required).

* The [Android NDK](https://developer.android.com/ndk/downloads/index.html) (`r10d` or newer).

* [NDK standalone toolchains](https://developer.android.com/ndk/guides/standalone_toolchain.html) for the following architectures:
* `armeabi-v7a`
* `arm64-v8a`
* `x86`

* A Java compiler (1.6 or later).

* A Rust compiler (1.16.0) that can cross-compile to the following
targets corresponding to the aforementioned NDK standalone toolchains:
* `armv7-linux-androideabi`
* `aarch64-linux-android`
* `i686-linux-android`

It is recommended to use [rustup](https://github.com/rust-lang-nursery/rustup.rs) to
manage multiple Rust compiler toolchains. Using rustup, the following commands
will install the necessary target-specific Rust binaries needed for Android:

rustup target add armv7-linux-androideabi
rustup target add i686-linux-android
rustup target add aarch64-linux-android

Alternatively a Rust compiler that supports the necessary targets can be built from source, e.g.:

./configure \
--prefix=/where/to/install \
--arm-linux-androideabi-ndk=/path/to/android-ndk-toolchain-armeabi-v7a \
--aarch64-linux-android-ndk=/path/to/android-ndk-toolchain-arm64-v8a \
--i686-linux-android-ndk=/path/to/android-ndk-toolchain-x86 \
--target=arm-linux-androideabi,aarch64-linux-android,i686-linux-android
make -j4
make install

* The `ANDROID_NDK_HOME` environment variable must be set and point to the
home directory of the NDK installation.

* The `ANDROID_NDK_TOOLCHAIN_ARM` environment variable must be set and point
to the home directory of the `armeabi-v7a` standalone toolchain.

* The `ANDROID_NDK_TOOLCHAIN_X86` environment variable must be set and point
to the home directory of the `x86` standalone toolchain.

* The `ANDROID_NDK_TOOLCHAIN_AARCH64` environment variable must be set and point
to the home directory of the `arm64-v8a` standalone toolchain.

With the prerequisites in place, the Android build can be run with:

cd android && make dist

The distribution artifacts will be in the `android/dist` directory, which includes
an [Android Library Archive](http://tools.android.com/tech-docs/new-build-system/aar-format) (`.aar`).

If [Maven](https://maven.apache.org) is installed (availble on [homebrew](https://formulae.brew.sh/formula/maven)), you can publish the aar to a your local Maven repository with the command:
In order to publish the binary to Bintray, you need to install the JFrog CLI (`jfrog-cli-go`) tool.

- Create a version using `jfrog` CLI
- Upload files to that version using the `jfrog` CLI. E.g:
```
mvn install:install-file \
-Dfile="<path to aar>" \
-DgroupId=com.wire \
-DartifactId=cryptobox-android \
-Dpackaging=aar \
-Dversion=<version number>
/usr/local/bin/jfrog bt u "cryptobox-android-1.1.1.*" \
"wire-android/releases/cryptobox-android/1.1.1" \
"com/wire/cryptobox-android/1.1.1/"
```

### Windows

You need:

* [MSYS2](http://msys2.github.io/) with MinGW-w64 toolchains

* The pkg-config from MinGW-w64 toolchain

pacman -S mingw-w64-x86_64-pkg-config

* A Java compiler (1.6 or later)

* A Rust compiler (1.6 or newer) with GNU ABI

* The `JAVA_HOME` environment variable must be set correctly for MSYS2

export JAVA_HOME="/c/Program Files/Java/jdk1.8.0_rev"

* The `PATH` environment variable must include JDK and Rust for MSYS2

## Sample Application

This project has a simple Android sample application that can be installed
Expand Down
Loading

0 comments on commit 24fb746

Please sign in to comment.