Skip to content

Commit

Permalink
disable prec via Preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
t-bltg committed Jan 8, 2023
1 parent 333b645 commit 43ff906
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions SnoopPrecompile/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ uuid = "66db9d55-30c0-4569-8b51-7e840670fc0c"
authors = ["Tim Holy <tim.holy@gmail.com> and contributors"]
version = "1.0.2"

[deps]
Preferences = "21216c6a-2e73-6563-6e65-726566657250"

[compat]
Preferences = "1"
julia = "1"

[extras]
Expand Down
5 changes: 5 additions & 0 deletions SnoopPrecompile/src/SnoopPrecompile.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
module SnoopPrecompile

using Preferences

export @precompile_all_calls, @precompile_setup

const verbose = Ref(false) # if true, prints all the precompiles
const have_inference_tracking = isdefined(Core.Compiler, :__set_measure_typeinf)
const have_force_compile = isdefined(Base, :Experimental) && isdefined(Base.Experimental, Symbol("#@force_compile"))
const do_precompile = Base.VERSION >= v"1.6" ? @load_preference("precompile", true) : true

function precompile_roots(roots)
@assert have_inference_tracking
Expand Down Expand Up @@ -44,6 +47,7 @@ end
- indirect runtime-dispatched calls to such methods.
"""
macro precompile_all_calls(ex::Expr)
do_precompile || return :()
if have_force_compile
ex = quote
begin
Expand Down Expand Up @@ -101,6 +105,7 @@ runtime dispatches (though they will be precompiled anyway if the runtime-callee
to your package).
"""
macro precompile_setup(ex::Expr)
do_precompile || return :()
return esc(quote
# let
if ccall(:jl_generating_output, Cint, ()) == 1 || $SnoopPrecompile.verbose[]
Expand Down

0 comments on commit 43ff906

Please sign in to comment.