summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-01-22 22:41:59 +0800
committerruki <[email protected]>2024-01-25 12:09:58 +0800
commit4f7105af06f2b9f390b3441328911b48cb35b7e9 (patch)
tree0bff8e691b26f1d97f35a5255d9b4070fcefa8f6
parent5d2f15a1004be7baaaeb08b2e196ad77c52f9647 (diff)
improve compile runtime rules
-rw-r--r--xmake/core/project/target.lua16
-rw-r--r--xmake/modules/core/tools/clang.lua3
-rw-r--r--xmake/rules/utils/compiler_runtime/xmake.lua17
-rw-r--r--xmake/toolchains/xcode/load_macosx.lua2
4 files changed, 19 insertions, 19 deletions
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua
index 19f19e664..e2262049a 100644
--- a/xmake/core/project/target.lua
+++ b/xmake/core/project/target.lua
@@ -2384,19 +2384,9 @@ end
function _instance:runtimes()
local runtimes = self:_memcache():get("runtimes")
if runtimes == nil then
- runtimes = self:get("runtimes") or config.get("runtimes")
- if self:is_plat("windows") then
- runtimes = runtimes or config.get("vs_runtime")
- elseif self:is_plat("android") then
- runtimes = runtimes or config.get("ndk_cxxstl")
- end
- if type(runtimes) == "string" then
- runtimes = runtimes:split(",", {plain = true})
- if #runtimes > 0 then
- runtimes = table.unwrap(runtimes)
- else
- runtimes = nil
- end
+ runtimes = self:get("runtimes")
+ if runtimes and #runtimes > 0 then
+ runtimes = table.unwrap(runtimes)
end
runtimes = runtimes or false
self:_memcache():set("runtimes", runtimes)
diff --git a/xmake/modules/core/tools/clang.lua b/xmake/modules/core/tools/clang.lua
index c9c6b854d..7e1f37b8d 100644
--- a/xmake/modules/core/tools/clang.lua
+++ b/xmake/modules/core/tools/clang.lua
@@ -207,6 +207,7 @@ function nf_runtime(self, runtime)
end
return maps and maps[runtime]
else
+ --[[
local maps
if kind == "cxx" then
maps = {
@@ -222,7 +223,7 @@ function nf_runtime(self, runtime)
["stdc++_static"] = {"-stdlib=libstdc++", "-static-libstdc++"},
["stdc++_shared"] = "-stdlib=libstdc++",
}
- end
+ end]]
return maps and maps[runtime]
end
end
diff --git a/xmake/rules/utils/compiler_runtime/xmake.lua b/xmake/rules/utils/compiler_runtime/xmake.lua
index f8e3d39d0..61681b235 100644
--- a/xmake/rules/utils/compiler_runtime/xmake.lua
+++ b/xmake/rules/utils/compiler_runtime/xmake.lua
@@ -21,11 +21,18 @@
-- define rule: utils.compiler.runtime
rule("utils.compiler.runtime")
on_config(function (target)
-
- -- set vs runtime
- local vs_runtime = get_config("vs_runtime")
- if vs_runtime and target:is_plat("windows") and not target:get("runtimes") then
- target:set("runtimes", vs_runtime)
+ local runtimes = get_config("runtimes")
+ if not runtimes and target:is_plat("windows") then
+ runtimes = get_config("vs_runtime")
+ end
+ if not runtimes and target:is_plat("android") then
+ runtimes = get_config("ndk_cxxstl")
+ end
+ if runtimes and not target:get("runtimes") then
+ if type(runtimes) == "string" then
+ runtimes = runtimes:split(",", {plain = true})
+ end
+ target:set("runtimes", runtimes)
end
end)
diff --git a/xmake/toolchains/xcode/load_macosx.lua b/xmake/toolchains/xcode/load_macosx.lua
index 039152067..a52ad9389 100644
--- a/xmake/toolchains/xcode/load_macosx.lua
+++ b/xmake/toolchains/xcode/load_macosx.lua
@@ -83,4 +83,6 @@ function main(toolchain)
-- init flags for objc/c++ (with ldflags and shflags)
-- we can use `add_mxflags("-fno-objc-arc")` to override it in xmake.lua
toolchain:add("mxflags", "-fobjc-arc")
+
+ print("11", toolchain:runtimes())
end