33 */
44
55import ckbuild.*
6- import ckbuild.openssl.*
7- import org.jetbrains.kotlin.gradle.*
8- import org.jetbrains.kotlin.gradle.plugin.*
9- import org.jetbrains.kotlin.gradle.plugin.mpp.*
10- import org.jetbrains.kotlin.gradle.targets.native.tasks.*
11- import org.jetbrains.kotlin.gradle.tasks.*
126
137plugins {
148 id(" ckbuild.multiplatform-library" )
159 id(" ckbuild.multiplatform-provider-tests" )
16- id( " ckbuild.use-openssl " )
10+ alias(libs.plugins.nativebuilds )
1711}
1812
1913description = " cryptography-kotlin OpenSSL3 provider (prebuilt)"
2014
21- @OptIn(ExperimentalKotlinGradlePluginApi ::class )
2215kotlin {
2316 nativeTargets()
2417
@@ -31,61 +24,12 @@ kotlin {
3124 sourceSets {
3225 commonMain.dependencies {
3326 api(projects.cryptographyProviderOpenssl3Api)
27+ api(libs.nativebuilds.openssl.libcrypto)
3428 }
3529 commonTest.dependencies {
3630 api(projects.cryptographyProviderOpenssl3Test)
3731 }
3832 }
39-
40- targets.withType<KotlinNativeTarget >().configureEach {
41- cinterop(" linking" , " common" )
42- }
43-
44- // for mingw we link `zlib` statically, as on final-users Windows PCs, `zlib` is not installed by default,
45- // while linking works fine (because K/N provides `zlib` inside it), running executable will fail.
46- //
47- // on other platforms `zlib` is pre-installed, so there are no such issues
48- //
49- // to properly test this on CI (where `zlib` is available),
50- // we need to remove from PATH all paths that contain `zlib1.dll`.
51- // we don't remove those paths from PATH automatically to not iterate over all files in PATH at configuration time.
52- // instead, we do check if the new (adapted) PATH doesn't contain `zlib1.dll` at task execution time
53- mingwX64 {
54- testRuns.configureEach {
55- @Suppress(" UNCHECKED_CAST" )
56- (this as ExecutionTaskHolder <KotlinNativeTest >).executionTask.configure {
57- // those values found experimentally on CI machines...
58- val knownPathsWithZlibDll = setOf (
59- " C:\\ Program Files\\ Git\\ mingw64\\ bin" ,
60- " C:\\ Program Files\\ Microsoft Service Fabric\\ bin\\ Fabric\\ Fabric.Code" ,
61- " C:\\ Strawberry\\ c\\ bin"
62- )
63- val currentPath = providers.environmentVariable(" PATH" ).get()
64- val paths = currentPath
65- .split(" ;" )
66- .filter(String ::isNotBlank)
67- .filter { it !in knownPathsWithZlibDll }
68- val newPath = paths.joinToString(" ;" )
69-
70- environment(" PATH" , newPath)
71- doFirst {
72- val folders = paths.mapNotNull { folder ->
73- val hasZlib = File (folder).listFiles()?.any { it.name == " zlib1.dll" } == true
74- if (hasZlib) folder else null
75- }
76- if (folders.isNotEmpty()) {
77- error(" Found `zlib1.dll` in paths: ${folders.joinToString(" \n " , " \n " )} " )
78- }
79- }
80- }
81- }
82- }
83- }
84-
85- tasks.withType<CInteropProcess >().configureEach {
86- uses(openssl.v3_5) {
87- settings.extraOpts(" -libraryPath" , libDirectory(konanTarget).get().asFile.absolutePath)
88- }
8933}
9034
9135providerTests {
0 commit comments