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

Commit

Permalink
update stuff, improve android build compat
Browse files Browse the repository at this point in the history
possible to build capi on linux and the android app on windows
  • Loading branch information
valpackett committed Sep 23, 2016
1 parent 5a87469 commit e83ac77
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 22 deletions.
15 changes: 8 additions & 7 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import org.apache.tools.ant.taskdefs.condition.Os
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
buildToolsVersion "24.0.2"

defaultConfig {
applicationId "technology.unrelenting.freepass"
Expand Down Expand Up @@ -33,31 +34,31 @@ android {
abi {
enable true
reset()
//include 'x86', 'armeabi', 'armeabi-v7a', 'arm64-v8a'
include 'arm64-v8a'
include 'x86', 'arm64-v8a', 'armeabi', 'armeabi-v7a'
universalApk true
}
}

packagingOptions {
// Dick.
pickFirst 'META-INF/services/com.fasterxml.jackson.core.JsonFactory'
exclude 'META-INF/LICENSE'
}

applicationVariants.all { variant ->
variant.javaCompile.outputs.upToDateWhen { task ->
variant.javaCompiler.outputs.upToDateWhen { task ->
file('src/main/jni/jniVault.cpp').lastModified() >
file('src/main/kotlin/technology/unrelenting/freepass/Vault.kt').lastModified()
}
variant.javaCompile.doLast {
variant.javaCompiler.doLast {
def path = configurations.compile.find { File file -> file.name.startsWith('javacpp') }.absolutePath
javaexec {
main = "org.bytedeco.javacpp.tools.Builder"
classpath path
args "-cp", variant.javaCompile.destinationDir, '-d', 'src/main/jni', '-nocompile', 'technology.unrelenting.freepass.Vault'
args "-cp", variant.javaCompiler.destinationDir, '-d', 'src/main/jni', '-nocompile', 'technology.unrelenting.freepass.Vault'
}
exec {
commandLine "${android.getNdkDirectory()}/ndk-build",
commandLine "${android.getNdkDirectory()}/ndk-build${Os.isFamily(Os.FAMILY_WINDOWS) ? '.cmd' : ''}",
"NDK_PROJECT_PATH=${file('.').absolutePath}",
"NDK_APPLICATION_MK=${file('./Application.mk').absolutePath}"//, "V=1"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ object Vault {
var isOpen = false

init {
Loader.load()
//Loader.load() // javacpp's loader tries to compute the full path inside the jar for some reason
// and ends up with .../arm/... instead of .../armeabi-v7a/... or .../arm64-v7a/...
System.loadLibrary("jniVault")
freepass_init()
}

Expand Down
6 changes: 3 additions & 3 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.0.2'
ext.kotlin_version = '1.0.4'
ext.anko_version = '0.8.3'
ext.support_version = '24.0.0'
ext.support_version = '24.2.1'
ext.jackson_version = '2.8.0.rc1'
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.android.tools.build:gradle:2.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down
4 changes: 2 additions & 2 deletions android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Oct 21 11:34:03 PDT 2015
#Fri Sep 23 21:00:06 MSK 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
2 changes: 1 addition & 1 deletion capi/.cargo/config
Original file line number Diff line number Diff line change
@@ -1 +1 @@
paths = ["../../../rust-lang/libc"]
paths = []
5 changes: 3 additions & 2 deletions capi/build-android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
: ${NDK_STANDALONE:="/opt/ndk"}
: ${NDK_STANDALONE_ARM64:="/opt/ndk64"}
: ${NDK_STANDALONE_X86:="/opt/ndkx86"}
: ${ANDROID_HOME:="`brew --prefix android-sdk`"}
: ${NDK_HOME:="`brew --prefix android-ndk`"}
: ${CARGO:="`which cargo`"}
: ${BUILD_MODE:="release"}
Expand All @@ -20,7 +19,6 @@ if [[ "$BUILD_MODE" == "release" ]]; then
fi
RUSTC_OPTS="--crate-type=dylib"

echo "Android SDK: $ANDROID_HOME"
echo "Android NDK: $NDK_HOME"
echo "Android NDK standalone: $NDK_STANDALONE"
echo "Rust: $RUST_PREFIX"
Expand All @@ -31,18 +29,21 @@ set -e

echo "=> Building for arm"
DYLD_LIBRARY_PATH="$NDK_STANDALONE/lib:$DYLD_LIBRARY_PATH" \
LD_LIBRARY_PATH="$NDK_STANDALONE/lib:$LD_LIBRARY_PATH" \
PATH="$NDK_STANDALONE/arm-linux-androideabi/bin:$NDK_STANDALONE/bin:$PATH" \
SODIUM_LIB_DIR="$SODIUM_ROOT/libsodium-android-armv6/lib" \
$CARGO rustc $CARGO_OPTS --target=arm-linux-androideabi -- $RUSTC_OPTS -C linker=arm-linux-androideabi-gcc -C ar=arm-linux-androideabi-ar

echo "=> Building for aarch64"
DYLD_LIBRARY_PATH="$NDK_STANDALONE_ARM64/lib:$DYLD_LIBRARY_PATH" \
LD_LIBRARY_PATH="$NDK_STANDALONE_ARM64/lib:$LD_LIBRARY_PATH" \
PATH="$NDK_STANDALONE_ARM64/aarch64-linux-android/bin:$NDK_STANDALONE_ARM64/bin:$PATH" \
SODIUM_LIB_DIR="$SODIUM_ROOT/libsodium-android-armv8-a/lib" \
$CARGO rustc $CARGO_OPTS --target=aarch64-linux-android -- $RUSTC_OPTS -C linker=aarch64-linux-android-gcc -C ar=aarch64-linux-android-ar

echo "=> Building for i686"
DYLD_LIBRARY_PATH="$NDK_STANDALONE_X86/lib:$DYLD_LIBRARY_PATH" \
LD_LIBRARY_PATH="$NDK_STANDALONE_X86/lib:$LD_LIBRARY_PATH" \
PATH="$NDK_STANDALONE_X86/i686-linux-android/bin:$NDK_STANDALONE_X86/bin:$PATH" \
SODIUM_LIB_DIR="$SODIUM_ROOT/libsodium-android-i686/lib" \
$CARGO rustc $CARGO_OPTS --target=i686-linux-android -- $RUSTC_OPTS -C linker=i686-linux-android-gcc -C ar=i686-linux-android-ar
Expand Down
4 changes: 2 additions & 2 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ name = "freepass_core"

[features]
default = ["keepass", "filesystem"]
filesystem = ["fuse", "time"]
filesystem = ["fuse"]

[dependencies]
chrono = { version = "0", features = ["rustc-serialize"] }
Expand All @@ -24,7 +24,7 @@ sodiumoxide = "0"
rusterpassword = "0"
keepass = { version = "0", optional = true }
fuse = { git = "https://github.com/zargony/rust-fuse.git", optional = true } # XXX: BSD unmount fix haven't been released yet
time = { version = "0.1", optional = true }
time = { version = "0.1" }
libc = "0.2"
rand = "0"
cbor = "0"
Expand Down
4 changes: 2 additions & 2 deletions core/src/attachments.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use cbor::{CborBytes};
use std::collections::btree_map::BTreeMap;
use time::{now, Timespec};
use std::path::Path;
#[cfg(feature = "filesystem")] use std::io::{Cursor, Write};
#[cfg(feature = "filesystem")] use std::path::Path;
#[cfg(feature = "filesystem")] use libc::{ENOENT, EIO};
#[cfg(feature = "filesystem")] use time::{now, Timespec};
#[cfg(feature = "filesystem")] use fuse::*;


Expand Down
2 changes: 1 addition & 1 deletion core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ extern crate rand;
extern crate chrono;
#[cfg(feature = "keepass")] extern crate keepass;

#[cfg(feature = "filesystem")] extern crate time;
extern crate time;
#[cfg(feature = "filesystem")] extern crate fuse;

pub mod util;
Expand Down
1 change: 0 additions & 1 deletion ios/Freepass/Deps/Bond
Submodule Bond deleted from f4f57f

0 comments on commit e83ac77

Please sign in to comment.