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 tools.deploy.libraries vocabs.metadata.resources ;
12 IN: tools.deploy.backend
14 : copy-vm ( executable bundle-name -- vm )
15 prepend-path vm over copy-file ;
17 TUPLE: vocab-manifest vocabs libraries ;
19 : copy-resources ( manifest name dir -- )
20 append-path swap vocabs>> [ copy-vocab-resources ] with each ;
22 ERROR: cant-deploy-library-file library ;
24 : copy-library ( dir library -- )
26 [ nip swap over file-name append-path copy-file ]
27 [ cant-deploy-library-file ] if* ;
30 : copy-libraries ( manifest name dir -- )
31 append-path swap libraries>> [ copy-library ] with each ;
33 : image-name ( vocab bundle-name -- str )
34 prepend-path ".image" append ;
37 readln [ print flush copy-lines ] when* ;
39 : run-with-output ( arguments -- )
44 +low-priority+ >>priority
45 utf8 [ copy-lines ] with-process-reader ;
47 : make-boot-image ( -- )
48 #! If stage1 image doesn't exist, create one.
49 my-boot-image-name resource-path exists?
50 [ my-arch make-image ] unless ;
52 : bootstrap-profile ( -- profile )
54 deploy-math? get [ "math" , ] when
55 deploy-threads? get [ "threads" , ] when
57 deploy-ui? get [ "ui" , ] when
58 deploy-unicode? get [ "unicode" , ] when
59 native-io? [ "io" , ] when
62 : staging-image-name ( profile -- name )
63 "-" join "staging." ".image" surround temp-file ;
65 DEFER: ?make-staging-image
67 : staging-command-line ( profile -- flags )
71 "-i=" my-boot-image-name append ,
73 dup but-last ?make-staging-image
74 "-resource-path=" "" resource-path append ,
75 "-i=" over but-last staging-image-name append ,
76 "-run=tools.deploy.restage" ,
78 "-output-image=" over staging-image-name append ,
79 "-include=" swap " " join append ,
84 : run-factor ( vm flags -- )
85 swap prefix dup . run-with-output ; inline
87 : make-staging-image ( profile -- )
88 vm swap staging-command-line run-factor ;
90 : ?make-staging-image ( profile -- )
91 dup staging-image-name exists?
92 [ drop ] [ make-staging-image ] if ;
94 : make-deploy-config ( vocab -- file )
95 [ deploy-config vocab-roots get vocab-roots associate assoc-union unparse-use ]
96 [ "deploy-config-" prepend temp-file ] bi
97 [ utf8 set-file-contents ] keep ;
99 : deploy-command-line ( image vocab manifest-file config -- flags )
101 bootstrap-profile ?make-staging-image
104 "-i=" bootstrap-profile staging-image-name append ,
105 "-resource-path=" "" resource-path append ,
106 "-run=tools.deploy.shaker" ,
107 "-vocab-manifest-out=" prepend ,
108 [ "-deploy-vocab=" prepend , ]
109 [ make-deploy-config "-deploy-config=" prepend , ] bi
110 "-output-image=" prepend ,
115 : parse-vocab-manifest-file ( path -- vocab-manifest )
117 dup first "VOCABS:" =
118 [ "LIBRARIES:" split1 vocab-manifest boa ]
119 [ "invalid vocab manifest!" throw ] if ;
121 : make-deploy-image ( vm image vocab config -- manifest )
123 over "vocab-manifest-" prepend temp-file
124 [ swap deploy-command-line run-factor ]
125 [ parse-vocab-manifest-file ] bi ;
127 HOOK: deploy* os ( vocab -- )