summaryrefslogtreecommitdiff
path: root/xmake/modules/detect
diff options
context:
space:
mode:
authorruki <[email protected]>2021-01-13 15:50:30 +0800
committerGitHub <[email protected]>2021-01-13 15:50:30 +0800
commit8e6b8624edfba6725df0c53c912be158c1900c11 (patch)
treeb92c0d6d544b54799507c64eaa28145bc8072f0a /xmake/modules/detect
parentdc5ca1d6899eae23268dfac0b7ead5051a788aae (diff)
parent3bbc5074add71d4f5d864f6cfe02abb6646ac4ac (diff)
Merge pull request #1195 from xmake-io/unicode
fix msvc and unicode
Diffstat (limited to 'xmake/modules/detect')
-rw-r--r--xmake/modules/detect/sdks/find_vstudio.lua13
1 files changed, 9 insertions, 4 deletions
diff --git a/xmake/modules/detect/sdks/find_vstudio.lua b/xmake/modules/detect/sdks/find_vstudio.lua
index 309b3dd64..d908bcc5a 100644
--- a/xmake/modules/detect/sdks/find_vstudio.lua
+++ b/xmake/modules/detect/sdks/find_vstudio.lua
@@ -43,9 +43,11 @@ function _load_vcvarsall(vcvarsall, vsver, arch, opt)
-- make the genvcvars.bat
opt = opt or {}
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")
+ -- @note we need get utf8 output from cmd.exe
+ -- because some %PATH% and other envs maybe contains unicode characters
+ file:print("chcp 65001")
-- fix error caused by the new vsDevCmd.bat of vs2019
-- @see https://github.com/xmake-io/xmake/issues/549
if vsver and tonumber(vsver) >= 16 then
@@ -57,16 +59,19 @@ function _load_vcvarsall(vcvarsall, vsver, arch, opt)
file:print("call \"%s\" %s %s > nul", vcvarsall, arch, opt.sdkver and opt.sdkver or "")
end
for idx, var in ipairs(vcvars) do
- file:print("echo " .. var .. " = %%" .. var .. "%% %s %s", idx == 1 and ">" or ">>", genvcvars_dat)
+ file:print("echo " .. var .. " = %%" .. var .. "%%")
end
file:close()
-- run genvcvars.bat
- os.run(genvcvars_bat)
+ local outdata = try {function () return os.iorun(genvcvars_bat) end}
+ if not outdata then
+ return
+ end
-- load all envirnoment variables
local variables = {}
- for _, line in ipairs((io.readfile(genvcvars_dat) or ""):split("\n")) do
+ for _, line in ipairs(outdata:split("\n")) do
local p = line:find('=', 1, true)
if p then
local name = line:sub(1, p - 1):trim()