]> gitweb.factorcode.org Git - factor.git/blob - basis/bootstrap/stage2.factor
scryfall: better moxfield words
[factor.git] / basis / bootstrap / stage2.factor
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
6 vocabs vocabs.loader ;
7 IN: bootstrap.stage2
8
9 SYMBOL: core-bootstrap-time
10
11 SYMBOL: bootstrap-time
12
13 : strip-encodings ( -- )
14     os unix? [
15         [
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
19     ] when ;
20
21 : default-image-name ( -- string )
22     vm-path file-name os windows? [ "." split1-last drop ] when
23     ".image" append resource-path ;
24
25 : load-component ( name -- )
26     dup "* Loading the " write write " component" print
27     "bootstrap." prepend require ;
28
29 : load-components ( -- )
30     "include" "exclude" [ get-global split-words harvest ] bi@ diff
31     [ load-component ] each ;
32
33 : print-time ( us -- )
34     1,000,000,000 /i
35     60 /mod swap
36     number>string write
37     " minutes and " write number>string write " seconds." print ;
38
39 : print-report ( -- )
40     "Core bootstrap completed in " write core-bootstrap-time get print-time
41     "Bootstrap completed in "      write bootstrap-time      get print-time
42
43     "Bootstrapping is complete." print
44     "Now, you can run Factor:" print
45     vm-path write " -i=" write "output-image" get print flush ;
46
47 : save/restore-error ( quot -- )
48     error get-global
49     original-error get-global
50     error-continuation get-global
51     [ call ] 3dip
52     error-continuation set-global
53     original-error set-global
54     error set-global ; inline
55
56 CONSTANT: default-components
57     "math compiler threads io tools ui ui.tools unicode help handbook"
58
59 [
60     ! We time bootstrap
61     nano-count
62
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
66
67     default-image-name "output-image" set-global
68
69     default-components "include" set-global
70     "" "exclude" set-global
71
72     strip-encodings
73
74     (command-line) parse-command-line
75
76     ! Set dll paths
77     os windows? [ "windows" require ] when
78
79     "staging" get [
80         "stage2: deployment mode" print
81     ] [
82         "debugger" require
83         "listener" require
84     ] if
85
86     load-components
87
88     nano-count over - core-bootstrap-time set-global
89
90     run-bootstrap-init
91
92     nano-count swap - bootstrap-time set-global
93     print-report
94
95     "staging" get [
96         "resource:basis/bootstrap/finish-staging.factor" run-file
97     ] [
98         "resource:basis/bootstrap/finish-bootstrap.factor" run-file
99     ] if
100
101     f error set-global
102     f original-error set-global
103     f error-continuation set-global
104     "output-image" get save-image-and-exit
105 ] [
106     drop
107     [
108         load-help? off
109         [ "resource:basis/bootstrap/bootstrap-error.factor" parse-file ] save/restore-error
110         call
111     ] with-scope
112 ] recover