diff options
| author | ruki <[email protected]> | 2024-03-18 23:52:01 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-03-18 23:52:01 +0800 |
| commit | 8f40dc67f661f46de7a073ea079587faebf0f1af (patch) | |
| tree | 9a56acb9dac1c1b90c13fd34a8d59acf20a3150b /xmake/modules | |
| parent | ca16db30058d8a512d73a7bee28e57f72de4c338 (diff) | |
use new progress
Diffstat (limited to 'xmake/modules')
| -rw-r--r-- | xmake/modules/async/runjobs.lua | 10 | ||||
| -rw-r--r-- | xmake/modules/private/action/build/object.lua | 4 | ||||
| -rw-r--r-- | xmake/modules/private/async/buildjobs.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/utils/progress.lua | 4 |
4 files changed, 10 insertions, 10 deletions
diff --git a/xmake/modules/async/runjobs.lua b/xmake/modules/async/runjobs.lua index 476efe08f..299b868df 100644 --- a/xmake/modules/async/runjobs.lua +++ b/xmake/modules/async/runjobs.lua @@ -40,12 +40,12 @@ end -- runjobs("test", function () os.sleep(10000) end, { progress = { chars = {'/','\'} } }) -- see module utils.progress -- -- local jobs = jobpool.new() --- local root = jobs:addjob("job/root", function (index, total) --- print(index, total) +-- local root = jobs:addjob("job/root", function (index, total, opt) +-- print(index, total, opt.progress) -- end) -- for i = 1, 3 do --- local job = jobs:addjob("job/" .. i, function (index, total) --- print(index, total) +-- local job = jobs:addjob("job/" .. i, function (index, total, opt) +-- print(index, total, opt.progress) -- end, {rootjob = root}) -- end -- runjobs("test", jobs, {comax = 6, timeout = 1000, on_timer = function (running_jobs_indices) end}) @@ -252,8 +252,8 @@ function main(name, jobs, opt) if opt.curdir then os.cd(opt.curdir) end - jobfunc(i, total, {progress = progress_wrapper}) count = count + 1 + jobfunc(i, total, {progress = progress_wrapper}) end running_jobs_indices[i] = nil end, diff --git a/xmake/modules/private/action/build/object.lua b/xmake/modules/private/action/build/object.lua index 486c2e7ce..c4c646cba 100644 --- a/xmake/modules/private/action/build/object.lua +++ b/xmake/modules/private/action/build/object.lua @@ -142,8 +142,8 @@ function main(target, batchjobs, sourcebatch, opt) local objectfile = sourcebatch.objectfiles[i] local dependfile = sourcebatch.dependfiles[i] local sourcekind = assert(sourcebatch.sourcekind, "%s: sourcekind not found!", sourcefile) - batchjobs:addjob(sourcefile, function (index, total) - local build_opt = table.join({objectfile = objectfile, dependfile = dependfile, sourcekind = sourcekind, progress = (index * 100) / total}, opt) + batchjobs:addjob(sourcefile, function (index, total, jobopt) + local build_opt = table.join({objectfile = objectfile, dependfile = dependfile, sourcekind = sourcekind, progress = jobopt.progress}, opt) build_object(target, sourcefile, build_opt) end, {rootjob = rootjob, distcc = opt.distcc}) end diff --git a/xmake/modules/private/async/buildjobs.lua b/xmake/modules/private/async/buildjobs.lua index d19335167..dc2e736f3 100644 --- a/xmake/modules/private/async/buildjobs.lua +++ b/xmake/modules/private/async/buildjobs.lua @@ -51,7 +51,7 @@ end nodes["node1"] = { name = "node1", deps = {"node2", "node3"}, - job = batchjobs:newjob("/job/node1", function(index, total) + job = batchjobs:newjob("/job/node1", function(index, total, opt) end) } --]] diff --git a/xmake/modules/utils/progress.lua b/xmake/modules/utils/progress.lua index 2655f0701..aefaef1af 100644 --- a/xmake/modules/utils/progress.lua +++ b/xmake/modules/utils/progress.lua @@ -75,7 +75,7 @@ end -- show the message with progress function show(progress, format, ...) - progress = math.floor(progress) + progress = type(progress) == "table" and progress:percent() or math.floor(progress) local progress_prefix = "${color.build.progress}" .. theme.get("text.build.progress_format") .. ":${clear} " if option.get("verbose") then cprint(progress_prefix .. "${dim}" .. format, progress, ...) @@ -114,7 +114,7 @@ end -- get the message text with progress function text(progress, format, ...) - progress = math.floor(progress) + progress = type(progress) == "table" and progress:percent() or math.floor(progress) local progress_prefix = "${color.build.progress}" .. theme.get("text.build.progress_format") .. ":${clear} " if option.get("verbose") then return string.format(progress_prefix .. "${dim}" .. format, progress, ...) |
