1 ! Copyright (C) 2007, 2009 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 debugger
7 io.streams.c io.files io.files.temp io.pathnames io.directories
8 io.directories.hierarchy io.backend quotations io.launcher
9 tools.deploy.config tools.deploy.config.editor bootstrap.image
10 io.encodings.utf8 destructors accessors hashtables
11 vocabs.metadata.resources ;
12 IN: tools.deploy.backend
14 : copy-vm ( executable bundle-name -- vm )
15 prepend-path vm over copy-file ;
17 : copy-resources ( manifest name dir -- )
18 append-path swap [ copy-vocab-resources ] with each ;
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 deploy-math? get [ "math" , ] when
42 deploy-threads? get [ "threads" , ] when
44 deploy-ui? get [ "ui" , ] when
45 deploy-unicode? get [ "unicode" , ] when
46 native-io? [ "io" , ] when
49 : staging-image-name ( profile -- name )
50 "-" join "staging." ".image" surround temp-file ;
52 DEFER: ?make-staging-image
54 : staging-command-line ( profile -- flags )
58 "-i=" my-boot-image-name append ,
60 dup but-last ?make-staging-image
61 "-resource-path=" "" resource-path append ,
62 "-i=" over but-last staging-image-name append ,
63 "-run=tools.deploy.restage" ,
65 "-output-image=" over staging-image-name append ,
66 "-include=" swap " " join append ,
71 : run-factor ( vm flags -- )
72 swap prefix dup . run-with-output ; inline
74 : make-staging-image ( profile -- )
75 vm swap staging-command-line run-factor ;
77 : ?make-staging-image ( profile -- )
78 dup staging-image-name exists?
79 [ drop ] [ make-staging-image ] if ;
81 : make-deploy-config ( vocab -- file )
82 [ deploy-config vocab-roots get vocab-roots associate assoc-union unparse-use ]
83 [ "deploy-config-" prepend temp-file ] bi
84 [ utf8 set-file-contents ] keep ;
86 : deploy-command-line ( image vocab manifest-file config -- flags )
88 bootstrap-profile ?make-staging-image
91 "-i=" bootstrap-profile staging-image-name append ,
92 "-resource-path=" "" resource-path append ,
93 "-run=tools.deploy.shaker" ,
94 "-vocab-manifest-out=" prepend ,
95 [ "-deploy-vocab=" prepend , ]
96 [ make-deploy-config "-deploy-config=" prepend , ] bi
97 "-output-image=" prepend ,
102 : make-deploy-image ( vm image vocab config -- manifest )
104 over "vocab-manifest-" prepend temp-file
105 [ swap deploy-command-line run-factor ]
106 [ utf8 file-lines ] bi ;
108 HOOK: deploy* os ( vocab -- )