@@ -580,26 +580,9 @@ function warnbanner(msg...; label="[ WARNING ]", prefix="")
580
580
warn (prefix= " " , " =" ^ cols)
581
581
end
582
582
583
- function build! (pkgs:: Vector , buildstream:: IO , seen:: Set )
584
- for pkg in pkgs
585
- pkg == " julia" && continue
586
- pkg in seen ? continue : push! (seen,pkg)
587
- Read. isinstalled (pkg) || throw (PkgError (" $pkg is not an installed package" ))
588
- build! (Read. requires_list (pkg),buildstream,seen)
589
- path = abspath (pkg," deps" ," build.jl" )
590
- isfile (path) || continue
591
- println (buildstream, path) # send to build process for evalfile
592
- flush (buildstream)
593
- end
594
- end
595
-
596
- function build! (pkgs:: Vector , errs:: Dict , seen:: Set = Set ())
597
- # To isolate the build from the running Julia process, we
598
- # execute the build.jl files in a separate process that
599
- # is sitting there waiting for paths to evaluate. Errors
600
- # are serialized to errfile for later retrieval into errs[pkg]
601
- errfile = tempname ()
602
- close (open (errfile, " w" )) # create empty file
583
+ function build (pkg:: AbstractString , build_file:: AbstractString , errfile:: AbstractString )
584
+ # To isolate the build from the running Julia process, we execute each build.jl file in
585
+ # a separate process. Errors are serialized to errfile for later reporting.
603
586
# TODO : serialize the same way the load cache does, not with strings
604
587
LOAD_PATH = filter (x -> x isa AbstractString, Base. LOAD_PATH )
605
588
code = """
@@ -610,48 +593,52 @@ function build!(pkgs::Vector, errs::Dict, seen::Set=Set())
610
593
empty!(Base.DL_LOAD_PATH)
611
594
append!(Base.DL_LOAD_PATH, $(repr (Base. DL_LOAD_PATH)) )
612
595
open("$(escape_string (errfile)) ", "a") do f
613
- pkg = ""
614
- atexit(() -> !isempty(pkg) && run_build())
615
- function run_build()
616
- for path in eachline(STDIN)
617
- pkg = basename(dirname(dirname(path)))
618
- try
619
- info("Building \$ pkg")
620
- cd(dirname(path)) do
621
- evalfile(path)
622
- end
623
- catch err
624
- Base.Pkg.Entry.warnbanner(err, label="[ ERROR: \$ pkg ]")
625
- serialize(f, pkg)
626
- serialize(f, err)
627
- end
596
+ pkg, build_file = "$pkg ", "$(escape_string (build_file)) "
597
+ try
598
+ info("Building \$ pkg")
599
+ cd(dirname(build_file)) do
600
+ evalfile(build_file)
628
601
end
602
+ catch err
603
+ Base.Pkg.Entry.warnbanner(err, label="[ ERROR: \$ pkg ]")
604
+ serialize(f, pkg)
605
+ serialize(f, err)
629
606
end
630
- run_build()
631
- pkg = ""
632
607
end
633
608
"""
634
- io, pobj = open (pipeline (detach (` $(Base. julia_cmd ()) -O0
635
- --compilecache=$(Bool (Base. JLOptions (). use_compilecache) ? " yes" : " no" )
636
- --history-file=no
637
- --color=$(Base. have_color ? " yes" : " no" )
638
- --eval $code ` ), stderr = STDERR), " w" , STDOUT)
609
+ cmd = ` $(Base. julia_cmd ()) -O0
610
+ --compilecache=$(Bool (Base. JLOptions (). use_compilecache) ? " yes" : " no" )
611
+ --history-file=no
612
+ --color=$(Base. have_color ? " yes" : " no" )
613
+ --eval $code `
614
+
615
+ success (pipeline (cmd, stderr = STDERR))
616
+ end
617
+
618
+ function build! (pkgs:: Vector , seen:: Set , errfile:: AbstractString )
619
+ for pkg in pkgs
620
+ pkg == " julia" && continue
621
+ pkg in seen ? continue : push! (seen,pkg)
622
+ Read. isinstalled (pkg) || throw (PkgError (" $pkg is not an installed package" ))
623
+ build! (Read. requires_list (pkg), seen, errfile)
624
+ path = abspath (pkg," deps" ," build.jl" )
625
+ isfile (path) || continue
626
+ build (pkg, path, errfile) || error (" Build process failed." )
627
+ end
628
+ end
629
+
630
+ function build! (pkgs:: Vector , errs:: Dict , seen:: Set = Set ())
631
+ errfile = tempname ()
632
+ touch (errfile) # create empty file
639
633
try
640
- build! (pkgs, io, seen)
641
- close (io)
642
- wait (pobj)
643
- success (pobj) || error (" Build process failed." )
634
+ build! (pkgs, seen, errfile)
644
635
open (errfile, " r" ) do f
645
636
while ! eof (f)
646
637
pkg = deserialize (f)
647
638
err = deserialize (f)
648
639
errs[pkg] = err
649
640
end
650
641
end
651
- catch err
652
- close (io)
653
- isa (err, PkgError) ? wait (pobj) : kill (pobj)
654
- rethrow (err)
655
642
finally
656
643
isfile (errfile) && Base. rm (errfile)
657
644
end
0 commit comments