Skip to content

Commit

Permalink
snoopiBot
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Dec 12, 2019
1 parent af397ab commit dcdd5e1
Showing 1 changed file with 40 additions and 1 deletion.
41 changes: 40 additions & 1 deletion src/utilities.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export precompileActivator, precompileDeactivator, precompilePath
export precompileActivator, precompileDeactivator, precompilePath, @snoopiBot

"""
precompilePath(packageName::String)
Expand Down Expand Up @@ -95,3 +95,42 @@ function precompileDeactivator(packagePath::String, precompilePath::String)
end

end

"""
snoopiBot(packageName::String, snoopScript)
macro that generates precompile files and includes them in the package. Calls other utitlities.
"""
macro snoopiBot(packageName::String, snoopScript)

# by default run "runtests"
# = :(using MatLang; include(joinpath(dirname(dirname(pathof(MatLang))), "test","runtests.jl")); )

################################################################
const packagePath = joinpath(pwd(),"src","$packageName.jl")

quote
################################################################
using SnoopCompile
################################################################
const rootPath = pwd()
precompileDeactivator($packagePath, precompilePath($packageName));
cd(@__DIR__)
################################################################

### Log the compiles
data = @snoopi begin
$snoopScript
end

################################################################
### Parse the compiles and generate precompilation scripts
pc = SnoopCompile.parcel(data)
onlypackage = Dict(package => sort(pc[package]))
SnoopCompile.write("$(pwd())/precompile",onlypackage)
################################################################
cd(rootPath)
precompileActivator($packagePath, precompilePath($packageName))
end

end

0 comments on commit dcdd5e1

Please sign in to comment.