2020-08-18 10:52:42 +02:00
|
|
|
import org.gradle.internal.os.OperatingSystem
|
|
|
|
|
2021-10-25 14:27:02 +02:00
|
|
|
val includeAndroid = System.getProperty("includeAndroid")?.toBoolean() ?: true
|
|
|
|
|
|
|
|
if (includeAndroid) {
|
|
|
|
evaluationDependsOn(":jni:android")
|
|
|
|
}
|
2020-07-01 12:15:04 +02:00
|
|
|
|
2020-08-18 10:52:42 +02:00
|
|
|
val currentOs = OperatingSystem.current()
|
2022-03-23 15:45:45 +01:00
|
|
|
val bash = "bash"
|
2020-07-01 12:15:04 +02:00
|
|
|
|
|
|
|
val buildSecp256k1 by tasks.creating { group = "build" }
|
|
|
|
|
2020-07-09 15:54:34 +03:00
|
|
|
val buildSecp256k1Host by tasks.creating(Exec::class) {
|
2020-07-01 12:15:04 +02:00
|
|
|
group = "build"
|
|
|
|
buildSecp256k1.dependsOn(this)
|
|
|
|
|
2020-07-09 15:54:34 +03:00
|
|
|
val target = when {
|
|
|
|
currentOs.isLinux -> "linux"
|
|
|
|
currentOs.isMacOsX -> "darwin"
|
|
|
|
currentOs.isWindows -> "mingw"
|
2020-08-18 10:52:42 +02:00
|
|
|
else -> error("Unsupported OS $currentOs")
|
2020-07-09 15:54:34 +03:00
|
|
|
}
|
2020-07-03 19:12:38 +02:00
|
|
|
|
2020-07-01 12:15:04 +02:00
|
|
|
inputs.files(projectDir.resolve("build.sh"))
|
|
|
|
outputs.dir(projectDir.resolve("build/$target"))
|
|
|
|
|
|
|
|
workingDir = projectDir
|
|
|
|
environment("TARGET", target)
|
2022-03-23 15:45:45 +01:00
|
|
|
commandLine(bash, "-l", "build.sh")
|
2020-07-01 12:15:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
val buildSecp256k1Ios by tasks.creating(Exec::class) {
|
|
|
|
group = "build"
|
|
|
|
buildSecp256k1.dependsOn(this)
|
|
|
|
|
|
|
|
onlyIf { currentOs.isMacOsX }
|
|
|
|
|
|
|
|
inputs.files(projectDir.resolve("build-ios.sh"))
|
|
|
|
outputs.dir(projectDir.resolve("build/ios"))
|
|
|
|
|
|
|
|
workingDir = projectDir
|
2020-07-09 15:54:34 +03:00
|
|
|
commandLine(bash, "build-ios.sh")
|
2020-07-01 12:15:04 +02:00
|
|
|
}
|
|
|
|
|
2021-10-25 14:27:02 +02:00
|
|
|
if (includeAndroid) {
|
2020-07-01 12:15:04 +02:00
|
|
|
|
2021-10-25 14:27:02 +02:00
|
|
|
val buildSecp256k1Android by tasks.creating {
|
|
|
|
group = "build"
|
|
|
|
buildSecp256k1.dependsOn(this)
|
|
|
|
}
|
2020-07-01 12:15:04 +02:00
|
|
|
|
2021-10-25 14:27:02 +02:00
|
|
|
fun creatingBuildSecp256k1Android(arch: String) = tasks.creating(Exec::class) {
|
|
|
|
group = "build"
|
|
|
|
buildSecp256k1Android.dependsOn(this)
|
|
|
|
|
|
|
|
inputs.files(projectDir.resolve("build-android.sh"))
|
|
|
|
outputs.dir(projectDir.resolve("build/android/$arch"))
|
|
|
|
|
|
|
|
workingDir = projectDir
|
|
|
|
|
|
|
|
val toolchain = when {
|
|
|
|
currentOs.isLinux -> "linux-x86_64"
|
|
|
|
currentOs.isMacOsX -> "darwin-x86_64"
|
|
|
|
currentOs.isWindows -> "windows-x86_64"
|
|
|
|
else -> error("No Android toolchain defined for this OS: $currentOs")
|
|
|
|
}
|
|
|
|
environment("TOOLCHAIN", toolchain)
|
|
|
|
environment("ARCH", arch)
|
|
|
|
environment("ANDROID_NDK", (project(":jni:android").extensions["android"] as com.android.build.gradle.LibraryExtension).ndkDirectory)
|
|
|
|
commandLine(bash, "build-android.sh")
|
2020-07-01 12:15:04 +02:00
|
|
|
}
|
2021-10-25 14:27:02 +02:00
|
|
|
|
|
|
|
val buildSecp256k1AndroidX86_64 by creatingBuildSecp256k1Android("x86_64")
|
|
|
|
val buildSecp256k1AndroidX86 by creatingBuildSecp256k1Android("x86")
|
|
|
|
val buildSecp256k1AndroidArm64v8a by creatingBuildSecp256k1Android("arm64-v8a")
|
|
|
|
val buildSecp256k1AndroidArmeabiv7a by creatingBuildSecp256k1Android("armeabi-v7a")
|
2020-07-01 12:15:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
val clean by tasks.creating {
|
2020-07-01 13:53:26 +02:00
|
|
|
group = "build"
|
2020-07-01 12:15:04 +02:00
|
|
|
doLast {
|
|
|
|
delete(projectDir.resolve("build"))
|
|
|
|
}
|
|
|
|
}
|