Skip to content

Commit

Permalink
Cross-compilation brought up to latest OpenSSL and Android SDK 26
Browse files Browse the repository at this point in the history
  • Loading branch information
Hainish committed Apr 4, 2024
1 parent 8a1d00b commit f7fa657
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 23 deletions.
8 changes: 4 additions & 4 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ linker = "i686-linux-gnu-gcc"
linker = "aarch64-linux-gnu-gcc"

[target.aarch64-linux-android]
linker = "aarch64-linux-android21-clang"
linker = "aarch64-linux-android26-clang"
rustflags = ["-C", "link-args=-Wl,-rpath,/data/data/com.termux/files/usr/lib"]

[target.armv7-linux-androideabi]
linker = "armv7a-linux-androideabi21-clang"
linker = "armv7a-linux-androideabi26-clang"
rustflags = ["-C", "link-args=-Wl,-rpath,/data/data/com.termux/files/usr/lib"]

[target.i686-linux-android]
linker = "i686-linux-android21-clang"
linker = "i686-linux-android26-clang"
rustflags = ["-C", "link-args=-Wl,-rpath,/data/data/com.termux/files/usr/lib"]

[target.x86_64-linux-android]
linker = "x86_64-linux-android21-clang"
linker = "x86_64-linux-android26-clang"
rustflags = ["-C", "link-args=-Wl,-rpath,/data/data/com.termux/files/usr/lib"]
37 changes: 18 additions & 19 deletions build-remote.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# Build `apkeep` for release from a fresh Debian 10 x64 install
# Build `apkeep` for release from a fresh Debian 12 x64 install

ssh -o 'StrictHostKeyChecking no' apkeep-compiler << 'EOF'
sudo dpkg --add-architecture armhf
Expand All @@ -11,7 +11,7 @@ sudo apt-get -y install git build-essential libssl-dev pkg-config unzip gcc-mult
sudo apt-get -y install libc6-armhf-cross libc6-dev-armhf-cross gcc-arm-linux-gnueabihf libssl-dev:armhf
sudo apt-get -y install libc6-i386-cross libc6-dev-i386-cross gcc-i686-linux-gnu libssl-dev:i386
sudo apt-get -y install libc6-arm64-cross libc6-dev-arm64-cross gcc-aarch64-linux-gnu libssl-dev:arm64
sudo apt-get -y install clang-11 llvm-11 lld-11
sudo apt-get -y install clang-16 llvm-16 lld-16
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > /tmp/get_rust.sh
bash /tmp/get_rust.sh -y
source ~/.cargo/env
Expand All @@ -29,65 +29,64 @@ export PKG_CONFIG_PATH="/usr/lib/aarch-linux-gnu-gcc/pkgconfig"
cargo build --release --target=aarch64-unknown-linux-gnu
cd ~
wget https://www.openssl.org/source/openssl-3.0.7.tar.gz
tar -zxvf openssl-3.0.7.tar.gz
cd openssl-3.0.7
wget https://www.openssl.org/source/openssl-3.2.1.tar.gz
tar -zxvf openssl-3.2.1.tar.gz
cd openssl-3.2.1
wget https://raw.githubusercontent.com/EFForg/apkeep-files/main/Configurations-15-android.conf.patch
patch -u Configurations/15-android.conf Configurations-15-android.conf.patch
export OPENSSL_DIR=$PWD
export OPENSSL_LIB_DIR=$PWD
cd ~
wget https://dl.google.com/android/repository/android-ndk-r22b-linux-x86_64.zip
# later versions are available, but run into problems: see https://github.com/bbqsrc/cargo-ndk/issues/22
unzip android-ndk-r22b-linux-x86_64.zip
cd android-ndk-r22b
wget https://dl.google.com/android/repository/android-ndk-r26c-linux.zip
unzip android-ndk-r26c.zip
cd android-ndk-r26c
export ANDROID_NDK_ROOT="$PWD"
export OLDPATH="$PATH"
export PATH="$PWD/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH"
export AR="llvm-ar"
cd $OPENSSL_DIR
./Configure android-arm64 -D__ANDROID_API__=21
./Configure android-arm64 -D__ANDROID_API__=26
make
cd ../apkeep
cargo build --release --target=aarch64-linux-android
cd $OPENSSL_DIR
make clean
./Configure android-arm -D__ANDROID_API__=21
./Configure android-arm -D__ANDROID_API__=26
make
cd ../apkeep
cargo build --release --target=armv7-linux-androideabi
cd $OPENSSL_DIR
make clean
./Configure android-x86 -D__ANDROID_API__=21
./Configure android-x86 -D__ANDROID_API__=26
make
cd ../apkeep
cargo build --release --target=i686-linux-android
cd $OPENSSL_DIR
make clean
./Configure android-x86_64 -D__ANDROID_API__=21
./Configure android-x86_64 -D__ANDROID_API__=26
make
cd ../apkeep
cargo build --release --target=x86_64-linux-android
export PATH="$OLDPATH"
unset AR
sudo ln -s clang-11 /usr/bin/clang && sudo ln -s clang /usr/bin/clang++ && sudo ln -s lld-11 /usr/bin/ld.lld
sudo ln -s clang-11 /usr/bin/clang-cl && sudo ln -s llvm-ar-11 /usr/bin/llvm-lib && sudo ln -s lld-link-11 /usr/bin/lld-link && sudo ln -s lld-link /usr/bin/link.exe
sudo ln -s clang-16 /usr/bin/clang && sudo ln -s clang /usr/bin/clang++ && sudo ln -s lld-16 /usr/bin/ld.lld
sudo ln -s clang-16 /usr/bin/clang-cl && sudo ln -s llvm-ar-16 /usr/bin/llvm-lib && sudo ln -s lld-link-16 /usr/bin/lld-link && sudo ln -s lld-link /usr/bin/link.exe
cd ~
wget https://github.com/EFForg/apkeep-files/raw/main/openssl-3.0.7-static-x86_64-pc-windows-msvc.tar.gz
tar -zxvf openssl-3.0.7-static-x86_64-pc-windows-msvc.tar.gz
cd openssl-3.0.7
wget https://github.com/EFForg/apkeep-files/raw/main/openssl-3.2.1-static-x86_64-pc-windows-msvc.tar.gz
tar -zxvf openssl-3.2.1-static-x86_64-pc-windows-msvc.tar.gz
cd openssl-3.2.1
export OPENSSL_DIR=$PWD
export OPENSSL_LIB_DIR=$PWD
XWIN_VERSION="0.2.9"
XWIN_VERSION="0.5.1"
XWIN_PREFIX="xwin-$XWIN_VERSION-x86_64-unknown-linux-musl"
curl --fail -L https://github.com/Jake-Shadle/xwin/releases/download/$XWIN_VERSION/$XWIN_PREFIX.tar.gz | tar -xzv -C ~/.cargo/bin --strip-components=1 $XWIN_PREFIX/xwin
cd ~ && mkdir xwin
Expand Down

0 comments on commit f7fa657

Please sign in to comment.