-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android rust build fix #57
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,63 @@ | ||
FROM lakoo/android-ndk:latest | ||
|
||
RUN curl https://sh.rustup.rs -sSf | \ | ||
sh -s -- --default-toolchain none -y | ||
ENV PATH=/root/.cargo/bin:/opt/android-ndk-linux/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH | ||
|
||
RUN rustup toolchain install 1.50.0 | ||
|
||
RUN rustup target add i686-linux-android | ||
RUN rustup target add armv7-linux-androideabi | ||
RUN rustup target add aarch64-linux-android | ||
|
||
RUN echo "[target.aarch64-linux-android]" >> ~/.cargo/config | ||
RUN echo "ar = \"aarch64-linux-android-ar\"" >> ~/.cargo/config | ||
RUN echo "linker = \"aarch64-linux-android24-clang\"" >> ~/.cargo/config | ||
RUN echo "" >> ~/.cargo/config | ||
|
||
RUN echo "[target.armv7-linux-androideabi]" >> ~/.cargo/config | ||
RUN echo "ar = \"arm-linux-androideabi-ar\"" >> ~/.cargo/config | ||
RUN echo "linker = \"armv7a-linux-androideabi24-clang\"" >> ~/.cargo/config | ||
RUN echo "" >> ~/.cargo/config | ||
|
||
RUN echo "[target.i686-linux-android]" >> ~/.cargo/config | ||
RUN echo "ar = \"i686-linux-android-ar\"" >> ~/.cargo/config | ||
RUN echo "linker = \"i686-linux-android24-clang\"" >> ~/.cargo/config | ||
RUN echo "" >> ~/.cargo/config | ||
FROM stunnar/rustndk:latest | ||
|
||
# install needed libaries | ||
RUN apt-get update | ||
RUN apt-get install -y gcc make automake build-essential | ||
RUN apt-get install -y curl wget gcc make automake build-essential | ||
|
||
RUN cd /opt && wget https://www.openssl.org/source/old/1.1.1/openssl-1.1.1e.tar.gz && \ | ||
tar xvf openssl-1.1.1e.tar.gz && cd openssl-1.1.1e && \ | ||
# make open ssl 3.0.1 for targets | ||
RUN cd /opt && wget https://www.openssl.org/source/openssl-3.0.1.tar.gz && \ | ||
tar xvf openssl-3.0.1.tar.gz && cd openssl-3.0.1 && \ | ||
mkdir x86 && mkdir aarch64 && mkdir armv7 | ||
|
||
RUN cd /opt/openssl-1.1.1e && \ | ||
./Configure --prefix=/opt/openssl-1.1.1e/aarch64 android-arm64 -D__ANDROID_API__=24 && \ | ||
RUN cd /opt/openssl-3.0.1 && \ | ||
./Configure --prefix=/opt/openssl-3.0.1/aarch64 android-arm64 -D__ANDROID_API__=29 && \ | ||
make -j$(nproc) && make -j$(nproc) install && \ | ||
make clean && make distclean | ||
|
||
RUN cd /opt/openssl-1.1.1e && \ | ||
./Configure --prefix=/opt/openssl-1.1.1e/armv7 android-arm -D__ANDROID_API__=24 && \ | ||
RUN cd /opt/openssl-3.0.1 && \ | ||
./Configure --prefix=/opt/openssl-3.0.1/armv7 android-arm -D__ANDROID_API__=29 && \ | ||
make -j$(nproc) && make -j$(nproc) install && \ | ||
make clean && make distclean | ||
|
||
RUN cd /opt/openssl-1.1.1e && \ | ||
./Configure --prefix=/opt/openssl-1.1.1e/x86 android-x86 -D__ANDROID_API__=24 && \ | ||
RUN cd /opt/openssl-3.0.1 && \ | ||
./Configure --prefix=/opt/openssl-3.0.1/x86 android-x86 -D__ANDROID_API__=29 && \ | ||
make -j$(nproc) && make -j$(nproc) install && \ | ||
make clean && make distclean | ||
|
||
|
||
# build zecwalletmobile | ||
RUN rustup component add rustfmt | ||
|
||
RUN apt-get install -y git | ||
RUN cd /opt && git clone --depth=1 https://github.com/zecwalletco/zecwallet-mobile zecwalletmobile && cd zecwalletmobile/rust/android && cargo fetch && cargo build --release && rm -rf /opt/zecwalletmobile | ||
|
||
# install various other needed libs | ||
RUN apt-get install --assume-yes --no-install-recommends \ | ||
g++-aarch64-linux-gnu \ | ||
libc6-dev-arm64-cross | ||
|
||
# configure target build settings | ||
RUN rustup target install aarch64-linux-android | ||
RUN echo "[target.aarch64-linux-android]" >> /usr/local/cargo/config | ||
RUN echo "ar = \"llvm-ar\"" >> /usr/local/cargo/config | ||
RUN echo "linker = \"aarch64-linux-android29-clang\"" >> /usr/local/cargo/config | ||
RUN echo "" >> /usr/local/cargo/config | ||
|
||
RUN rustup target install armv7-linux-androideabi | ||
RUN echo "[target.armv7-linux-androideabi]" >> /usr/local/cargo/config | ||
RUN echo "ar = \"llvm-ar\"" >> /usr/local/cargo/config | ||
RUN echo "linker = \"armv7a-linux-androideabi29-clang\"" >> /usr/local/cargo/config | ||
RUN echo "" >> /usr/local/cargo/config | ||
|
||
RUN rustup target install i686-linux-android | ||
RUN echo "[target.i686-linux-android]" >> /usr/local/cargo/config | ||
RUN echo "ar = \"llvm-ar\"" >> /usr/local/cargo/config | ||
RUN echo "linker = \"i686-linux-android29-clang\"" >> /usr/local/cargo/config | ||
RUN echo "" >> /usr/local/cargo/config | ||
|
||
ENV OPENSSL_STATIC=yes | ||
|
||
# including nightly build to be able to compile -lgcc library | ||
RUN rustup install nightly-x86_64-unknown-linux-gnu | ||
RUN rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-gnu | ||
RUN rustup component add rustfmt --toolchain nightly-x86_64-unknown-linux-gnu |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
ARG rust_ver=1.56 | ||
FROM rust:${rust_ver}-slim-bullseye | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are we using 'slim'? From this doc it seems like this is a space optimization? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't remember what directed my decision, I believe it was over dependences and other containers I saw and got ideas from |
||
|
||
ARG android_ndk_ver=r23b | ||
ARG cargo_ndk_ver=2.5.0 | ||
ARG build_rev=0 | ||
|
||
# get latest stable toolchain | ||
RUN rustup toolchain install stable | ||
|
||
# Install Rust targets for Android platforms | ||
RUN rustup target add aarch64-linux-android \ | ||
armv7-linux-androideabi \ | ||
i686-linux-android \ | ||
x86_64-linux-android | ||
|
||
|
||
# Install Android NDK | ||
RUN apt-get update \ | ||
&& apt-get upgrade -y \ | ||
&& apt-get install -y --no-install-recommends --no-install-suggests \ | ||
ca-certificates \ | ||
make \ | ||
&& update-ca-certificates \ | ||
\ | ||
# Install installation tools | ||
&& toolDeps="curl unzip" \ | ||
&& apt-get install -y --no-install-recommends --no-install-suggests \ | ||
$toolDeps \ | ||
\ | ||
# Install NDK itself | ||
&& curl -fL -o /tmp/android-ndk.zip \ | ||
https://dl.google.com/android/repository/android-ndk-${android_ndk_ver}-linux.zip \ | ||
&& unzip /tmp/android-ndk.zip -d /usr/local/ \ | ||
\ | ||
# Cleanup unnecessary stuff | ||
&& apt-get purge -y --auto-remove \ | ||
-o APT::AutoRemove::RecommendsImportant=false \ | ||
$toolDeps \ | ||
&& rm -rf /var/lib/apt/lists/* \ | ||
/tmp/* | ||
|
||
# Path to the Android NDK for cargo-ndk Cargo plugin | ||
ENV ANDROID_NDK_HOME=/usr/local/android-ndk-${android_ndk_ver} \ | ||
NDK_HOME=/usr/local/android-ndk-${android_ndk_ver} \ | ||
ANDROID_NDK_ROOT=/usr/local/android-ndk-${android_ndk_ver} | ||
|
||
ENV PATH=/root/.cargo/bin:/usr/local/android-ndk-${android_ndk_ver}/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH | ||
|
||
|
||
# Install cargo-ndk Cargo plugin | ||
RUN cargo install cargo-ndk \ | ||
\ | ||
# Cleanup unnecessary stuff | ||
&& rm -rf /usr/local/cargo/registry/ \ | ||
/tmp/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo "libraries"