diff options
| author | ruki <[email protected]> | 2025-02-13 23:23:19 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-02-13 23:23:19 +0800 |
| commit | 5073a4a7a6a80fef383d22f503c76e2dbadc80ac (patch) | |
| tree | 66b5ab6c4f6c99ee44e8baf44281fda205164cc0 | |
| parent | 452cfe7f8803f4c9fd110a80058b03e975b09e30 (diff) | |
add kotlin-native test
| -rw-r--r-- | tests/projects/kotlin-native/console/src/main.kt | 3 | ||||
| -rw-r--r-- | tests/projects/kotlin-native/console/xmake.lua | 7 | ||||
| -rw-r--r-- | xmake/languages/kotlin/xmake.lua | 2 | ||||
| -rw-r--r-- | xmake/rules/kotlin-native/xmake.lua | 30 | ||||
| -rw-r--r-- | xmake/toolchains/kotlin-native/xmake.lua | 61 |
5 files changed, 102 insertions, 1 deletions
diff --git a/tests/projects/kotlin-native/console/src/main.kt b/tests/projects/kotlin-native/console/src/main.kt new file mode 100644 index 000000000..543f5ac8f --- /dev/null +++ b/tests/projects/kotlin-native/console/src/main.kt @@ -0,0 +1,3 @@ +fun main() { + println("hello xmake!") +} diff --git a/tests/projects/kotlin-native/console/xmake.lua b/tests/projects/kotlin-native/console/xmake.lua new file mode 100644 index 000000000..81211d52d --- /dev/null +++ b/tests/projects/kotlin-native/console/xmake.lua @@ -0,0 +1,7 @@ +add_rules("mode.debug", "mode.release") +add_requires("kotlin-native") +target("test") + set_kind("binary") + add_files("src/*.kt") + set_toolchains("@kotlin-native") + diff --git a/xmake/languages/kotlin/xmake.lua b/xmake/languages/kotlin/xmake.lua index ec702ce8d..3269ea6cd 100644 --- a/xmake/languages/kotlin/xmake.lua +++ b/xmake/languages/kotlin/xmake.lua @@ -19,7 +19,7 @@ -- language("kotlin") - add_rules("kotlin") + add_rules("kotlin-native") set_sourcekinds {kc = ".kt"} set_sourceflags {kc = "kcflags"} set_targetkinds {binary = "kcld", static = "kcar", shared = "kcsh"} diff --git a/xmake/rules/kotlin-native/xmake.lua b/xmake/rules/kotlin-native/xmake.lua new file mode 100644 index 000000000..d1f5c31d4 --- /dev/null +++ b/xmake/rules/kotlin-native/xmake.lua @@ -0,0 +1,30 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file xmake.lua +-- + +rule("kotlin-native.build") + set_sourcekinds("kc") + on_load(function (target) + -- TODO + end) + on_build("build.target") + +rule("kotlin-native") + add_deps("kotlin-native.build") + add_deps("utils.inherit.links") diff --git a/xmake/toolchains/kotlin-native/xmake.lua b/xmake/toolchains/kotlin-native/xmake.lua new file mode 100644 index 000000000..9787fc204 --- /dev/null +++ b/xmake/toolchains/kotlin-native/xmake.lua @@ -0,0 +1,61 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file xmake.lua +-- + +toolchain("kotlin-native") + set_kind("standalone") + set_homepage("https://kotlinlang.org") + set_description("The Kotlin Programming Language Compiler. ") + + set_toolset("kc", "$(env KC)", "kotlinc-native") + set_toolset("kcld", "$(env KC)", "kotlinc-native") + set_toolset("kcsh", "$(env KC)", "kotlinc-native") + set_toolset("kcar", "$(env KC)", "kotlinc-native") + + on_check(function (toolchain) + import("lib.detect.find_tool") + + local paths = {} + for _, package in ipairs(toolchain:packages()) do + local envs = package:envs() + if envs then + table.join2(paths, envs.PATH) + end + end + if toolchain:bindir() then + table.insert(paths, toolchain:bindir()) + end + local kotlinc_native = find_tool("kotlinc-native", {paths = paths}) + if kotlinc_native and kotlinc_native.program then + kotlinc_native = kotlinc_native.program + end + if kotlinc_native then + if path.is_absolute(kotlinc_native) then + local bindir = path.directory(kotlinc_native) + toolchain:config_set("bindir", bindir) + toolchain:config_set("sdkdir", path.directory(bindir)) + end + toolchain:configs_save() + return true + end + end) + + on_load(function (toolchain) + -- TODO + end) |
