1 ! Copyright (C) 2004, 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors init namespaces words words.symbol io
4 kernel.private math memory continuations kernel io.files
5 io.pathnames io.backend system parser vocabs sequences
6 vocabs.loader combinators splitting source-files strings
7 definitions assocs compiler.units math.parser
8 generic sets command-line parser.notes ;
11 SYMBOL: core-bootstrap-time
13 SYMBOL: bootstrap-time
15 : strip-encodings ( -- )
18 P" resource:core/io/encodings/utf16/utf16.factor"
19 P" resource:core/io/encodings/utf16n/utf16n.factor" [ forget ] bi@
21 "io.encodings.utf16n" [ child-vocabs [ forget-vocab ] each ] bi@
22 ] with-compilation-unit
25 : default-image-name ( -- string )
26 vm file-name os windows? [ "." split1-last drop ] when
27 ".image" append resource-path ;
29 : load-components ( -- )
31 [ get-global " " split harvest ] bi@
33 [ "bootstrap." prepend require ] each ;
35 : count-words ( pred -- )
36 all-words swap count number>string write ; inline
38 : print-time ( us -- )
42 " minutes and " write number>string write " seconds." print ;
45 "Core bootstrap completed in " write core-bootstrap-time get print-time
46 "Bootstrap completed in " write bootstrap-time get print-time
48 "Bootstrapping is complete." print
49 "Now, you can run Factor:" print
50 vm write " -i=" write "output-image" get print flush ;
52 : save/restore-error ( quot -- )
54 original-error get-global
55 error-continuation get-global
57 error-continuation set-global
58 original-error set-global
59 error set-global ; inline
65 ! parser.notes sets this to t in the global namespace.
66 ! We have to change it back in finish-bootstrap.factor
67 f parser-quiet? set-global
69 default-image-name "output-image" set-global
71 "math compiler threads help io tools ui ui.tools unicode handbook" "include" set-global
72 "" "exclude" set-global
76 (command-line) parse-command-line
79 os windows? [ "windows" require ] when
81 "staging" get "deploy-vocab" get or [
82 "stage2: deployment mode" print
91 nano-count over - core-bootstrap-time set-global
96 f original-error set-global
97 f error-continuation set-global
99 nano-count swap - bootstrap-time set-global
103 "tools.deploy.shaker" run
106 "vocab:bootstrap/finish-staging.factor" run-file
108 "vocab:bootstrap/finish-bootstrap.factor" run-file
111 "output-image" get save-image-and-exit
117 [ "vocab:bootstrap/bootstrap-error.factor" parse-file ] save/restore-error