From 11ba8e1356abcdd6efa9716c5e9dfd337764aeae Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 18 May 2022 00:52:52 +0800 Subject: add build cache stub --- xmake/modules/core/tools/cl.lua | 3 ++- xmake/modules/private/cache/build_cache.lua | 32 +++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 xmake/modules/private/cache/build_cache.lua diff --git a/xmake/modules/core/tools/cl.lua b/xmake/modules/core/tools/cl.lua index fc3ef5622..e4d36f9e6 100644 --- a/xmake/modules/core/tools/cl.lua +++ b/xmake/modules/core/tools/cl.lua @@ -507,7 +507,8 @@ function compile(self, sourcefile, objectfile, dependinfo, flags, opt) -- use vstool to compile and enable vs_unicode_output @see https://github.com/xmake-io/xmake/issues/528 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})) - return distcc_build_client.singleton():compile(program, argv, {envs = self:runenvs(), preprocess = _preprocess, tool = self, target = opt.target}) + return distcc_build_client.singleton():compile(program, argv, {envs = self:runenvs(), + preprocess = _preprocess, tool = self, target = opt.target}) else local program, argv = compargv(self, sourcefile, objectfile, compflags, opt) return vstool.iorunv(program, argv, {envs = self:runenvs()}) diff --git a/xmake/modules/private/cache/build_cache.lua b/xmake/modules/private/cache/build_cache.lua new file mode 100644 index 000000000..6537f691b --- /dev/null +++ b/xmake/modules/private/cache/build_cache.lua @@ -0,0 +1,32 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file build_cache.lua +-- + +-- imports +import("core.project.config") + +-- is enabled? +function enabled() + local build_cache = _g.build_cache + if build_cache == nil and config.get("ccache") then + _g.build_cache = build_cache or false + end + return build_cache or false +end + -- cgit v1.3.1