File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -1176,6 +1176,13 @@ function precompile(ctx::Context, pkgs::Vector{PackageSpec}; internal_call::Bool
11761176 end
11771177end
11781178
1179+ function precompile (f, args... ; kwargs... )
1180+ Base. ScopedValues. @with _autoprecompilation_enabled_scoped => false begin
1181+ f ()
1182+ Pkg. precompile (args... ; kwargs... )
1183+ end
1184+ end
1185+
11791186function tree_hash (repo:: LibGit2.GitRepo , tree_hash:: String )
11801187 try
11811188 return LibGit2. GitObject (repo, tree_hash)
Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ usable_io(io) = (io isa Base.TTY) || (io isa IOContext{IO} && io.io isa Base.TTY
6565can_fancyprint (io:: IO ) = (usable_io (io)) && (get (ENV , " CI" , nothing ) != " true" )
6666
6767_autoprecompilation_enabled:: Bool = true
68- _autoprecompilation_enabled_scoped = ScopedValue {Bool} (true )
68+ _autoprecompilation_enabled_scoped = Base . ScopedValues . ScopedValue {Bool} (true )
6969autoprecompilation_enabled (state:: Bool ) = (autoprecompilation_enabled = state)
7070function should_autoprecompile ()
7171 if Base. JLOptions (). use_compiled_modules == 1 &&
@@ -204,11 +204,21 @@ const add = API.add
204204 Pkg.precompile(; strict::Bool=false, timing::Bool=false)
205205 Pkg.precompile(pkg; strict::Bool=false, timing::Bool=false)
206206 Pkg.precompile(pkgs; strict::Bool=false, timing::Bool=false)
207+ Pkg.precompile(f, args...; kwargs...)
207208
208209Precompile all or specific dependencies of the project in parallel.
209210
210211Set `timing=true` to show the duration of the precompilation of each dependency.
211212
213+ To delay autoprecompilation of multiple Pkg actions until the end use.
214+ This may be most efficient while manipulating the environment in various ways.
215+
216+ ```julia
217+ Pkg.precompile() do
218+ # Pkg actions here
219+ end
220+ ```
221+
212222!!! note
213223 Errors will only throw when precompiling the top-level dependencies, given that
214224 not all manifest dependencies may be loaded by the top-level dependencies on the given system.
You can’t perform that action at this time.
0 commit comments