1 ! Copyright (C) 2008, 2011 Eduardo Cavazos, Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors arrays calendar combinators
4 combinators.short-circuit continuations fry io.directories
5 io.launcher io.pathnames kernel macros make mason.config
6 mason.notify mason.platform mason.report namespaces quotations
7 sequences splitting system ;
10 : nmake-cmd ( -- args )
11 { "nmake" "/f" "nmakefile" }
12 target-cpu get name>> "." split "-" join suffix ;
14 : gnu-make-cmd ( -- args )
16 target-os get name>> target-cpu get name>> (platform)
19 : mason-child-make-cmd ( -- args )
21 { [ target-os get windows = ] [ nmake-cmd ] }
25 : make-mason-child-vm ( -- )
28 mason-child-make-cmd >>command
29 "../compile-log" >>stdout
35 ! On windows, process launches relative to current process, ignoring
36 ! current-directory variables. Must pass absolute-path of factor.com
37 : mason-child-vm ( -- string )
38 target-os get windows = [
39 "./factor.com" absolute-path
44 : mason-child-boot-cmd ( -- cmd )
47 "-i=" target-boot-image-name append ,
52 : bootstrap-mason-child ( -- )
55 mason-child-boot-cmd >>command
57 "../boot-log" >>stdout
64 : mason-child-test-cmd ( -- cmd ) mason-child-vm "-run=mason.test" 2array ;
66 : test-mason-child ( -- )
69 mason-child-test-cmd >>command
71 "../test-log" >>stdout
78 : recover-else ( try catch else -- )
79 [ [ '[ @ f t ] ] [ '[ @ f ] ] bi* recover ] dip '[ drop @ ] when ; inline
81 MACRO: recover-cond ( alist -- )
82 dup { [ length 1 = ] [ first callable? ] } 1&&
84 [ first first2 ] [ rest ] bi
85 '[ _ _ [ _ recover-cond ] recover-else ]
88 : build-child ( -- status )
90 { [ notify-make-vm make-mason-child-vm ] [ compile-failed ] }
91 { [ notify-boot bootstrap-mason-child ] [ boot-failed ] }
92 { [ notify-test test-mason-child ] [ test-failed ] }