summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author白喵 <[email protected]>2024-07-04 12:37:25 +0800
committer白喵 <[email protected]>2024-07-04 12:37:25 +0800
commitd77ca871e7edc2b5cdfae70f5073dca247d6cc58 (patch)
tree691bab941df019f2caeb6794913bb580598956de
parentc1802f741f225ef32109fa0f8adc396528a18951 (diff)
fix msvc output when toolset less than 8.0
-rw-r--r--xmake/modules/private/tools/vstool.lua16
-rw-r--r--xmake/toolchains/msvc/load.lua13
2 files changed, 27 insertions, 2 deletions
diff --git a/xmake/modules/private/tools/vstool.lua b/xmake/modules/private/tools/vstool.lua
index 97a278d7b..68db4a949 100644
--- a/xmake/modules/private/tools/vstool.lua
+++ b/xmake/modules/private/tools/vstool.lua
@@ -24,6 +24,12 @@ function runv(program, argv, opt)
-- init options
opt = opt or {}
+ -- if has VS_BINARY_OUTPUT dont enable unicode output
+ local envs = opt.envs or {}
+ if envs.VS_BINARY_OUTPUT then
+ return os.runv(program, argv, opt)
+ end
+
-- make temporary output and error file
local outpath = os.tmpfile()
local errpath = os.tmpfile()
@@ -31,7 +37,7 @@ function runv(program, argv, opt)
-- enable unicode output for vs toolchains, e.g. cl.exe, link.exe and etc.
-- @see https://github.com/xmake-io/xmake/issues/528
- opt.envs = table.join(opt.envs or {}, {VS_UNICODE_OUTPUT = outfile:rawfd()})
+ opt.envs = table.join(envs, {VS_UNICODE_OUTPUT = outfile:rawfd()})
-- execute it
local ok, syserrors = os.execv(program, argv, table.join(opt, {try = true, stdout = outfile, stderr = errpath}))
@@ -85,6 +91,12 @@ function iorunv(program, argv, opt)
-- init options
opt = opt or {}
+
+ -- if has VS_BINARY_OUTPUT dont enable unicode output
+ local envs = opt.envs or {}
+ if envs.VS_BINARY_OUTPUT then
+ return os.runv(program, argv, opt)
+ end
-- make temporary output and error file
local outpath = os.tmpfile()
@@ -93,7 +105,7 @@ function iorunv(program, argv, opt)
-- enable unicode output for vs toolchains, e.g. cl.exe, link.exe and etc.
-- @see https://github.com/xmake-io/xmake/issues/528
- opt.envs = table.join(opt.envs or {}, {VS_UNICODE_OUTPUT = outfile:rawfd()})
+ opt.envs = table.join(envs, {VS_UNICODE_OUTPUT = outfile:rawfd()})
-- run command
local ok, syserrors = os.execv(program, argv, table.join(opt, {try = true, stdout = outfile, stderr = errpath}))
diff --git a/xmake/toolchains/msvc/load.lua b/xmake/toolchains/msvc/load.lua
index 90aec06a9..b49541ed0 100644
--- a/xmake/toolchains/msvc/load.lua
+++ b/xmake/toolchains/msvc/load.lua
@@ -78,5 +78,18 @@ function main(toolchain)
_add_vsenv(toolchain, name, curenvs)
end
end
+
+ -- check and add vs_binary_output env
+ local vs_binary = {
+ ["2003"] = true,
+ ["7.0"] = true,
+ ["6.0"] = true,
+ ["5.0"] = true,
+ ["4.2"] = true
+ }
+ local vs = toolchain:config("vs")
+ if vs and vs_binary[vs] then
+ toolchain:add("runenvs", "VS_BINARY_OUTPUT", "1")
+ end
end