 
 : build-child ( -- status )
     {
-        { [ notify-make-vm make-vm ] [ compile-failed ] }
-        { [ notify-boot boot ] [ boot-failed ] }
-        { [ notify-test test ] [ test-failed ] }
+        { [ notify-make-vm make-mason-child-vm ] [ compile-failed ] }
+        { [ notify-boot bootstrap-mason-child ] [ boot-failed ] }
+        { [ notify-test test-mason-child ] [ test-failed ] }
         [ success ]
     } recover-cond ;

! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays calendar combinators
combinators.short-circuit continuations fry io.directories
io.launcher kernel macros make mason.config mason.notify
mason.platform mason.report namespaces quotations sequences
splitting system ;
IN: mason.child

: nmake-cmd ( -- args )

    target-os get name>> target-cpu get name>> (platform)
    2array ;

: mason-child-make-cmd ( -- args )
    {
        { [ target-os get windows = ] [ nmake-cmd ] }
        [ gnu-make-cmd ]
    } cond ;

: make-mason-child-vm ( -- )
    "factor" [
        <process>
            mason-child-make-cmd >>command
            "../compile-log" >>stdout
            +stdout+ >>stderr
            +new-group+ >>group
        try-process
    ] with-directory ;

! On windows, process launches relative to current process, ignoring
! current-directory variables. Must pass absolute-path of factor.com
: mason-child-vm ( -- string )
    target-os get windows = [
        "./factor.com" absolute-path
    ] [
        "./factor"
    ] if ;

: mason-child-boot-cmd ( -- cmd )
    [
        mason-child-vm ,
        "-i=" target-boot-image-name append ,
        "-no-user-init" ,
        boot-flags get %
    ] { } make ;

: bootstrap-mason-child ( -- )
    "factor" [
        <process>
            mason-child-boot-cmd >>command
            +closed+ >>stdin
            "../boot-log" >>stdout
            +stdout+ >>stderr
