diff options
| author | ruki <[email protected]> | 2022-05-20 21:02:30 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-05-20 21:02:30 +0800 |
| commit | c3fd2dd9110aa41cd321d5e73823f57f2d25ff8c (patch) | |
| tree | 77112fa976889fc8c01befe5fdc9c45f10cf9073 | |
| parent | 5480e275ffb9412e2c48be9725c2ef9e29b909b9 (diff) | |
build small file in local
| -rw-r--r-- | xmake/modules/core/tools/cl.lua | 10 | ||||
| -rw-r--r-- | xmake/modules/core/tools/gcc.lua | 12 | ||||
| -rw-r--r-- | xmake/modules/private/service/distcc_build/client.lua | 14 |
3 files changed, 31 insertions, 5 deletions
diff --git a/xmake/modules/core/tools/cl.lua b/xmake/modules/core/tools/cl.lua index ca66ede29..a3a3dc5aa 100644 --- a/xmake/modules/core/tools/cl.lua +++ b/xmake/modules/core/tools/cl.lua @@ -464,10 +464,20 @@ end -- do compile function _compile(self, sourcefile, objectfile, compflags, opt) local cppinfo + local build_in_local if distcc_build_client.is_distccjob() and distcc_build_client.singleton():has_freejobs() then local program, argv = compargv(self, sourcefile, objectfile, compflags, table.join(opt, {rawargs = true})) cppinfo = distcc_build_client.singleton():compile(program, argv, {envs = self:runenvs(), preprocess = _preprocess, tool = self, target = opt.target}) + if cppinfo and build_in_local then + vstool.iorunv(program, winos.cmdargv(table.join(cppinfo.cppflags, "-Fo" .. cppinfo.objectfile, cppinfo.cppfile)), {envs = self:runenvs()}) + if build_cache.is_enabled() and build_cache.is_supported(self:kind()) then + local cachekey = build_cache.cachekey(program, cppinfo.cppfile, cppinfo.cppflags, self:runenvs()) + if cachekey then + build_cache.put(cachekey, cppinfo.objectfile) + end + end + end elseif build_cache.is_enabled() and build_cache.is_supported(self:kind()) then local program, argv = compargv(self, sourcefile, objectfile, compflags, table.join(opt, {rawargs = true})) cppinfo = _preprocess(program, argv, {envs = self:runenvs(), target = opt.target}) diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua index 8a6cc7b84..16c650768 100644 --- a/xmake/modules/core/tools/gcc.lua +++ b/xmake/modules/core/tools/gcc.lua @@ -476,9 +476,19 @@ end -- do compile function _compile(self, sourcefile, objectfile, compflags, opt) local cppinfo + local build_in_local local program, argv = compargv(self, sourcefile, objectfile, compflags) if distcc_build_client.is_distccjob() and distcc_build_client.singleton():has_freejobs() then - cppinfo = distcc_build_client.singleton():compile(program, argv, {envs = self:runenvs(), preprocess = _preprocess, tool = self}) + cppinfo, build_in_local = distcc_build_client.singleton():compile(program, argv, {envs = self:runenvs(), preprocess = _preprocess, tool = self}) + if cppinfo and build_in_local then + os.iorunv(program, table.join(cppinfo.cppflags, "-o", cppinfo.objectfile, cppinfo.cppfile), {envs = self:runenvs()}) + if build_cache.is_enabled() and build_cache.is_supported(self:kind()) then + local cachekey = build_cache.cachekey(program, cppinfo.cppfile, cppinfo.cppflags, self:runenvs()) + if cachekey then + build_cache.put(cachekey, cppinfo.objectfile) + end + end + end elseif build_cache.is_enabled() and build_cache.is_supported(self:kind()) then local t = os.mclock() cppinfo = _preprocess(program, argv, {envs = self:runenvs(), tool = self}) diff --git a/xmake/modules/private/service/distcc_build/client.lua b/xmake/modules/private/service/distcc_build/client.lua index 80b92ab63..3730ea9a9 100644 --- a/xmake/modules/private/service/distcc_build/client.lua +++ b/xmake/modules/private/service/distcc_build/client.lua @@ -233,6 +233,7 @@ function distcc_build_client:compile(program, argv, opt) opt = opt or {} local preprocess = assert(opt.preprocess, "preprocessor not found!") local cppinfo = preprocess(program, argv, opt) + local build_in_local = false if cppinfo then -- get objectfile from the build cache first local cached = false @@ -248,9 +249,14 @@ function distcc_build_client:compile(program, argv, opt) -- do distcc compilation if not cached then - session:compile(cppinfo.sourcefile, cppinfo.objectfile, cppinfo.cppfile, cppinfo.cppflags, opt) - if cachekey then - build_cache.put(cachekey, cppinfo.objectfile) + -- we just compile the large preprocessed file in remote + if os.filesize(cppinfo.cppfile) > 4096 then + session:compile(cppinfo.sourcefile, cppinfo.objectfile, cppinfo.cppfile, cppinfo.cppflags, opt) + if cachekey then + build_cache.put(cachekey, cppinfo.objectfile) + end + else + build_in_local = true end end end @@ -260,7 +266,7 @@ function distcc_build_client:compile(program, argv, opt) -- unlock this host self:_host_status_unlock(host) - return cppinfo + return cppinfo, build_in_local end -- get the status |
