summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2021-01-27 23:17:13 +0800
committerruki <[email protected]>2021-01-27 23:17:13 +0800
commit0d06846a572219abb13a6454600bcb802b9b7076 (patch)
tree0fad40f10ea31189933a76b72538e566c2be3406
parentabaaa6c248d7b0a92a289e00b76d5da53802cd2b (diff)
improve winos.cmdargv
-rw-r--r--xmake/core/base/winos.lua22
1 files changed, 20 insertions, 2 deletions
diff --git a/xmake/core/base/winos.lua b/xmake/core/base/winos.lua
index 5e64d200f..4a18d19ee 100644
--- a/xmake/core/base/winos.lua
+++ b/xmake/core/base/winos.lua
@@ -172,8 +172,26 @@ function winos.cmdargv(argv, key)
if f then
-- we need split args file to solve `fatal error LNK1170: line in command file contains 131071 or more characters`
-- @see https://github.com/xmake-io/xmake/issues/812
- for _, arg in ipairs(argv) do
- f:write(os.args(arg, {escape = true}) .. "\n")
+ local idx = 1
+ while idx <= #argv do
+ arg = argv[idx]
+ -- we need ensure `/name value` in same line,
+ -- otherwise cl.exe will prompt that the corresponding parameter value cannot be found
+ --
+ -- e.g.
+ --
+ -- /sourceDependencies xxxx.json
+ -- -Dxxx
+ -- foo.obj
+ --
+ if idx + 1 <= #argv and arg:find("^[-/]") and not argv[idx + 1]:find("^[-/]") then
+ f:write(os.args(arg) .. " ")
+ f:write(os.args(argv[idx + 1]) .. "\n")
+ idx = idx + 2
+ else
+ f:write(os.args(arg) .. "\n")
+ idx = idx + 1
+ end
end
f:close()
end