diff options
| author | ruki <[email protected]> | 2022-05-28 10:46:55 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-05-28 10:46:55 +0800 |
| commit | 500a25f81136a0883a479bcd754dcaff2e0bbb04 (patch) | |
| tree | ee3d279cb11938ddb2770c1a85bfdaec23ea89e1 | |
| parent | 7d5a9b498a47c47554daee8839e4f9caac1dcc64 (diff) | |
add build.ccache policy
| -rw-r--r-- | xmake/core/project/policy.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/private/cache/build_cache.lua | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/xmake/core/project/policy.lua b/xmake/core/project/policy.lua index f95918283..775ecef63 100644 --- a/xmake/core/project/policy.lua +++ b/xmake/core/project/policy.lua @@ -45,6 +45,8 @@ function policy.policies() ["build.across_targets_in_parallel"] = {description = "Enable compile the source files for each target in parallel.", default = true, type = "boolean"}, -- merge archive intead of linking for all dependent targets ["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.", default = true, type = "boolean"}, -- we need enable longpaths when building target or installing package ["platform.longpaths"] = {description = "Enable long paths when building target or installing package on windows.", default = false, type = "boolean"}, -- lock required packages diff --git a/xmake/modules/private/cache/build_cache.lua b/xmake/modules/private/cache/build_cache.lua index b62165f29..4f098c983 100644 --- a/xmake/modules/private/cache/build_cache.lua +++ b/xmake/modules/private/cache/build_cache.lua @@ -22,6 +22,7 @@ import("core.base.bytes") import("core.base.hashset") import("core.project.config") +import("core.project.project") import("private.service.client_config") import("private.service.remote_cache.client", {alias = "remote_cache_client"}) @@ -39,7 +40,15 @@ end function is_enabled() local build_cache = _g.build_cache if build_cache == nil then - build_cache = config.get("ccache") or false + if build_cache == nil and os.isfile(os.projectfile()) then + local policy = project.policy("build.ccache") + if policy ~= nil then + build_cache = policy + end + end + if build_cache == nil then + build_cache = config.get("ccache") or false + end _g.build_cache = build_cache end return build_cache or false |
