diff options
| author | ruki <[email protected]> | 2022-04-14 23:09:14 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-04-14 23:09:14 +0800 |
| commit | 5bcfeceab31c4b922cc44fb47d02f9cbc3ee161e (patch) | |
| tree | 77753b5cba8281825665b71b38f46305782a8e4f | |
| parent | caa80ac181303850ee88d6ffd653f5acb34122de (diff) | |
improve to print output
| -rw-r--r-- | xmake/modules/private/service/remote_build/client.lua | 13 | ||||
| -rw-r--r-- | xmake/modules/private/service/remote_build/session.lua | 11 |
2 files changed, 21 insertions, 3 deletions
diff --git a/xmake/modules/private/service/remote_build/client.lua b/xmake/modules/private/service/remote_build/client.lua index 02ed18ffa..d1121a028 100644 --- a/xmake/modules/private/service/remote_build/client.lua +++ b/xmake/modules/private/service/remote_build/client.lua @@ -225,6 +225,7 @@ function remote_build_client:runcmd(program, argv) local ok = false local buff = bytes(8192) local command = os.args(table.join(program, argv)) + local leftstr = "" cprint("%s: run ${bright}%s${clear} in %s:%d ..", self, command, addr, port) if sock then local stream = socket_stream(sock) @@ -235,13 +236,17 @@ function remote_build_client:runcmd(program, argv) if msg:is_data() then local data = stream:recv(buff, msg:body().size) if data then - utils.cprintf(data:str()) + leftstr = leftstr .. data:str() + local pos = leftstr:lastof("\n", true) + if pos then + cprint(leftstr:sub(1, pos - 1)) + leftstr = leftstr:sub(pos + 1) + end else errors = string.format("recv output data(%d) failed!", msg:body().size) break end else - vprint(msg:body()) if msg:success() then ok = true else @@ -255,11 +260,15 @@ function remote_build_client:runcmd(program, argv) end end end + if #leftstr > 0 then + cprint(leftstr) + end if ok then print("%s: run command ok!", self) else print("%s: run command failed in %s:%d, %s", self, addr, port, errors or "unknown") end + io.flush() end -- is connected? diff --git a/xmake/modules/private/service/remote_build/session.lua b/xmake/modules/private/service/remote_build/session.lua index 0502759d5..561acbb82 100644 --- a/xmake/modules/private/service/remote_build/session.lua +++ b/xmake/modules/private/service/remote_build/session.lua @@ -141,11 +141,17 @@ function session:_read_pipe(opt) local rpipe = opt.rpipe local verbose = option.get("verbose") vprint("%s: %s: reading data ..", self, rpipe) + local leftstr = "" while not opt.stop do local real, data = rpipe:read(buff) if real > 0 then if verbose then - utils.printf(data:str()) + leftstr = leftstr .. data:str() + local pos = leftstr:lastof("\n", true) + if pos then + cprint(leftstr:sub(1, pos - 1)) + leftstr = leftstr:sub(pos + 1) + end end if not self:_send_data(data) then break; @@ -159,6 +165,9 @@ function session:_read_pipe(opt) end end rpipe:close() + if #leftstr > 0 then + cprint(leftstr) + end vprint("%s: %s read data end", self, rpipe) end |
