Skip to content

Commit 56cf730

Browse files
IanButterworthtopolarity
authored andcommitted
separate to a function
1 parent 539a05d commit 56cf730

File tree

1 file changed

+33
-30
lines changed

1 file changed

+33
-30
lines changed

base/precompilation.jl

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,38 @@ function full_name(exts::Dict{PkgId, String}, pkg::PkgId)
373373
end
374374
end
375375

376+
function excluded_circular_deps_explanation(circular_deps, cycles)
377+
outer_deps = copy(circular_deps)
378+
cycles_names = ""
379+
for cycle in cycles
380+
filter!(!in(cycle), outer_deps)
381+
cycle_str = ""
382+
for (i, pkg) in enumerate(cycle)
383+
j = max(0, i - 1)
384+
if i == 1
385+
line = ""
386+
elseif i < length(cycle)
387+
line = "" * " " ^j
388+
else
389+
line = "" * "" ^j * " "
390+
end
391+
line = color_string(line, :light_black) * full_name(exts, pkg) * "\n"
392+
cycle_str *= line
393+
end
394+
cycles_names *= cycle_str
395+
end
396+
plural1 = length(cycles) > 1 ? "these cycles" : "this cycle"
397+
plural2 = length(cycles) > 1 ? "cycles" : "cycle"
398+
msg = """Circular dependency detected.
399+
Precompilation will be skipped for dependencies in $plural1:
400+
$cycles_names"""
401+
if !isempty(outer_deps)
402+
msg *= "Precompilation will also be skipped for the following, which depend on the above $plural2:\n"
403+
msg *= join((" " * full_name(exts, pkg) for pkg in outer_deps), "\n")
404+
end
405+
return msg
406+
end
407+
376408
function precompilepkgs(pkgs::Vector{String}=String[];
377409
internal_call::Bool=false,
378410
strict::Bool = false,
@@ -592,36 +624,7 @@ function _precompilepkgs(pkgs::Vector{String},
592624
end
593625
end
594626
if !isempty(circular_deps)
595-
outer_deps = copy(circular_deps)
596-
cycles_names = ""
597-
for cycle in cycles
598-
filter!(!in(cycle), outer_deps)
599-
cycle_str = ""
600-
for (i, pkg) in enumerate(cycle)
601-
j = max(0, i - 1)
602-
if i == 1
603-
line = ""
604-
elseif i < length(cycle)
605-
line = "" * " " ^j
606-
else
607-
line = "" * "" ^j * " "
608-
end
609-
line = color_string(line, :light_black) * full_name(exts, pkg) * "\n"
610-
cycle_str *= line
611-
end
612-
cycles_names *= cycle_str
613-
end
614-
plural1 = length(cycles) > 1 ? "these cycles" : "this cycle"
615-
plural2 = length(outer_deps) > 1 ? "have" : "has"
616-
plural3 = length(cycles) > 1 ? "cycles" : "cycle"
617-
msg = """Circular dependency detected.
618-
Precompilation will be skipped for dependencies in $plural1:
619-
$cycles_names"""
620-
if !isempty(outer_deps)
621-
msg *= "Precompilation will also be skipped for the following, which depend on the above $plural3:\n"
622-
msg *= join((" " * full_name(exts, pkg) for pkg in outer_deps), "\n")
623-
end
624-
@warn msg
627+
@warn excluded_circular_deps_explanation(circular_deps, cycles)
625628
end
626629
@debug "precompile: circular dep check done"
627630

0 commit comments

Comments
 (0)