diff options
| author | ruki <[email protected]> | 2024-07-04 15:23:04 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-07-04 15:23:04 +0800 |
| commit | 4ddedfff88911667afbf491854921ed532f53167 (patch) | |
| tree | 6b4c61846b1e81d6341ada047cdb705a8c7db8d7 | |
| parent | 0bf2063be116379a675551e81129c0a6e7d48168 (diff) | |
| parent | a2558e300b831c9c933939505041b65973c7b0df (diff) | |
Merge pull request #5303 from ChrisCatCP/vs_unicode
fix msvc output when toolset less than 8.0
| -rw-r--r-- | xmake/modules/private/tools/vstool.lua | 16 | ||||
| -rw-r--r-- | xmake/toolchains/msvc/load.lua | 7 |
2 files changed, 21 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..486c8e217 100644 --- a/xmake/toolchains/msvc/load.lua +++ b/xmake/toolchains/msvc/load.lua @@ -20,6 +20,7 @@ -- imports import("core.base.option") +import("core.base.semver") import("core.project.config") import("detect.sdks.find_vstudio") @@ -78,5 +79,11 @@ function main(toolchain) _add_vsenv(toolchain, name, curenvs) end end + + -- check and add vs_binary_output env + local vs = toolchain:config("vs") + if vs and semver.is_valid(vs) and semver.compare(vs, "2005") < 0 then + toolchain:add("runenvs", "VS_BINARY_OUTPUT", "1") + end end |
