factor/extra/tools/deploy/deploy.factor

65 lines
1.7 KiB
Factor
Raw Normal View History

2007-09-20 18:09:08 -04:00
! Copyright (C) 2007 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
2007-10-06 13:37:47 -04:00
quotations io.launcher words.private tools.deploy.config ;
2007-09-20 18:09:08 -04:00
IN: tools.deploy
<PRIVATE
: (copy-lines) ( stream -- stream )
dup stream-readln [ print flush (copy-lines) ] when* ;
: copy-lines ( stream -- )
[ (copy-lines) ] [ stream-close ] [ ] cleanup ;
2007-10-06 13:37:47 -04:00
: boot-image-name ( -- string )
cpu dup "ppc" = [ os "-" rot 3append ] when ;
2007-09-20 18:09:08 -04:00
: stage2 ( vm flags -- )
[
2007-10-06 13:37:47 -04:00
"\"" % swap % "\" -i=boot." %
boot-image-name
% ".image" %
2007-09-20 18:09:08 -04:00
[ " " % % ] each
] "" make
2007-10-06 13:37:47 -04:00
dup print <process-stream>
dup duplex-stream-out stream-close
copy-lines ;
2007-09-20 18:09:08 -04:00
2007-10-31 01:09:24 -04:00
: ?append swap [ append ] [ drop ] if ;
2007-09-20 18:09:08 -04:00
: profile-string ( config -- string )
2007-10-31 01:09:24 -04:00
[
""
deploy-math? get " math" ?append
deploy-compiler? get " compiler" ?append
deploy-ui? get " ui" ?append
native-io? " io" ?append
2007-10-31 01:09:24 -04:00
] bind ;
2007-09-20 18:09:08 -04:00
: deploy-command-line ( vm image vocab config -- vm flags )
[
"\"-include=" swap profile-string "\"" 3append ,
"-deploy-vocab=" swap append ,
"\"-output-image=" swap "\"" 3append ,
! "-no-stack-traces" ,
2007-09-20 18:09:08 -04:00
"-no-user-init" ,
] { } make ;
PRIVATE>
: deploy* ( vm image vocab config -- )
deploy-command-line stage2 ;
: deploy ( vocab -- )
2007-10-09 02:07:59 -04:00
"" resource-path cd
2007-09-20 18:09:08 -04:00
vm over ".image" append rot dup deploy-config deploy* ;