Skip to content

Commit 1e21727

Browse files
KristofferCKristofferC
andauthored
Homogenize the progress bar in Pkg and base package precompilation (#55588)
- Fix a missing check to `always_reprint` that has been fixed in Pkg - The header was in `light_green` while in Pkg it was `green`. - The progress bar for downloading packages and artifacts was in green while compiling package was in blue. - The progress bar is now attached to the "Precompiling packages" header like for artifact and package downloads. Co-authored-by: KristofferC <[email protected]>
1 parent ed08457 commit 1e21727

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

base/precompilation.jl

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ function show_progress(io::IO, p::MiniProgressBar; termwidth=nothing, carriagere
285285
return
286286
end
287287
t = time()
288-
if p.has_shown && (t - p.time_shown) < PROGRESS_BAR_TIME_GRANULARITY[]
288+
if !p.always_reprint && p.has_shown && (t - p.time_shown) < PROGRESS_BAR_TIME_GRANULARITY[]
289289
return
290290
end
291291
p.time_shown = t
@@ -301,9 +301,11 @@ function show_progress(io::IO, p::MiniProgressBar; termwidth=nothing, carriagere
301301
max_progress_width = max(0, min(termwidth - textwidth(p.header) - textwidth(progress_text) - 10 , p.width))
302302
n_filled = ceil(Int, max_progress_width * perc / 100)
303303
n_left = max_progress_width - n_filled
304+
headers = split(p.header, ' ')
304305
to_print = sprint(; context=io) do io
305306
print(io, " "^p.indent)
306-
printstyled(io, p.header, color=p.color, bold=true)
307+
printstyled(io, headers[1], " "; color=:green, bold=true)
308+
printstyled(io, join(headers[2:end], ' '))
307309
print(io, " ")
308310
printstyled(io, ""^n_filled; color=p.color)
309311
printstyled(io, perc >= 95 ? "" : ""; color=p.color)
@@ -343,7 +345,7 @@ import Base: StaleCacheKey
343345

344346
can_fancyprint(io::IO) = io isa Base.TTY && (get(ENV, "CI", nothing) != "true")
345347

346-
function printpkgstyle(io, header, msg; color=:light_green)
348+
function printpkgstyle(io, header, msg; color=:green)
347349
printstyled(io, header; color, bold=true)
348350
println(io, " ", msg)
349351
end
@@ -564,9 +566,6 @@ function precompilepkgs(pkgs::Vector{String}=String[];
564566
if !manifest
565567
if isempty(pkgs)
566568
pkgs = [pkg.name for pkg in direct_deps]
567-
target = "all packages"
568-
else
569-
target = join(pkgs, ", ")
570569
end
571570
# restrict to dependencies of given packages
572571
function collect_all_deps(depsmap, dep, alldeps=Set{Base.PkgId}())
@@ -602,18 +601,16 @@ function precompilepkgs(pkgs::Vector{String}=String[];
602601
return
603602
end
604603
end
605-
else
606-
target = "manifest"
607604
end
608605

609606
nconfigs = length(configs)
607+
target = nothing
610608
if nconfigs == 1
611609
if !isempty(only(configs)[1])
612-
target *= " for configuration $(join(only(configs)[1], " "))"
610+
target = "for configuration $(join(only(configs)[1], " "))"
613611
end
614-
target *= "..."
615612
else
616-
target *= " for $nconfigs compilation configurations..."
613+
target = "for $nconfigs compilation configurations..."
617614
end
618615
@debug "precompile: packages filtered"
619616

@@ -695,15 +692,19 @@ function precompilepkgs(pkgs::Vector{String}=String[];
695692
try
696693
wait(first_started)
697694
(isempty(pkg_queue) || interrupted_or_done.set) && return
698-
fancyprint && lock(print_lock) do
699-
printpkgstyle(io, :Precompiling, target)
700-
print(io, ansi_disablecursor)
695+
lock(print_lock) do
696+
if target !== nothing
697+
printpkgstyle(io, :Precompiling, target)
698+
end
699+
if fancyprint
700+
print(io, ansi_disablecursor)
701+
end
701702
end
702703
t = Timer(0; interval=1/10)
703704
anim_chars = ["","","",""]
704705
i = 1
705706
last_length = 0
706-
bar = MiniProgressBar(; indent=2, header = "Progress", color = Base.info_color(), percentage=false, always_reprint=true)
707+
bar = MiniProgressBar(; indent=0, header = "Precompiling packages ", color = :green, percentage=false, always_reprint=true)
707708
n_total = length(depsmap) * length(configs)
708709
bar.max = n_total - n_already_precomp
709710
final_loop = false
@@ -832,8 +833,10 @@ function precompilepkgs(pkgs::Vector{String}=String[];
832833
config_str = "$(join(flags, " "))"
833834
name *= color_string(" $(config_str)", :light_black)
834835
end
835-
!fancyprint && lock(print_lock) do
836-
isempty(pkg_queue) && printpkgstyle(io, :Precompiling, target)
836+
lock(print_lock) do
837+
if !fancyprint && target === nothing && isempty(pkg_queue)
838+
printpkgstyle(io, :Precompiling, "packages...")
839+
end
837840
end
838841
push!(pkg_queue, pkg_config)
839842
started[pkg_config] = true

0 commit comments

Comments
 (0)