summaryrefslogtreecommitdiff
path: root/xmake/modules/package/tools
diff options
context:
space:
mode:
authorruki <[email protected]>2023-06-06 23:35:08 +0800
committerruki <[email protected]>2023-06-06 23:35:08 +0800
commitbe433ce47536db2b420d9744a19cf02d94ecb9b9 (patch)
treee77af99182d196f59a6dc87d1f23417d19b24216 /xmake/modules/package/tools
parent2a76eb4639af33cac5adf07be29abae34e5614bd (diff)
add toolchain utils
Diffstat (limited to 'xmake/modules/package/tools')
-rw-r--r--xmake/modules/package/tools/cmake.lua13
-rw-r--r--xmake/modules/package/tools/xmake.lua13
2 files changed, 6 insertions, 20 deletions
diff --git a/xmake/modules/package/tools/cmake.lua b/xmake/modules/package/tools/cmake.lua
index 97829c36a..b3d669c51 100644
--- a/xmake/modules/package/tools/cmake.lua
+++ b/xmake/modules/package/tools/cmake.lua
@@ -28,6 +28,7 @@ import("lib.detect.find_file")
import("lib.detect.find_tool")
import("package.tools.ninja")
import("detect.sdks.find_emsdk")
+import("private.utils.toolchain", {alias = "toolchain_utils"})
-- get the number of parallel jobs
function _get_parallel_njobs(opt)
@@ -75,16 +76,8 @@ end
-- is the toolchain compatible with the host?
function _is_toolchain_compatible_with_host(package)
- local toolchains = package:config("toolchains")
- if toolchains then
- toolchains = table.wrap(toolchains)
- if is_host("linux", "macosx", "bsd") then
- for _, name in ipairs(toolchains) do
- if name:startswith("clang") or name:startswith("gcc") then
- return true
- end
- end
- elseif is_host("windows") and table.contains(toolchains, "msvc") then
+ for _, name in ipairs(package:config("toolchains")) do
+ if toolchain_utils.is_compatible_with_host(name) then
return true
end
end
diff --git a/xmake/modules/package/tools/xmake.lua b/xmake/modules/package/tools/xmake.lua
index c138e770e..e253fee16 100644
--- a/xmake/modules/package/tools/xmake.lua
+++ b/xmake/modules/package/tools/xmake.lua
@@ -25,6 +25,7 @@ import("core.tool.toolchain")
import("core.project.project")
import("core.package.repository")
import("private.action.require.impl.package", {alias = "require_package"})
+import("private.utils.toolchain", {alias = "toolchain_utils"})
-- get config from toolchains
function _get_config_from_toolchains(package, name)
@@ -38,16 +39,8 @@ end
-- is the toolchain compatible with the host?
function _is_toolchain_compatible_with_host(package)
- local toolchains = package:config("toolchains")
- if toolchains then
- toolchains = table.wrap(toolchains)
- if is_host("linux", "macosx", "bsd") then
- for _, name in ipairs(toolchains) do
- if name:startswith("clang") or name:startswith("gcc") then
- return true
- end
- end
- elseif is_host("windows") and table.contains(toolchains, "msvc") then
+ for _, name in ipairs(package:config("toolchains")) do
+ if toolchain_utils.is_compatible_with_host(name) then
return true
end
end