diff options
| author | ruki <[email protected]> | 2022-05-18 22:25:35 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-05-18 13:09:42 +0800 |
| commit | 05b98d524b5b524683c6f59c1b59a0bab088b1dc (patch) | |
| tree | 1c79cbda6f96b9c707aa42f69aae9baa9f35d859 /xmake/modules/core/tools/cl.lua | |
| parent | 3674a502ae48035813cac69525162d7a7f89ba28 (diff) | |
enable build cache
Diffstat (limited to 'xmake/modules/core/tools/cl.lua')
| -rw-r--r-- | xmake/modules/core/tools/cl.lua | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/xmake/modules/core/tools/cl.lua b/xmake/modules/core/tools/cl.lua index e4d36f9e6..6a67d5621 100644 --- a/xmake/modules/core/tools/cl.lua +++ b/xmake/modules/core/tools/cl.lua @@ -26,6 +26,7 @@ import("core.project.project") import("core.language.language") import("private.tools.vstool") import("private.tools.cl.parse_include") +import("private.cache.build_cache") import("private.service.distcc_build.client", {alias = "distcc_build_client"}) import("utils.progress") @@ -509,6 +510,24 @@ function compile(self, sourcefile, objectfile, dependinfo, flags, opt) local program, argv = compargv(self, sourcefile, objectfile, compflags, table.join(opt, {rawargs = true})) return distcc_build_client.singleton():compile(program, argv, {envs = self:runenvs(), preprocess = _preprocess, tool = self, target = opt.target}) + 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})) + local outdata, errdata, _, _, cppfile, cppflags = _preprocess(program, argv, {envs = self:runenvs(), target = opt.target}) + local cached = false + local cachekey + cachekey = build_cache.cachekey(program, cppfile, cppflags, self:runenvs()) + local objectfile_cached = build_cache.get(cachekey) + if objectfile_cached then + os.cp(objectfile_cached, objectfile) + cached = true + end + if not cached then + vstool.iorunv(program, winos.cmdargv(argv), {envs = self:runenvs()}) + if cachekey then + build_cache.put(cachekey, objectfile) + end + end + return outdata, errdata else local program, argv = compargv(self, sourcefile, objectfile, compflags, opt) return vstool.iorunv(program, argv, {envs = self:runenvs()}) |
