2020-08-18 10:52:42 +02:00
|
|
|
import org.gradle.internal.os.OperatingSystem
|
|
|
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
|
2021-03-11 17:53:50 +01:00
|
|
|
import org.jetbrains.dokka.Platform
|
2020-07-09 15:54:34 +03:00
|
|
|
|
2020-06-26 13:48:50 +02:00
|
|
|
plugins {
|
2024-01-23 15:44:06 +01:00
|
|
|
kotlin("multiplatform") version "1.9.22"
|
|
|
|
id("org.jetbrains.dokka") version "1.9.10"
|
2020-07-02 11:39:42 +02:00
|
|
|
`maven-publish`
|
2020-06-26 13:48:50 +02:00
|
|
|
}
|
|
|
|
|
2020-07-01 12:15:04 +02:00
|
|
|
buildscript {
|
|
|
|
repositories {
|
|
|
|
google()
|
2021-03-08 16:50:25 +01:00
|
|
|
mavenCentral()
|
2020-07-01 12:15:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
2023-04-11 18:42:06 +02:00
|
|
|
classpath("com.android.tools.build:gradle:7.3.1")
|
2024-01-23 15:44:06 +01:00
|
|
|
classpath("org.jetbrains.dokka:dokka-gradle-plugin:1.9.10")
|
2020-07-01 12:15:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
allprojects {
|
|
|
|
group = "fr.acinq.secp256k1"
|
2024-03-12 10:09:34 +01:00
|
|
|
version = "0.16.0-SNAPSHOT"
|
2020-07-01 12:15:04 +02:00
|
|
|
|
|
|
|
repositories {
|
|
|
|
google()
|
2021-03-11 17:53:50 +01:00
|
|
|
mavenCentral()
|
2020-07-01 12:15:04 +02:00
|
|
|
}
|
2020-06-26 13:48:50 +02:00
|
|
|
}
|
|
|
|
|
2020-08-18 10:52:42 +02:00
|
|
|
val currentOs = OperatingSystem.current()
|
2020-06-26 13:48:50 +02:00
|
|
|
|
|
|
|
kotlin {
|
|
|
|
explicitApi()
|
|
|
|
|
2020-08-18 10:52:42 +02:00
|
|
|
val commonMain by sourceSets.getting
|
2020-06-26 17:10:48 +02:00
|
|
|
|
2020-06-26 13:48:50 +02:00
|
|
|
jvm {
|
|
|
|
compilations.all {
|
|
|
|
kotlinOptions.jvmTarget = "1.8"
|
|
|
|
}
|
2020-06-26 17:10:48 +02:00
|
|
|
}
|
|
|
|
|
2020-08-18 10:52:42 +02:00
|
|
|
fun KotlinNativeTarget.secp256k1CInterop(target: String) {
|
2020-06-26 17:10:48 +02:00
|
|
|
compilations["main"].cinterops {
|
|
|
|
val libsecp256k1 by creating {
|
|
|
|
includeDirs.headerFilterOnly(project.file("native/secp256k1/include/"))
|
2020-07-01 12:15:04 +02:00
|
|
|
tasks[interopProcessingTaskName].dependsOn(":native:buildSecp256k1${target.capitalize()}")
|
2020-06-26 13:48:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-06-26 17:10:48 +02:00
|
|
|
|
2024-01-23 15:44:06 +01:00
|
|
|
val nativeMain by sourceSets.creating
|
2020-06-26 17:10:48 +02:00
|
|
|
|
2024-01-23 15:44:06 +01:00
|
|
|
linuxX64 {
|
2020-07-09 15:54:34 +03:00
|
|
|
secp256k1CInterop("host")
|
2020-06-26 17:10:48 +02:00
|
|
|
}
|
|
|
|
|
2024-03-04 17:58:20 +01:00
|
|
|
macosX64 {
|
|
|
|
secp256k1CInterop("host")
|
|
|
|
}
|
|
|
|
|
|
|
|
macosArm64 {
|
|
|
|
secp256k1CInterop("host")
|
|
|
|
}
|
|
|
|
|
2024-01-23 15:44:06 +01:00
|
|
|
iosX64 {
|
|
|
|
secp256k1CInterop("ios")
|
|
|
|
}
|
|
|
|
|
|
|
|
iosArm64 {
|
|
|
|
secp256k1CInterop("ios")
|
|
|
|
}
|
|
|
|
|
|
|
|
iosSimulatorArm64 {
|
2020-07-01 12:15:04 +02:00
|
|
|
secp256k1CInterop("ios")
|
2020-06-26 17:10:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
sourceSets.all {
|
2022-09-21 16:00:19 +02:00
|
|
|
languageSettings.optIn("kotlin.RequiresOptIn")
|
2020-06-26 17:10:48 +02:00
|
|
|
}
|
2020-06-26 13:48:50 +02:00
|
|
|
}
|
|
|
|
|
2020-06-29 13:02:45 +02:00
|
|
|
// Disable cross compilation
|
2020-07-02 12:19:29 +02:00
|
|
|
allprojects {
|
|
|
|
plugins.withId("org.jetbrains.kotlin.multiplatform") {
|
|
|
|
afterEvaluate {
|
2020-08-18 10:52:42 +02:00
|
|
|
val currentOs = OperatingSystem.current()
|
2020-07-02 12:19:29 +02:00
|
|
|
val targets = when {
|
|
|
|
currentOs.isLinux -> listOf()
|
2024-01-23 15:44:06 +01:00
|
|
|
currentOs.isMacOsX -> listOf("linuxX64")
|
|
|
|
currentOs.isWindows -> listOf("linuxX64")
|
|
|
|
else -> listOf("linuxX64")
|
2020-08-18 10:52:42 +02:00
|
|
|
}.mapNotNull { kotlin.targets.findByName(it) as? KotlinNativeTarget }
|
2020-07-02 12:19:29 +02:00
|
|
|
|
|
|
|
configure(targets) {
|
|
|
|
compilations.all {
|
|
|
|
cinterops.all { tasks[interopProcessingTaskName].enabled = false }
|
|
|
|
compileKotlinTask.enabled = false
|
|
|
|
tasks[processResourcesTaskName].enabled = false
|
|
|
|
}
|
|
|
|
binaries.all { linkTask.enabled = false }
|
|
|
|
|
|
|
|
mavenPublication {
|
|
|
|
val publicationToDisable = this
|
|
|
|
tasks.withType<AbstractPublishToMaven>().all { onlyIf { publication != publicationToDisable } }
|
|
|
|
tasks.withType<GenerateModuleMetadata>().all { onlyIf { publication.get() != publicationToDisable } }
|
|
|
|
}
|
|
|
|
}
|
2020-06-29 13:02:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-02 11:39:42 +02:00
|
|
|
allprojects {
|
2021-03-11 17:53:50 +01:00
|
|
|
val javadocJar = tasks.create<Jar>("javadocJar") {
|
|
|
|
archiveClassifier.set("javadoc")
|
|
|
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
|
|
|
}
|
|
|
|
|
|
|
|
// Publication
|
2020-07-02 11:39:42 +02:00
|
|
|
plugins.withId("maven-publish") {
|
|
|
|
publishing {
|
|
|
|
publications.withType<MavenPublication>().configureEach {
|
2021-03-11 17:53:50 +01:00
|
|
|
version = project.version.toString()
|
|
|
|
artifact(javadocJar)
|
2020-07-02 11:39:42 +02:00
|
|
|
pom {
|
2021-03-11 17:53:50 +01:00
|
|
|
name.set("secp256k1 for Kotlin/Multiplatform")
|
2020-07-02 11:39:42 +02:00
|
|
|
description.set("Bitcoin's secp256k1 library ported to Kotlin/Multiplatform for JVM, Android, iOS & Linux")
|
|
|
|
url.set("https://github.com/ACINQ/secp256k1-kmp")
|
|
|
|
licenses {
|
2021-03-11 17:53:50 +01:00
|
|
|
license {
|
|
|
|
name.set("Apache License v2.0")
|
|
|
|
url.set("https://www.apache.org/licenses/LICENSE-2.0")
|
|
|
|
}
|
2020-07-02 11:39:42 +02:00
|
|
|
}
|
|
|
|
issueManagement {
|
|
|
|
system.set("Github")
|
|
|
|
url.set("https://github.com/ACINQ/secp256k1-kmp/issues")
|
|
|
|
}
|
|
|
|
scm {
|
|
|
|
connection.set("https://github.com/ACINQ/secp256k1-kmp.git")
|
2021-03-11 17:53:50 +01:00
|
|
|
url.set("https://github.com/ACINQ/secp256k1-kmp")
|
|
|
|
}
|
|
|
|
developers {
|
|
|
|
developer {
|
|
|
|
name.set("ACINQ")
|
|
|
|
email.set("hello@acinq.co")
|
|
|
|
}
|
2020-07-02 11:39:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-03-11 17:53:50 +01:00
|
|
|
|
|
|
|
if (project.name !in listOf("native", "tests")) {
|
|
|
|
afterEvaluate {
|
|
|
|
val dokkaOutputDir = buildDir.resolve("dokka")
|
|
|
|
|
|
|
|
tasks.dokkaHtml {
|
|
|
|
outputDirectory.set(file(dokkaOutputDir))
|
|
|
|
dokkaSourceSets {
|
|
|
|
configureEach {
|
|
|
|
val platformName = when (platform.get()) {
|
|
|
|
Platform.jvm -> "jvm"
|
|
|
|
Platform.js -> "js"
|
|
|
|
Platform.native -> "native"
|
|
|
|
Platform.common -> "common"
|
2023-05-11 17:53:41 +02:00
|
|
|
Platform.wasm -> "wasm"
|
2021-03-11 17:53:50 +01:00
|
|
|
}
|
|
|
|
displayName.set(platformName)
|
|
|
|
|
|
|
|
perPackageOption {
|
|
|
|
matchingRegex.set(".*\\.internal.*") // will match all .internal packages and sub-packages
|
|
|
|
suppress.set(true)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
val deleteDokkaOutputDir by tasks.register<Delete>("deleteDokkaOutputDirectory") {
|
|
|
|
delete(dokkaOutputDir)
|
|
|
|
}
|
|
|
|
|
|
|
|
javadocJar.dependsOn(deleteDokkaOutputDir, tasks.dokkaHtml)
|
|
|
|
javadocJar.from(dokkaOutputDir)
|
|
|
|
}
|
|
|
|
}
|
2020-07-02 11:39:42 +02:00
|
|
|
}
|
2020-07-09 15:54:34 +03:00
|
|
|
|
2020-08-18 10:52:42 +02:00
|
|
|
allprojects {
|
|
|
|
afterEvaluate {
|
|
|
|
tasks.withType<AbstractTestTask>() {
|
|
|
|
testLogging {
|
|
|
|
events("passed", "skipped", "failed", "standard_out", "standard_error")
|
|
|
|
showExceptions = true
|
|
|
|
showStackTraces = true
|
|
|
|
}
|
2020-07-09 15:54:34 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|