-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
53 lines (43 loc) · 1.36 KB
/
build.gradle
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
apply plugin: 'java'
apply plugin: 'com.google.protobuf'
// define repositories
repositories {
mavenCentral()
}
// define dependencies
dependencies {
compile 'com.google.protobuf:protobuf-java:3.4.0'
compile 'io.grpc:grpc-protobuf:1.6.1' // for com.google.common.primitives
}
// build script
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.3'
}
}
// protobuf protoc
protobuf{
protoc {
artifact = 'com.google.protobuf:protoc:3.4.0'
}
}
// define environment variables
def nativeIncludeDir = "build/generated"
def javaHome = "/home/hamersaw/.sdkman/candidates/java/current"
// generate jni headers
task generateJniHeaders(type: Exec) {
commandLine "javac", "-h", "$nativeIncludeDir", "-d", "$nativeIncludeDir", "src/main/java/com/bushpath/anamnesis/checksum/Checksum.java", "src/main/java/com/bushpath/anamnesis/checksum/NativeChecksumCRC32.java"
}
// compile cpp program
task compileCpp(type: Exec) {
commandLine "g++", "-o", "$nativeIncludeDir/libcrc.so",
"-lc", "-shared", "-fPIC",
"-I", "$nativeIncludeDir", "-I", "$javaHome/include",
"-I", "$javaHome/include/linux/", "src/main/cpp/crc.cpp"
dependsOn generateJniHeaders
}
// define jar depends
jar.dependsOn generateJniHeaders, compileCpp