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 tools.deploy.config.editor
9 bootstrap.image 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 -- )
17 append-path "resource:fonts/" swap copy-tree-into
20 : image-name ( vocab bundle-name -- str )
21 prepend-path ".image" append ;
24 readln [ print flush copy-lines ] when* ;
26 : run-with-output ( arguments -- )
31 +low-priority+ >>priority
32 utf8 [ copy-lines ] with-process-reader ;
34 : make-boot-image ( -- )
35 #! If stage1 image doesn't exist, create one.
36 my-boot-image-name resource-path exists?
37 [ my-arch make-image ] unless ;
39 : bootstrap-profile ( -- profile )
41 { "math" deploy-math? }
42 { "compiler" deploy-compiler? }
43 { "threads" deploy-threads? }
45 { "unicode" deploy-unicode? }
46 } [ nip get ] assoc-filter keys
47 native-io? [ "io" suffix ] when ;
49 : staging-image-name ( profile -- name )
51 swap strip-word-names? [ "strip" suffix ] when
52 "-" join ".image" 3append temp-file ;
54 DEFER: ?make-staging-image
56 : staging-command-line ( profile -- flags )
61 "-i=" my-boot-image-name append ,
63 dup but-last ?make-staging-image
65 "-resource-path=" "" resource-path append ,
67 "-i=" over but-last staging-image-name append ,
69 "-run=tools.deploy.restage" ,
72 "-output-image=" over staging-image-name append ,
74 "-include=" swap " " join append ,
76 strip-word-names? [ "-no-stack-traces" , ] when
81 : run-factor ( vm flags -- )
82 swap prefix dup . run-with-output ; inline
84 : make-staging-image ( profile -- )
85 vm swap staging-command-line run-factor ;
87 : ?make-staging-image ( profile -- )
88 dup staging-image-name exists?
89 [ drop ] [ make-staging-image ] if ;
91 : make-deploy-config ( vocab -- file )
92 [ deploy-config unparse-use ]
93 [ "deploy-config-" prepend temp-file ] bi
94 [ utf8 set-file-contents ] keep ;
96 : deploy-command-line ( image vocab config -- flags )
98 bootstrap-profile ?make-staging-image
101 "-i=" bootstrap-profile staging-image-name append ,
103 "-resource-path=" "" resource-path append ,
105 "-run=tools.deploy.shaker" ,
107 [ "-deploy-vocab=" prepend , ]
108 [ make-deploy-config "-deploy-config=" prepend , ] bi
110 "-output-image=" prepend ,
112 strip-word-names? [ "-no-stack-traces" , ] when
116 : make-deploy-image ( vm image vocab config -- )
118 deploy-command-line run-factor ;
120 HOOK: deploy* os ( vocab -- )