diff options
| author | ruki <[email protected]> | 2023-09-02 00:42:10 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-09-02 00:42:10 +0800 |
| commit | 872b8411ec92a080f189685faa319f1af87b4534 (patch) | |
| tree | 3182034d969795aa9755855afc74b2ad62d32431 | |
| parent | 28b382739fa9cef9298b0e515e020d0f5ab7039b (diff) | |
add global ccache policy
| -rw-r--r-- | xmake/core/project/policy.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/private/cache/build_cache.lua | 15 |
2 files changed, 15 insertions, 2 deletions
diff --git a/xmake/core/project/policy.lua b/xmake/core/project/policy.lua index 0f9fe9762..db35b091c 100644 --- a/xmake/core/project/policy.lua +++ b/xmake/core/project/policy.lua @@ -46,6 +46,8 @@ function policy.policies() ["build.merge_archive"] = {description = "Enable merge archive intead of linking for all dependent targets.", default = false, type = "boolean"}, -- C/C++ build cache ["build.ccache"] = {description = "Enable C/C++ build cache.", type = "boolean"}, + -- Use global storage if build.ccache is enabled + ["build.ccache.global_storage"] = {description = "Use global storge if build.ccache is enabled.", type = "boolean"}, -- Enable build warning output, it's disabled by default and we need `xmake -w/-vD` to look at it. ["build.warning"] = {description = "Enable build warning output.", type = "boolean"}, -- Enable LTO linker-time optimization for c/c++ building. 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 |
