Skip to content

Commit dc5dfd7

Browse files
committed
openssl, rust 2018, xargo
* Using openssl-1.1.0j * Using Rust 2018 * Removed Xargo dependency
1 parent ac20c00 commit dc5dfd7

File tree

11 files changed

+74
-63
lines changed

11 files changed

+74
-63
lines changed

buildall.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ set -e
44

55
sh rust-build/pre_build_rust_keylock_android.sh
66
sh rust-build/build_rust_for_rust_keylock_android.sh
7-
mvn -f java/pom.xml clean install
7+
mvn -f java/pom.xml clean install

java/src/main/java/org/astonbitecode/rustkeylock/callbacks/ShowEntriesSetCb.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,6 @@ public class ShowEntriesSetCb extends NativeCallbackToRustChannelSupport {
3232
public void apply(List<JavaEntry> entries, String filter) {
3333
Log.d(TAG, "ShowEntriesSetCb with filter " + filter);
3434
InterfaceWithRust.INSTANCE.setCallback(this);
35-
// // Workaround for handling empty list from Rust
36-
// if (entriesSet.numberOfEntries == 1 && entriesSet.getEntries().get(0).name.equals(Defs.EMPTY_ARG)
37-
// && entriesSet.getEntries().get(0).user.equals(Defs.EMPTY_ARG)
38-
// && entriesSet.getEntries().get(0).pass.equals(Defs.EMPTY_ARG)
39-
// && entriesSet.getEntries().get(0).desc.equals(Defs.EMPTY_ARG)) {
40-
// entries = new ArrayList<>();
41-
// } else {
42-
// entries = entriesSet.getEntries();
43-
// }
4435

4536
MainActivity mainActivity = MainActivity.getActiveActivity();
4637
Runnable uiRunnable = new UiThreadRunnable(entries, filter, mainActivity);

rust-build/build_rust_for_rust_keylock_android.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ mkdir -p $ANDROID_JAVA_NATIVE
2020
cd $ANDROID_RUST
2121

2222
ANDROID_TOOLCHAIN_DIR=$BASEDIR/android-toolchain
23-
OPENSSL_BUILD_DIR=$BASEDIR/tools/openssl-1.1.0g/build
24-
CC="${ANDROID_TOOLCHAIN_DIR}/bin/arm-linux-androideabi-gcc" 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
23+
OPENSSL_BUILD_DIR=$BASEDIR/tools/openssl-1.1.0j/build
24+
CC="${ANDROID_TOOLCHAIN_DIR}/bin/arm-linux-androideabi-gcc" AR="${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
2525

2626
echo "Copying $ANDROID_RUST_KEYLOCK_LIB to $ANDROID_JAVA_NATIVE"
2727
cp $ANDROID_RUST_KEYLOCK_LIB $ANDROID_JAVA_NATIVE

rust-build/libs/android-arm.jar

-43.4 KB
Binary file not shown.

rust-build/pre_build_rust_keylock_android.sh

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ CARGO_HOME=$BASEDIR/tools/.cargo RUSTUP_HOME=$BASEDIR/tools/.rustup sh tools/rus
2424
$CARGO_HOME/bin/rustup default stable
2525
$CARGO_HOME/bin/rustup target add arm-linux-androideabi
2626

27-
# Install xargo
28-
$CARGO_HOME/bin/cargo install xargo --force --root $CARGO_HOME
29-
3027
# Create an Android toolchain
3128
cd $BASEDIR
3229

@@ -47,9 +44,9 @@ fi
4744

4845
ANDROID_NDK_HOME=${ANDROID_NDK}
4946

50-
echo Installing the Android toolchain
47+
echo Installing the Android toolchain using NDK: $ANDROID_NDK
5148

52-
sh $ANDROID_NDK/build/tools/make-standalone-toolchain.sh --platform=android-16 --arch=arm --install-dir=android-toolchain > /dev/null
49+
$ANDROID_NDK/build/tools/make-standalone-toolchain.sh --platform=android-16 --arch=arm --install-dir=android-toolchain > /dev/null
5350

5451
cd android-toolchain
5552
ANDROID_TOOLCHAIN_DIR=`pwd`
@@ -72,22 +69,28 @@ EOF
7269

7370
# Get and build the openssl
7471

75-
ANDROID_NDK_ROOT=${ANDROID_NDK}
72+
# Export the ANDROID_TOOLCHAIN variable to be used for building the openssl
73+
export ANDROID_TOOLCHAIN=$ANDROID_TOOLCHAIN_DIR/bin
74+
export ANDROID_NDK_ROOT=${ANDROID_NDK}
7675

7776
cd $BASEDIR/tools
7877

79-
curl -O https://www.openssl.org/source/openssl-1.1.0g.tar.gz
80-
tar xzf openssl-1.1.0g.tar.gz
81-
OPENSSL_SRC_DIR=$BASEDIR/tools/openssl-1.1.0g
78+
curl -O https://www.openssl.org/source/openssl-1.1.0j.tar.gz
79+
tar xzf openssl-1.1.0j.tar.gz
80+
81+
export OPENSSL_SRC_DIR=$BASEDIR/tools/openssl-1.1.0j
82+
83+
# Delete the mandroid flag as clang does not recognize it
84+
sed -i 's/-mandroid //g' ${OPENSSL_SRC_DIR}/Configurations/10-main.conf
8285

8386
. ../rust-build/setenv-android.sh
8487

8588
cd $OPENSSL_SRC_DIR
8689

8790
echo Building openssl
88-
89-
./config shared no-ssl2 no-ssl3 no-comp no-hw no-engine --openssldir=$OPENSSL_SRC_DIR/build --prefix=$OPENSSL_SRC_DIR/build
91+
#./config android shared no-ssl3 no-comp no-hw no-engine --openssldir=$OPENSSL_SRC_DIR/build --prefix=$OPENSSL_SRC_DIR/build
92+
./Configure android-armeabi shared no-ssl3 no-comp no-hw no-asm --openssldir=$OPENSSL_SRC_DIR/build --prefix=$OPENSSL_SRC_DIR/build
9093
make all > /dev/null
91-
make install CC=$ANDROID_TOOLCHAIN/arm-linux-androideabi-gcc RANLIB=$ANDROID_TOOLCHAIN/arm-linux-androideabi-ranlib > /dev/null
94+
make install CC=$ANDROID_TOOLCHAIN/arm-linux-androideabi-clang RANLIB=$ANDROID_TOOLCHAIN/arm-linux-androideabi-ranlib > /dev/null
9295

9396
echo openssl build success

rust-build/setenv-android.sh

Lines changed: 43 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#!/bin/bash
2+
3+
set -e
4+
25
# Cross-compile environment for Android on ARMv7 and x86
36
#
47
# Contents licensed under the terms of the OpenSSL license
@@ -9,6 +12,8 @@
912

1013
#####################################################################
1114

15+
echo ===========setenv-android starts=============
16+
1217
# Set ANDROID_NDK_ROOT to you NDK location. For example,
1318
# /opt/android-ndk-r8e or /opt/android-ndk-r9. This can be done in a
1419
# login script. If ANDROID_NDK_ROOT is not specified, the script will
@@ -22,8 +27,8 @@
2227
# list in $ANDROID_NDK_ROOT/toolchains. This value is always used.
2328
# _ANDROID_EABI="x86-4.6"
2429
# _ANDROID_EABI="arm-linux-androideabi-4.6"
25-
_ANDROID_EABI="arm-linux-androideabi-4.8"
26-
#_ANDROID_EABI="arm-linux-androideabi-4.9"
30+
#_ANDROID_EABI="arm-linux-androideabi-4.8"
31+
_ANDROID_EABI="arm-linux-androideabi-4.9"
2732

2833
# Set _ANDROID_ARCH to the architecture you are building for.
2934
# This value is always used.
@@ -103,14 +108,18 @@ fi
103108
# doing things according to the NDK documentation for Ice Cream Sandwich.
104109
# https://android.googlesource.com/platform/ndk/+/ics-mr0/docs/STANDALONE-TOOLCHAIN.html
105110

106-
ANDROID_TOOLCHAIN=""
107-
for host in "linux-x86_64" "linux-x86" "darwin-x86_64" "darwin-x86"
108-
do
109-
if [ -d "$ANDROID_NDK_ROOT/toolchains/$_ANDROID_EABI/prebuilt/$host/bin" ]; then
110-
ANDROID_TOOLCHAIN="$ANDROID_NDK_ROOT/toolchains/$_ANDROID_EABI/prebuilt/$host/bin"
111-
break
112-
fi
113-
done
111+
if [ -z "$ANDROID_TOOLCHAIN" ]; then
112+
113+
ANDROID_TOOLCHAIN=""
114+
for host in "linux-x86_64" "linux-x86" "darwin-x86_64" "darwin-x86"
115+
do
116+
if [ -d "$ANDROID_NDK_ROOT/toolchains/$_ANDROID_EABI/prebuilt/$host/bin" ]; then
117+
export ANDROID_TOOLCHAIN="$ANDROID_NDK_ROOT/toolchains/$_ANDROID_EABI/prebuilt/$host/bin"
118+
break
119+
fi
120+
done
121+
fi
122+
114123

115124
# Error checking
116125
if [ -z "$ANDROID_TOOLCHAIN" ] || [ ! -d "$ANDROID_TOOLCHAIN" ]; then
@@ -120,12 +129,12 @@ if [ -z "$ANDROID_TOOLCHAIN" ] || [ ! -d "$ANDROID_TOOLCHAIN" ]; then
120129
fi
121130

122131
case $_ANDROID_ARCH in
123-
arch-arm)
132+
arch-arm)
124133
ANDROID_TOOLS="arm-linux-androideabi-gcc arm-linux-androideabi-ranlib arm-linux-androideabi-ld"
125134
;;
126-
arch-x86)
135+
arch-x86)
127136
ANDROID_TOOLS="i686-linux-android-gcc i686-linux-android-ranlib i686-linux-android-ld"
128-
;;
137+
;;
129138
*)
130139
echo "ERROR ERROR ERROR"
131140
;;
@@ -151,9 +160,10 @@ fi
151160

