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 layouts macros make mason.config
6 mason.notify mason.platform mason.report math.parser namespaces
7 quotations sequences splitting system system-info ;
10 : gnu-make-cmd ( -- args )
12 target-os get name>> target-cpu get name>> (platform)
15 HOOK: compile-factor-command os ( -- array )
16 M: unix compile-factor-command ( -- array )
19 ! Windows has separate 32/64 bit shells, so assuming the cell bits here is fine
20 ! because it won't find the right toolchain otherwise.
21 M: windows compile-factor-command ( -- array )
22 { "nmake" "/f" "NMakefile" } cell-bits 64 = "x86-64-vista" "x86-32-vista" ? suffix ;
24 HOOK: factor-path os ( -- path )
25 M: unix factor-path "./factor" ;
26 M: windows factor-path "./factor.com" ;
28 : make-mason-child-vm ( -- )
31 compile-factor-command >>command
32 "../compile-log" >>stdout
38 ! On windows, process launches relative to current process, ignoring
39 ! current-directory variables. Must pass absolute-path of factor.com
40 : mason-child-vm ( -- string )
41 target-os get windows = [
42 "./factor.com" absolute-path
47 : mason-child-boot-cmd ( -- cmd )
50 "-i=" target-boot-image-name append ,
55 : bootstrap-mason-child ( -- )
58 mason-child-boot-cmd >>command
60 "../boot-log" >>stdout
67 : mason-child-test-cmd ( -- cmd )
70 os windows? cpu x86.64? and [ "-codeheap=200" , ] when
74 : test-mason-child ( -- )
77 mason-child-test-cmd >>command
79 "../test-log" >>stdout
86 : recover-else ( try catch else -- )
87 [ [ '[ @ f t ] ] [ '[ @ f ] ] bi* recover ] dip '[ drop @ ] when ; inline
89 MACRO: recover-cond ( alist -- quot )
90 dup { [ length 1 = ] [ first callable? ] } 1&&
92 [ first first2 ] [ rest ] bi
93 '[ _ _ [ _ recover-cond ] recover-else ]
96 : build-child ( -- status )
98 { [ notify-make-vm make-mason-child-vm ] [ compile-failed ] }
99 { [ notify-boot bootstrap-mason-child ] [ boot-failed ] }
100 { [ notify-test test-mason-child ] [ test-failed ] }