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

96 lines
2.5 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
2008-03-06 21:44:52 -05:00
bootstrap.image io.encodings.utf8 accessors ;
2008-01-05 19:37:13 -05:00
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 -- )
2008-03-06 21:44:52 -05:00
<process>
swap >>command
+stdout+ >>stderr
+closed+ >>stdin
utf8 <process-stream>
2008-02-08 22:15:29 -05:00
dup copy-lines
2008-03-07 22:28:51 -05:00
process>> wait-for-process zero? [
2008-02-08 22:15:29 -05:00
"Deployment failed" throw
] unless ;
: 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 ( -- profile )
[
"math" deploy-math? get ?,
"compiler" deploy-compiler? get ?,
"ui" deploy-ui? get ?,
"io" native-io? ?,
] { } make ;
2008-01-05 19:37:13 -05:00
: staging-image-name ( -- name )
"staging."
bootstrap-profile strip-word-names? [ "strip" add ] when
"-" 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=" staging-image-name append ,
"-include=" bootstrap-profile " " join append ,
strip-word-names? [ "-no-stack-traces" , ] when
"-no-user-init" ,
] { } make
] bind ;
2008-01-05 19:37:13 -05:00
: run-factor ( vm flags -- )
2008-03-07 22:28:51 -05:00
swap add* dup . 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=" staging-image-name append ,
"-run=tools.deploy.shaker" ,
2008-01-05 19:37:13 -05:00
"-deploy-vocab=" swap append ,
2008-01-05 19:37:13 -05:00
"-output-image=" swap append ,
2008-01-05 19:37:13 -05:00
strip-word-names? [ "-no-stack-traces" , ] when
] { } make
] bind ;
2008-01-05 19:37:13 -05:00
: 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 -- )