152161
# For the Android SYSROOT. Can be used on the command line with --sysroot
153162
# https://android.googlesource.com/platform/ndk/+/ics-mr0/docs/STANDALONE-TOOLCHAIN.html
154-
export ANDROID_SYSROOT="$ANDROID_NDK_ROOT/platforms/$_ANDROID_API/$_ANDROID_ARCH"
163+
#export ANDROID_SYSROOT="$ANDROID_NDK_ROOT/platforms/$_ANDROID_API/$_ANDROID_ARCH"
164+
export ANDROID_SYSROOT="$ANDROID_TOOLCHAIN/../sysroot"
165+
export NDK_SYSROOT="$ANDROID_NDK_ROOT/sysroot"
155166
export CROSS_SYSROOT="$ANDROID_SYSROOT"
156-
export NDK_SYSROOT="$ANDROID_SYSROOT"
157167

158168
# Error checking
159169
if [ -z "$ANDROID_SYSROOT" ] || [ ! -d "$ANDROID_SYSROOT" ]; then
@@ -210,9 +220,8 @@ fi
210220

211221
# For the Android toolchain
212222
# https://android.googlesource.com/platform/ndk/+/ics-mr0/docs/STANDALONE-TOOLCHAIN.html
213-
export ANDROID_SYSROOT="$ANDROID_NDK_ROOT/platforms/$_ANDROID_API/$_ANDROID_ARCH"
214223
export SYSROOT="$ANDROID_SYSROOT"
215-
export NDK_SYSROOT="$ANDROID_SYSROOT"
224+
export NDK_SYSROOT="$ANDROID_NDK_ROOT/sysroot"
216225
export ANDROID_NDK_SYSROOT="$ANDROID_SYSROOT"
217226
export ANDROID_API="$_ANDROID_API"
218227

