diff options
| author | ruki <[email protected]> | 2022-05-15 00:10:26 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-05-15 00:10:26 +0800 |
| commit | 129b240a59eb5ecdb5b5288c03997a7eb07aa47b (patch) | |
| tree | 52bdad90096290815c4e3fae6276389f4b1b2e76 | |
| parent | 9a10308a41d9e1b03e0b5249058e839d6920aa91 (diff) | |
send empty data
| -rw-r--r-- | xmake/modules/private/service/distcc_build/client_session.lua | 14 | ||||
| -rw-r--r-- | xmake/modules/private/service/distcc_build/server_session.lua | 14 | ||||
| -rw-r--r-- | xmake/modules/private/service/stream.lua | 5 |
3 files changed, 24 insertions, 9 deletions
diff --git a/xmake/modules/private/service/distcc_build/client_session.lua b/xmake/modules/private/service/distcc_build/client_session.lua index bcd9d04de..01aaf8b6f 100644 --- a/xmake/modules/private/service/distcc_build/client_session.lua +++ b/xmake/modules/private/service/distcc_build/client_session.lua @@ -120,12 +120,14 @@ function client_session:_gcc_iorunv(program, argv, opt) local stream = self:stream() if stream:send_msg(message.new_compile(self:id(), opt.toolname, flags, path.filename(sourcefile), {token = self:token()})) and stream:send_file(cppfile, {compress = os.filesize(cppfile) > 4096}) and stream:flush() then - local msg = stream:recv_msg() - if msg then - if msg:success() and stream:recv_file(objectfile) then - ok = true - else - errors = msg:errors() + if stream:recv_file(objectfile) then + local msg = stream:recv_msg() + if msg then + if msg:success() then + ok = true + else + errors = msg:errors() + end end end end diff --git a/xmake/modules/private/service/distcc_build/server_session.lua b/xmake/modules/private/service/distcc_build/server_session.lua index 912e807fa..6347393e4 100644 --- a/xmake/modules/private/service/distcc_build/server_session.lua +++ b/xmake/modules/private/service/distcc_build/server_session.lua @@ -87,14 +87,22 @@ function server_session:compile(respmsg) local sourcename = respmsg.sourcename local sourcedir = path.join(self:workdir(), (hash.uuid4():gsub("-", ""))) local sourcefile = path.join(sourcedir, sourcename) + local objectfile = sourcefile .. ".o" if not stream:recv_file(sourcefile) then raise("recv %s failed!", sourcename) end - print("recv %s", sourcefile) + -- do compile + -- TODO - -- remove source files - os.rm(sourcefile) + -- send object file + if not stream:send_emptydata() then + raise("send %s failed!", objectfile) + end + + -- remove files + os.tryrm(sourcefile) + os.tryrm(objectfile) end -- set stream diff --git a/xmake/modules/private/service/stream.lua b/xmake/modules/private/service/stream.lua index cfbb4ed87..095c773c4 100644 --- a/xmake/modules/private/service/stream.lua +++ b/xmake/modules/private/service/stream.lua @@ -160,6 +160,11 @@ function stream:send_string(str, opt) return self:send_data(bytes(str), opt) end +-- send empty data +function stream:send_emptydata(opt) + return self:send_header(0) +end + -- send file function stream:send_file(filepath, opt) |
