Load of small fixes, updates API, and added tests
1apply plugin: 'com.android.library'
2apply plugin: 'kotlin-android-extensions'
3apply plugin: 'kotlin-android'
4
5android {
6 compileSdkVersion 28
7
8 defaultConfig {
9 minSdkVersion 15
10 targetSdkVersion 28
11 versionCode 1
12 versionName "1.0"
13
14 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
15
16 }
17
18 buildTypes {
19 release {
20 minifyEnabled false
21 proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
22 }
23 }
24
25 sourceSets {
26 main {
27 jni.srcDirs = []
28 jniLibs.srcDir 'src/main/libs'
29 }
30 }
31}
32
33repositories {
34 mavenCentral()
35}
36
37dependencies {
38 implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
39 implementation "androidx.core:core:1.0.1"
40
41 testImplementation 'junit:junit:4.12'
42 androidTestImplementation 'androidx.test:runner:1.1.1'
43 androidTestImplementation 'androidx.test:rules:1.1.1'
44 androidTestImplementation 'org.hamcrest:hamcrest-library:1.3'
45}
46
47def rustBasePath = "src/main/rust"
48def cargoOutputDir = "${rustBasePath}/target"
49def archTriplets = ['arm64-v8a': 'aarch64-linux-android',
50 'armeabi-v7a': 'armv7-linux-androideabi',
51 'x86': 'i686-linux-android']
52
53archTriplets.each { arch, target ->
54 // Build with cargo
55 tasks.create(name: "cargo-build-${arch}", type: Exec, description: "Building core for ${arch}") {
56 workingDir rustBasePath
57 commandLine 'cargo', 'build', "--target=${target}", '--release'
58 }
59
60 // Copy build libs into this app's libs directory
61 tasks.create(name: "rust-sync-${arch}", type: Copy, dependsOn: "cargo-build-${arch}", description: "Copy rust libs for (${arch}) to jniLibs") {
62 from "${cargoOutputDir}/${target}/release"
63 include "*.so"
64 into "src/main/libs/${arch}"
65 }
66
67 // Hook up tasks to execute before building java
68 tasks.withType(JavaCompile) {
69 compileTask -> compileTask.dependsOn "rust-sync-${arch}"
70 }
71 preBuild.dependsOn "rust-sync-${arch}"
72
73 // Hook up clean tasks
74 tasks.create(name: "clean-${arch}", type: Delete, description: "Deleting built libs for ${arch}") {
75 delete fileTree("${cargoOutputDir}/${target}/release") {
76 include '*.so'
77 }
78 }
79
80 clean.dependsOn "clean-${arch}"
81}