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 ;
21 : (copy-lines) ( stream -- )
23 [ print flush (copy-lines) ] [ 2drop ] if ;
25 : copy-lines ( stream -- )
26 [ (copy-lines) ] with-disposal ;
28 : run-with-output ( arguments -- )
33 +low-priority+ >>priority
34 utf8 <process-reader*>
36 wait-for-process zero? [ "Deployment failed" throw ] unless ;
38 : make-boot-image ( -- )
39 #! If stage1 image doesn't exist, create one.
40 my-boot-image-name resource-path exists?
41 [ my-arch make-image ] unless ;
43 : bootstrap-profile ( -- profile )
45 { "math" deploy-math? }
46 { "compiler" deploy-compiler? }
47 { "threads" deploy-threads? }
49 { "random" deploy-random? }
50 } [ nip get ] assoc-filter keys
51 native-io? [ "io" suffix ] when ;
53 : staging-image-name ( profile -- name )
55 swap strip-word-names? [ "strip" suffix ] when
56 "-" join ".image" 3append temp-file ;
58 DEFER: ?make-staging-image
60 : staging-command-line ( profile -- flags )
63 "-i=" my-boot-image-name append ,
65 dup but-last ?make-staging-image
67 "-resource-path=" "" resource-path append ,
69 "-i=" over but-last staging-image-name append ,
71 "-run=tools.deploy.restage" ,
74 "-output-image=" over staging-image-name append ,
76 "-include=" swap " " join append ,
78 strip-word-names? [ "-no-stack-traces" , ] when
83 : run-factor ( vm flags -- )
84 swap prefix dup . run-with-output ; inline
86 : make-staging-image ( profile -- )
87 vm swap staging-command-line run-factor ;
89 : ?make-staging-image ( profile -- )
90 dup staging-image-name exists?
91 [ drop ] [ make-staging-image ] if ;
93 : deploy-command-line ( image vocab config -- flags )
95 bootstrap-profile ?make-staging-image
98 "-i=" bootstrap-profile staging-image-name append ,
100 "-resource-path=" "" resource-path append ,
102 "-run=tools.deploy.shaker" ,
104 "-deploy-vocab=" prepend ,
106 "-output-image=" prepend ,
108 strip-word-names? [ "-no-stack-traces" , ] when
112 : make-deploy-image ( vm image vocab config -- )
114 deploy-command-line run-factor ;
116 HOOK: deploy* os ( vocab -- )