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 IN: tools.deploy.backend
13 : copy-vm ( executable bundle-name -- vm )
14 prepend-path vm over copy-file ;
16 CONSTANT: theme-path "basis/ui/gadgets/theme/"
18 : copy-theme ( name dir -- )
21 theme-path append-path
23 [ theme-path "resource:" prepend swap copy-tree ] bi
26 : image-name ( vocab bundle-name -- str )
27 prepend-path ".image" append ;
30 readln [ print flush copy-lines ] when* ;
32 : run-with-output ( arguments -- )
37 +low-priority+ >>priority
38 utf8 [ copy-lines ] with-process-reader ;
40 : make-boot-image ( -- )
41 #! If stage1 image doesn't exist, create one.
42 my-boot-image-name resource-path exists?
43 [ my-arch make-image ] unless ;
45 : bootstrap-profile ( -- profile )
47 deploy-math? get [ "math" , ] when
48 deploy-threads? get [ "threads" , ] when
50 deploy-ui? get [ "ui" , ] when
51 deploy-unicode? get [ "unicode" , ] when
52 native-io? [ "io" , ] when
55 : staging-image-name ( profile -- name )
56 "-" join "staging." ".image" surround temp-file ;
58 DEFER: ?make-staging-image
60 : staging-command-line ( profile -- flags )
64 "-i=" my-boot-image-name append ,
66 dup but-last ?make-staging-image
67 "-resource-path=" "" resource-path append ,
68 "-i=" over but-last staging-image-name append ,
69 "-run=tools.deploy.restage" ,
71 "-output-image=" over staging-image-name append ,
72 "-include=" swap " " join append ,
76 : run-factor ( vm flags -- )
77 swap prefix dup . run-with-output ; inline
79 : make-staging-image ( profile -- )
80 vm swap staging-command-line run-factor ;
82 : ?make-staging-image ( profile -- )
83 dup staging-image-name exists?
84 [ drop ] [ make-staging-image ] if ;
86 : make-deploy-config ( vocab -- file )
87 [ deploy-config vocab-roots get vocab-roots associate assoc-union unparse-use ]
88 [ "deploy-config-" prepend temp-file ] bi
89 [ utf8 set-file-contents ] keep ;
91 : deploy-command-line ( image vocab config -- flags )
93 bootstrap-profile ?make-staging-image
96 "-i=" bootstrap-profile staging-image-name append ,
97 "-resource-path=" "" resource-path append ,
98 "-run=tools.deploy.shaker" ,
99 [ "-deploy-vocab=" prepend , ]
100 [ make-deploy-config "-deploy-config=" prepend , ] bi
101 "-output-image=" prepend ,
105 : make-deploy-image ( vm image vocab config -- )
107 deploy-command-line run-factor ;
109 HOOK: deploy* os ( vocab -- )