From dcdd5e1cc3a81a4781f26307d4c1cce0c81712bd Mon Sep 17 00:00:00 2001 From: aminya Date: Thu, 12 Dec 2019 11:25:05 +0330 Subject: [PATCH] snoopiBot --- src/utilities.jl | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/src/utilities.jl b/src/utilities.jl index 4d7daad28..1daa207d3 100644 --- a/src/utilities.jl +++ b/src/utilities.jl @@ -1,4 +1,4 @@ -export precompileActivator, precompileDeactivator, precompilePath +export precompileActivator, precompileDeactivator, precompilePath, @snoopiBot """ precompilePath(packageName::String) @@ -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