diff options
| author | ruki <[email protected]> | 2018-10-20 09:32:43 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2018-10-20 09:32:43 +0800 |
| commit | 783cc8c25729b2ed9a5dd9f928dcdbf4e0eda6bd (patch) | |
| tree | 79e055d584fd126bd0a987bdc29410a985fe5ab6 | |
| parent | a99a556f6ffe6ec70bee3c3444313198e93c32a0 (diff) | |
add vs_toolset option
| -rw-r--r-- | xmake/modules/detect/sdks/find_vstudio.lua | 23 | ||||
| -rw-r--r-- | xmake/platforms/windows/check.lua | 4 | ||||
| -rw-r--r-- | xmake/platforms/windows/xmake.lua | 54 |
3 files changed, 46 insertions, 35 deletions
diff --git a/xmake/modules/detect/sdks/find_vstudio.lua b/xmake/modules/detect/sdks/find_vstudio.lua index 5d1689c36..3f375feac 100644 --- a/xmake/modules/detect/sdks/find_vstudio.lua +++ b/xmake/modules/detect/sdks/find_vstudio.lua @@ -42,14 +42,18 @@ local vcvars = {"path", "UCRTVersion"} -- load vcvarsall environment variables -function _load_vcvarsall(vcvarsall, arch) +function _load_vcvarsall(vcvarsall, arch, vcvars_ver) -- make the genvcvars.bat local genvcvars_bat = os.tmpfile() .. "_genvcvars.bat" local genvcvars_dat = os.tmpfile() .. "_genvcvars.txt" local file = io.open(genvcvars_bat, "w") file:print("@echo off") - file:print("call \"%s\" %s > nul", vcvarsall, arch) + if vcvars_ver then + file:print("call \"%s\" %s -vcvars_ver=%s > nul", vcvarsall, arch, vcvars_ver) + else + file:print("call \"%s\" %s > nul", vcvarsall, arch) + end for idx, var in ipairs(vcvars) do file:print("echo " .. var .. " = %%" .. var .. "%% %s %s", idx == 1 and ">" or ">>", genvcvars_dat) end @@ -114,10 +118,12 @@ end -- find vstudio environment -- +-- @param opt the options, .e.g {vcvars_ver = 14.0} +-- -- @return { 2008 = {version = "9.0", vcvarsall = {x86 = {path = .., lib = .., include = ..}}} -- , 2017 = {version = "15.0", vcvarsall = {x64 = {path = .., lib = ..}}}} -- -function main() +function main(opt) -- init vsvers local vsvers = @@ -152,6 +158,9 @@ function main() , ["4.2"] = "VS42COMNTOOLS" } + -- init options + opt = opt or {} + -- find the single current MSVC/VS from environment variables local VCInstallDir = os.getenv("VCInstallDir") if VCInstallDir and (VCInstallDir ~= "") then @@ -194,8 +203,8 @@ function main() if os.isfile(vcvarsall) then -- load vcvarsall - local vcvarsall_x86 = _load_vcvarsall(vcvarsall, "x86") - local vcvarsall_x64 = _load_vcvarsall(vcvarsall, "x64") + local vcvarsall_x86 = _load_vcvarsall(vcvarsall, "x86", opt.vcvars_ver) + local vcvarsall_x64 = _load_vcvarsall(vcvarsall, "x64", opt.vcvars_ver) -- save results local results = {} @@ -244,8 +253,8 @@ function main() if vcvarsall then -- load vcvarsall - local vcvarsall_x86 = _load_vcvarsall(vcvarsall, "x86") - local vcvarsall_x64 = _load_vcvarsall(vcvarsall, "x64") + local vcvarsall_x86 = _load_vcvarsall(vcvarsall, "x86", opt.vcvars_ver) + local vcvarsall_x64 = _load_vcvarsall(vcvarsall, "x64", opt.vcvars_ver) -- save results results[vsvers[version]] = {version = version, vcvarsall_bat = vcvarsall, vcvarsall = {x86 = vcvarsall_x86, x64 = vcvarsall_x64}} diff --git a/xmake/platforms/windows/check.lua b/xmake/platforms/windows/check.lua index dccb9a30f..34c8f004f 100644 --- a/xmake/platforms/windows/check.lua +++ b/xmake/platforms/windows/check.lua @@ -39,7 +39,7 @@ function _check_vsenv(config) end -- find vstudio - local vstudio = find_vstudio() + local vstudio = find_vstudio({vcvars_ver = config.get("vs_toolset")}) if vstudio then -- make order vsver @@ -105,7 +105,7 @@ function _check_vs(config) -- failed print("checking for the Microsoft Visual Studio (%s) version ... no", config.get("arch")) print("please run:") - print(" - xmake config --vs=xxx") + print(" - xmake config --vs=xxx [--vs_toolset=xxx]") print("or - xmake global --vs=xxx") raise() end diff --git a/xmake/platforms/windows/xmake.lua b/xmake/platforms/windows/xmake.lua index 77d142b0a..7d28792fa 100644 --- a/xmake/platforms/windows/xmake.lua +++ b/xmake/platforms/windows/xmake.lua @@ -84,35 +84,37 @@ platform("windows") set_menu { config = { - {category = "Visual Studio SDK Configuration" } - , {nil, "vs", "kv", "auto", "The Microsoft Visual Studio" } - , {category = "Cuda SDK Configuration" } - , {nil, "cuda", "kv", "auto", "The Cuda SDK Directory" } - , {category = "Qt SDK Configuration" } - , {nil, "qt", "kv", "auto", "The Qt SDK Directory" } - , {nil, "qt_sdkver", "kv", "auto", "The Qt SDK Version" } - , {category = "WDK Configuration" } - , {nil, "wdk", "kv", "auto", "The WDK Directory" } - , {nil, "wdk_sdkver","kv", "auto", "The WDK Version" } - , {nil, "wdk_winver","kv", "auto", "The WDK Windows Version", - " - win10_rs3", - " - win10", - " - win81", - " - win8", - " - win7", - " - win7_[sp1|sp2|sp3]" } - , {category = "Vcpkg Configuration" } - , {nil, "vcpkg", "kv", "auto", "The Vcpkg Directory" } + {category = "Visual Studio SDK Configuration" } + , {nil, "vs", "kv", "auto", "The Microsoft Visual Studio" } + , {nil, "vs_toolset", "kv", nil, "The Microsoft Visual Studio Toolset Version" + , " .e.g --vs_toolset=14.0" } + , {category = "Cuda SDK Configuration" } + , {nil, "cuda", "kv", "auto", "The Cuda SDK Directory" } + , {category = "Qt SDK Configuration" } + , {nil, "qt", "kv", "auto", "The Qt SDK Directory" } + , {nil, "qt_sdkver", "kv", "auto", "The Qt SDK Version" } + , {category = "WDK Configuration" } + , {nil, "wdk", "kv", "auto", "The WDK Directory" } + , {nil, "wdk_sdkver", "kv", "auto", "The WDK Version" } + , {nil, "wdk_winver", "kv", "auto", "The WDK Windows Version", + " - win10_rs3", + " - win10", + " - win81", + " - win8", + " - win7", + " - win7_[sp1|sp2|sp3]" } + , {category = "Vcpkg Configuration" } + , {nil, "vcpkg", "kv", "auto", "The Vcpkg Directory" } } - , global = + , global = { - { } - , {nil, "vs", "kv", "auto", "The Microsoft Visual Studio" } - , {nil, "cuda", "kv", "auto", "The Cuda SDK Directory" } - , {nil, "qt", "kv", "auto", "The Qt SDK Directory" } - , {nil, "wdk", "kv", "auto", "The WDK Directory" } - , {nil, "vcpkg", "kv", "auto", "The Vcpkg Directory" } + { } + , {nil, "vs", "kv", "auto", "The Microsoft Visual Studio" } + , {nil, "cuda", "kv", "auto", "The Cuda SDK Directory" } + , {nil, "qt", "kv", "auto", "The Qt SDK Directory" } + , {nil, "wdk", "kv", "auto", "The WDK Directory" } + , {nil, "vcpkg", "kv", "auto", "The Vcpkg Directory" } } } |
