@@ -395,14 +395,13 @@ function precompilepkgs(pkgs::Vector{String}=String[];
395395 # in the current environment (i.e. their triggers are present)
396396 parent_to_exts = Dict {Base.PkgId, Vector{Base.PkgId}} ()
397397 # inverse map of `parent_to_ext` above (ext → parent)
398- ext_to_parent_name = Dict {Base.PkgId, String } ()
398+ ext_to_parent = Dict {Base.PkgId, Base.PkgId } ()
399399
400400 for (dep, deps) in env. deps
401401 pkg = Base. PkgId (dep, env. names[dep])
402402 Base. in_sysimage (pkg) && continue
403403 deps = [Base. PkgId (x, env. names[x]) for x in deps]
404404 direct_deps[pkg] = filter! (! Base. in_sysimage, deps)
405- pkg_exts = Dict {Base.PkgId, Vector{Base.PkgId}} ()
406405 for (ext_name, trigger_uuids) in env. extensions[dep]
407406 triggers = Base. PkgId[] # triggers for `ext`
408407 push! (triggers, pkg) # depends on parent package
@@ -421,12 +420,13 @@ function precompilepkgs(pkgs::Vector{String}=String[];
421420 ext = Base. PkgId (ext_uuid, ext_name)
422421 filter! (! Base. in_sysimage, triggers)
423422
423+ if ! haskey (parent_to_exts, pkg)
424+ parent_to_exts[pkg] = Base. PkgId[]
425+ end
426+
424427 direct_deps[ext] = triggers
425- ext_to_parent_name[ext] = pkg. name
426- pkg_exts[ext] = triggers
427- end
428- if ! isempty (pkg_exts)
429- parent_to_exts[pkg] = collect (keys (pkg_exts))
428+ ext_to_parent[ext] = pkg
429+ push! (parent_to_exts[pkg], ext)
430430 end
431431 end
432432
@@ -436,15 +436,15 @@ function precompilepkgs(pkgs::Vector{String}=String[];
436436 ]
437437
438438 # consider exts of project deps to be project deps so that errors are reported
439- append! (project_deps, keys (filter (d-> last (d) in keys (env. project_deps), ext_to_parent_name )))
439+ append! (project_deps, keys (filter (d-> last (d). name in keys (env. project_deps), ext_to_parent )))
440440
441441 @debug " precompile: deps collected"
442442 # this loop must be run after the full direct_deps map has been populated
443443 for (pkg, pkg_exts) in parent_to_exts
444444 # find any packages that depend on the extension(s)'s deps and replace those deps in their deps list with the extension(s),
445445 # basically injecting the extension into the precompile order in the graph, to avoid race to precompile extensions
446446 for (_pkg, deps) in direct_deps # for each manifest dep
447- if ! in (_pkg, keys (ext_to_parent_name )) && pkg in deps # if not an extension and depends on pkg
447+ if ! in (_pkg, keys (ext_to_parent )) && pkg in deps # if not an extension and depends on pkg
448448 append! (deps, pkg_exts) # add the package extensions to deps
449449 filter! (! isequal (pkg), deps) # remove the pkg from deps
450450 end
@@ -542,7 +542,7 @@ function precompilepkgs(pkgs::Vector{String}=String[];
542542 collect_all_deps (direct_deps, dep_pkgid, keep)
543543 end
544544 end
545- for ext in keys (ext_to_parent_name )
545+ for ext in keys (ext_to_parent )
546546 if issubset (collect_all_deps (direct_deps, ext), keep) # if all extension deps are kept
547547 push! (keep, ext)
548548 end
@@ -691,7 +691,7 @@ function precompilepkgs(pkgs::Vector{String}=String[];
691691 for pkg_config in pkg_queue_show
692692 dep, config = pkg_config
693693 loaded = warn_loaded && haskey (Base. loaded_modules, dep)
694- _name = haskey (ext_to_parent_name , dep) ? string (ext_to_parent_name [dep], " → " , dep. name) : dep. name
694+ _name = haskey (ext_to_parent , dep) ? string (ext_to_parent [dep]. name , " → " , dep. name) : dep. name
695695 name = dep in project_deps ? _name : string (color_string (_name, :light_black ))
696696 if nconfigs > 1 && ! isempty (config[1 ])
697697 config_str = " $(join (config[1 ], " " )) "
@@ -784,7 +784,7 @@ function precompilepkgs(pkgs::Vector{String}=String[];
784784 std_pipe = Base. link_pipe! (Pipe (); reader_supports_async= true , writer_supports_async= true )
785785 t_monitor = @async monitor_std (pkg_config, std_pipe; single_requested_pkg)
786786
787- _name = haskey (ext_to_parent_name , pkg) ? string (ext_to_parent_name [pkg], " → " , pkg. name) : pkg. name
787+ _name = haskey (ext_to_parent , pkg) ? string (ext_to_parent [pkg]. name , " → " , pkg. name) : pkg. name
788788 name = is_project_dep ? _name : string (color_string (_name, :light_black ))
789789 if nconfigs > 1 && ! isempty (flags)
790790 config_str = " $(join (flags, " " )) "
@@ -809,7 +809,7 @@ function precompilepkgs(pkgs::Vector{String}=String[];
809809 t = @elapsed ret = precompile_pkgs_maybe_cachefile_lock (io, print_lock, fancyprint, pkg_config, pkgspidlocked, hascolor) do
810810 Base. with_logger (Base. NullLogger ()) do
811811 # The false here means we ignore loaded modules, so precompile for a fresh session
812- Base. compilecache (pkg, sourcepath, std_pipe, std_pipe, false ; flags, cacheflags, isext = haskey (ext_to_parent_name , pkg))
812+ Base. compilecache (pkg, sourcepath, std_pipe, std_pipe, false ; flags, cacheflags, isext = haskey (ext_to_parent , pkg))
813813 end
814814 end
815815 if ret isa Base. PrecompilableError
@@ -920,7 +920,7 @@ function precompilepkgs(pkgs::Vector{String}=String[];
920920 else
921921 join (split (strip (err), " \n " ), color_string (" \n │ " , Base. warn_color ()))
922922 end
923- name = haskey (ext_to_parent_name , pkg) ? string (ext_to_parent_name [pkg], " → " , pkg. name) : pkg. name
923+ name = haskey (ext_to_parent , pkg) ? string (ext_to_parent [pkg]. name , " → " , pkg. name) : pkg. name
924924 print (iostr, color_string (" \n ┌ " , Base. warn_color ()), name, color_string (" \n │ " , Base. warn_color ()), err, color_string (" \n └ " , Base. warn_color ()))
925925 end
926926 end
0 commit comments