@@ -221,15 +230,20 @@ export ANDROID_API="$_ANDROID_API"
221230
export ANDROID_DEV="$ANDROID_NDK_ROOT/platforms/$_ANDROID_API/$_ANDROID_ARCH/usr"
222231
export HOSTCC=gcc
223232

224-
VERBOSE=1
225-
if [ ! -z "$VERBOSE" ] && [ "$VERBOSE" != "0" ]; then
226-
echo "ANDROID_NDK_ROOT: $ANDROID_NDK_ROOT"
227-
echo "ANDROID_ARCH: $_ANDROID_ARCH"
228-
echo "ANDROID_EABI: $_ANDROID_EABI"
229-
echo "ANDROID_API: $ANDROID_API"
230-
echo "ANDROID_SYSROOT: $ANDROID_SYSROOT"
231-
echo "ANDROID_TOOLCHAIN: $ANDROID_TOOLCHAIN"
232-
echo "FIPS_SIG: $FIPS_SIG"
233-
echo "CROSS_COMPILE: $CROSS_COMPILE"
234-
echo "ANDROID_DEV: $ANDROID_DEV"
235-
fi
233+
echo "ANDROID_TOOLS: $ANDROID_TOOLS"
234+
echo "ANDROID_NDK_ROOT: $ANDROID_NDK_ROOT"
235+
echo "ANDROID_ARCH: $_ANDROID_ARCH"
236+
echo "ANDROID_EABI: $_ANDROID_EABI"
237+
echo "ANDROID_API: $ANDROID_API"
238+
echo "ANDROID_SYSROOT: $ANDROID_SYSROOT"
239+
echo "ANDROID_TOOLCHAIN: $ANDROID_TOOLCHAIN"
240+
echo "FIPS_SIG: $FIPS_SIG"
241+
echo "CROSS_SYS_ROOT: $CROSS_SYSROOT"
242+
echo "NDK_SYSROOT: $NDK_SYSROOT"
243+
echo "MACHINE: $MACHINE"
244+
echo "SYSTEM: $SYSTEM"
245+
echo "ARCH: $ARCH"
246+
echo "CROSS_COMPILE: $CROSS_COMPILE"
247+
echo "ANDROID_DEV: $ANDROID_DEV"
248+
249+
echo ===========setenv-android completed=============

