@@ -372,8 +372,8 @@ function precompilepkgs(pkgs::Vector{String}=String[];
372372 configs:: Union{Config,Vector{Config}} = (` ` => Base. CacheFlags ()),
373373 io:: IO = stderr ,
374374 # asking for timing disables fancy mode, as timing is shown in non-fancy mode
375- fancyprint:: Bool = can_fancyprint (io) && ! timing
376- )
375+ fancyprint:: Bool = can_fancyprint (io) && ! timing,
376+ manifest :: Bool = false , )
377377
378378 configs = configs isa Config ? [configs] : configs
379379
@@ -529,53 +529,57 @@ function precompilepkgs(pkgs::Vector{String}=String[];
529529 end
530530 @debug " precompile: circular dep check done"
531531
532- if isempty (pkgs)
533- pkgs = [pkg. name for pkg in direct_deps]
534- target = " all packages"
532+ if ! manifest
533+ if isempty (pkgs)
534+ pkgs = [pkg. name for pkg in direct_deps]
535+ target = " all packages"
536+ else
537+ target = join (pkgs, " , " )
538+ end
539+ # restrict to dependencies of given packages
540+ function collect_all_deps (depsmap, dep, alldeps= Set {Base.PkgId} ())
541+ for _dep in depsmap[dep]
542+ if ! (_dep in alldeps)
543+ push! (alldeps, _dep)
544+ collect_all_deps (depsmap, _dep, alldeps)
545+ end
546+ end
547+ return alldeps
548+ end
549+ keep = Set {Base.PkgId} ()
550+ for dep in depsmap
551+ dep_pkgid = first (dep)
552+ if dep_pkgid. name in pkgs
553+ push! (keep, dep_pkgid)
554+ collect_all_deps (depsmap, dep_pkgid, keep)
555+ end
556+ end
557+ for ext in keys (exts)
558+ if issubset (collect_all_deps (depsmap, ext), keep) # if all extension deps are kept
559+ push! (keep, ext)
560+ end
561+ end
562+ filter! (d-> in (first (d), keep), depsmap)
563+ if isempty (depsmap)
564+ if _from_loading
565+ # if called from loading precompilation it may be a package from another environment stack so
566+ # don't error and allow serial precompilation to try
567+ # TODO : actually handle packages from other envs in the stack
568+ return
569+ else
570+ return
571+ end
572+ end
535573 else
536- target = join (pkgs, " , " )
574+ target = " manifest "
537575 end
576+
538577 nconfig = length (configs)
539578 if nconfig > 1
540579 target *= " for $nconfig compilation configurations..."
541580 else
542581 target *= " ..."
543582 end
544-
545- # restrict to dependencies of given packages
546- function collect_all_deps (depsmap, dep, alldeps= Set {Base.PkgId} ())
547- for _dep in depsmap[dep]
548- if ! (_dep in alldeps)
549- push! (alldeps, _dep)
550- collect_all_deps (depsmap, _dep, alldeps)
551- end
552- end
553- return alldeps
554- end
555- keep = Set {Base.PkgId} ()
556- for dep in depsmap
557- dep_pkgid = first (dep)
558- if dep_pkgid. name in pkgs
559- push! (keep, dep_pkgid)
560- collect_all_deps (depsmap, dep_pkgid, keep)
561- end
562- end
563- for ext in keys (exts)
564- if issubset (collect_all_deps (depsmap, ext), keep) # if all extension deps are kept
565- push! (keep, ext)
566- end
567- end
568- filter! (d-> in (first (d), keep), depsmap)
569- if isempty (depsmap)
570- if _from_loading
571- # if called from loading precompilation it may be a package from another environment stack so
572- # don't error and allow serial precompilation to try
573- # TODO : actually handle packages from other envs in the stack
574- return
575- else
576- error (" No direct dependencies outside of the sysimage found matching $(repr (pkgs)) " )
577- end
578- end
579583 @debug " precompile: packages filtered"
580584
581585 pkg_queue = PkgConfig[]
0 commit comments