summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xmake/actions/build/deprecated/build.lua2
-rw-r--r--xmake/modules/private/action/build/target.lua8
-rw-r--r--xmake/modules/utils/progress.lua50
3 files changed, 33 insertions, 27 deletions
diff --git a/xmake/actions/build/deprecated/build.lua b/xmake/actions/build/deprecated/build.lua
index 26c86c9a3..dd6698b96 100644
--- a/xmake/actions/build/deprecated/build.lua
+++ b/xmake/actions/build/deprecated/build.lua
@@ -274,7 +274,7 @@ function main(targets_root, opt)
runjobs("build", batchjobs, {on_exit = function (errors)
import("utils.progress")
if errors then
- progress.show_output(errors)
+ progress.show_output("")
end
end, comax = option.get("jobs") or 1, curdir = curdir, distcc = distcc})
os.cd(curdir)
diff --git a/xmake/modules/private/action/build/target.lua b/xmake/modules/private/action/build/target.lua
index 19d4db853..315feab61 100644
--- a/xmake/modules/private/action/build/target.lua
+++ b/xmake/modules/private/action/build/target.lua
@@ -787,8 +787,8 @@ function run_targetjobs(targets_root, opt)
local curdir = os.curdir()
async_runjobs(job_kind, jobgraph, {on_exit = function (errors)
import("utils.progress")
- if errors and progress.showing_without_scroll() then
- print("")
+ if errors then
+ progress.show_output("")
end
end,
comax = opt.jobs or option.get("jobs") or 1, curdir = curdir,
@@ -807,8 +807,8 @@ function run_filejobs(targets_root, opt)
local curdir = os.curdir()
async_runjobs(job_kind, jobgraph, {on_exit = function (errors)
import("utils.progress")
- if errors and progress.showing_without_scroll() then
- print("")
+ if errors then
+ progress.show_output("")
end
end,
comax = opt.jobs or option.get("jobs") or 1, curdir = curdir,
diff --git a/xmake/modules/utils/progress.lua b/xmake/modules/utils/progress.lua
index ed2a911c1..0da5b4cbb 100644
--- a/xmake/modules/utils/progress.lua
+++ b/xmake/modules/utils/progress.lua
@@ -172,40 +172,46 @@ function _show_progress_with_multirow_refresh(progress, format, ...)
tty.erase_line_to_start().cr()
cprint(progress_line)
- -- update the subprogress infos
+ -- update the current progress info
local current_time = os.mclock()
- local lineinfo = progress_lineinfos[running]
- if lineinfo == nil then
- lineinfo = {start_time = current_time, spent_time = 0, running = running}
- progress_lineinfos[running] = lineinfo
- else
- lineinfo.spent_time = current_time - lineinfo.start_time
- lineinfo.start_time = current_time
- end
- local timecolor = ""
- local spent_time = lineinfo.spent_time
- if spent_time > 1000 then
- timecolor = "${color.build.progress_veryslow}"
- elseif spent_time > 500 then
- timecolor = "${color.build.progress_slow}"
+ local current_lineinfo = progress_lineinfos[running]
+ if current_lineinfo == nil then
+ current_lineinfo = {start_time = current_time, spent_time = 0, running = running}
+ progress_lineinfos[running] = current_lineinfo
end
if is_finished then
- lineinfo.progress_line = nil
+ current_lineinfo.progress_msg = nil
else
- local subprogress_line = _strip_progress_line(vformat(" > %s%0.02fs${clear} ", timecolor, spent_time / 1000) .. progress_msg)
- lineinfo.progress_line = subprogress_line
+ current_lineinfo.progress_msg = progress_msg
end
-- sort the progress lines by the spent time
- local lineinfos = {}
+ local order_lineinfos = {}
for _, progress_lineinfo in pairs(progress_lineinfos) do
- table.insert(lineinfos, progress_lineinfo)
+ local progress_msg = progress_lineinfo.progress_msg
+ if progress_msg then
+ local timecolor = ""
+ local spent_time = current_time - progress_lineinfo.start_time
+ if spent_time > 1000 then
+ timecolor = "${color.build.progress_veryslow}"
+ elseif spent_time > 500 then
+ timecolor = "${color.build.progress_slow}"
+ end
+ progress_lineinfo.spent_time = spent_time
+ local subprogress_line = _strip_progress_line(vformat(" > %s%0.02fs${clear} ", timecolor, spent_time / 1000) .. progress_msg)
+ progress_lineinfo.progress_line = subprogress_line
+ table.insert(order_lineinfos, progress_lineinfo)
+ else
+ progress_lineinfo.spent_time = 0
+ progress_lineinfo.progress_line = nil
+ end
end
- table.sort(lineinfos, function (a, b) return a.spent_time > b.spent_time end)
+ table.sort(order_lineinfos, function (a, b) return a.spent_time > b.spent_time end)
+ current_lineinfo.start_time = current_time
-- show the subprocess lines
linecount = 0
- for _, lineinfo in ipairs(lineinfos) do
+ for _, lineinfo in ipairs(order_lineinfos) do
-- we need not show it if the progress job is idle in runjobs now
local progress_running = lineinfo.running
if progress_running and progress_running:data("runjobs.running") == false then