diff options
| author | ruki <[email protected]> | 2022-05-20 22:24:41 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-05-20 22:24:41 +0800 |
| commit | c710b189a6501578c29f1c882cdf711663950f62 (patch) | |
| tree | c5c7b10deb260fd31c8615bd4ec2891dfff068e5 /xmake/modules/core/tools/cl.lua | |
| parent | 6fad9d40962d1c137d65394e99ea84acba5fe5cc (diff) | |
improve compile and build cache
Diffstat (limited to 'xmake/modules/core/tools/cl.lua')
| -rw-r--r-- | xmake/modules/core/tools/cl.lua | 33 |
1 files changed, 8 insertions, 25 deletions
diff --git a/xmake/modules/core/tools/cl.lua b/xmake/modules/core/tools/cl.lua index ab17b2aa3..12bb9d445 100644 --- a/xmake/modules/core/tools/cl.lua +++ b/xmake/modules/core/tools/cl.lua @@ -467,39 +467,22 @@ function _preprocess(program, argv, opt) end} end +-- compile preprocessed file +function _compile_preprocessed_file(program, cppinfo, opt) + vstool.iorunv(program, winos.cmdargv(table.join(cppinfo.cppflags, "-Fo" .. cppinfo.objectfile, cppinfo.cppfile)), opt) +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, remote = true}) - 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 + preprocess = _preprocess, compile = _compile_preprocessed_file, target = opt.target, remote = true, tool = self}) 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}) - if cppinfo then - local cachekey = build_cache.cachekey(program, cppinfo.cppfile, cppinfo.cppflags, self:runenvs()) - local objectfile_cached = build_cache.get(cachekey) - if objectfile_cached then - os.cp(objectfile_cached, cppinfo.objectfile) - else - vstool.iorunv(program, winos.cmdargv(table.join(cppinfo.cppflags, "-Fo" .. cppinfo.objectfile, cppinfo.cppfile)), {envs = self:runenvs()}) - if cachekey then - build_cache.put(cachekey, cppinfo.objectfile) - end - end - os.rm(cppinfo.cppfile) - end + cppinfo = build_cache.build(program, argv, {envs = self:runenvs(), + preprocess = _preprocess, compile = _compile_preprocessed_file, target = opt.target}) end if cppinfo then return cppinfo.outdata, cppinfo.errdata |
