summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-05-15 14:34:06 +0800
committerruki <[email protected]>2022-05-15 14:34:06 +0800
commit35b45c71346256fdccb098287a2f2d2f604eeb28 (patch)
tree51c500d62b32efa3bc90362d9c068d51a0e6742a
parent58e7061326dca02c2e818aba33e8950f2297b709 (diff)
cache tool
-rw-r--r--xmake/modules/private/service/distcc_build/server_session.lua29
1 files changed, 28 insertions, 1 deletions
diff --git a/xmake/modules/private/service/distcc_build/server_session.lua b/xmake/modules/private/service/distcc_build/server_session.lua
index 884f47c3b..8b86f44b1 100644
--- a/xmake/modules/private/service/distcc_build/server_session.lua
+++ b/xmake/modules/private/service/distcc_build/server_session.lua
@@ -26,6 +26,8 @@ import("core.base.global")
import("core.base.option")
import("core.base.hashset")
import("core.base.scheduler")
+import("core.tool.toolchain")
+import("core.cache.memcache")
import("private.service.server_config", {alias = "config"})
import("private.service.message")
@@ -173,9 +175,34 @@ function server_session:statusfile()
return path.join(self:workdir(), "status.txt")
end
+-- get cache
+function server_session:_cache()
+ return memcache.cache("distcc_build_server.session")
+end
+
+-- get tool
+function server_session:_tool(name, opt)
+ opt = opt or {}
+ local plat = opt.plat
+ local arch = opt.arch
+ local toolkind = opt.toolkind
+ local cachekey = name .. (plat or "") .. (arch or "") .. toolkind
+ local cacheinfo = self:_cache():get(cachekey)
+ if not cacheinfo then
+ local toolchain_inst = toolchain.load(name, {plat = plat, arch = arch})
+ local program, toolname = toolchain_inst:tool(toolkind)
+ assert(program, "%s/%s not found!", name, toolkind)
+ cacheinfo = {program, toolname}
+ self:_cache():set(cachekey, cacheinfo)
+ end
+ return cacheinfo[1], cacheinfo[2]
+end
+
-- do compile job for gcc
function server_session:_gcc_compile(toolname, flags, sourcefile, objectfile, opt)
- os.vrunv(toolname, table.join(flags, "-o", objectfile, sourcefile))
+ local program, toolname_real = self:_tool(opt.toolchain, opt)
+ assert(toolname_real == toolname, "toolname is not matched, %s != %s", toolname, toolname_real)
+ os.vrunv(program, table.join(flags, "-o", objectfile, sourcefile))
end
-- do compile job for g++