diff options
| -rw-r--r-- | xmake/toolchains/clang-cl/load.lua | 15 | ||||
| -rw-r--r-- | xmake/toolchains/msvc/load.lua | 15 |
2 files changed, 24 insertions, 6 deletions
diff --git a/xmake/toolchains/clang-cl/load.lua b/xmake/toolchains/clang-cl/load.lua index 3b0da0e0a..3763b8d2e 100644 --- a/xmake/toolchains/clang-cl/load.lua +++ b/xmake/toolchains/clang-cl/load.lua @@ -24,7 +24,7 @@ import("core.project.config") import("detect.sdks.find_vstudio") -- add the given vs environment -function _add_vsenv(toolchain, name) +function _add_vsenv(toolchain, name, curenvs) -- get vcvars local vcvars = toolchain:config("vcvars") @@ -35,6 +35,14 @@ function _add_vsenv(toolchain, name) -- 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 @@ -57,12 +65,13 @@ function main(toolchain) -- 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) + _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) + _add_vsenv(toolchain, name, curenvs) end end diff --git a/xmake/toolchains/msvc/load.lua b/xmake/toolchains/msvc/load.lua index 51b851c00..90aec06a9 100644 --- a/xmake/toolchains/msvc/load.lua +++ b/xmake/toolchains/msvc/load.lua @@ -24,7 +24,7 @@ import("core.project.config") import("detect.sdks.find_vstudio") -- add the given vs environment -function _add_vsenv(toolchain, name) +function _add_vsenv(toolchain, name, curenvs) -- get vcvars local vcvars = toolchain:config("vcvars") @@ -35,6 +35,14 @@ function _add_vsenv(toolchain, name) -- 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 @@ -61,12 +69,13 @@ function main(toolchain) -- 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) + _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) + _add_vsenv(toolchain, name, curenvs) end end end |
