1 ! Copyright (C) 2007, 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: namespaces make continuations.private kernel.private init
4 assocs kernel vocabs words sequences memory io system arrays
5 continuations math definitions mirrors splitting parser classes
6 summary layouts vocabs.loader prettyprint.config prettyprint
7 debugger io.streams.c io.files io.backend quotations io.launcher
8 words.private tools.deploy.config bootstrap.image
9 io.encodings.utf8 destructors accessors ;
10 IN: tools.deploy.backend
12 : copy-vm ( executable bundle-name extension -- vm )
13 [ prepend-path ] dip append vm over copy-file ;
15 : copy-fonts ( name dir -- )
16 append-path "resource:fonts/" swap copy-tree-into ;
18 : image-name ( vocab bundle-name -- str )
19 prepend-path ".image" append ;
22 readln [ print flush copy-lines ] when* ;
24 : run-with-output ( arguments -- )
29 +low-priority+ >>priority
30 utf8 [ copy-lines ] with-process-reader ;
32 : make-boot-image ( -- )
33 #! If stage1 image doesn't exist, create one.
34 my-boot-image-name resource-path exists?
35 [ my-arch make-image ] unless ;
37 : bootstrap-profile ( -- profile )
39 { "math" deploy-math? }
40 { "compiler" deploy-compiler? }
41 { "threads" deploy-threads? }
43 { "random" deploy-random? }
44 } [ nip get ] assoc-filter keys
45 native-io? [ "io" suffix ] when ;
47 : staging-image-name ( profile -- name )
49 swap strip-word-names? [ "strip" suffix ] when
50 "-" join ".image" 3append temp-file ;
52 DEFER: ?make-staging-image
54 : staging-command-line ( profile -- flags )
57 "-i=" my-boot-image-name append ,
59 dup but-last ?make-staging-image
61 "-resource-path=" "" resource-path append ,
63 "-i=" over but-last staging-image-name append ,
65 "-run=tools.deploy.restage" ,
68 "-output-image=" over staging-image-name append ,
70 "-include=" swap " " join append ,
72 strip-word-names? [ "-no-stack-traces" , ] when
77 : run-factor ( vm flags -- )
78 swap prefix dup . run-with-output ; inline
80 : make-staging-image ( profile -- )
81 vm swap staging-command-line run-factor ;
83 : ?make-staging-image ( profile -- )
84 dup staging-image-name exists?
85 [ drop ] [ make-staging-image ] if ;
87 : deploy-command-line ( image vocab config -- flags )
89 bootstrap-profile ?make-staging-image
92 "-i=" bootstrap-profile staging-image-name append ,
94 "-resource-path=" "" resource-path append ,
96 "-run=tools.deploy.shaker" ,
98 "-deploy-vocab=" prepend ,
100 "-output-image=" prepend ,
102 strip-word-names? [ "-no-stack-traces" , ] when
106 : make-deploy-image ( vm image vocab config -- )
108 deploy-command-line run-factor ;
110 HOOK: deploy* os ( vocab -- )