summaryrefslogtreecommitdiff
path: root/xmake/modules/private/cache/build_cache.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2022-05-18 22:25:35 +0800
committerruki <[email protected]>2022-05-18 13:09:42 +0800
commit05b98d524b5b524683c6f59c1b59a0bab088b1dc (patch)
tree1c79cbda6f96b9c707aa42f69aae9baa9f35d859 /xmake/modules/private/cache/build_cache.lua
parent3674a502ae48035813cac69525162d7a7f89ba28 (diff)
enable build cache
Diffstat (limited to 'xmake/modules/private/cache/build_cache.lua')
-rw-r--r--xmake/modules/private/cache/build_cache.lua24
1 files changed, 20 insertions, 4 deletions
diff --git a/xmake/modules/private/cache/build_cache.lua b/xmake/modules/private/cache/build_cache.lua
index 629c903a3..62ddeafa2 100644
--- a/xmake/modules/private/cache/build_cache.lua
+++ b/xmake/modules/private/cache/build_cache.lua
@@ -19,10 +19,11 @@
--
-- imports
+import("core.base.hashset")
import("core.project.config")
-- is enabled?
-function enabled()
+function is_enabled()
local build_cache = _g.build_cache
if build_cache == nil then
build_cache = config.get("ccache") or false
@@ -31,6 +32,16 @@ function enabled()
return build_cache or false
end
+-- is supported?
+function is_supported(sourcekind)
+ local sourcekinds = _g.sourcekinds
+ if sourcekinds == nil then
+ sourcekinds = hashset.of("cc", "cxx", "mm", "mxx")
+ _g.sourcekinds = sourcekinds
+ end
+ return sourcekinds:has(sourcekind)
+end
+
-- get cache key
function cachekey(program, cppfile, cppflags, envs)
local items = {program}
@@ -38,9 +49,14 @@ function cachekey(program, cppfile, cppflags, envs)
table.sort(items)
table.insert(items, hash.sha256(cppfile))
if envs then
- for k, v in pairs(table.orderpairs(envs)) do
- table.insert(items, k)
- table.insert(items, v)
+ local basename = path.basename(program)
+ if basename == "cl" then
+ for _, name in ipairs({"WindowsSDKVersion", "VCToolsVersion", "LIB"}) do
+ local val = envs[name]
+ if val then
+ table.insert(items, val)
+ end
+ end
end
end
return (hash.uuid(table.concat(items, "")):gsub("-", "")):lower()