summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-05-14 00:47:48 +0800
committerruki <[email protected]>2022-05-14 00:47:48 +0800
commit95425d9a244a557141107e0113e308664676be7a (patch)
tree03272695fad31f2aa27441ecaab46f86ed24ef5d
parent1d7e2f54f9da78e6e2d40f2f4f0510755bddf439 (diff)
patch distcc freejobs
-rw-r--r--xmake/actions/build/build.lua4
-rw-r--r--xmake/modules/private/async/runjobs.lua6
-rw-r--r--xmake/modules/private/service/distcc_build/client.lua10
3 files changed, 18 insertions, 2 deletions
diff --git a/xmake/actions/build/build.lua b/xmake/actions/build/build.lua
index 4b86dd538..fcb116d88 100644
--- a/xmake/actions/build/build.lua
+++ b/xmake/actions/build/build.lua
@@ -250,12 +250,12 @@ function main(targetname, group_pattern)
local batchjobs = get_batchjobs(targetname, group_pattern)
if batchjobs and batchjobs:size() > 0 then
local curdir = os.curdir()
- runjobs("build", batchjobs, {comax = option.get("jobs") or 1, on_exit = function (errors)
+ runjobs("build", batchjobs, {on_exit = function (errors)
import("utils.progress")
if errors and progress.showing_without_scroll() then
print("")
end
- end, curdir = curdir, count_as_index = true, distcc = distcc})
+ end, comax = option.get("jobs") or 1, curdir = curdir, count_as_index = true, distcc = distcc})
os.cd(curdir)
end
end
diff --git a/xmake/modules/private/async/runjobs.lua b/xmake/modules/private/async/runjobs.lua
index a4ea2bc10..3d9d36b7d 100644
--- a/xmake/modules/private/async/runjobs.lua
+++ b/xmake/modules/private/async/runjobs.lua
@@ -50,6 +50,8 @@ end
-- end
-- runjobs("test", jobs, {comax = 6, timeout = 1000, on_timer = function (running_jobs_indices) end})
--
+-- distributed build:
+-- runjobs("test", jobs, {comax = 6, distcc = distcc_build_client.singleton()}
--
function main(name, jobs, opt)
@@ -57,6 +59,7 @@ function main(name, jobs, opt)
op = opt or {}
local total = opt.total or (type(jobs) == "table" and jobs:size()) or 1
local comax = opt.comax or math.min(total, 4)
+ local distcc = opt.distcc
local timeout = opt.timeout or 500
local group_name = name
local jobs_cb = type(jobs) == "function" and jobs or nil
@@ -158,6 +161,9 @@ function main(name, jobs, opt)
while index < total do
scheduler.co_group_begin(group_name, function (co_group)
local freemax = comax - #co_group
+ if distcc then
+ freemax = freemax + distcc:freejobs()
+ end
local max = math.min(index + freemax, total)
local jobfunc = jobs_cb
while index < max do
diff --git a/xmake/modules/private/service/distcc_build/client.lua b/xmake/modules/private/service/distcc_build/client.lua
index 02399d927..890a316a8 100644
--- a/xmake/modules/private/service/distcc_build/client.lua
+++ b/xmake/modules/private/service/distcc_build/client.lua
@@ -152,6 +152,16 @@ function distcc_build_client:is_connected()
return self:status().connected
end
+-- get max jobs count
+function distcc_build_client:maxjobs()
+ return 0
+end
+
+-- get free jobs count
+function distcc_build_client:freejobs()
+ return 0
+end
+
-- get the status
function distcc_build_client:status()
local status = self._STATUS