Native jni build (#5)
* Each native library is in its own jar. Got rid of cross compilation. The project is `secp256k1` and not `secp256k1-kmp`. * Updated CI to use all 3 OS VMs Co-authored-by: Salomon BRYS <salomon@kodein.net>
This commit is contained in:
@@ -3,8 +3,27 @@ plugins {
|
||||
`maven-publish`
|
||||
}
|
||||
|
||||
kotlin {
|
||||
explicitApi()
|
||||
val currentOs = org.gradle.internal.os.OperatingSystem.current()
|
||||
val bash = if (currentOs.isWindows) "bash.exe" else "bash"
|
||||
|
||||
val buildNativeHost by tasks.creating(Exec::class) {
|
||||
group = "build"
|
||||
dependsOn(":jni:generateHeaders")
|
||||
dependsOn(":native:buildSecp256k1Host")
|
||||
|
||||
val target = when {
|
||||
currentOs.isLinux -> "linux"
|
||||
currentOs.isMacOsX -> "darwin"
|
||||
currentOs.isWindows -> "mingw"
|
||||
else -> error("Unsupported OS $currentOs")
|
||||
}
|
||||
|
||||
inputs.files(projectDir.resolve("build.sh"))
|
||||
outputs.dir(buildDir.resolve(target))
|
||||
|
||||
workingDir = projectDir
|
||||
environment("TARGET", target)
|
||||
commandLine(bash, "build.sh")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -12,26 +31,17 @@ dependencies {
|
||||
implementation(kotlin("stdlib-jdk8"))
|
||||
}
|
||||
|
||||
val copyJni by tasks.creating(Sync::class) {
|
||||
dependsOn(":jni:buildNativeJni")
|
||||
from(rootDir.resolve("jni/build/jni/linux/libsecp256k1-jni.so")) { rename { "libsecp256k1-jni-linux-x86_64.so" } }
|
||||
from(rootDir.resolve("jni/build/jni/darwin/libsecp256k1-jni.dylib")) { rename { "libsecp256k1-jni-darwin-x86_64.dylib" } }
|
||||
from(rootDir.resolve("jni/build/jni/mingw/secp256k1-jni.dll")) { rename { "secp256k1-jni-mingw-x86_64.dll" } }
|
||||
into(buildDir.resolve("jniResources/fr/acinq/secp256k1/jni/native"))
|
||||
}
|
||||
|
||||
(tasks["processResources"] as ProcessResources).apply {
|
||||
dependsOn("copyJni")
|
||||
from(buildDir.resolve("jniResources"))
|
||||
}
|
||||
|
||||
java.withSourcesJar()
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
create<MavenPublication>("jvm") {
|
||||
artifactId = "secp256k1-jni-jvm"
|
||||
artifactId = "secp256k1-jni-jvm-extract"
|
||||
from(components["java"])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
tasks["clean"].doLast {
|
||||
delete("$buildDir/build/cmake")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user