diff options
| author | ruki <[email protected]> | 2024-05-23 22:59:35 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-05-23 22:59:35 +0800 |
| commit | dc2e263f79ecd7c71662cae167767594a5420689 (patch) | |
| tree | 9d4f0a94c5b233ca82a38b8494e2eea8ef6d4d50 | |
| parent | be0da314e2a706fff2d10ef68588275d2a90e638 (diff) | |
fix icx/ifort envs
| -rw-r--r-- | xmake/toolchains/icx/load.lua | 27 | ||||
| -rw-r--r-- | xmake/toolchains/ifort/load.lua | 27 |
2 files changed, 30 insertions, 24 deletions
diff --git a/xmake/toolchains/icx/load.lua b/xmake/toolchains/icx/load.lua index 74f021c07..f20ca31de 100644 --- a/xmake/toolchains/icx/load.lua +++ b/xmake/toolchains/icx/load.lua @@ -43,12 +43,12 @@ function _add_vsenv(toolchain, name, curenvs) break end end - toolchain:add("runenvs", name, table.unwrap(path.splitenv(new))) + toolchain:add("runenvs", name, table.unpack(path.splitenv(new))) end end -- add the given icx environment -function _add_icxenv(toolchain, name) +function _add_icxenv(toolchain, name, curenvs) -- get icxvarsall local icxvarsall = toolchain:config("varsall") @@ -61,9 +61,17 @@ function _add_icxenv(toolchain, name) local icxenv = icxvarsall[arch] or {} -- get the paths for the icx environment - local env = icxenv[name] - if env then - toolchain:add("runenvs", name:upper(), path.splitenv(env)) + local new = icxvarsall[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.unpack(path.splitenv(new))) end end @@ -93,17 +101,12 @@ function _load_intel_on_windows(toolchain) toolchain:set("toolset", "as", "icx") end - -- add icx environments - _add_icxenv(toolchain, "PATH") - _add_icxenv(toolchain, "LIB") - _add_icxenv(toolchain, "INCLUDE") - _add_icxenv(toolchain, "LIBPATH") - - -- add vs environments + -- add vs/icx environments local expect_vars = {"PATH", "LIB", "INCLUDE", "LIBPATH"} local curenvs = os.getenvs() for _, name in ipairs(expect_vars) do _add_vsenv(toolchain, name, curenvs) + _add_icxenv(toolchain, name, curenvs) end for _, name in ipairs(find_vstudio.get_vcvars()) do if not table.contains(expect_vars, name:upper()) then diff --git a/xmake/toolchains/ifort/load.lua b/xmake/toolchains/ifort/load.lua index d0333ea77..8eb616475 100644 --- a/xmake/toolchains/ifort/load.lua +++ b/xmake/toolchains/ifort/load.lua @@ -43,12 +43,12 @@ function _add_vsenv(toolchain, name, curenvs) break end end - toolchain:add("runenvs", name, table.unwrap(path.splitenv(new))) + toolchain:add("runenvs", name, table.unpack(path.splitenv(new))) end end -- add the given ifort environment -function _add_ifortenv(toolchain, name) +function _add_ifortenv(toolchain, name, curenvs) -- get ifortvarsall local ifortvarsall = toolchain:config("varsall") @@ -61,9 +61,17 @@ function _add_ifortenv(toolchain, name) local ifortenv = ifortvarsall[arch] or {} -- get the paths for the ifort environment - local env = ifortenv[name] - if env then - toolchain:add("runenvs", name:upper(), path.splitenv(env)) + local new = ifortvarsall[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.unpack(path.splitenv(new))) end end @@ -82,17 +90,12 @@ function _load_intel_on_windows(toolchain) toolchain:set("toolset", "fcsh", "ifort.exe") toolchain:set("toolset", "ar", "link.exe") - -- add ifort environments - _add_ifortenv(toolchain, "PATH") - _add_ifortenv(toolchain, "LIB") - _add_ifortenv(toolchain, "INCLUDE") - _add_ifortenv(toolchain, "LIBPATH") - - -- add vs environments + -- add ifort and 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) + _add_ifortenv(toolchain, name, curenvs) end for _, name in ipairs(find_vstudio.get_vcvars()) do if not table.contains(expect_vars, name:upper()) then |
