diff options
| author | ruki <[email protected]> | 2025-02-20 22:45:35 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-02-20 22:45:35 +0800 |
| commit | 6807d5763f16e779697af79764b4ea6dd79b6fef (patch) | |
| tree | f48f64adefd9c7f90107223f265e29be20285e74 | |
| parent | 12e6b2e55738d259561da396f0fc63c468fd6147 (diff) | |
improve cname for kotlin
5 files changed, 2 insertions, 24 deletions
diff --git a/tests/projects/kotlin-native/shared_library/src/foo.kt b/tests/projects/kotlin-native/shared_library/src/foo.kt index 64ed2a016..cc5184bd7 100644 --- a/tests/projects/kotlin-native/shared_library/src/foo.kt +++ b/tests/projects/kotlin-native/shared_library/src/foo.kt @@ -1,8 +1,2 @@ -@file:OptIn(ExperimentalNativeApi::class) - -import kotlin.experimental.ExperimentalNativeApi -import kotlinx.cinterop.* - -@ExperimentalNativeApi @CName("kotlin_add") fun add(a: Int, b: Int): Int = a + b diff --git a/tests/projects/kotlin-native/static_library/src/foo.kt b/tests/projects/kotlin-native/static_library/src/foo.kt index 64ed2a016..cc5184bd7 100644 --- a/tests/projects/kotlin-native/static_library/src/foo.kt +++ b/tests/projects/kotlin-native/static_library/src/foo.kt @@ -1,8 +1,2 @@ -@file:OptIn(ExperimentalNativeApi::class) - -import kotlin.experimental.ExperimentalNativeApi -import kotlinx.cinterop.* - -@ExperimentalNativeApi @CName("kotlin_add") fun add(a: Int, b: Int): Int = a + b diff --git a/xmake/rules/kotlin-native/xmake.lua b/xmake/rules/kotlin-native/xmake.lua index be3c39bac..69fcb6027 100644 --- a/xmake/rules/kotlin-native/xmake.lua +++ b/xmake/rules/kotlin-native/xmake.lua @@ -24,11 +24,13 @@ rule("kotlin-native.build") if target:is_static() then target:add("arflags", {"-produce", "static"}, {force = true}) target:add("includedirs", target:targetdir(), {interface = true}) + target:add("kcflags", "-opt-in=kotlin.experimental.ExperimentalNativeApi", {force = true}) if target:is_plat("macosx") then target:add("frameworks", "Foundation", "CoreFoundation", {interface = true}) end elseif target:is_shared() then target:add("shflags", {"-produce", "dynamic"}, {force = true}) + target:add("kcflags", "-opt-in=kotlin.experimental.ExperimentalNativeApi", {force = true}) target:add("includedirs", target:targetdir(), {interface = true}) end target:set("policy", "build.fence", true) diff --git a/xmake/templates/kotlin/shared_library/project/src/foo.kt b/xmake/templates/kotlin/shared_library/project/src/foo.kt index 64ed2a016..cc5184bd7 100644 --- a/xmake/templates/kotlin/shared_library/project/src/foo.kt +++ b/xmake/templates/kotlin/shared_library/project/src/foo.kt @@ -1,8 +1,2 @@ -@file:OptIn(ExperimentalNativeApi::class) - -import kotlin.experimental.ExperimentalNativeApi -import kotlinx.cinterop.* - -@ExperimentalNativeApi @CName("kotlin_add") fun add(a: Int, b: Int): Int = a + b diff --git a/xmake/templates/kotlin/static_library/project/src/foo.kt b/xmake/templates/kotlin/static_library/project/src/foo.kt index 64ed2a016..cc5184bd7 100644 --- a/xmake/templates/kotlin/static_library/project/src/foo.kt +++ b/xmake/templates/kotlin/static_library/project/src/foo.kt @@ -1,8 +1,2 @@ -@file:OptIn(ExperimentalNativeApi::class) - -import kotlin.experimental.ExperimentalNativeApi -import kotlinx.cinterop.* - -@ExperimentalNativeApi @CName("kotlin_add") fun add(a: Int, b: Int): Int = a + b |
