diff options
| author | ruki <[email protected]> | 2022-11-01 22:54:09 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-11-01 22:54:09 +0800 |
| commit | e639c493025b5d6c5cbdbe588759d34ff8d772b4 (patch) | |
| tree | 1e91823aee729fb798f61e38480a2ad61a580e06 /xmake/modules/private/cache/build_cache.lua | |
| parent | 055c7aa757886af0faa87c21e407495ead4c066e (diff) | |
disable ccache for c++modules
Diffstat (limited to 'xmake/modules/private/cache/build_cache.lua')
| -rw-r--r-- | xmake/modules/private/cache/build_cache.lua | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/xmake/modules/private/cache/build_cache.lua b/xmake/modules/private/cache/build_cache.lua index 4cb1be5ca..24124417c 100644 --- a/xmake/modules/private/cache/build_cache.lua +++ b/xmake/modules/private/cache/build_cache.lua @@ -21,12 +21,23 @@ -- imports import("core.base.bytes") import("core.base.hashset") +import("core.cache.memcache") import("core.project.config") import("core.project.policy") import("core.project.project") import("private.service.client_config") import("private.service.remote_cache.client", {alias = "remote_cache_client"}) +-- get memcache +function _memcache() + local cache = _g.memcache + if not cache then + cache = memcache.cache("build_cache") + _g.memcache = cache + end + return cache +end + -- get exist info function _get_existinfo() local existinfo = _g.existinfo @@ -38,21 +49,27 @@ function _get_existinfo() end -- is enabled? -function is_enabled() - local build_cache = _g.build_cache - if build_cache == nil then - if build_cache == nil and os.isfile(os.projectfile()) then +function is_enabled(target) + local key = tostring(target or "all") + local result = _memcache():get2("enabled", key) + if result == nil then + -- target may be option instance + if target and target.policy then + result = target:policy("build.ccache") + end + if result == nil and os.isfile(os.projectfile()) then local policy = project.policy("build.ccache") if policy ~= nil then - build_cache = policy + result = policy end end - if build_cache == nil then - build_cache = config.get("ccache") or false + if result == nil then + result = config.get("ccache") end - _g.build_cache = build_cache + result = result or false + _memcache():set2("enabled", key) end - return build_cache or false + return result end -- is supported? |
