Skip to content

Commit 13c893e

Browse files
committed
Merge branch 'master' of github.com:rust-keylock/rust-keylock-android
2 parents 598da3f + d4d63aa commit 13c893e

File tree

3 files changed

+93
-0
lines changed

3 files changed

+93
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
/android-toolchain/
55
/tools/
66
/android-ndk-r10e/
7+
/rust/rust-keylock-android-rust.iml

rust-build/fdroid_build.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
BASEDIR=$(dirname "$0")
6+
cd $BASEDIR/../
7+
BASEDIR=`pwd`
8+
echo Base directory is $BASEDIR
9+
10+
ANDROID_RUST="$BASEDIR/rust"
11+
ANDROID_RUST_KEYLOCK_LIB="$ANDROID_RUST/target/arm-linux-androideabi/release/librustkeylockandroid.so"
12+
ANDROID_JAVA_NATIVE="$BASEDIR/java/libs/armeabi/"
13+
14+
mkdir -p $ANDROID_JAVA_NATIVE
15+
cd $ANDROID_RUST
16+
17+
ANDROID_TOOLCHAIN_DIR=$BASEDIR/android-toolchain
18+
OPENSSL_BUILD_DIR=$BASEDIR/tools/openssl-1.1.0g/build
19+
20+
echo "ANDROID_TOOLCHAIN_DIR: $ANDROID_TOOLCHAIN_DIR"
21+
echo "OPENSSL_BUILD_DIR: $OPENSSL_BUILD_DIR"
22+
echo "CARGO_HOME: $CARGO_HOME"
23+
24+
CC_arm_linux_androideabi="${ANDROID_TOOLCHAIN_DIR}/bin/arm-linux-androideabi-gcc" AR_arm_linux_androideabi="${ANDROID_TOOLCHAIN_DIR}/bin/arm-linux-androideabi-ar" OPENSSL_DIR=${OPENSSL_BUILD_DIR} OPENSSL_LIB_DIR=${OPENSSL_BUILD_DIR}/lib OPENSSL_INCLUDE_DIR=${OPENSSL_BUILD_DIR}/include OPENSSL_STATIC=true $CARGO_HOME/bin/cargo build --target=arm-linux-androideabi --release
25+
26+
echo "Copying $ANDROID_RUST_KEYLOCK_LIB to $ANDROID_JAVA_NATIVE"
27+
cp $ANDROID_RUST_KEYLOCK_LIB $ANDROID_JAVA_NATIVE
28+
29+
echo "Rust build for rust-keylock-android completed."

rust-build/fdroid_pre_build.sh

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
BASEDIR=$(dirname "$0")
6+
cd $BASEDIR/../
7+
BASEDIR=`pwd`
8+
echo Base directory is $BASEDIR
9+
10+
# Create an Android toolchain
11+
cd $BASEDIR
12+
13+
ANDROID_NDK_HOME=${ANDROID_NDK}
14+
15+
echo Installing the Android toolchain using NDK: $ANDROID_NDK
16+
17+
$ANDROID_NDK/build/tools/make-standalone-toolchain.sh --platform=android-16 --arch=arm --install-dir=android-toolchain > /dev/null
18+
19+
cd android-toolchain
20+
ANDROID_TOOLCHAIN_DIR=`pwd`
21+
22+
echo Android toolchain installed in $ANDROID_TOOLCHAIN_DIR
23+
24+
# Go to the .cargo directory
25+
cd $HOME
26+
mkdir -p .cargo
27+
cd .cargo
28+
CURR_DIR=`pwd`
29+
echo Entered directory $CURR_DIR
30+
31+
# Create a config file
32+
cat > config << EOF
33+
[target]
34+
[target.arm-linux-androideabi]
35+
linker = "${ANDROID_TOOLCHAIN_DIR}/bin/arm-linux-androideabi-gcc"
36+
EOF
37+
38+
# Get and build the openssl
39+
40+
# Export the ANDROID_TOOLCHAIN variable to be used for building the openssl
41+
export ANDROID_TOOLCHAIN=$ANDROID_TOOLCHAIN_DIR/bin
42+
export ANDROID_NDK_ROOT=${ANDROID_NDK}
43+
44+
cd $BASEDIR/tools
45+
46+
curl -O https://www.openssl.org/source/openssl-1.1.0g.tar.gz
47+
tar xzf openssl-1.1.0g.tar.gz
48+
49+
export OPENSSL_SRC_DIR=$BASEDIR/tools/openssl-1.1.0g
50+
51+
# Delete the mandroid flag as clang does not recognize it
52+
sed -i 's/-mandroid //g' ${OPENSSL_SRC_DIR}/Configurations/10-main.conf
53+
54+
. $BASEDIR/rust-build/setenv-android.sh
55+
56+
cd $OPENSSL_SRC_DIR
57+
58+
echo Building openssl
59+
./Configure android-armeabi shared no-ssl3 no-comp no-hw no-asm --openssldir=$OPENSSL_SRC_DIR/build --prefix=$OPENSSL_SRC_DIR/build
60+
make all
61+
make install CC=$ANDROID_TOOLCHAIN/arm-linux-androideabi-clang RANLIB=$ANDROID_TOOLCHAIN/arm-linux-androideabi-ranlib
62+
63+
echo openssl build success

0 commit comments

Comments
 (0)