1 ! Copyright (C) 2004, 2008 Slava Pestov.
2 ! See https://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" forget
17 "io.encodings.utf16" loaded-child-vocab-names [ forget-vocab ] each
18 ] with-compilation-unit
21 : default-image-name ( -- string )
22 vm-path file-name os windows? [ "." split1-last drop ] when
23 ".image" append resource-path ;
25 : load-component ( name -- )
26 dup "* Loading the " write write " component" print
27 "bootstrap." prepend require ;
29 : load-components ( -- )
30 "include" "exclude" [ get-global split-words harvest ] bi@ diff
31 [ load-component ] each ;
33 : print-time ( us -- )
37 " minutes and " write number>string write " seconds." print ;
40 "Core bootstrap completed in " write core-bootstrap-time get print-time
41 "Bootstrap completed in " write bootstrap-time get print-time
43 "Bootstrapping is complete." print
44 "Now, you can run Factor:" print
45 vm-path write " -i=" write "output-image" get print flush ;
47 : save/restore-error ( quot -- )
49 original-error get-global
50 error-continuation get-global
52 error-continuation set-global
53 original-error set-global
54 error set-global ; inline
56 CONSTANT: default-components
57 "math compiler threads io tools ui ui.tools unicode help handbook"
63 ! parser.notes sets this to t in the global namespace.
64 ! We have to change it back in finish-bootstrap.factor
65 f parser-quiet? set-global
67 default-image-name "output-image" set-global
69 default-components "include" set-global
70 "" "exclude" set-global
74 (command-line) parse-command-line
77 os windows? [ "windows" require ] when
80 "stage2: deployment mode" print
88 nano-count over - core-bootstrap-time set-global
92 nano-count swap - bootstrap-time set-global
96 "resource:basis/bootstrap/finish-staging.factor" run-file
98 "resource:basis/bootstrap/finish-bootstrap.factor" run-file
102 f original-error set-global
103 f error-continuation set-global
104 "output-image" get save-image-and-exit
109 [ "resource:basis/bootstrap/bootstrap-error.factor" parse-file ] save/restore-error