Skip to content

Commit 66a420c

Browse files
committed
Add back cinterop
1 parent 60a3427 commit 66a420c

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

runtime/runtime-core/build.gradle.kts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import aws.sdk.kotlin.gradle.kmp.NATIVE_ENABLED
77
import aws.sdk.kotlin.gradle.util.typedProp
8+
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
89
import org.jetbrains.kotlin.konan.target.HostManager
910
import java.nio.file.Files
1011
import java.nio.file.Paths
@@ -33,6 +34,7 @@ kotlin {
3334
nativeMain {
3435
dependencies {
3536
api(libs.crt.kotlin)
37+
implementation(libs.kotlin.multiplatform.bignum)
3638
}
3739
}
3840

@@ -50,17 +52,24 @@ kotlin {
5052
}
5153
}
5254

53-
nativeMain {
54-
dependencies {
55-
implementation(libs.kotlin.multiplatform.bignum)
56-
}
57-
}
58-
5955
all {
6056
languageSettings.optIn("aws.smithy.kotlin.runtime.InternalApi")
6157
}
6258
}
6359

60+
if (NATIVE_ENABLED && !HostManager.hostIsMingw) {
61+
targets.withType<KotlinNativeTarget> {
62+
compilations["main"].cinterops {
63+
val interopDir = "$projectDir/posix/src/posixInterop/cinterop"
64+
create("environ") {
65+
includeDirs(interopDir)
66+
packageName("aws.smithy.platform.posix")
67+
headers(listOf("$interopDir/environ.h"))
68+
}
69+
}
70+
}
71+
}
72+
6473
if (NATIVE_ENABLED && HostManager.hostIsMingw) {
6574
mingwX64 {
6675
val mingwHome = findMingwHome()
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#ifndef ENVIRON_H
2+
#define ENVIRON_H
3+
4+
// External declaration to get environment variables
5+
extern char **environ;
6+
7+
// Helper function to get the environ pointer
8+
char** get_environ_ptr() {
9+
return environ;
10+
}
11+
12+
#endif

0 commit comments

Comments
 (0)