diff options
| author | ruki <[email protected]> | 2022-06-19 22:37:52 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-06-19 22:37:52 +0800 |
| commit | eb965315b1030cc2de426909500d34f99d281943 (patch) | |
| tree | 98f7783e18f3c58d118e86f766636d7e2c0ecb8c /xmake/modules | |
| parent | ec26291e8e26310e8e5d57e2c39fbabeaeff8c22 (diff) | |
get outdata/errdata from distcc
Diffstat (limited to 'xmake/modules')
3 files changed, 35 insertions, 5 deletions
diff --git a/xmake/modules/private/service/distcc_build/client.lua b/xmake/modules/private/service/distcc_build/client.lua index eec99a14c..7d3aed752 100644 --- a/xmake/modules/private/service/distcc_build/client.lua +++ b/xmake/modules/private/service/distcc_build/client.lua @@ -261,8 +261,10 @@ function distcc_build_client:compile(program, argv, opt) local compile_fallback = opt.compile_fallback if compile_fallback then local ok = try {function () - session:compile(cppinfo.sourcefile, cppinfo.objectfile, cppinfo.cppfile, cppinfo.cppflags, + local outdata, errdata = session:compile(cppinfo.sourcefile, cppinfo.objectfile, cppinfo.cppfile, cppinfo.cppflags, table.join(opt, {cachekey = cachekey})) + cppinfo.outdata = outdata + cppinfo.errdata = errdata return true end} if not ok then @@ -273,8 +275,10 @@ function distcc_build_client:compile(program, argv, opt) cppinfo.errdata = errdata end else - session:compile(cppinfo.sourcefile, cppinfo.objectfile, cppinfo.cppfile, cppinfo.cppflags, + local outdata, errdata = session:compile(cppinfo.sourcefile, cppinfo.objectfile, cppinfo.cppfile, cppinfo.cppflags, table.join(opt, {cachekey = cachekey})) + cppinfo.outdata = outdata + cppinfo.errdata = errdata end if cachekey then local extrainfo diff --git a/xmake/modules/private/service/distcc_build/client_session.lua b/xmake/modules/private/service/distcc_build/client_session.lua index 45c3de6cb..c3a24f075 100644 --- a/xmake/modules/private/service/distcc_build/client_session.lua +++ b/xmake/modules/private/service/distcc_build/client_session.lua @@ -100,6 +100,7 @@ function client_session:compile(sourcefile, objectfile, cppfile, cppflags, opt) local cachekey = opt.cachekey local toolchain = tool:toolchain():name() local stream = self:stream() + local outdata, errdata if stream:send_msg(message.new_compile(self:id(), toolname, toolkind, plat, arch, toolchain, cppflags, path.filename(sourcefile), {token = self:token(), cachekey = cachekey})) and stream:send_file(cppfile, {compress = os.filesize(cppfile) > 4096}) and stream:flush() then @@ -108,6 +109,9 @@ function client_session:compile(sourcefile, objectfile, cppfile, cppflags, opt) local msg = stream:recv_msg() if msg then if msg:success() then + local body = msg:body() + outdata = body.outdata + errdata = body.errdata ok = true else errors = msg:errors() @@ -119,6 +123,7 @@ function client_session:compile(sourcefile, objectfile, cppfile, cppflags, opt) end os.tryrm(cppfile) assert(ok, errors or "unknown errors!") + return outdata, errdata end -- get work directory diff --git a/xmake/modules/private/service/distcc_build/server_session.lua b/xmake/modules/private/service/distcc_build/server_session.lua index 3680d9306..39fa0cd0f 100644 --- a/xmake/modules/private/service/distcc_build/server_session.lua +++ b/xmake/modules/private/service/distcc_build/server_session.lua @@ -101,6 +101,7 @@ function server_session:compile(respmsg) local sourcedir = path.join(self:buildir(), (hash.uuid4():gsub("-", ""))) local sourcefile = path.join(sourcedir, sourcename) local objectfile = (cachekey and path.join(self:cachedir(), cachekey:sub(1, 2), cachekey) or sourcefile) .. ".o" + local objectfile_infofile = objectfile .. ".txt" if not stream:recv_file(sourcefile) then raise("recv %s failed!", sourcename) end @@ -108,6 +109,7 @@ function server_session:compile(respmsg) -- do compile local errors local ok + local outdata, errdata if not (cachekey and os.isfile(objectfile)) then -- no cached object file? ok = try { @@ -119,7 +121,19 @@ function server_session:compile(respmsg) if not os.isdir(objectdir) then os.mkdir(objectdir) end - compile(self, toolname, flags, sourcefile, objectfile, body) + outdata, errdata = compile(self, toolname, flags, sourcefile, objectfile, body) + local extrainfo + if outdata and #outdata ~= 0 then + extrainfo = extrainfo or {} + extrainfo.outdata = outdata + end + if errdata and #errdata ~= 0 then + extrainfo = extrainfo or {} + extrainfo.errdata = errdata + end + if extrainfo then + io.save(objectfile_infofile, extrainfo) + end return os.isfile(objectfile) end, catch @@ -134,6 +148,11 @@ function server_session:compile(respmsg) end else vprint("send cached object file %s ..", objectfile) + if os.isfile(objectfile_infofile) then + local extrainfo = io.load(objectfile_infofile) + outdata = extrainfo.outdata + errdata = extrainfo.errdata + end ok = true end @@ -142,6 +161,8 @@ function server_session:compile(respmsg) if not stream:send_file(objectfile, {compress = os.filesize(objectfile) > 4096}) then raise("send %s failed!", objectfile) end + body.outdata = outdata + body.errdata = errdata else if not stream:send_emptydata() then raise("send empty data failed!") @@ -242,7 +263,7 @@ end function server_session:_gcc_compile(toolname, flags, sourcefile, objectfile, opt) local program, toolname_real, runenvs = self:_tool(opt.toolchain, opt) assert(toolname_real == toolname, "toolname is not matched, %s != %s", toolname, toolname_real) - os.iorunv(program, table.join(flags, "-o", objectfile, sourcefile), {envs = runenvs}) + return os.iorunv(program, table.join(flags, "-o", objectfile, sourcefile), {envs = runenvs}) end -- do compile job for g++ @@ -264,7 +285,7 @@ end function server_session:_cl_compile(toolname, flags, sourcefile, objectfile, opt) local program, toolname_real, runenvs = self:_tool(opt.toolchain, opt) assert(toolname_real == toolname, "toolname is not matched, %s != %s", toolname, toolname_real) - vstool.iorunv(program, winos.cmdargv(table.join(flags, "-Fo" .. objectfile, sourcefile)), {envs = runenvs}) + return vstool.iorunv(program, winos.cmdargv(table.join(flags, "-Fo" .. objectfile, sourcefile)), {envs = runenvs}) end function server_session:__tostring() |
