summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoy Ivy III <[email protected]>2018-10-13 01:23:26 -0500
committerRoy Ivy III <[email protected]>2018-10-14 16:24:36 -0500
commitfe0c464cfdf0498bf6df69a8965931255e94884b (patch)
treea00de4c50a49ab590a1115132e7ae70b1d266c58
parent65f989753d3e3f64dc61bcb37e3725423297bfa7 (diff)
fix detection strategy for MSVC/VS2017+
* fixes the MSVC/VS 2017 detection problem discussed within <https://github.com/tboox/xmake/issues/225> .# Discussion MSVC/VS versions >= 15.0 will no longer be setting registry entries for tool location purposes. But `vswhere` (included with MSVC/VS versions >= 15.2, and placed in a guaranteed location) can instead be used to find the needed path. `os.runv(...)` is used as the tool to gather `vswhere` output instead of `($shell ...)` in order to avoid some `($shell ...)` limitations. Commands containing white space and/or special characters (eg, '[', ')') are difficult or impossible to pass through the current `($shell ...)` implementation, causing application exceptions. Both white space and the noted special characters are needed to construct the required `vswhere` command. ref: <https://github.com/Microsoft/vswhere/blob/master/README.md> @@ <https://archive.is/mEmdu>
-rw-r--r--xmake/modules/detect/sdks/find_vstudio.lua17
1 files changed, 16 insertions, 1 deletions
diff --git a/xmake/modules/detect/sdks/find_vstudio.lua b/xmake/modules/detect/sdks/find_vstudio.lua
index 7cf4dca17..9baf50bc6 100644
--- a/xmake/modules/detect/sdks/find_vstudio.lua
+++ b/xmake/modules/detect/sdks/find_vstudio.lua
@@ -24,6 +24,7 @@
-- imports
import("lib.detect.find_file")
+import("detect.tools.find_vswhere")
-- init vc variables
local vcvars = {"path",
@@ -193,6 +194,19 @@ function main()
local results = {}
for _, version in ipairs({"15.0", "14.0", "12.0", "11.0", "10.0", "9.0", "8.0", "7.1", "7.0", "6.0", "5.0", "4.2"}) do
+ -- find VC install path (and aux build path) using `vswhere` (for version >= 15.0)
+ -- * version > 15.0 eschews registry entries; but `vswhere` (included with version >= 15.2) can be used to find VC install path
+ -- ref: https://github.com/Microsoft/vswhere/blob/master/README.md @@ https://archive.is/mEmdu
+ local vswhere_VCAuxiliaryBuildDir = nil
+ if ((version+0) >= 15) then
+ local vswhere = find_vswhere()
+ if vswhere then
+ local vswhere_vrange = format("%s,%s)", version, (version+1))
+ local out, err = os.iorunv(vswhere, {"-property", "installationpath", "-products", "Microsoft.VisualStudio.Product.BuildTools", "-version", vswhere_vrange})
+ if out then vswhere_VCAuxiliaryBuildDir = out:trim().."\\VC\\Auxiliary\\Build" end
+ end
+ end
+
-- init pathes
local pathes =
{
@@ -201,7 +215,8 @@ function main()
format("$(reg HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\VisualStudio\\SxS\\VS7;%s)\\VC", version),
format("$(reg HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VS7;%s)\\VC\\Auxiliary\\Build", version),
format("$(reg HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\VisualStudio\\SxS\\VS7;%s)\\VC\\Auxiliary\\Build", version),
- format("$(env %s)\\..\\..\\VC", vsenvs[version] or "")
+ format("$(env %s)\\..\\..\\VC", vsenvs[version] or ""),
+ (vswhere_VCAuxiliaryBuildDir or "")
}
-- find vcvarsall.bat, vcvars32.bat for vs7.1