diff options
| author | ruki <[email protected]> | 2018-05-19 00:46:16 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2018-05-18 22:37:36 +0800 |
| commit | 90008609b8044bd4f600c9cc11e792b1eb4c03e5 (patch) | |
| tree | 0cac18a49ce69826331f38822d32c53001fb43e8 /xmake/core/base/os.lua | |
| parent | 344d26e6176003b72e8af45ff9202b2f7d11d3dc (diff) | |
improve command arguments
Diffstat (limited to 'xmake/core/base/os.lua')
| -rw-r--r-- | xmake/core/base/os.lua | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua index 71a6119f6..e5377820f 100644 --- a/xmake/core/base/os.lua +++ b/xmake/core/base/os.lua @@ -501,8 +501,8 @@ function os.tmpdir() end -- generate the temporary file path -function os.tmpfile() - return path.join(os.tmpdir(), "_" .. (hash.uuid():gsub("-", ""))) +function os.tmpfile(key) + return path.join(os.tmpdir(), "_" .. (hash.uuid(key):gsub("-", ""))) end -- run command @@ -583,8 +583,19 @@ function os.execv(program, argv, opt) wildcards = true end - -- init arguments - local args = wildcards and os.argw(argv) or argv + -- translate arguments for wildcards + argv = wildcards and os.argw(argv) or argv + + -- too long arguments for windows? + local argsfile = nil + if os.host() == "windows" then + local args = os.args(argv) + if #args > 256 then + argsfile = os.tmpfile(args) .. ".args.txt" + io.writefile(argsfile, args) + argv = {"@" .. argsfile} + end + end -- is not executable program file? local filename = program @@ -594,13 +605,13 @@ function os.execv(program, argv, opt) local splitinfo = program:split("%s") filename = splitinfo[1] if #splitinfo > 1 then - args = table.join(table.slice(splitinfo, 2), args) + argv = table.join(table.slice(splitinfo, 2), argv) end end -- open command local ok = -1 - local proc = process.openv(filename, args, opt.stdout, opt.stderr) + local proc = process.openv(filename, argv, opt.stdout, opt.stderr) if proc ~= nil then -- wait process @@ -635,6 +646,11 @@ function os.execv(program, argv, opt) process.close(proc) end + -- remove arguments file + if argsfile and os.isfile(argsfile) then + os.rm(argsfile) + end + -- ok? return ok end |
