@@ -725,22 +725,66 @@ function warnbanner(msg...; label="[ WARNING ]", prefix="")
725
725
warn (prefix= " " , " =" ^ cols)
726
726
end
727
727
728
- function build! (pkgs:: Vector , errs :: Dict , seen:: Set = Set () )
728
+ function build! (pkgs:: Vector , buildstream :: IO , seen:: Set )
729
729
for pkg in pkgs
730
730
pkg == " julia" && continue
731
731
pkg in seen && continue
732
- build! (Read. requires_list (pkg),errs ,push! (seen,pkg))
732
+ build! (Read. requires_list (pkg),buildstream ,push! (seen,pkg))
733
733
Read. isinstalled (pkg) || throw (PkgError (" $pkg is not an installed package" ))
734
734
path = abspath (pkg," deps" ," build.jl" )
735
735
isfile (path) || continue
736
- info (" Building $pkg " )
737
- cd (dirname (path)) do
738
- try evalfile (path)
739
- catch err
740
- warnbanner (err, label= " [ ERROR: $pkg ]" )
736
+ println (buildstream, path) # send to build process for evalfile
737
+ flush (buildstream)
738
+ end
739
+ end
740
+
741
+ function build! (pkgs:: Vector , errs:: Dict , seen:: Set = Set ())
742
+ # To isolate the build from the running Julia process, we
743
+ # execute the build.jl files in a separate process that
744
+ # is sitting there waiting for paths to evaluate. Errors
745
+ # are serialized to errfile for later retrieval into errs[pkg]
746
+ errfile = tempname ()
747
+ close (open (errfile, " w" )) # create empty file
748
+ code = """
749
+ open("$(escape_string (errfile)) ", "a") do f
750
+ for path_ in eachline(STDIN)
751
+ path = chomp(path_)
752
+ pkg = basename(dirname(dirname(path)))
753
+ try
754
+ info("Building \$ pkg")
755
+ cd(dirname(path)) do
756
+ evalfile(path)
757
+ end
758
+ catch err
759
+ Base.Pkg.Entry.warnbanner(err, label="[ ERROR: \$ pkg ]")
760
+ serialize(f, pkg)
761
+ serialize(f, err)
762
+ end
763
+ end
764
+ end
765
+ """
766
+ io, pobj = open (detach (` $(Base. julia_cmd ())
767
+ --history-file=no
768
+ --color=$(Base. have_color ? " yes" : " no" )
769
+ --eval $code ` ), " w" , STDOUT)
770
+ try
771
+ build! (pkgs, io, seen)
772
+ close (io)
773
+ wait (pobj)
774
+ success (pobj) || error (" Build process failed." )
775
+ open (errfile, " r" ) do f
776
+ while ! eof (f)
777
+ pkg = deserialize (f)
778
+ err = deserialize (f)
741
779
errs[pkg] = err
742
780
end
743
781
end
782
+ catch
783
+ kill (pobj)
784
+ close (io)
785
+ rethrow ()
786
+ finally
787
+ isfile (errfile) && Base. rm (errfile)
744
788
end
745
789
end
746
790
0 commit comments