summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-03-18 18:11:05 +0800
committerGitHub <[email protected]>2024-03-18 18:11:05 +0800
commit1ab1302b0568c83dbfe150d2cd67331f8ec9661c (patch)
treef7f4073c1675d79921fa47abb1e4c3da350d63f5
parentef76c91d0517361173246f6ee62b3b6c3ba1e29e (diff)
parent9847562068e7a9460a04f69d8146f5e89dd591f5 (diff)
Merge pull request #4849 from xmake-io/progress
Improve progress
-rw-r--r--tests/modules/scheduler/runjobs.lua16
-rw-r--r--xmake/actions/build/build.lua22
-rw-r--r--xmake/actions/build/build_files.lua2
-rw-r--r--xmake/actions/build/kinds/binary.lua4
-rw-r--r--xmake/actions/build/kinds/object.lua24
-rw-r--r--xmake/actions/build/kinds/shared.lua4
-rw-r--r--xmake/actions/build/kinds/static.lua4
-rw-r--r--xmake/actions/test/main.lua4
-rw-r--r--xmake/modules/async/runjobs.lua30
-rw-r--r--xmake/modules/private/action/build/object.lua4
-rw-r--r--xmake/modules/private/async/buildjobs.lua2
-rw-r--r--xmake/modules/utils/progress.lua22
-rw-r--r--xmake/rules/c++/modules/modules_support/builder.lua4
-rw-r--r--xmake/rules/c++/modules/modules_support/clang/builder.lua14
-rw-r--r--xmake/rules/c++/modules/modules_support/gcc/builder.lua14
-rw-r--r--xmake/rules/c++/modules/modules_support/msvc/builder.lua14
-rw-r--r--xmake/rules/protobuf/proto.lua4
17 files changed, 103 insertions, 85 deletions
diff --git a/tests/modules/scheduler/runjobs.lua b/tests/modules/scheduler/runjobs.lua
index d84f23152..4e2a98cc0 100644
--- a/tests/modules/scheduler/runjobs.lua
+++ b/tests/modules/scheduler/runjobs.lua
@@ -2,12 +2,12 @@ import("core.base.scheduler")
import("private.async.jobpool")
import("async.runjobs")
-function _jobfunc(index, total)
+function _jobfunc(index, total, opt)
print("%s: run job (%d/%d)", scheduler.co_running(), index, total)
local dt = os.mclock()
os.sleep(1000)
dt = os.mclock() - dt
- print("%s: run job (%d/%d) end, dt: %d ms", scheduler.co_running(), index, total, dt)
+ print("%s: run job (%d/%d) end, progress: %s, dt: %d ms", scheduler.co_running(), index, total, opt.progress, dt)
end
function main()
@@ -22,16 +22,16 @@ function main()
-- test jobs
print("==================================== test jobs ====================================")
local jobs = jobpool.new()
- local root = jobs:addjob("job/root", function (idx, total)
- _jobfunc(idx, total)
+ local root = jobs:addjob("job/root", function (index, total, opt)
+ _jobfunc(index, total, opt)
end)
for i = 1, 3 do
- local job = jobs:addjob("job/" .. i, function (idx, total)
- _jobfunc(idx, total)
+ local job = jobs:addjob("job/" .. i, function (index, total, opt)
+ _jobfunc(index, total, opt)
end, {rootjob = root})
for j = 1, 50 do
- jobs:addjob("job/" .. i .. "/" .. j, function (idx, total)
- _jobfunc(idx, total)
+ jobs:addjob("job/" .. i .. "/" .. j, function (index, total, opt)
+ _jobfunc(index, total, opt)
end, {rootjob = job})
end
end
diff --git a/xmake/actions/build/build.lua b/xmake/actions/build/build.lua
index 1db197cd6..43e28bf21 100644
--- a/xmake/actions/build/build.lua
+++ b/xmake/actions/build/build.lua
@@ -48,16 +48,16 @@ function _add_batchjobs_builtin(batchjobs, rootjob, target)
if r:extraconf("build", "batch") then
job, job_leaf = assert(script(target, batchjobs, {rootjob = job or rootjob}), "rule(%s):on_build(): no returned job!", r:name())
else
- job = batchjobs:addjob("rule/" .. r:name() .. "/build", function (index, total)
- script(target, {progress = (index * 100) / total})
+ job = batchjobs:addjob("rule/" .. r:name() .. "/build", function (index, total, opt)
+ script(target, {progress = opt.progress})
end, {rootjob = job or rootjob})
end
else
local buildcmd = r:script("buildcmd")
if buildcmd then
- job = batchjobs:addjob("rule/" .. r:name() .. "/build", function (index, total)
+ job = batchjobs:addjob("rule/" .. r:name() .. "/build", function (index, total, opt)
local batchcmds_ = batchcmds.new({target = target})
- buildcmd(target, batchcmds_, {progress = (index * 100) / total})
+ buildcmd(target, batchcmds_, {progress = opt.progress})
batchcmds_:runcmds({changed = target:is_rebuilt(), dryrun = option.get("dry-run")})
end, {rootjob = job or rootjob})
end
@@ -100,8 +100,8 @@ function _add_batchjobs(batchjobs, rootjob, target)
-- print("build it")
-- end)
--
- job = batchjobs:addjob(target:name() .. "/build", function (index, total)
- script(target, {progress = (index * 100) / total})
+ job = batchjobs:addjob(target:name() .. "/build", function (index, total, opt)
+ script(target, {progress = opt.progress})
end, {rootjob = rootjob})
end
return job, job_leaf or job
@@ -118,10 +118,10 @@ function _add_batchjobs_for_target(batchjobs, rootjob, target)
-- add after_build job for target
local pkgenvs = _g.pkgenvs or {}
_g.pkgenvs = pkgenvs
- local job_build_after = batchjobs:addjob(target:name() .. "/after_build", function (index, total)
+ local job_build_after = batchjobs:addjob(target:name() .. "/after_build", function (index, total, opt)
-- do after_build
- local progress = (index * 100) / total
+ local progress = opt.progress
local after_build = target:script("build_after")
if after_build then
after_build(target, {progress = progress})
@@ -158,7 +158,7 @@ function _add_batchjobs_for_target(batchjobs, rootjob, target)
local job_build, job_build_leaf = _add_batchjobs(batchjobs, job_build_after, target)
-- add before_build job for target
- local job_build_before = batchjobs:addjob(target:name() .. "/before_build", function (index, total)
+ local job_build_before = batchjobs:addjob(target:name() .. "/before_build", function (index, total, opt)
-- enter package environments
-- https://github.com/xmake-io/xmake/issues/4033
@@ -184,7 +184,7 @@ function _add_batchjobs_for_target(batchjobs, rootjob, target)
-- do before_build
-- we cannot add batchjobs for this rule scripts, @see https://github.com/xmake-io/xmake/issues/2684
- local progress = (index * 100) / total
+ local progress = opt.progress
local before_build = target:script("build_before")
if before_build then
before_build(target, {progress = progress})
@@ -299,7 +299,7 @@ function main(targetnames, group_pattern)
if errors and progress.showing_without_scroll() then
print("")
end
- end, comax = option.get("jobs") or 1, curdir = curdir, count_as_index = true, distcc = distcc})
+ end, comax = option.get("jobs") or 1, curdir = curdir, distcc = distcc})
os.cd(curdir)
end
end
diff --git a/xmake/actions/build/build_files.lua b/xmake/actions/build/build_files.lua
index 909e4e54b..57b586173 100644
--- a/xmake/actions/build/build_files.lua
+++ b/xmake/actions/build/build_files.lua
@@ -202,7 +202,7 @@ function main(targetname, group_pattern, sourcefiles)
local batchjobs = _get_batchjobs(targetname, group_pattern, filepatterns)
if batchjobs and batchjobs:size() > 0 then
local curdir = os.curdir()
- runjobs("build_files", batchjobs, {comax = option.get("jobs") or 1, curdir = curdir, count_as_index = true})
+ runjobs("build_files", batchjobs, {comax = option.get("jobs") or 1, curdir = curdir})
os.cd(curdir)
else
wprint("%s not found!", sourcefiles)
diff --git a/xmake/actions/build/kinds/binary.lua b/xmake/actions/build/kinds/binary.lua
index dd14d5c95..2f5bad0fc 100644
--- a/xmake/actions/build/kinds/binary.lua
+++ b/xmake/actions/build/kinds/binary.lua
@@ -156,8 +156,8 @@ end
function main(batchjobs, rootjob, target)
-- add link job
- local job_link = batchjobs:addjob(target:name() .. "/link", function (index, total)
- _link_target(target, {progress = (index * 100) / total})
+ local job_link = batchjobs:addjob(target:name() .. "/link", function (index, total, opt)
+ _link_target(target, {progress = opt.progress})
end, {rootjob = rootjob})
-- we only need to return and depend the link job for each target,
diff --git a/xmake/actions/build/kinds/object.lua b/xmake/actions/build/kinds/object.lua
index 829378f1b..ab7f3b149 100644
--- a/xmake/actions/build/kinds/object.lua
+++ b/xmake/actions/build/kinds/object.lua
@@ -100,8 +100,8 @@ function _add_batchjobs_for_rule(batchjobs, rootjob, target, sourcebatch, suffix
if ruleinst:extraconf(scriptname, "batch") then
script(target, batchjobs, sourcebatch, {rootjob = rootjob, distcc = ruleinst:extraconf(scriptname, "distcc")})
else
- batchjobs:addjob("rule/" .. rulename .. "/" .. scriptname, function (index, total)
- script(target, sourcebatch, {progress = (index * 100) / total})
+ batchjobs:addjob("rule/" .. rulename .. "/" .. scriptname, function (index, total, opt)
+ script(target, sourcebatch, {progress = opt.progress})
end, {rootjob = rootjob})
end
end
@@ -113,8 +113,8 @@ function _add_batchjobs_for_rule(batchjobs, rootjob, target, sourcebatch, suffix
if script then
local sourcekind = sourcebatch.sourcekind
for _, sourcefile in ipairs(sourcebatch.sourcefiles) do
- batchjobs:addjob(sourcefile, function (index, total)
- script(target, sourcefile, {sourcekind = sourcekind, progress = (index * 100) / total})
+ batchjobs:addjob(sourcefile, function (index, total, opt)
+ script(target, sourcefile, {sourcekind = sourcekind, progress = opt.progress})
end, {rootjob = rootjob, distcc = ruleinst:extraconf(scriptname, "distcc")})
end
end
@@ -125,10 +125,10 @@ function _add_batchjobs_for_rule(batchjobs, rootjob, target, sourcebatch, suffix
scriptname = "buildcmd_files" .. (suffix and ("_" .. suffix) or "")
script = ruleinst:script(scriptname)
if script then
- batchjobs:addjob("rule/" .. rulename .. "/" .. scriptname, function (index, total)
+ batchjobs:addjob("rule/" .. rulename .. "/" .. scriptname, function (index, total, opt)
local batchcmds_ = batchcmds.new({target = target})
local distcc = ruleinst:extraconf(scriptname, "distcc")
- script(target, batchcmds_, sourcebatch, {progress = (index * 100) / total, distcc = distcc})
+ script(target, batchcmds_, sourcebatch, {progress = opt.progress, distcc = distcc})
batchcmds_:runcmds({changed = target:is_rebuilt(), dryrun = option.get("dry-run")})
end, {rootjob = rootjob})
end
@@ -141,9 +141,9 @@ function _add_batchjobs_for_rule(batchjobs, rootjob, target, sourcebatch, suffix
if script then
local sourcekind = sourcebatch.sourcekind
for _, sourcefile in ipairs(sourcebatch.sourcefiles) do
- batchjobs:addjob(sourcefile, function (index, total)
+ batchjobs:addjob(sourcefile, function (index, total, opt)
local batchcmds_ = batchcmds.new({target = target})
- script(target, batchcmds_, sourcefile, {sourcekind = sourcekind, progress = (index * 100) / total})
+ script(target, batchcmds_, sourcefile, {sourcekind = sourcekind, progress = opt.progress})
batchcmds_:runcmds({changed = target:is_rebuilt(), dryrun = option.get("dry-run")})
end, {rootjob = rootjob, distcc = ruleinst:extraconf(scriptname, "distcc")})
end
@@ -177,8 +177,8 @@ function _add_batchjobs_for_target(batchjobs, rootjob, target, sourcebatch, suff
if target:extraconf(scriptname, "batch") then
script(target, batchjobs, sourcebatch, {rootjob = rootjob, distcc = target:extraconf(scriptname, "distcc")})
else
- batchjobs:addjob(target:name() .. "/" .. scriptname, function (index, total)
- script(target, sourcebatch, {progress = (index * 100) / total})
+ batchjobs:addjob(target:name() .. "/" .. scriptname, function (index, total, opt)
+ script(target, sourcebatch, {progress = opt.progress})
end, {rootjob = rootjob})
end
return true
@@ -188,8 +188,8 @@ function _add_batchjobs_for_target(batchjobs, rootjob, target, sourcebatch, suff
if script then
local sourcekind = sourcebatch.sourcekind
for _, sourcefile in ipairs(sourcebatch.sourcefiles) do
- batchjobs:addjob(sourcefile, function (index, total)
- script(target, sourcefile, {sourcekind = sourcekind, progress = (index * 100) / total})
+ batchjobs:addjob(sourcefile, function (index, total, opt)
+ script(target, sourcefile, {sourcekind = sourcekind, progress = opt.progress})
end, {rootjob = rootjob, distcc = target:extraconf(scriptname, "distcc")})
end
return true
diff --git a/xmake/actions/build/kinds/shared.lua b/xmake/actions/build/kinds/shared.lua
index f4763c608..81cf0ebb5 100644
--- a/xmake/actions/build/kinds/shared.lua
+++ b/xmake/actions/build/kinds/shared.lua
@@ -156,8 +156,8 @@ end
function main(batchjobs, rootjob, target)
-- add link job
- local job_link = batchjobs:addjob(target:name() .. "/link", function (index, total)
- _link_target(target, {progress = (index * 100) / total})
+ local job_link = batchjobs:addjob(target:name() .. "/link", function (index, total, opt)
+ _link_target(target, {progress = opt.progress})
end, {rootjob = rootjob})
-- we only need to return and depend the link job for each target,
diff --git a/xmake/actions/build/kinds/static.lua b/xmake/actions/build/kinds/static.lua
index 0d75b58c6..47668770d 100644
--- a/xmake/actions/build/kinds/static.lua
+++ b/xmake/actions/build/kinds/static.lua
@@ -156,8 +156,8 @@ end
function main(batchjobs, rootjob, target)
-- add link job
- local job_link = batchjobs:addjob(target:name() .. "/link", function (index, total)
- _link_target(target, {progress = (index * 100) / total})
+ local job_link = batchjobs:addjob(target:name() .. "/link", function (index, total, opt)
+ _link_target(target, {progress = opt.progress})
end, {rootjob = rootjob})
-- we only need to return and depend the link job for each target,
diff --git a/xmake/actions/test/main.lua b/xmake/actions/test/main.lua
index ccc69e897..852f00662 100644
--- a/xmake/actions/test/main.lua
+++ b/xmake/actions/test/main.lua
@@ -270,7 +270,7 @@ function _run_tests(tests)
print("running tests ...")
local report = {passed = 0, total = #ordertests}
local jobs = tonumber(option.get("jobs")) or os.default_njob()
- runjobs("run_tests", function (index)
+ runjobs("run_tests", function (index, total, opt)
local testinfo = ordertests[index]
if testinfo then
local target = testinfo.target
@@ -286,7 +286,7 @@ function _run_tests(tests)
if option.get("verbose") then
progress_format = progress_format .. "${dim}"
end
- local progress = math.floor(index * 100 / #ordertests)
+ local progress = opt.progress:percent()
local padding = maxwidth - #testinfo.name
cprint(progress_format .. "%s%s .................................... " .. status_color .. "%s${clear} ${bright}%0.3fs",
progress, testinfo.name, (" "):rep(padding), passed and "passed" or "failed", spent / 1000)
diff --git a/xmake/modules/async/runjobs.lua b/xmake/modules/async/runjobs.lua
index 19090da5d..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 (idx, total)
--- print(idx, 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 (idx, total)
--- print(idx, 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})
@@ -154,12 +154,30 @@ function main(name, jobs, opt)
-- run jobs
local index = 0
local count = 0
- local count_as_index = opt.count_as_index
local priority_prev = 0
local priority_curr = 0
local job_pending = nil
local abort = false
local abort_errors
+ local progress_wrapper = {}
+ progress_wrapper.current = function ()
+ return count
+ end
+ progress_wrapper.total = function ()
+ return total
+ end
+ progress_wrapper.percent = function ()
+ if total and total > 0 then
+ return math.floor((count * 100) / total)
+ else
+ return 0
+ end
+ end
+ debug.setmetatable(progress_wrapper, {
+ __tostring = function ()
+ return string.format("%d%%", progress_wrapper.percent())
+ end
+ })
while index < total do
scheduler.co_group_begin(group_name, function (co_group)
local freemax = comax - #co_group
@@ -234,8 +252,8 @@ function main(name, jobs, opt)
if opt.curdir then
os.cd(opt.curdir)
end
- jobfunc(count_as_index and count or i, total)
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 074046a69..aefaef1af 100644
--- a/xmake/modules/utils/progress.lua
+++ b/xmake/modules/utils/progress.lua
@@ -26,10 +26,10 @@ import("core.base.tty")
import("core.theme.theme")
-- define module
-local process = process or object { _init = { "_RUNNING", "_INDEX", "_STREAM", "_OPT" } }
+local progress = progress or object { _init = { "_RUNNING", "_INDEX", "_STREAM", "_OPT" } }
-- stop the progress indicator, clear written frames
-function process:stop()
+function progress:stop()
if self._RUNNING ~= 0 then
self:clear()
self._RUNNING = 0
@@ -37,7 +37,7 @@ function process:stop()
end
end
-function process:_clear()
+function progress:_clear()
if self._RUNNING == 1 then
tty.erase_line_to_end()
self._RUNNING = 2
@@ -46,14 +46,14 @@ function process:_clear()
end
-- clear previous frame of the progress indicator
-function process:clear()
+function progress:clear()
if self:_clear() then
self._STREAM:flush()
end
end
-- write next frame of the progress indicator
-function process:write()
+function progress:write()
local chars = self._OPT.chars[self._INDEX % #self._OPT.chars + 1]
tty.cursor_and_attrs_save()
self._STREAM:write(chars)
@@ -64,7 +64,7 @@ function process:write()
end
-- check if the progress indicator is running
-function process:running()
+function progress:running()
return self._RUNNING and true or false
end
@@ -73,9 +73,9 @@ function showing_without_scroll()
return _g.showing_without_scroll
end
--- show the message with process
+-- 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, ...)
@@ -112,9 +112,9 @@ function show(progress, format, ...)
end
end
--- get the message text with process
+-- 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, ...)
@@ -135,5 +135,5 @@ function new(stream, opt)
if opt.chars == nil or #opt.chars == 0 then
opt.chars = theme.get("text.spinner.chars")
end
- return process {_OPT = opt, _STREAM = stream, _RUNNING = 0, _INDEX = 0}
+ return progress {_OPT = opt, _STREAM = stream, _RUNNING = 0, _INDEX = 0}
end
diff --git a/xmake/rules/c++/modules/modules_support/builder.lua b/xmake/rules/c++/modules/modules_support/builder.lua
index 523a421b0..c56ac0731 100644
--- a/xmake/rules/c++/modules/modules_support/builder.lua
+++ b/xmake/rules/c++/modules/modules_support/builder.lua
@@ -385,11 +385,11 @@ function generate_metadata(target, modules)
end
local jobs = option.get("jobs") or os.default_njob()
- runjobs(target:name() .. "_install_modules", function(index)
+ runjobs(target:name() .. "_install_modules", function(index, total, jobopt)
local module = public_modules[index]
local name, _, cppfile = compiler_support.get_provided_module(module)
local metafilepath = compiler_support.get_metafile(target, cppfile)
- progress.show((index * 100) / #public_modules, "${color.build.target}<%s> generating.module.metadata %s", target:name(), name)
+ progress.show(jobopt.progress, "${color.build.target}<%s> generating.module.metadata %s", target:name(), name)
local metadata = _generate_meta_module_info(target, name, cppfile, module.requires)
json.savefile(metafilepath, metadata)
end, {comax = jobs, total = #public_modules})
diff --git a/xmake/rules/c++/modules/modules_support/clang/builder.lua b/xmake/rules/c++/modules/modules_support/clang/builder.lua
index 6c36feff6..f0b853b87 100644
--- a/xmake/rules/c++/modules/modules_support/clang/builder.lua
+++ b/xmake/rules/c++/modules/modules_support/clang/builder.lua
@@ -204,7 +204,7 @@ function make_module_buildjobs(target, batchjobs, job_name, deps, opt)
name = job_name,
deps = table.join(target:name() .. "_populate_module_map", deps),
sourcefile = opt.cppfile,
- job = batchjobs:newjob(name or opt.cppfile, function(index, total)
+ job = batchjobs:newjob(name or opt.cppfile, function(index, total, jobopt)
local mapped_bmi
if provide and compiler_support.memcache():get2(target:name() .. name, "reuse") then
if not target:is_binary() then
@@ -252,18 +252,18 @@ function make_module_buildjobs(target, batchjobs, job_name, deps, opt)
local bmifile = mapped_bmi or bmifile
if target:is_binary() then
if mapped_bmi then
- progress.show((index * 100) / total, "${color.build.target}<%s> ${clear}${color.build.object}compiling.objectfile.$(mode) %s", target:name(), name or opt.cppfile)
+ progress.show(jobopt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.objectfile.$(mode) %s", target:name(), name or opt.cppfile)
_compile_objectfile_step(target, bmifile, opt.cppfile, opt.objectfile)
else
- progress.show((index * 100) / total, "${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s", target:name(), name or opt.cppfile)
+ progress.show(jobopt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s", target:name(), name or opt.cppfile)
_compile_one_step(target, bmifile, opt.cppfile, opt.objectfile, {std = (name == "std" or name == "std.compat")})
end
else
if (not public and not external) or (external and private_dep) then
- progress.show((index * 100) / total, "${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s", target:name(), name or opt.cppfile)
+ progress.show(jobopt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s", target:name(), name or opt.cppfile)
_compile_one_step(target, bmifile, opt.cppfile, opt.objectfile, {std = (name == "std" or name == "std.compat")})
else
- progress.show((index * 100) / total, "${color.build.target}<%s> ${clear}${color.build.object}compiling.bmi.$(mode) %s", target:name(), name or opt.cppfile)
+ progress.show(jobopt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.bmi.$(mode) %s", target:name(), name or opt.cppfile)
_compile_bmi_step(target, bmifile, opt.cppfile, {std = (name == "std" or name == "std.compat")})
end
end
@@ -352,7 +352,7 @@ function make_headerunit_buildjobs(target, job_name, batchjobs, headerunit, bmif
return {
name = job_name,
sourcefile = headerunit.path,
- job = batchjobs:newjob(job_name, function(index, total)
+ job = batchjobs:newjob(job_name, function(index, total, jobopt)
if not os.isdir(outputdir) then
os.mkdir(outputdir)
end
@@ -366,7 +366,7 @@ function make_headerunit_buildjobs(target, job_name, batchjobs, headerunit, bmif
local depvalues = {compinst:program(), compflags}
if opt.build then
- progress.show((index * 100) / total, "${color.build.target}<%s> ${clear}${color.build.object}compiling.headerunit.$(mode) %s", target:name(), headerunit.name)
+ progress.show(jobopt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.headerunit.$(mode) %s", target:name(), headerunit.name)
_compile(target, _make_headerunitflags(target, headerunit, bmifile), headerunit.path, bmifile)
end
diff --git a/xmake/rules/c++/modules/modules_support/gcc/builder.lua b/xmake/rules/c++/modules/modules_support/gcc/builder.lua
index 0c9b8c1b1..e2d6f95c5 100644
--- a/xmake/rules/c++/modules/modules_support/gcc/builder.lua
+++ b/xmake/rules/c++/modules/modules_support/gcc/builder.lua
@@ -183,7 +183,7 @@ function make_module_buildjobs(target, batchjobs, job_name, deps, opt)
name = job_name,
deps = table.join(target:name() .. "_populate_module_map", deps),
sourcefile = opt.cppfile,
- job = batchjobs:newjob(name or opt.cppfile, function(index, total)
+ job = batchjobs:newjob(name or opt.cppfile, function(index, total, jobopt)
local mapped_bmi
if provide and compiler_support.memcache():get2(target:name() .. name, "reuse") then
if not target:is_binary() then
@@ -220,18 +220,18 @@ function make_module_buildjobs(target, batchjobs, job_name, deps, opt)
local sourcefile
if target:is_binary() then
if mapped_bmi then
- progress.show((index * 100) / total, "${color.build.target}<%s> ${clear}${color.build.object}compiling.objectfile.$(mode) %s", target:name(), name or opt.cppfile)
+ progress.show(jobopt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.objectfile.$(mode) %s", target:name(), name or opt.cppfile)
sourcefile = bmifile
else
- progress.show((index * 100) / total, "${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s", target:name(), name or opt.cppfile)
+ progress.show(jobopt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s", target:name(), name or opt.cppfile)
sourcefile = opt.cppfile
end
else
if (not public and not external) or (external and private_dep) then
- progress.show((index * 100) / total, "${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s", target:name(), name or opt.cppfile)
+ progress.show(jobopt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s", target:name(), name or opt.cppfile)
sourcefile = opt.cppfile
else
- progress.show((index * 100) / total, "${color.build.target}<%s> ${clear}${color.build.object}compiling.bmi.$(mode) %s", target:name(), name or opt.cppfile)
+ progress.show(jobopt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.bmi.$(mode) %s", target:name(), name or opt.cppfile)
local module_onlyflag = compiler_support.get_moduleonlyflag(target)
table.insert(flags, module_onlyflag)
sourcefile = opt.cppfile
@@ -333,7 +333,7 @@ function make_headerunit_buildjobs(target, job_name, batchjobs, headerunit, bmif
return {
name = job_name,
sourcefile = headerunit.path,
- job = batchjobs:newjob(job_name, function(index, total)
+ job = batchjobs:newjob(job_name, function(index, total, jobopt)
if not os.isdir(outputdir) then
os.mkdir(outputdir)
end
@@ -348,7 +348,7 @@ function make_headerunit_buildjobs(target, job_name, batchjobs, headerunit, bmif
if opt.build then
local headerunit_mapper = _generate_headerunit_modulemapper_file({name = path.normalize(headerunit.path), bmifile = bmifile})
- progress.show((index * 100) / total, "${color.build.target}<%s> ${clear}${color.build.object}compiling.headerunit.$(mode) %s", target:name(), headerunit.name)
+ progress.show(jobopt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.headerunit.$(mode) %s", target:name(), headerunit.name)
if option.get("diagnosis") then
print("mapper file:\n%s", io.readfile(headerunit_mapper))
end
diff --git a/xmake/rules/c++/modules/modules_support/msvc/builder.lua b/xmake/rules/c++/modules/modules_support/msvc/builder.lua
index a46dae34a..5a67df409 100644
--- a/xmake/rules/c++/modules/modules_support/msvc/builder.lua
+++ b/xmake/rules/c++/modules/modules_support/msvc/builder.lua
@@ -267,7 +267,7 @@ function make_module_buildjobs(target, batchjobs, job_name, deps, opt)
name = job_name,
deps = table.join(target:name() .. "_populate_module_map", deps),
sourcefile = opt.cppfile,
- job = batchjobs:newjob(name or opt.cppfile, function(index, total)
+ job = batchjobs:newjob(name or opt.cppfile, function(index, total, jobopt)
local mapped_bmi
if provide and compiler_support.memcache():get2(target:name() .. name, "reuse") then
@@ -316,18 +316,18 @@ function make_module_buildjobs(target, batchjobs, job_name, deps, opt)
local bmifile = mapped_bmi or bmifile
if target:is_binary() then
if mapped_bmi then
- progress.show((index * 100) / total, "${color.build.target}<%s> ${clear}${color.build.object}compiling.objectfile.$(mode) %s", target:name(), name or opt.cppfile)
+ progress.show(jobopt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.objectfile.$(mode) %s", target:name(), name or opt.cppfile)
_compile_objectfile_step(target, bmifile, opt.cppfile, opt.objectfile, provide)
else
- progress.show((index * 100) / total, "${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s", target:name(), name or opt.cppfile)
+ progress.show(jobopt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s", target:name(), name or opt.cppfile)
_compile_one_step(target, bmifile, opt.cppfile, opt.objectfile, provide)
end
else
if (not public and not external) or (external and private_dep) then
- progress.show((index * 100) / total, "${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s", target:name(), name or opt.cppfile)
+ progress.show(jobopt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s", target:name(), name or opt.cppfile)
_compile_one_step(target, bmifile, opt.cppfile, opt.objectfile, provide)
else
- progress.show((index * 100) / total, "${color.build.target}<%s> ${clear}${color.build.object}compiling.bmi.$(mode) %s", target:name(), name or opt.cppfile)
+ progress.show(jobopt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.bmi.$(mode) %s", target:name(), name or opt.cppfile)
_compile_bmi_step(target, bmifile, opt.cppfile, opt.objectfile, provide)
end
end
@@ -416,7 +416,7 @@ function make_headerunit_buildjobs(target, job_name, batchjobs, headerunit, bmif
return {
name = job_name,
sourcefile = headerunit.path,
- job = batchjobs:newjob(job_name, function(index, total)
+ job = batchjobs:newjob(job_name, function(index, total, jobopt)
if not os.isdir(outputdir) then
os.mkdir(outputdir)
end
@@ -432,7 +432,7 @@ function make_headerunit_buildjobs(target, job_name, batchjobs, headerunit, bmif
local name = headerunit.unique and headerunit.name or headerunit.path
if opt.build then
- progress.show((index * 100) / total, "${color.build.target}<%s> ${clear}${color.build.object}compiling.headerunit.$(mode) %s", target:name(), headerunit.name)
+ progress.show(jobopt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.headerunit.$(mode) %s", target:name(), headerunit.name)
_compile(target, _make_headerunitflags(target, headerunit, bmifile), name, target:objectfile(headerunit.path), true)
end
diff --git a/xmake/rules/protobuf/proto.lua b/xmake/rules/protobuf/proto.lua
index 0be0cbb96..91dc4c727 100644
--- a/xmake/rules/protobuf/proto.lua
+++ b/xmake/rules/protobuf/proto.lua
@@ -294,9 +294,9 @@ function build_cxfiles(target, batchjobs, sourcebatch, opt, sourcekind)
local nodename = node_rulename .. "/" .. sourcefile_proto
nodes[nodename] = {
name = nodename,
- job = batchjobs:addjob(nodename, function(index, total)
+ job = batchjobs:addjob(nodename, function(index, total, jobopt)
local batchcmds_ = batchcmds.new({target = target})
- buildcmd_pfiles(target, batchcmds_, sourcefile_proto, {progress = (index * 100) / total}, sourcekind)
+ buildcmd_pfiles(target, batchcmds_, sourcefile_proto, {progress = jobopt.progress}, sourcekind)
batchcmds_:runcmds({changed = target:is_rebuilt(), dryrun = option.get("dry-run")})
end)
}