diff options
| author | ruki <[email protected]> | 2020-03-19 23:27:06 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-03-19 14:42:38 +0800 |
| commit | 873f5c6486e24ce9809f7251ea3507699af6855c (patch) | |
| tree | 3f227538055857b6363e112cb9522cd1f8a344df | |
| parent | 796e85b52bd46a7b9faf2fcd1f8f50549fc1ec60 (diff) | |
fix vstool
| -rw-r--r-- | xmake/core/sandbox/modules/os.lua | 6 | ||||
| -rw-r--r-- | xmake/modules/private/tools/vstool.lua | 32 |
2 files changed, 28 insertions, 10 deletions
diff --git a/xmake/core/sandbox/modules/os.lua b/xmake/core/sandbox/modules/os.lua index 21c29c7ff..0436eced3 100644 --- a/xmake/core/sandbox/modules/os.lua +++ b/xmake/core/sandbox/modules/os.lua @@ -383,7 +383,9 @@ function sandbox_os.execv(program, argv, opt) end os.raise(errors) end - return ok + + -- we need return results if opt.try is enabled + return ok, errors end -- execute command and echo verbose info if [-v|--verbose] option is enabled @@ -407,7 +409,7 @@ function sandbox_os.vexecv(program, argv, opt) end -- run it - sandbox_os.execv(program, argv, opt) + return sandbox_os.execv(program, argv, opt) end -- match files or directories diff --git a/xmake/modules/private/tools/vstool.lua b/xmake/modules/private/tools/vstool.lua index fc1217a65..7b124c5e7 100644 --- a/xmake/modules/private/tools/vstool.lua +++ b/xmake/modules/private/tools/vstool.lua @@ -34,7 +34,7 @@ function runv(program, argv, opt) local envs = {VS_UNICODE_OUTPUT = outfile:rawfd()} -- execute it - local ok = os.execv(program, argv, table.join(opt, {try = true, stdout = outfile, stderr = errpath, envs = envs})) + local ok, syserrors = os.execv(program, argv, table.join(opt, {try = true, stdout = outfile, stderr = errpath, envs = envs})) -- close outfile first outfile:close() @@ -52,10 +52,18 @@ function runv(program, argv, opt) -- make the default errors if not errors or #errors == 0 then - if argv ~= nil then - errors = string.format("vstool.runv(%s %s) failed(%d)!", program, table.concat(argv, ' '), ok) + + -- get command + local cmd = program + if argv then + cmd = cmd .. " " .. os.args(argv) + end + + -- get errors + if ok ~= nil then + errors = string.format("vstool.runv(%s) failed(%d)", cmd, ok) else - errors = string.format("vstool.runv(%s) failed(%d)!", program, ok) + errors = string.format("vstool.runv(%s), error: %s", cmd, syserrors and syserrors or "unknown") end end @@ -88,7 +96,7 @@ function iorunv(program, argv, opt) local envs = {VS_UNICODE_OUTPUT = outfile:rawfd()} -- run command - local ok = os.execv(program, argv, table.join(opt, {try = true, stdout = outfile, stderr = errpath, envs = envs})) + local ok, syserrors = os.execv(program, argv, table.join(opt, {try = true, stdout = outfile, stderr = errpath, envs = envs})) -- get output and error data outfile:close() @@ -110,10 +118,18 @@ function iorunv(program, argv, opt) -- make the default errors if not errors or #errors == 0 then - if argv ~= nil then - errors = string.format("vstool.iorunv(%s %s) failed(%d)!", program, table.concat(argv, ' '), ok) + + -- get command + local cmd = program + if argv then + cmd = cmd .. " " .. os.args(argv) + end + + -- get errors + if ok ~= nil then + errors = string.format("vstool.iorunv(%s) failed(%d)", cmd, ok) else - errors = string.format("vstool.iorunv(%s) failed(%d)!", program, ok) + errors = string.format("vstool.iorunv(%s), error: %s", cmd, syserrors and syserrors or "unknown") end end |
