-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild.gradle
More file actions
56 lines (45 loc) · 1.42 KB
/
Copy pathbuild.gradle
File metadata and controls
56 lines (45 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import org.apache.tools.ant.taskdefs.condition.Os
plugins {
id 'java'
}
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withInputStream { localProperties.load(it) }
}
def sdkDir = localProperties.getProperty('sdk.dir')
def ndkDir = localProperties.getProperty('ndk.dir') ?: "${sdkDir}/ndk/27.3.13750724"
def rustProjectDir = file("rapier")
def apiLevel = "21"
tasks.register('compileRustAndroid', Exec) {
group = 'rust'
workingDir rustProjectDir
environment "ANDROID_NDK_HOME", ndkDir
commandLine 'cargo', 'ndk',
'-t', 'arm64-v8a',
'-t', 'armeabi-v7a',
'-t', 'x86_64',
'-t', 'x86',
'--platform', apiLevel,
'build', '--release'
}
tasks.register('buildRustNatives') {
group = 'build'
description = 'Compiles all Rust natives using cargo-ndk.'
dependsOn compileRustAndroid
finalizedBy 'copyRustNatives'
}
tasks.register('copyRustNatives', Copy) {
into("target/android")
def mapping = [
'aarch64-linux-android': 'arm64-v8a',
'armv7-linux-androideabi': 'armeabi-v7a',
'x86_64-linux-android': 'x86_64',
'i686-linux-android': 'x86'
]
mapping.each { rustTarget, androidAbi ->
from("target/${rustTarget}/release/libsable_rapier.so") {
into androidAbi
}
}
}