Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eval build.jl files in a separate Julia process for Pkg.build #13506

Merged
merged 1 commit into from
Oct 9, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 51 additions & 7 deletions base/pkg/entry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -725,22 +725,66 @@ function warnbanner(msg...; label="[ WARNING ]", prefix="")
warn(prefix="", "="^cols)
end

function build!(pkgs::Vector, errs::Dict, seen::Set=Set())
function build!(pkgs::Vector, buildstream::IO, seen::Set)
for pkg in pkgs
pkg == "julia" && continue
pkg in seen && continue
build!(Read.requires_list(pkg),errs,push!(seen,pkg))
build!(Read.requires_list(pkg),buildstream,push!(seen,pkg))
Read.isinstalled(pkg) || throw(PkgError("$pkg is not an installed package"))
path = abspath(pkg,"deps","build.jl")
isfile(path) || continue
info("Building $pkg")
cd(dirname(path)) do
try evalfile(path)
catch err
warnbanner(err, label="[ ERROR: $pkg ]")
println(buildstream, path) # send to build process for evalfile
flush(buildstream)
end
end

function build!(pkgs::Vector, errs::Dict, seen::Set=Set())
# To isolate the build from the running Julia process, we
# execute the build.jl files in a separate process that
# is sitting there waiting for paths to evaluate. Errors
# are serialized to errfile for later retrieval into errs[pkg]
errfile = tempname()
close(open(errfile, "w")) # create empty file
code = """
open("$(escape_string(errfile))", "a") do f
for path_ in eachline(STDIN)
path = chomp(path_)
pkg = basename(dirname(dirname(path)))
try
info("Building \$pkg")
cd(dirname(path)) do
evalfile(path)
end
catch err
Base.Pkg.Entry.warnbanner(err, label="[ ERROR: \$pkg ]")
serialize(f, pkg)
serialize(f, err)
end
end
end
"""
io, pobj = open(detach(`$(Base.julia_cmd())
--history-file=no
--color=$(Base.have_color ? "yes" : "no")
--eval $code`), "w", STDOUT)
try
build!(pkgs, io, seen)
close(io)
wait(pobj)
success(pobj) || error("Build process failed.")
open(errfile, "r") do f
while !eof(f)
pkg = deserialize(f)
err = deserialize(f)
errs[pkg] = err
end
end
catch
kill(pobj)
close(io)
rethrow()
finally
isfile(errfile) && Base.rm(errfile)
end
end

Expand Down