summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2025-02-17 23:30:31 +0800
committerruki <[email protected]>2025-02-17 23:30:31 +0800
commit05a0116f17526052b8d99bf076eab99083605518 (patch)
treee2125d02de07c48a61aa483bcf1ed6cc3914ce03
parent20a0069543f7445a11a35a93c766341c2adb3016 (diff)
add target for harmony
-rw-r--r--xmake/toolchains/kotlin-native/xmake.lua40
1 files changed, 39 insertions, 1 deletions
diff --git a/xmake/toolchains/kotlin-native/xmake.lua b/xmake/toolchains/kotlin-native/xmake.lua
index 9787fc204..0260e3ac4 100644
--- a/xmake/toolchains/kotlin-native/xmake.lua
+++ b/xmake/toolchains/kotlin-native/xmake.lua
@@ -57,5 +57,43 @@ toolchain("kotlin-native")
end)
on_load(function (toolchain)
- -- TODO
+ import("private.core.base.is_cross")
+
+ -- kotlinc-native -list-targets
+ local target_plat = toolchain:plat()
+ local target_arch = toolchain:arch()
+ if target_plat and target_arch and is_cross(target_plat, target_arch) then
+ if target_plat == "macosx" then
+ target_plat = "macos"
+ elseif target_plat == "iphoneos" then
+ target_plat = "ios"
+ local simulator = toolchain:config("appledev") == "simulator"
+ if simulator then
+ target_plat = target_plat .. "_simulator"
+ end
+ elseif target_plat == "appletvos" then
+ target_plat = "tvos"
+ local simulator = toolchain:config("appledev") == "simulator"
+ if simulator then
+ target_plat = target_plat .. "_simulator"
+ end
+ elseif target_plat == "harmony" then
+ -- we need to port kotlin-native source code to add ohos_arm64 target support
+ target_plat = "ohos"
+ end
+ if target_arch == "x86_64" then
+ target_arch = "x64"
+ elseif target_arch == "i386" then
+ target_arch = "x86"
+ elseif target_arch == "arm64-v8a" then
+ target_arch = "arm64"
+ elseif target_arch == "armeabi-v7a" then
+ target_arch = "arm32"
+ end
+ local target = target_plat .. "_" .. target_arch
+ toolchain:add("kcflags", {"-target", target})
+ else
+ toolchain:set("kcshflags", "")
+ toolchain:set("kcldflags", "")
+ end
end)