Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cryptography-providers/cryptokit/swift/Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:6.2
// swift-tools-version:6.1
import PackageDescription

// dwc = dev.whyoleg.cryptography
Expand Down
18 changes: 4 additions & 14 deletions cryptography-providers/openssl3/api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,15 @@
*/

import ckbuild.*
import ckbuild.openssl.*
import org.jetbrains.kotlin.gradle.*
import org.jetbrains.kotlin.gradle.plugin.mpp.*
import org.jetbrains.kotlin.gradle.tasks.*
import com.ensody.nativebuilds.*

plugins {
id("ckbuild.multiplatform-library")
id("ckbuild.use-openssl")
alias(libs.plugins.nativebuilds)
}

description = "cryptography-kotlin OpenSSL3 provider (API)"

@OptIn(ExperimentalKotlinGradlePluginApi::class)
kotlin {
nativeTargets()

Expand All @@ -33,13 +29,7 @@ kotlin {
implementation(projects.cryptographyProviderBase)
}

targets.withType<KotlinNativeTarget>().configureEach {
cinterop("declarations", "common")
}
}

tasks.withType<CInteropProcess>().configureEach {
uses(openssl.v3_0) {
settings.includeDirs(includeDirectory(konanTarget))
cinterops(libs.nativebuilds.openssl.headers) {
definitionFile.set(file("src/commonMain/cinterop/declarations.def"))
}
}
60 changes: 2 additions & 58 deletions cryptography-providers/openssl3/prebuilt/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,15 @@
*/

import ckbuild.*
import ckbuild.openssl.*
import org.jetbrains.kotlin.gradle.*
import org.jetbrains.kotlin.gradle.plugin.*
import org.jetbrains.kotlin.gradle.plugin.mpp.*
import org.jetbrains.kotlin.gradle.targets.native.tasks.*
import org.jetbrains.kotlin.gradle.tasks.*

plugins {
id("ckbuild.multiplatform-library")
id("ckbuild.multiplatform-provider-tests")
id("ckbuild.use-openssl")
alias(libs.plugins.nativebuilds)
}

description = "cryptography-kotlin OpenSSL3 provider (prebuilt)"

@OptIn(ExperimentalKotlinGradlePluginApi::class)
kotlin {
nativeTargets()

Expand All @@ -31,61 +24,12 @@ kotlin {
sourceSets {
commonMain.dependencies {
api(projects.cryptographyProviderOpenssl3Api)
api(libs.nativebuilds.openssl.libcrypto)
}
commonTest.dependencies {
api(projects.cryptographyProviderOpenssl3Test)
}
}

targets.withType<KotlinNativeTarget>().configureEach {
cinterop("linking", "common")
}

// for mingw we link `zlib` statically, as on final-users Windows PCs, `zlib` is not installed by default,
// while linking works fine (because K/N provides `zlib` inside it), running executable will fail.
//
// on other platforms `zlib` is pre-installed, so there are no such issues
//
// to properly test this on CI (where `zlib` is available),
// we need to remove from PATH all paths that contain `zlib1.dll`.
// we don't remove those paths from PATH automatically to not iterate over all files in PATH at configuration time.
// instead, we do check if the new (adapted) PATH doesn't contain `zlib1.dll` at task execution time
mingwX64 {
testRuns.configureEach {
@Suppress("UNCHECKED_CAST")
(this as ExecutionTaskHolder<KotlinNativeTest>).executionTask.configure {
// those values found experimentally on CI machines...
val knownPathsWithZlibDll = setOf(
"C:\\Program Files\\Git\\mingw64\\bin",
"C:\\Program Files\\Microsoft Service Fabric\\bin\\Fabric\\Fabric.Code",
"C:\\Strawberry\\c\\bin"
)
val currentPath = providers.environmentVariable("PATH").get()
val paths = currentPath
.split(";")
.filter(String::isNotBlank)
.filter { it !in knownPathsWithZlibDll }
val newPath = paths.joinToString(";")

environment("PATH", newPath)
doFirst {
val folders = paths.mapNotNull { folder ->
val hasZlib = File(folder).listFiles()?.any { it.name == "zlib1.dll" } == true
if (hasZlib) folder else null
}
if (folders.isNotEmpty()) {
error("Found `zlib1.dll` in paths: ${folders.joinToString("\n", "\n")}")
}
}
}
}
}
}

tasks.withType<CInteropProcess>().configureEach {
uses(openssl.v3_5) {
settings.extraOpts("-libraryPath", libDirectory(konanTarget).get().asFile.absolutePath)
}
}

providerTests {
Expand Down

This file was deleted.

Binary file not shown.
6 changes: 6 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ maven-publish = "0.34.0"
# other
bouncycastle = "1.81"
logback = "1.5.18"
nativebuilds = "0.4.0"
openssl = "3.6.0.1"

[libraries]
kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
Expand All @@ -43,6 +45,9 @@ kotlinx-benchmark-runtime = { module = "org.jetbrains.kotlinx:kotlinx-benchmark-

bouncycastle = { module = "org.bouncycastle:bcprov-jdk18on", version.ref = "bouncycastle" }

nativebuilds-openssl-libcrypto = { module = "com.ensody.nativebuilds:openssl-libcrypto", version.ref = "openssl" }
nativebuilds-openssl-headers = { module = "com.ensody.nativebuilds:openssl", version.ref = "openssl" }

androidx-test = { module = "androidx.test:runner", version.ref = "androidx-test" }

ktor-serialization-cbor = { module = "io.ktor:ktor-serialization-kotlinx-cbor", version.ref = "ktor" }
Expand All @@ -65,3 +70,4 @@ kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref
kotlin-plugin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
kotlin-dokka = { id = "org.jetbrains.dokka", version.ref = "kotlin-dokka" }
android-kotlin-multiplatform-library = { id = "com.android.kotlin.multiplatform.library", version.ref = "android" }
nativebuilds = { id = "com.ensody.nativebuilds", version.ref = "nativebuilds" }