diff options
| author | ruki <[email protected]> | 2024-11-25 22:40:55 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-11-25 22:40:55 +0800 |
| commit | a650e13a84797e6cba52052981691a6fde1cf980 (patch) | |
| tree | 1617871b1d664aefa79f945510229bd0d8f3bc30 | |
| parent | 8b3be6b7ffb9c006e013a121de3aaa9e5faa9986 (diff) | |
improve msvc toolchain for packages
| -rw-r--r-- | tests/projects/package/toolchain_msvc/xmake.lua | 1 | ||||
| -rw-r--r-- | xmake/toolchains/clang-cl/check.lua | 13 | ||||
| -rw-r--r-- | xmake/toolchains/msvc/check.lua | 13 |
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 |
