diff options
| author | ruki <[email protected]> | 2025-02-25 23:29:45 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-02-25 23:29:45 +0800 |
| commit | 87693d5c7c360b3218032bc2bff4253a27ad0425 (patch) | |
| tree | 48f8961deb103b7152fdac18dd8761955c303d0e | |
| parent | ac47c85eb55b510b6b40a567ad86fb02a7a25425 (diff) | |
add cli-parser test
| -rw-r--r-- | tests/projects/kotlin-native/package/cli-parser/src/main.kt | 10 | ||||
| -rw-r--r-- | tests/projects/kotlin-native/package/cli-parser/xmake.lua | 10 | ||||
| -rw-r--r-- | tests/projects/kotlin-native/package/json/src/main.kt (renamed from tests/projects/kotlin-native/package/src/main.kt) | 0 | ||||
| -rw-r--r-- | tests/projects/kotlin-native/package/json/xmake.lua (renamed from tests/projects/kotlin-native/package/xmake.lua) | 5 | ||||
| -rw-r--r-- | xmake/rules/kotlin-native/xmake.lua | 1 |
5 files changed, 23 insertions, 3 deletions
diff --git a/tests/projects/kotlin-native/package/cli-parser/src/main.kt b/tests/projects/kotlin-native/package/cli-parser/src/main.kt new file mode 100644 index 000000000..dae11c45c --- /dev/null +++ b/tests/projects/kotlin-native/package/cli-parser/src/main.kt @@ -0,0 +1,10 @@ +import kotlinx.cli.ArgParser +import kotlinx.cli.ArgType +import kotlinx.cli.default + +fun main(args: Array<String>) { + val parser = ArgParser("example") + val name by parser.option(ArgType.String, shortName = "n", description = "Your name").default("World") + parser.parse(args) + println("Hello, $name!") +} diff --git a/tests/projects/kotlin-native/package/cli-parser/xmake.lua b/tests/projects/kotlin-native/package/cli-parser/xmake.lua new file mode 100644 index 000000000..f2cfdac2b --- /dev/null +++ b/tests/projects/kotlin-native/package/cli-parser/xmake.lua @@ -0,0 +1,10 @@ +add_rules("mode.debug", "mode.release") + +add_requires("kotlin-native") +add_requires("kotlin-native::org.jetbrains.kotlinx:kotlinx-cli 0.3.6", {alias = "kotlinx-cli"}) + +target("test") + set_kind("binary") + add_files("src/*.kt") + add_packages("kotlinx-cli") + set_toolchains("@kotlin-native") diff --git a/tests/projects/kotlin-native/package/src/main.kt b/tests/projects/kotlin-native/package/json/src/main.kt index ec15ce26d..ec15ce26d 100644 --- a/tests/projects/kotlin-native/package/src/main.kt +++ b/tests/projects/kotlin-native/package/json/src/main.kt diff --git a/tests/projects/kotlin-native/package/xmake.lua b/tests/projects/kotlin-native/package/json/xmake.lua index 14d74faf8..2f085de15 100644 --- a/tests/projects/kotlin-native/package/xmake.lua +++ b/tests/projects/kotlin-native/package/json/xmake.lua @@ -2,11 +2,10 @@ add_rules("mode.debug", "mode.release") add_requires("kotlin-native") add_requires("kotlin-native::org.jetbrains.kotlinx:kotlinx-serialization-json 1.8.0", {alias = "json"}) -add_requires("kotlin-native::org.jetbrains.kotlinx:kotlinx-serialization-json 1.8.0", {alias = "json"}) +add_requires("kotlin-native::org.jetbrains.kotlinx:kotlinx-serialization-core 1.8.0", {alias = "core"}) target("test") set_kind("binary") add_files("src/*.kt") - add_packages("json") + add_packages("json", "core") set_toolchains("@kotlin-native") - diff --git a/xmake/rules/kotlin-native/xmake.lua b/xmake/rules/kotlin-native/xmake.lua index 386c85677..f2bd9ed5c 100644 --- a/xmake/rules/kotlin-native/xmake.lua +++ b/xmake/rules/kotlin-native/xmake.lua @@ -21,6 +21,7 @@ rule("kotlin-native.build") set_sourcekinds("kc") on_load(function (target) + target:add("kcflags", "-opt-in=kotlinx.cinterop.ExperimentalForeignApi", {force = true}) if target:is_static() then target:add("arflags", {"-produce", "static"}, {force = true}) target:add("includedirs", target:targetdir(), {interface = true}) |
