diff options
| author | ruki <[email protected]> | 2025-09-10 17:34:22 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-09-10 17:34:22 +0800 |
| commit | e47954aadbb5dd06b9a09b31792de72cc01295a4 (patch) | |
| tree | 929feeaeb4d2800937f925e29131cbac7cf9879e /xmake/modules | |
| parent | 73e8fef22ad9381e525962104a60b97e37cdf209 (diff) | |
| parent | c589a45b14063d6f21fcfd1e192ebf360ca6c2b7 (diff) | |
Merge pull request #6787 from xmake-io/msvc
Support for vs2026
Diffstat (limited to 'xmake/modules')
| -rw-r--r-- | xmake/modules/detect/sdks/find_vstudio.lua | 6 | ||||
| -rw-r--r-- | xmake/modules/package/manager/conan/v1/install_package.lua | 12 | ||||
| -rw-r--r-- | xmake/modules/package/tools/cmake.lua | 13 | ||||
| -rw-r--r-- | xmake/modules/private/action/trybuild/cmake.lua | 15 | ||||
| -rw-r--r-- | xmake/modules/private/action/trybuild/msbuild.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/private/utils/toolchain.lua | 15 |
6 files changed, 25 insertions, 38 deletions
diff --git a/xmake/modules/detect/sdks/find_vstudio.lua b/xmake/modules/detect/sdks/find_vstudio.lua index ba81d1993..cf56fcca9 100644 --- a/xmake/modules/detect/sdks/find_vstudio.lua +++ b/xmake/modules/detect/sdks/find_vstudio.lua @@ -56,7 +56,8 @@ local vcvars = {"path", -- init vsvers local vsvers = { - ["17.0"] = "2022" + ["18.0"] = "2026" +, ["17.0"] = "2022" , ["16.0"] = "2019" , ["15.0"] = "2017" , ["14.0"] = "2015" @@ -75,7 +76,8 @@ local vsvers = -- init vsenvs local vsenvs = { - ["17.0"] = "VS170COMNTOOLS" + ["18.0"] = "VS180COMNTOOLS" +, ["17.0"] = "VS170COMNTOOLS" , ["16.0"] = "VS160COMNTOOLS" , ["15.0"] = "VS150COMNTOOLS" , ["14.0"] = "VS140COMNTOOLS" diff --git a/xmake/modules/package/manager/conan/v1/install_package.lua b/xmake/modules/package/manager/conan/v1/install_package.lua index 22bdb0bfd..d96727eb7 100644 --- a/xmake/modules/package/manager/conan/v1/install_package.lua +++ b/xmake/modules/package/manager/conan/v1/install_package.lua @@ -27,6 +27,7 @@ import("core.platform.platform") import("lib.detect.find_tool") import("devel.git") import("net.fasturl") +import("private.utils.toolchain", {alias = "toolchain_utils"}) -- get build env function _conan_get_build_env(name, plat) @@ -197,20 +198,11 @@ function main(conan, name, opt) -- set compiler settings if opt.plat == "windows" then - local vsvers = {["2022"] = "17", - ["2019"] = "16", - ["2017"] = "15", - ["2015"] = "14", - ["2013"] = "12", - ["2012"] = "11", - ["2010"] = "10", - ["2008"] = "9", - ["2005"] = "8"} local vs = assert(config.get("vs"), "vs not found!") table.insert(argv, "-s") table.insert(argv, "compiler=Visual Studio") table.insert(argv, "-s") - table.insert(argv, "compiler.version=" .. assert(vsvers[vs], "unknown msvc version!")) + table.insert(argv, "compiler.version=" .. toolchain_utils.get_vsver(vs)) if configs.runtimes then table.insert(argv, "-s") table.insert(argv, "compiler.runtime=" .. configs.runtimes) diff --git a/xmake/modules/package/tools/cmake.lua b/xmake/modules/package/tools/cmake.lua index 21eed5392..cbf9bcb37 100644 --- a/xmake/modules/package/tools/cmake.lua +++ b/xmake/modules/package/tools/cmake.lua @@ -764,20 +764,9 @@ end -- get cmake generator for msvc function _get_cmake_generator_for_msvc(package) - local vsvers = - { - ["2022"] = "17", - ["2019"] = "16", - ["2017"] = "15", - ["2015"] = "14", - ["2013"] = "12", - ["2012"] = "11", - ["2010"] = "10", - ["2008"] = "9" - } local vs = _get_msvc(package):config("vs") or config.get("vs") assert(vsvers[vs], "Unknown Visual Studio version: '" .. tostring(vs) .. "' set in project.") - return "Visual Studio " .. vsvers[vs] .. " " .. vs + return "Visual Studio " .. toolchain_utils.get_vsver(vs) .. " " .. vs end -- get configs for cmake generator diff --git a/xmake/modules/private/action/trybuild/cmake.lua b/xmake/modules/private/action/trybuild/cmake.lua index 3cf96c7e3..377c9c66e 100644 --- a/xmake/modules/private/action/trybuild/cmake.lua +++ b/xmake/modules/private/action/trybuild/cmake.lua @@ -395,20 +395,9 @@ end -- get cmake generator for msvc function _get_cmake_generator_for_msvc() - local vsvers = - { - ["2022"] = "17", - ["2019"] = "16", - ["2017"] = "15", - ["2015"] = "14", - ["2013"] = "12", - ["2012"] = "11", - ["2010"] = "10", - ["2008"] = "9" - } local vs = _get_msvc():config("vs") or config.get("vs") assert(vsvers[vs], "Unknown Visual Studio version: '" .. tostring(vs) .. "' set in project.") - return "Visual Studio " .. vsvers[vs] .. " " .. vs + return "Visual Studio " .. toolchain_utils.get_vsver(vs) .. " " .. vs end -- get configs for cmake generator @@ -500,7 +489,7 @@ end function _build_for_msvc(opt) local runenvs = _get_msvc_runenvs() local msbuild = find_tool("msbuild", {envs = runenvs}) - local slnfile = assert(find_file("*.sln", os.curdir()), "*.sln file not found!") + local slnfile = assert(find_file("*.sln", os.curdir()) or find_file("*.slnx", os.curdir()), "*.sln/slnx file not found!") os.vexecv(msbuild.program, {slnfile, "-nologo", "-t:Build", "-m", "-p:Configuration=" .. (is_mode("debug") and "Debug" or "Release"), "-p:Platform=" .. _get_vsarch()}, {envs = runenvs}) diff --git a/xmake/modules/private/action/trybuild/msbuild.lua b/xmake/modules/private/action/trybuild/msbuild.lua index 665bbf72c..a2baa9a6d 100644 --- a/xmake/modules/private/action/trybuild/msbuild.lua +++ b/xmake/modules/private/action/trybuild/msbuild.lua @@ -27,7 +27,7 @@ import("lib.detect.find_tool") -- find project file function _find_projectfile() - return find_file("*.sln", os.curdir()) + return find_file("*.sln", os.curdir()) or find_file("*.slnx", os.curdir()) end -- detect build-system and configuration file diff --git a/xmake/modules/private/utils/toolchain.lua b/xmake/modules/private/utils/toolchain.lua index 8fbd5c111..da2e9febf 100644 --- a/xmake/modules/private/utils/toolchain.lua +++ b/xmake/modules/private/utils/toolchain.lua @@ -35,6 +35,21 @@ function is_compatible_with_host(name) end end +-- get vs version +function get_vsver(vs) + local vsvers = {["2026"] = "18", + ["2022"] = "17", + ["2019"] = "16", + ["2017"] = "15", + ["2015"] = "14", + ["2013"] = "12", + ["2012"] = "11", + ["2010"] = "10", + ["2008"] = "9", + ["2005"] = "8"} + return assert(vsvers[vs], "unknown msvc version!") +end + -- get vs toolset version, e.g. v143, v144, .. function get_vs_toolset_ver(vs_toolset) local toolset_ver |
