Skip to content

Commit f9ca262

Browse files
committed
try catch, build multiple packages
1 parent 85df43b commit f9ca262

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

src/PackageCompiler.jl

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,15 @@ function snoop(path, compilationfile, csv, reuse)
4040
# replace `_` for free parameters, which print out a warning otherwise
4141
ln = replace(ln, delims, s"\1XXX\2")
4242
# only print out valid lines
43-
# TODO figure out why some precompile statements have undefined free variables in there
43+
# TODO figure out the actual problems and why snoop compile emits invalid code
4444
try
45-
eval(tmp_mod, parse(ln))
46-
println(io, ln)
45+
parse(ln) # parse to make sure expression is parsing without error
46+
# wrap in try catch to catch problematic code emitted by SnoopCompile
47+
# without interupting the whole precompilation
48+
# (usually, SnoopCompile emits 1% erroring statements)
49+
println(io, "try\n ", ln, "\nend")
4750
catch e
48-
warn("Not emitted: ", ln)
51+
warn("Not emitted because code couldn't parse: ", ln)
4952
end
5053
end
5154
end
@@ -95,8 +98,18 @@ function get_root_dir(path)
9598
end
9699
end
97100

101+
function snoop_package(package::String, sysimg_tmp, reuse)
102+
precompile_file = joinpath(sysimg_tmp, "precompile.jl")
103+
snoop(
104+
joinpath(testroot, "runtests.jl"),
105+
precompile_file,
106+
joinpath(sysimg_tmp, "snooped.csv"),
107+
reuse
108+
)
109+
end
98110

99-
function compile_package(package, force = false, reuse = false; debug = false)
111+
function compile_package(package::String...; force = false, reuse = false, debug = false)
112+
100113
realpath = if ispath(package)
101114
normpath(abspath(package))
102115
else
@@ -107,13 +120,7 @@ function compile_package(package, force = false, reuse = false; debug = false)
107120
sysimg_backup = joinpath(@__DIR__, "..", "sysimg_backup")
108121
isdir(sysimg_backup) || mkpath(sysimg_tmp)
109122
isdir(sysimg_tmp) || mkpath(sysimg_tmp)
110-
precompile_file = joinpath(sysimg_tmp, "precompile.jl")
111-
snoop(
112-
joinpath(testroot, "runtests.jl"),
113-
precompile_file,
114-
joinpath(sysimg_tmp, "snooped.csv"),
115-
reuse
116-
)
123+
117124
build_sysimg(joinpath(sysimg_tmp, "sys"), "native", precompile_file)
118125
if force
119126
try

0 commit comments

Comments
 (0)