summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2025-11-20 00:47:39 +0800
committerruki <[email protected]>2025-11-20 00:47:39 +0800
commit7aae7b19dc081cdc1e630406788425eb74bd9d4b (patch)
tree55e655e107542d7311c7212d4b4ec57373e2368f
parentbb23918bcc9423cecc98275759d529adf41f4ca5 (diff)
add timer to progress when building
-rw-r--r--xmake/modules/private/action/build/target.lua39
-rw-r--r--xmake/modules/private/check/checkers/clang/tidy.lua4
-rw-r--r--xmake/modules/utils/progress.lua10
-rw-r--r--xmake/plugins/format/main.lua4
4 files changed, 42 insertions, 15 deletions
diff --git a/xmake/modules/private/action/build/target.lua b/xmake/modules/private/action/build/target.lua
index c88d7b830..c3d21f399 100644
--- a/xmake/modules/private/action/build/target.lua
+++ b/xmake/modules/private/action/build/target.lua
@@ -28,6 +28,7 @@ import("async.runjobs", {alias = "async_runjobs"})
import("async.jobgraph", {alias = "async_jobgraph"})
import("private.utils.batchcmds")
import("private.utils.rule", {alias = "rule_utils"})
+import("utils.progress", {alias = "progress_utils"})
-- clean target for rebuilding
function _clean_target(target)
@@ -791,9 +792,22 @@ function run_targetjobs(targets_root, opt)
local jobgraph = get_targetjobs(targets_root, opt)
if jobgraph and not jobgraph:empty() then
local curdir = os.curdir()
- async_runjobs(job_kind, jobgraph, {
- comax = opt.jobs or option.get("jobs") or 1, curdir = curdir,
- distcc = opt.distcc, remote_only = opt.remote_only, progress_factor = opt.progress_factor})
+ local runjobs_opt = {
+ comax = opt.jobs or option.get("jobs") or 1,
+ curdir = curdir,
+ distcc = opt.distcc,
+ remote_only = opt.remote_only,
+ progress_factor = opt.progress_factor
+ }
+ -- Only set timer for multirow progress mode
+ if progress_utils.is_multirow() then
+ runjobs_opt.timeout = 1000
+ runjobs_opt.on_timer = function (running_indices)
+ -- Periodically refresh multirow progress to update elapsed time
+ progress_utils.refresh()
+ end
+ end
+ async_runjobs(job_kind, jobgraph, runjobs_opt)
os.cd(curdir)
return true
end
@@ -806,9 +820,22 @@ function run_filejobs(targets_root, opt)
local jobgraph = get_filejobs(targets_root, opt)
if jobgraph and not jobgraph:empty() then
local curdir = os.curdir()
- async_runjobs(job_kind, jobgraph, {
- comax = opt.jobs or option.get("jobs") or 1, curdir = curdir,
- distcc = opt.distcc, remote_only = opt.remote_only, progress_factor = opt.progress_factor})
+ local runjobs_opt = {
+ comax = opt.jobs or option.get("jobs") or 1,
+ curdir = curdir,
+ distcc = opt.distcc,
+ remote_only = opt.remote_only,
+ progress_factor = opt.progress_factor
+ }
+ -- Only set timer for multirow progress mode
+ if progress_utils.is_multirow() then
+ runjobs_opt.timeout = 1000
+ runjobs_opt.on_timer = function (running_indices)
+ -- Periodically refresh multirow progress to update elapsed time
+ progress_utils.refresh()
+ end
+ end
+ async_runjobs(job_kind, jobgraph, runjobs_opt)
os.cd(curdir)
return true
end
diff --git a/xmake/modules/private/check/checkers/clang/tidy.lua b/xmake/modules/private/check/checkers/clang/tidy.lua
index 66c9feb87..03568eb6e 100644
--- a/xmake/modules/private/check/checkers/clang/tidy.lua
+++ b/xmake/modules/private/check/checkers/clang/tidy.lua
@@ -160,9 +160,9 @@ function _check_sourcefiles(clang_tidy, sourcefiles, opt)
comax = opt.jobs or os.default_njob(),
showtips = false
}
- -- Only set timer for multirow refresh mode
+ -- Only set timer for multirow progress mode
if progress.is_multirow() then
- runjobs_opt.timeout = 500
+ runjobs_opt.timeout = 1000
runjobs_opt.on_timer = function (running_indices)
-- Periodically refresh multirow progress to update elapsed time
progress.refresh()
diff --git a/xmake/modules/utils/progress.lua b/xmake/modules/utils/progress.lua
index c8846e033..ff97a6d6c 100644
--- a/xmake/modules/utils/progress.lua
+++ b/xmake/modules/utils/progress.lua
@@ -388,6 +388,11 @@ function show_output(format, ...)
end
end
+-- check if multirow refresh mode is enabled
+function is_multirow()
+ return _is_multirow_refresh()
+end
+
-- refresh the multirow progress display to update elapsed time
-- this is useful for long-running tasks to keep the elapsed time updated
function refresh()
@@ -398,11 +403,6 @@ function refresh()
end
end
--- check if multirow refresh mode is enabled
-function is_multirow()
- return _is_multirow_refresh()
-end
-
-- abort the progress display mode, used for error exit or early termination
-- this function cleans up the progress display area and restores the terminal state
function show_abort()
diff --git a/xmake/plugins/format/main.lua b/xmake/plugins/format/main.lua
index e8b962e2e..7a4c53394 100644
--- a/xmake/plugins/format/main.lua
+++ b/xmake/plugins/format/main.lua
@@ -221,9 +221,9 @@ function main()
comax = jobs,
showtips = false
}
- -- Only set timer for multirow refresh mode
+ -- Only set timer for multirow progress mode
if progress.is_multirow() then
- runjobs_opt.timeout = 500
+ runjobs_opt.timeout = 1000
runjobs_opt.on_timer = function (running_indices)
-- Periodically refresh multirow progress to update elapsed time
progress.refresh()