summaryrefslogtreecommitdiff
path: root/xmake/modules/private/cache/build_cache.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2023-09-02 00:42:10 +0800
committerruki <[email protected]>2023-09-02 00:42:10 +0800
commit872b8411ec92a080f189685faa319f1af87b4534 (patch)
tree3182034d969795aa9755855afc74b2ad62d32431 /xmake/modules/private/cache/build_cache.lua
parent28b382739fa9cef9298b0e515e020d0f5ab7039b (diff)
add global ccache policy
Diffstat (limited to 'xmake/modules/private/cache/build_cache.lua')
-rw-r--r--xmake/modules/private/cache/build_cache.lua15
1 files changed, 13 insertions, 2 deletions
diff --git a/xmake/modules/private/cache/build_cache.lua b/xmake/modules/private/cache/build_cache.lua
index b0960c37a..6b3b85f52 100644
--- a/xmake/modules/private/cache/build_cache.lua
+++ b/xmake/modules/private/cache/build_cache.lua
@@ -21,6 +21,7 @@
-- imports
import("core.base.bytes")
import("core.base.hashset")
+import("core.base.global")
import("core.cache.memcache")
import("core.project.config")
import("core.project.policy")
@@ -124,8 +125,18 @@ end
-- get cache root directory
function rootdir()
- local cachedir = config.get("ccachedir")
- return cachedir or path.join(config.buildir(), ".build_cache")
+ local cachedir = _g.cachedir
+ if not cachedir then
+ cachedir = config.get("ccachedir")
+ if not cachedir and project.policy("build.ccache.global_storage") then
+ cachedir = path.join(global.directory(), ".build_cache")
+ end
+ if not cachedir then
+ cachedir = path.join(config.buildir(), ".build_cache")
+ end
+ _g.cachedir = cachedir
+ end
+ return cachedir
end
-- clean cached files