1 ! Copyright (C) 2007, 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors qualified io.streams.c init fry namespaces
4 assocs kernel parser lexer strings.parser tools.deploy.config
5 vocabs sequences words words.private memory kernel.private
6 continuations io prettyprint vocabs.loader debugger system
8 QUALIFIED: bootstrap.stage2
10 QUALIFIED: command-line
11 QUALIFIED: compiler.errors.private
12 QUALIFIED: compiler.units
13 QUALIFIED: continuations
14 QUALIFIED: definitions
19 QUALIFIED: libc.private
20 QUALIFIED: libc.private
22 QUALIFIED: prettyprint.config
23 QUALIFIED: source-files
26 IN: tools.deploy.shaker
28 : strip-init-hooks ( -- )
29 "Stripping startup hooks" show
30 "command-line" init-hooks get delete-at
31 "libc" init-hooks get delete-at
33 "threads" init-hooks get delete-at
36 "io.thread" init-hooks get delete-at
39 "io.backend" init-hooks get delete-at
42 : strip-debugger ( -- )
44 "Stripping debugger" show
45 "resource:extra/tools/deploy/shaker/strip-debugger.factor"
51 "Stripping manual memory management debug code" show
52 "resource:extra/tools/deploy/shaker/strip-libc.factor"
58 "Stripping unused Cocoa methods" show
59 "resource:extra/tools/deploy/shaker/strip-cocoa.factor"
63 : strip-word-names ( words -- )
64 "Stripping word names" show
65 [ f >>name f >>vocabulary drop ] each ;
67 : strip-word-defs ( words -- )
68 "Stripping symbolic word definitions" show
69 [ "no-def-strip" word-prop not ] filter
70 [ [ ] >>def drop ] each ;
72 : strip-word-props ( stripped-props words -- )
73 "Stripping word properties" show
77 '[ drop , member? not ] assoc-filter
82 : stripped-word-props ( -- seq )
91 "default-output-classes"
108 "predicate-definition"
138 : strip-words ( props -- )
140 deploy-word-props? get [ 2dup strip-word-props ] unless
141 deploy-word-defs? get [ dup strip-word-defs ] unless
142 strip-word-names? [ dup strip-word-names ] when
145 : strip-recompile-hook ( -- )
146 [ [ f ] { } map>assoc ]
147 compiler.units:recompile-hook
150 : strip-vocab-globals ( except names -- words )
151 [ child-vocabs [ words ] map concat ] map concat swap diff ;
153 : stripped-globals ( -- seq )
155 "callbacks" "alien.compiler" lookup ,
157 "inspector-hook" "inspector" lookup ,
160 bootstrap.stage2:bootstrap-time
162 continuations:error-continuation
163 continuations:error-thread
164 continuations:restarts
169 source-files:source-files
176 threads:initial-thread ,
179 strip-io? [ io.backend:io-backend , ] when
185 } strip-vocab-globals %
188 { } { "cpu" } strip-vocab-globals %
193 classes:class-and-cache
194 classes:class-not-cache
195 classes:class-or-cache
196 classes:class<=-cache
197 classes:classes-intersect-cache
198 classes:implementors-map
200 command-line:main-vocab-hook
202 compiler.units:recompile-hook
203 compiler.units:update-tuples-hook
212 listener:listener-hook
216 vocabs:load-vocab-hook
220 { } { "optimizer.math.partial" } strip-vocab-globals %
225 prettyprint.config:margin
226 prettyprint.config:string-limit
227 prettyprint.config:tab-size
233 compiler.errors.private:compiler-errors
234 continuations:thread-error-hook
238 deploy-c-types? get [
239 "c-types" "alien.c-types" lookup ,
243 "ui-error-hook" "ui.gadgets.worlds" lookup ,
246 "<computer>" "inference.dataflow" lookup [ , ] when*
248 "windows-messages" "windows.messages" lookup [ , ] when*
252 : strip-globals ( stripped-globals -- )
254 "Stripping globals" show
256 '[ drop , member? not ] assoc-filter
257 [ drop string? not ] assoc-filter ! strip CLI args
258 dup keys unparse show
262 : finish-deploy ( final-image -- )
264 >r { } set-datastack r>
269 "Saving final image" show
270 [ save-image-and-exit ] call-clear ;
274 : set-boot-quot* ( word -- )
277 init-hooks get values concat %
279 strip-io? [ \ flush , ] unless
280 ] [ ] make "Boot quotation: " write dup . flush
289 deploy-vocab get vocab-main set-boot-quot*
290 stripped-word-props >r
291 stripped-globals strip-globals
294 : (deploy) ( final-image vocab config -- )
295 #! Does the actual work of a deployment in the slave
300 deploy-vocab get require
304 print-error flush 1 exit
311 "Deploying " write dup write "..." print
312 dup deploy-config dup .