summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2025-02-13 23:27:49 +0800
committerruki <[email protected]>2025-02-13 23:27:49 +0800
commit6d10d9caded550963cd07bf5a189a8d1d12a3c5d (patch)
tree08aff8c87165bd67be14c1cf33e8aa9c3af805b6
parente27544eaedc9a323b1cb132928fd8a8ab24d13bd (diff)
add static library for kotlin
-rw-r--r--tests/projects/kotlin-native/static/src/main.kt3
-rw-r--r--tests/projects/kotlin-native/static/xmake.lua7
-rw-r--r--xmake/rules/kotlin-native/xmake.lua5
3 files changed, 15 insertions, 0 deletions
diff --git a/tests/projects/kotlin-native/static/src/main.kt b/tests/projects/kotlin-native/static/src/main.kt
new file mode 100644
index 000000000..543f5ac8f
--- /dev/null
+++ b/tests/projects/kotlin-native/static/src/main.kt
@@ -0,0 +1,3 @@
+fun main() {
+ println("hello xmake!")
+}
diff --git a/tests/projects/kotlin-native/static/xmake.lua b/tests/projects/kotlin-native/static/xmake.lua
new file mode 100644
index 000000000..2e827ec78
--- /dev/null
+++ b/tests/projects/kotlin-native/static/xmake.lua
@@ -0,0 +1,7 @@
+add_rules("mode.debug", "mode.release")
+add_requires("kotlin-native")
+target("test")
+ set_kind("static")
+ add_files("src/*.kt")
+ set_toolchains("@kotlin-native")
+
diff --git a/xmake/rules/kotlin-native/xmake.lua b/xmake/rules/kotlin-native/xmake.lua
index f917a06a3..a75cc8062 100644
--- a/xmake/rules/kotlin-native/xmake.lua
+++ b/xmake/rules/kotlin-native/xmake.lua
@@ -20,6 +20,11 @@
rule("kotlin-native.build")
set_sourcekinds("kc")
+ on_load(function (target)
+ if target:is_static() then
+ target:add("kcflags", {"-produce", "static"}, {force = true})
+ end
+ end)
on_build("build.target")
rule("kotlin-native")