rust/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "rustkeylockandroid"
33
version = "0.7.0"
44
authors = ["aston <[email protected]>"]
5-
edition = "2015"
5+
edition = "2018"
66

77
[lib]
88
name = "rustkeylockandroid"

rust/Xargo.toml

Lines changed: 0 additions & 3 deletions
This file was deleted.

rust/src/android_editor.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::sync::mpsc::{self, Receiver};
22

33
use j4rs::{Instance, InvocationArg, Jvm};
4+
use log::*;
45
// Copyright 2017 astonbitecode
56
// This file is part of rust-keylock password manager.
67
//
@@ -16,8 +17,14 @@ use j4rs::{Instance, InvocationArg, Jvm};
1617
//
1718
// You should have received a copy of the GNU General Public License
1819
// along with rust-keylock. If not, see <http://www.gnu.org/licenses/>.
19-
use rust_keylock::{AsyncEditor, Menu, MessageSeverity, RklConfiguration, Safe, UserOption,
20-
UserSelection};
20+
use rust_keylock::{
21+
AsyncEditor,
22+
Menu,
23+
MessageSeverity,
24+
RklConfiguration,
25+
Safe, UserOption,
26+
UserSelection,
27+
};
2128

2229
use super::japi;
2330

rust/src/japi.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ use std::sync::mpsc::{self, Receiver};
22
use std::thread;
33

44
use j4rs::{errors, Instance, InstanceReceiver};
5-
5+
use log::*;
66
use rust_keylock::{Entry, Menu, UserOption, UserSelection};
77
use rust_keylock::nextcloud::NextcloudConfiguration;
8+
use serde_derive::{Deserialize, Serialize};
89

910
pub fn handle_instance_receiver_result(instance_receiver_res: errors::Result<InstanceReceiver>) -> Receiver<UserSelection> {
1011
let (tx, rx) = mpsc::channel();

0 commit comments

Comments
 (0)