factor/extra/tools/deploy/backend/backend.factor

89 lines
2.3 KiB
Factor
Raw Normal View History

2008-01-05 19:37:13 -05:00
! Copyright (C) 2007, 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: namespaces continuations.private kernel.private init
assocs kernel vocabs words sequences memory io system arrays
continuations math definitions mirrors splitting parser classes
inspector layouts vocabs.loader prettyprint.config prettyprint
debugger io.streams.c io.streams.duplex io.files io.backend
quotations io.launcher words.private tools.deploy.config
bootstrap.image ;
IN: tools.deploy.backend
: (copy-lines) ( stream -- )
dup stream-readln dup
[ print flush (copy-lines) ] [ 2drop ] if ;
: copy-lines ( stream -- )
[ (copy-lines) ] with-disposal ;
2008-02-03 21:36:04 -05:00
: run-with-output ( arguments -- )
[
+arguments+ set
+stdout+ +stderr+ set
] H{ } make-assoc <process-stream>
dup duplex-stream-out dispose
copy-lines ;
: make-boot-image ( -- )
2008-01-05 19:37:13 -05:00
#! If stage1 image doesn't exist, create one.
my-boot-image-name resource-path exists?
2008-01-05 19:37:13 -05:00
[ my-arch make-image ] unless ;
: ?, [ , ] [ drop ] if ;
2008-01-05 19:37:13 -05:00
: bootstrap-profile ( config -- profile )
[
[
"math" deploy-math? get ?,
"compiler" deploy-compiler? get ?,
"ui" deploy-ui? get ?,
"io" native-io? ?,
] { } make
] bind ;
2008-01-05 19:37:13 -05:00
: staging-image-name ( profile -- name )
"staging." swap bootstrap-profile "-" join ".image" 3append ;
2008-01-05 19:37:13 -05:00
: staging-command-line ( config -- flags )
2008-01-05 19:37:13 -05:00
[
"-i=" my-boot-image-name append ,
"-output-image=" over staging-image-name append ,
"-include=" swap bootstrap-profile " " join append ,
"-no-stack-traces" ,
"-no-user-init" ,
] { } make ;
2008-01-05 19:37:13 -05:00
: run-factor ( vm flags -- )
dup . swap add* run-with-output ; inline
: make-staging-image ( vm config -- )
staging-command-line run-factor ;
: deploy-command-line ( image vocab config -- flags )
2008-01-05 19:37:13 -05:00
[
"-i=" swap staging-image-name append ,
"-run=tools.deploy.shaker" ,
2008-01-05 19:37:13 -05:00
"-deploy-vocab=" swap append ,
"-output-image=" swap append ,
"-no-stack-traces" ,
] { } make ;
: make-deploy-image ( vm image vocab config -- )
2008-02-04 21:49:59 -05:00
make-boot-image
dup staging-image-name exists? [
>r pick r> tuck make-staging-image
] unless
deploy-command-line run-factor ;
2008-01-05 19:37:13 -05:00
SYMBOL: deploy-implementation
HOOK: deploy* deploy-implementation ( vocab -- )