factor/basis/tools/deploy/backend/backend.factor

114 lines
3.6 KiB
Factor
Raw Normal View History

! Copyright (C) 2007, 2009 Slava Pestov.
2008-01-05 19:37:13 -05:00
! See http://factorcode.org/license.txt for BSD license.
USING: namespaces make continuations.private kernel.private init
2008-01-05 19:37:13 -05:00
assocs kernel vocabs words sequences memory io system arrays
continuations math definitions mirrors splitting parser classes
2009-04-26 03:42:37 -04:00
summary layouts vocabs.loader prettyprint.config prettyprint debugger
io.streams.c io.files io.files.temp io.pathnames io.directories
io.directories.hierarchy io.backend quotations io.launcher
tools.deploy.config tools.deploy.config.editor bootstrap.image
io.encodings.utf8 destructors accessors hashtables ;
2008-01-05 19:37:13 -05:00
IN: tools.deploy.backend
2008-05-10 16:22:38 -04:00
: copy-vm ( executable bundle-name -- vm )
2009-02-09 21:19:18 -05:00
prepend-path vm over copy-file ;
2008-05-10 16:22:38 -04:00
CONSTANT: theme-path "basis/ui/gadgets/theme/"
: copy-theme ( name dir -- )
deploy-ui? get [
append-path
theme-path append-path
[ make-directories ]
[ theme-path "resource:" prepend swap copy-tree ] bi
] [ 2drop ] if ;
2008-05-10 16:22:38 -04:00
: image-name ( vocab bundle-name -- str )
prepend-path ".image" append ;
2008-01-05 19:37:13 -05:00
2008-09-18 19:20:26 -04:00
: copy-lines ( -- )
readln [ print flush copy-lines ] when* ;
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
2008-03-26 16:59:11 -04:00
+low-priority+ >>priority
2008-09-18 19:20:26 -04:00
utf8 [ copy-lines ] with-process-reader ;
: 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 ;
: bootstrap-profile ( -- profile )
[
deploy-math? get [ "math" , ] when
deploy-threads? get [ "threads" , ] when
"compiler" ,
deploy-ui? get [ "ui" , ] when
deploy-unicode? get [ "unicode" , ] when
native-io? [ "io" , ] when
] { } make ;
2008-01-05 19:37:13 -05:00
2008-03-20 22:11:53 -04:00
: staging-image-name ( profile -- name )
"staging."
swap strip-word-names? [ "strip" suffix ] when
2008-03-20 22:11:53 -04:00
"-" join ".image" 3append temp-file ;
2008-01-05 19:37:13 -05:00
2008-03-20 22:11:53 -04:00
DEFER: ?make-staging-image
: staging-command-line ( profile -- flags )
2008-01-05 19:37:13 -05:00
[
"-staging" ,
2008-03-20 22:11:53 -04:00
dup empty? [
"-i=" my-boot-image-name append ,
2008-03-20 22:11:53 -04:00
] [
2008-05-07 02:38:34 -04:00
dup but-last ?make-staging-image
2008-03-20 22:11:53 -04:00
"-resource-path=" "" resource-path append ,
2008-05-07 02:38:34 -04:00
"-i=" over but-last staging-image-name append ,
2008-03-20 22:11:53 -04:00
"-run=tools.deploy.restage" ,
] if
"-output-image=" over staging-image-name append ,
"-include=" swap " " join append ,
strip-word-names? [ "-no-stack-traces" , ] when
"-no-user-init" ,
] { } make ;
2008-01-05 19:37:13 -05:00
: run-factor ( vm flags -- )
swap prefix dup . run-with-output ; inline
2008-03-20 22:11:53 -04:00
: make-staging-image ( profile -- )
2008-03-14 18:39:57 -04:00
vm swap staging-command-line run-factor ;
2008-03-20 22:11:53 -04:00
: ?make-staging-image ( profile -- )
dup staging-image-name exists?
2008-03-14 18:39:57 -04:00
[ drop ] [ make-staging-image ] if ;
2008-12-08 15:58:00 -05:00
: make-deploy-config ( vocab -- file )
[ deploy-config vocab-roots get vocab-roots associate assoc-union unparse-use ]
2008-12-08 17:02:31 -05:00
[ "deploy-config-" prepend temp-file ] bi
2008-12-08 15:58:00 -05:00
[ utf8 set-file-contents ] keep ;
: deploy-command-line ( image vocab config -- flags )
2008-01-05 19:37:13 -05:00
[
2008-03-20 22:11:53 -04:00
bootstrap-profile ?make-staging-image
[
2008-03-20 22:11:53 -04:00
"-i=" bootstrap-profile staging-image-name append ,
"-resource-path=" "" resource-path append ,
"-run=tools.deploy.shaker" ,
2008-12-08 15:58:00 -05:00
[ "-deploy-vocab=" prepend , ]
[ make-deploy-config "-deploy-config=" prepend , ] bi
"-output-image=" prepend ,
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
deploy-command-line run-factor ;
2008-01-05 19:37:13 -05:00
2008-04-02 20:46:37 -04:00
HOOK: deploy* os ( vocab -- )