summaryrefslogtreecommitdiff
path: root/xmake/toolchains/msvc/load.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2025-12-20 00:45:39 +0800
committerruki <[email protected]>2025-12-20 00:45:39 +0800
commitd3ded5d78ea15d2f2299cab3d03165ab8d07951b (patch)
treeebb675e7d9ef99a69294f024bea24ba22ac33cf6 /xmake/toolchains/msvc/load.lua
parentb89cfa3d77e20ddf8da83423052eba23f64d8777 (diff)
add vsenvs in toolchain utils
Diffstat (limited to 'xmake/toolchains/msvc/load.lua')
-rw-r--r--xmake/toolchains/msvc/load.lua37
1 files changed, 2 insertions, 35 deletions
diff --git a/xmake/toolchains/msvc/load.lua b/xmake/toolchains/msvc/load.lua
index 4f6aab45d..c606a0edc 100644
--- a/xmake/toolchains/msvc/load.lua
+++ b/xmake/toolchains/msvc/load.lua
@@ -22,31 +22,7 @@
import("core.base.option")
import("core.base.semver")
import("core.project.config")
-import("detect.sdks.find_vstudio")
-
--- add the given vs environment
-function _add_vsenv(toolchain, name, curenvs)
-
- -- get vcvars
- local vcvars = toolchain:config("vcvars")
- if not vcvars then
- return
- end
-
- -- get the paths for the vs environment
- local new = vcvars[name]
- if new then
- -- fix case naming conflict for cmake/msbuild between the new msvc envs and current environment, if we are running xmake in vs prompt.
- -- @see https://github.com/xmake-io/xmake/issues/4751
- for k, c in pairs(curenvs) do
- if name:lower() == k:lower() and name ~= k then
- name = k
- break
- end
- end
- toolchain:add("runenvs", name, table.unwrap(path.splitenv(new)))
- end
-end
+import("private.utils.toolchain", {alias = "toolchain_utils"})
-- main entry
function main(toolchain)
@@ -74,16 +50,7 @@ function main(toolchain)
end
-- add vs environments
- local expect_vars = {"PATH", "LIB", "INCLUDE", "LIBPATH"}
- local curenvs = os.getenvs()
- for _, name in ipairs(expect_vars) do
- _add_vsenv(toolchain, name, curenvs)
- end
- for _, name in ipairs(find_vstudio.get_vcvars()) do
- if not table.contains(expect_vars, name:upper()) then
- _add_vsenv(toolchain, name, curenvs)
- end
- end
+ toolchain_utils.add_vsenvs(toolchain)
-- check and add vs_binary_output env
local vs = toolchain:config("vs")