summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2025-02-25 22:52:53 +0800
committerruki <[email protected]>2025-02-25 11:42:10 +0800
commit764a267a30d0ad8f6bb360562463d257594e2474 (patch)
treecb842983f15f193d866ee77830e7d47d7b761925
parentfdca3b2904d158ab22f402f647fb9c34eaf2e587 (diff)
add kotlin-native package stub
-rw-r--r--tests/projects/kotlin-native/package/src/main.kt3
-rw-r--r--tests/projects/kotlin-native/package/xmake.lua11
-rw-r--r--xmake/modules/package/manager/kotlin-native/configurations.lua58
-rw-r--r--xmake/modules/package/manager/kotlin-native/find_package.lua37
-rw-r--r--xmake/modules/package/manager/kotlin-native/install_package.lua46
5 files changed, 155 insertions, 0 deletions
diff --git a/tests/projects/kotlin-native/package/src/main.kt b/tests/projects/kotlin-native/package/src/main.kt
new file mode 100644
index 000000000..543f5ac8f
--- /dev/null
+++ b/tests/projects/kotlin-native/package/src/main.kt
@@ -0,0 +1,3 @@
+fun main() {
+ println("hello xmake!")
+}
diff --git a/tests/projects/kotlin-native/package/xmake.lua b/tests/projects/kotlin-native/package/xmake.lua
new file mode 100644
index 000000000..1b7d146f3
--- /dev/null
+++ b/tests/projects/kotlin-native/package/xmake.lua
@@ -0,0 +1,11 @@
+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"})
+
+target("test")
+ set_kind("binary")
+ add_files("src/*.kt")
+ add_packages("json")
+ set_toolchains("@kotlin-native")
+
diff --git a/xmake/modules/package/manager/kotlin-native/configurations.lua b/xmake/modules/package/manager/kotlin-native/configurations.lua
new file mode 100644
index 000000000..831403d03
--- /dev/null
+++ b/xmake/modules/package/manager/kotlin-native/configurations.lua
@@ -0,0 +1,58 @@
+--!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 configurations.lua
+--
+
+-- get architecture for kotlin-native
+function arch(arch)
+ local archs = {
+ x86_64 = "x64",
+ i386 = "x86",
+ ["armeabi-v7a"] = "arm32",
+ ["arm64-v8a"] = "arm64",
+ armv7 = "arm32",
+ armv7s = "arm32"
+ }
+ return archs[arch] or arch
+end
+
+-- get platform for kotlin-native
+function plat(plat)
+ local plats = {
+ macosx = "macOS",
+ iphoneos = "ios",
+ appletvos = "tvos",
+ windows = "mingw"
+ }
+ return plats[plat] or plat
+end
+
+-- get triplet
+function triplet(plat, arch)
+ return plat .. arch
+end
+
+-- get configurations
+function main()
+ return {
+ repositories = {description = "set the maven repositories", default = {
+ "https://repo.maven.apache.org/maven2"
+ }}
+ }
+end
+
diff --git a/xmake/modules/package/manager/kotlin-native/find_package.lua b/xmake/modules/package/manager/kotlin-native/find_package.lua
new file mode 100644
index 000000000..b58eff6b4
--- /dev/null
+++ b/xmake/modules/package/manager/kotlin-native/find_package.lua
@@ -0,0 +1,37 @@
+--!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 find_package.lua
+--
+
+-- imports
+import("lib.detect.find_file")
+import("lib.detect.find_tool")
+import("core.base.option")
+import("core.project.config")
+import("core.project.target")
+import("package.manager.kotlin-native.configurations")
+
+-- find package from the kotlin-native package manager
+--
+-- @param name the package name, e.g. org.jetbrains.kotlinx:kotlinx-serialization-json 1.8.0
+-- @param opt the options, e.g. {verbose = true)
+--
+function main(name, opt)
+ opt = opt or {}
+
+end
diff --git a/xmake/modules/package/manager/kotlin-native/install_package.lua b/xmake/modules/package/manager/kotlin-native/install_package.lua
new file mode 100644
index 000000000..008295f02
--- /dev/null
+++ b/xmake/modules/package/manager/kotlin-native/install_package.lua
@@ -0,0 +1,46 @@
+--!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 install_package.lua
+--
+
+-- imports
+import("core.base.option")
+import("core.base.json")
+import("core.base.semver")
+import("lib.detect.find_tool")
+import("package.manager.kotlin-native.configurations")
+import("net.http")
+
+-- install package
+--
+-- @param name the package name, e.g. org.jetbrains.kotlinx:kotlinx-serialization-json 1.8.0
+-- @param opt the options, e.g. {verbose = true}
+--
+function main(name, opt)
+ opt = opt or {}
+ local configs = opt.configs or {}
+
+ -- init triplet
+ local arch = opt.arch
+ local plat = opt.plat
+ plat = configurations.plat(plat)
+ arch = configurations.arch(arch)
+ local triplet = configurations.triplet(plat, arch)
+
+
+end