1 ! Copyright (C) 2004, 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: command-line compiler.units continuations definitions io
4 io.pathnames kernel math math.parser memory namespaces parser
5 parser.notes sequences sets splitting system
9 SYMBOL: core-bootstrap-time
11 SYMBOL: bootstrap-time
13 : strip-encodings ( -- )
16 P" resource:core/io/encodings/utf16/utf16.factor"
17 P" resource:core/io/encodings/utf16n/utf16n.factor" [ forget ] bi@
19 "io.encodings.utf16n" [ loaded-child-vocab-names [ forget-vocab ] each ] bi@
20 ] with-compilation-unit
23 : default-image-name ( -- string )
24 vm-path file-name os windows? [ "." split1-last drop ] when
25 ".image" append resource-path ;
27 : load-component ( name -- )
28 dup "* Loading the " write write " component" print
29 "bootstrap." prepend require ;
31 : load-components ( -- )
32 "include" "exclude" [ get-global " " split harvest ] bi@ diff
33 [ load-component ] each ;
35 : print-time ( us -- )
39 " minutes and " write number>string write " seconds." print ;
42 "Core bootstrap completed in " write core-bootstrap-time get print-time
43 "Bootstrap completed in " write bootstrap-time get print-time
45 "Bootstrapping is complete." print
46 "Now, you can run Factor:" print
47 vm-path write " -i=" write "output-image" get print flush ;
49 : save/restore-error ( quot -- )
51 original-error get-global
52 error-continuation get-global
54 error-continuation set-global
55 original-error set-global
56 error set-global ; inline
58 CONSTANT: default-components
59 "math compiler threads io tools ui ui.tools unicode help handbook"
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 default-components "include" set-global
72 "" "exclude" set-global
76 (command-line) parse-command-line
79 os windows? [ "windows" require ] when
82 "stage2: deployment mode" print
90 nano-count over - core-bootstrap-time set-global
94 nano-count swap - bootstrap-time set-global
98 "vocab:bootstrap/finish-staging.factor" run-file
100 "vocab:bootstrap/finish-bootstrap.factor" run-file
104 f original-error set-global
105 f error-continuation set-global
106 "output-image" get save-image-and-exit
111 [ "vocab:bootstrap/bootstrap-error.factor" parse-file ] save/restore-error