@@ -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
code = """
604
587
empty!(Base.LOAD_PATH)
605
588
append!(Base.LOAD_PATH, $(repr (Base. LOAD_PATH )) )
@@ -608,49 +591,52 @@ function build!(pkgs::Vector, errs::Dict, seen::Set=Set())
608
591
empty!(Base.DL_LOAD_PATH)
609
592
append!(Base.DL_LOAD_PATH, $(repr (Base. DL_LOAD_PATH)) )
610
593
open("$(escape_string (errfile)) ", "a") do f
611
- pkg = ""
612
- atexit(() -> !isempty(pkg) && run_build())
613
- function run_build()
614
- for path_ in eachline(STDIN)
615
- path = chomp(path_)
616
- pkg = basename(dirname(dirname(path)))
617
- try
618
- info("Building \$ pkg")
619
- cd(dirname(path)) do
620
- evalfile(path)
621
- end
622
- catch err
623
- Base.Pkg.Entry.warnbanner(err, label="[ ERROR: \$ pkg ]")
624
- serialize(f, pkg)
625
- serialize(f, err)
626
- end
594
+ pkg, build_file = "$pkg ", "$(escape_string (build_file)) "
595
+ try
596
+ info("Building \$ pkg")
597
+ cd(dirname(build_file)) do
598
+ evalfile(build_file)
627
599
end
600
+ catch err
601
+ Base.Pkg.Entry.warnbanner(err, label="[ ERROR: \$ pkg ]")
602
+ serialize(f, pkg)
603
+ serialize(f, err)
628
604
end
629
- run_build()
630
- pkg = ""
631
605
end
632
606
"""
633
- io, pobj = open (pipeline (detach (` $(Base. julia_cmd ()) -O0
634
- --compilecache=$(Bool (Base. JLOptions (). use_compilecache) ? " yes" : " no" )
635
- --history-file=no
636
- --color=$(Base. have_color ? " yes" : " no" )
637
- --eval $code ` ), stderr = STDERR), " w" , STDOUT)
607
+ cmd = ` $(Base. julia_cmd ()) -O0
608
+ --compilecache=$(Bool (Base. JLOptions (). use_compilecache) ? " yes" : " no" )
609
+ --history-file=no
610
+ --color=$(Base. have_color ? " yes" : " no" )
611
+ --eval $code `
612
+
613
+ success (pipeline (cmd, stderr = STDERR))
614
+ end
615
+
616
+ function build! (pkgs:: Vector , seen:: Set , errfile:: AbstractString )
617
+ for pkg in pkgs
618
+ pkg == " julia" && continue
619
+ pkg in seen ? continue : push! (seen,pkg)
620
+ Read. isinstalled (pkg) || throw (PkgError (" $pkg is not an installed package" ))
621
+ build! (Read. requires_list (pkg), seen, errfile)
622
+ path = abspath (pkg," deps" ," build.jl" )
623
+ isfile (path) || continue
624
+ build (pkg, path, errfile) || error (" Build process failed." )
625
+ end
626
+ end
627
+
628
+ function build! (pkgs:: Vector , errs:: Dict , seen:: Set = Set ())
629
+ errfile = tempname ()
630
+ touch (errfile) # create empty file
638
631
try
639
- build! (pkgs, io, seen)
640
- close (io)
641
- wait (pobj)
642
- success (pobj) || error (" Build process failed." )
632
+ build! (pkgs, seen, errfile)
643
633
open (errfile, " r" ) do f
644
634
while ! eof (f)
645
635
pkg = deserialize (f)
646
636
err = deserialize (f)
647
637
errs[pkg] = err
648
638
end
649
639
end
650
- catch err
651
- close (io)
652
- isa (err, PkgError) ? wait (pobj) : kill (pobj)
653
- rethrow (err)
654
640
finally
655
641
isfile (errfile) && Base. rm (errfile)
656
642
end
0 commit comments