summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-11-25 22:40:55 +0800
committerruki <[email protected]>2024-11-25 22:40:55 +0800
commita650e13a84797e6cba52052981691a6fde1cf980 (patch)
tree1617871b1d664aefa79f945510229bd0d8f3bc30
parent8b3be6b7ffb9c006e013a121de3aaa9e5faa9986 (diff)
improve msvc toolchain for packages
-rw-r--r--tests/projects/package/toolchain_msvc/xmake.lua1
-rw-r--r--xmake/toolchains/clang-cl/check.lua13
-rw-r--r--xmake/toolchains/msvc/check.lua13
3 files changed, 25 insertions, 2 deletions
diff --git a/tests/projects/package/toolchain_msvc/xmake.lua b/tests/projects/package/toolchain_msvc/xmake.lua
index 35f6a0c41..2b1f7b56d 100644
--- a/tests/projects/package/toolchain_msvc/xmake.lua
+++ b/tests/projects/package/toolchain_msvc/xmake.lua
@@ -5,3 +5,4 @@ target("test")
set_kind("binary")
add_files("src/*.c")
set_toolchains("@msvc")
+ --set_toolchains("clang-cl@msvc")
diff --git a/xmake/toolchains/clang-cl/check.lua b/xmake/toolchains/clang-cl/check.lua
index b416a44ce..9f7022482 100644
--- a/xmake/toolchains/clang-cl/check.lua
+++ b/xmake/toolchains/clang-cl/check.lua
@@ -137,7 +137,6 @@ function _check_vc_build_tools(toolchain, sdkdir)
end
end
--- main entry
function main(toolchain)
-- only for windows or linux (msvc-wine)
@@ -154,6 +153,18 @@ function main(toolchain)
if sdkdir then
return _check_vc_build_tools(toolchain, sdkdir)
else
+ -- find it from packages
+ for _, package in ipairs(toolchain:packages()) do
+ local installdir = package:installdir()
+ if installdir and os.isdir(installdir) then
+ local result = _check_vc_build_tools(toolchain, installdir)
+ if result then
+ return result
+ end
+ end
+ end
+
+ -- find it from system
return _check_vstudio(toolchain)
end
end
diff --git a/xmake/toolchains/msvc/check.lua b/xmake/toolchains/msvc/check.lua
index 3c70d43c0..c40d4a202 100644
--- a/xmake/toolchains/msvc/check.lua
+++ b/xmake/toolchains/msvc/check.lua
@@ -128,7 +128,6 @@ function _check_vc_build_tools(toolchain, sdkdir)
end
end
--- main entry
function main(toolchain)
-- only for windows or linux (msvc-wine)
@@ -145,6 +144,18 @@ function main(toolchain)
if sdkdir then
return _check_vc_build_tools(toolchain, sdkdir)
else
+ -- find it from packages
+ for _, package in ipairs(toolchain:packages()) do
+ local installdir = package:installdir()
+ if installdir and os.isdir(installdir) then
+ local result = _check_vc_build_tools(toolchain, installdir)
+ if result then
+ return result
+ end
+ end
+ end
+
+ -- find it from system
return _check_vstudio(toolchain)
end
end