diff options
| author | ruki <[email protected]> | 2022-05-14 00:41:39 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-05-14 00:41:39 +0800 |
| commit | 1d7e2f54f9da78e6e2d40f2f4f0510755bddf439 (patch) | |
| tree | 28c8719baceb5d66e709de198fe2eb1bfebb9a59 | |
| parent | 2ff45f35b6e2c68ef4e9b84374e46bd8a204d4d2 (diff) | |
get distcc
| -rw-r--r-- | xmake/actions/build/build.lua | 11 | ||||
| -rw-r--r-- | xmake/modules/private/service/distcc_build/client.lua | 17 | ||||
| -rw-r--r-- | xmake/modules/private/service/remote_build/action.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/private/service/remote_build/client.lua | 17 |
4 files changed, 43 insertions, 4 deletions
diff --git a/xmake/actions/build/build.lua b/xmake/actions/build/build.lua index 598d4b2cf..4b86dd538 100644 --- a/xmake/actions/build/build.lua +++ b/xmake/actions/build/build.lua @@ -26,6 +26,8 @@ import("private.async.jobpool") import("private.async.runjobs") import("private.utils.batchcmds") import("core.base.hashset") +import("private.service.client_config") +import("private.service.distcc_build.client", {alias = "distcc_build_client"}) -- clean target for rebuilding function _clean_target(target) @@ -237,6 +239,13 @@ end -- the main entry function main(targetname, group_pattern) + -- enable distcc? + local distcc + if distcc_build_client.is_connected() then + client_config.load() + distcc = distcc_build_client.singleton() + end + -- build all jobs local batchjobs = get_batchjobs(targetname, group_pattern) if batchjobs and batchjobs:size() > 0 then @@ -246,7 +255,7 @@ function main(targetname, group_pattern) if errors and progress.showing_without_scroll() then print("") end - end, curdir = curdir, count_as_index = true}) + end, curdir = curdir, count_as_index = true, distcc = distcc}) os.cd(curdir) end end diff --git a/xmake/modules/private/service/distcc_build/client.lua b/xmake/modules/private/service/distcc_build/client.lua index f79b540b3..02399d927 100644 --- a/xmake/modules/private/service/distcc_build/client.lua +++ b/xmake/modules/private/service/distcc_build/client.lua @@ -338,8 +338,23 @@ function is_connected() end end -function main() +-- new a client instance +function new() local instance = distcc_build_client() instance:init() return instance end + +-- get the singleton +function singleton() + local instance = _g.singleton + if not instance then + instance = new() + _g.singleton = instance + end + return instance +end + +function main() + return new() +end diff --git a/xmake/modules/private/service/remote_build/action.lua b/xmake/modules/private/service/remote_build/action.lua index c7519bf5c..fcf3fff89 100644 --- a/xmake/modules/private/service/remote_build/action.lua +++ b/xmake/modules/private/service/remote_build/action.lua @@ -29,5 +29,5 @@ end function main() config.load() - remote_build_client():runcmd("xmake", xmake.argv()) + remote_build_client.singleton():runcmd("xmake", xmake.argv()) end diff --git a/xmake/modules/private/service/remote_build/client.lua b/xmake/modules/private/service/remote_build/client.lua index 565b0f3c3..841ca6b8c 100644 --- a/xmake/modules/private/service/remote_build/client.lua +++ b/xmake/modules/private/service/remote_build/client.lua @@ -530,8 +530,23 @@ function is_connected() end end -function main() +-- new a client instance +function new() local instance = remote_build_client() instance:init() return instance end + +-- get the singleton +function singleton() + local instance = _g.singleton + if not instance then + instance = new() + _g.singleton = instance + end + return instance +end + +function main() + return new() +end |
