diff options
| author | ruki <[email protected]> | 2022-06-19 22:20:15 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-06-19 22:20:20 +0800 |
| commit | ec26291e8e26310e8e5d57e2c39fbabeaeff8c22 (patch) | |
| tree | 84d7d96cc8b1e710df9ca07a398e40c4e2e938cc | |
| parent | ececb79202f2bcc91ee14de8abc2db0ae58931b0 (diff) | |
fix distcc cache
| -rw-r--r-- | xmake/modules/private/cache/build_cache.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/private/service/distcc_build/client.lua | 33 |
2 files changed, 30 insertions, 5 deletions
diff --git a/xmake/modules/private/cache/build_cache.lua b/xmake/modules/private/cache/build_cache.lua index be336dc52..13bebcbdf 100644 --- a/xmake/modules/private/cache/build_cache.lua +++ b/xmake/modules/private/cache/build_cache.lua @@ -200,7 +200,7 @@ function build(program, argv, opt) os.cp(objectfile_cached, cppinfo.objectfile) -- we need get outdata/errdata to show warnings, -- @see https://github.com/xmake-io/xmake/issues/2452 - if os.isfile(objectfile_infofile) then + if objectfile_infofile and os.isfile(objectfile_infofile) then local extrainfo = io.load(objectfile_infofile) cppinfo.outdata = extrainfo.outdata cppinfo.errdata = extrainfo.errdata diff --git a/xmake/modules/private/service/distcc_build/client.lua b/xmake/modules/private/service/distcc_build/client.lua index d4e71e32c..eec99a14c 100644 --- a/xmake/modules/private/service/distcc_build/client.lua +++ b/xmake/modules/private/service/distcc_build/client.lua @@ -240,9 +240,16 @@ function distcc_build_client:compile(program, argv, opt) local cachekey if build_cache.is_enabled() then cachekey = build_cache.cachekey(program, cppinfo, opt.envs) - local objectfile_cached = build_cache.get(cachekey) + local objectfile_cached, objectfile_infofile = build_cache.get(cachekey) if objectfile_cached then os.cp(objectfile_cached, cppinfo.objectfile) + -- we need get outdata/errdata to show warnings, + -- @see https://github.com/xmake-io/xmake/issues/2452 + if objectfile_infofile and os.isfile(objectfile_infofile) then + local extrainfo = io.load(objectfile_infofile) + cppinfo.outdata = extrainfo.outdata + cppinfo.errdata = extrainfo.errdata + end cached = true end end @@ -270,7 +277,16 @@ function distcc_build_client:compile(program, argv, opt) table.join(opt, {cachekey = cachekey})) end if cachekey then - build_cache.put(cachekey, cppinfo.objectfile) + local extrainfo + if cppinfo.outdata and #cppinfo.outdata ~= 0 then + extrainfo = extrainfo or {} + extrainfo.outdata = cppinfo.outdata + end + if cppinfo.errdata and #cppinfo.errdata ~= 0 then + extrainfo = extrainfo or {} + extrainfo.errdata = cppinfo.errdata + end + build_cache.put(cachekey, cppinfo.objectfile, extrainfo) end else build_in_local = true @@ -302,9 +318,18 @@ function distcc_build_client:compile(program, argv, opt) compile(program, cppinfo, opt) end if build_cache.is_enabled() then - local cachekey = build_cache.cachekey(program, cppinfo.cppfile, cppinfo.cppflags, opt.envs) + local cachekey = build_cache.cachekey(program, cppinfo, opt.envs) if cachekey then - build_cache.put(cachekey, cppinfo.objectfile) + local extrainfo + if cppinfo.outdata and #cppinfo.outdata ~= 0 then + extrainfo = extrainfo or {} + extrainfo.outdata = cppinfo.outdata + end + if cppinfo.errdata and #cppinfo.errdata ~= 0 then + extrainfo = extrainfo or {} + extrainfo.errdata = cppinfo.errdata + end + build_cache.put(cachekey, cppinfo.objectfile, extrainfo) end end end |
