diff options
| author | ruki <[email protected]> | 2020-05-27 00:50:35 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-05-26 23:03:31 +0800 |
| commit | 7690eaf09fd10101d67c10f8fdbf3fc0f02992fe (patch) | |
| tree | b7efd5d07e96ae89790fff71b26bc491b31aa8e7 /xmake/core/base/winos.lua | |
| parent | 8711cc579bc5519f400e25d09cee8d79f0e454bf (diff) | |
add winos.cmdargv
Diffstat (limited to 'xmake/core/base/winos.lua')
| -rw-r--r-- | xmake/core/base/winos.lua | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/xmake/core/base/winos.lua b/xmake/core/base/winos.lua index 22ffb5040..5841f5a6c 100644 --- a/xmake/core/base/winos.lua +++ b/xmake/core/base/winos.lua @@ -25,7 +25,6 @@ local winos = winos or {} local os = require("base/os") local semver = require("base/semver") - winos._ansi_cp = winos._ansi_cp or winos.ansi_cp winos._oem_cp = winos._oem_cp or winos.oem_cp @@ -148,10 +147,35 @@ function winos.version() -- save to cache winos._VERSION = winver or false - - -- done return winver end +-- get command arguments on windows to solve 8192 character command line length limit +function winos.cmdargv(argv, key) + + -- too long arguments? + local argn = 0 + for _, arg in ipairs(argv) do + argn = argn + #arg + if argn > 1024 then + break + end + end + if argn > 1024 then + local argsfile = os.tmpfile(key or table.concat(argv, '')) .. ".args.txt" + local f = io.open(argsfile, 'w') + 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") + end + f:close() + end + argv = {"@" .. argsfile} + end + return argv +end + -- return module: winos return winos |
