]> gitweb.factorcode.org Git - factor.git/blob - basis/bootstrap/stage2.factor
d2b522581d8f9eef05ca3d8191b60cc27163f204
[factor.git] / basis / bootstrap / stage2.factor
1 ! Copyright (C) 2004, 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors init namespaces words io kernel.private math
4 memory continuations kernel io.files io.pathnames io.backend
5 system parser vocabs sequences vocabs.loader combinators
6 splitting source-files strings definitions assocs
7 compiler.errors compiler.units math.parser generic sets
8 command-line ;
9 IN: bootstrap.stage2
10
11 SYMBOL: core-bootstrap-time
12
13 SYMBOL: bootstrap-time
14
15 : default-image-name ( -- string )
16     vm file-name os windows? [ "." split1 drop ] when
17     ".image" append resource-path ;
18
19 : do-crossref ( -- )
20     "Cross-referencing..." print flush
21     H{ } clone crossref set-global
22     xref-words
23     xref-generics
24     xref-sources ;
25
26 : load-components ( -- )
27     "include" "exclude"
28     [ get-global " " split harvest ] bi@
29     diff
30     [ "bootstrap." prepend require ] each ;
31
32 : count-words ( pred -- )
33     all-words swap count number>string write ;
34
35 : print-time ( ms -- )
36     1000 /i
37     60 /mod swap
38     number>string write
39     " minutes and " write number>string write " seconds." print ;
40
41 : print-report ( -- )
42     "Core bootstrap completed in " write core-bootstrap-time get print-time
43     "Bootstrap completed in "      write bootstrap-time      get print-time
44
45     [ compiled>> ] count-words " compiled words" print
46     [ symbol? ] count-words " symbol words" print
47     [ ] count-words " words total" print
48
49     "Bootstrapping is complete." print
50     "Now, you can run Factor:" print
51     vm write " -i=" write "output-image" get print flush ;
52
53 [
54     ! We time bootstrap
55     millis
56
57     default-image-name "output-image" set-global
58
59     "math compiler threads help io tools ui ui.tools unicode handbook" "include" set-global
60     "" "exclude" set-global
61
62     (command-line) parse-command-line
63
64     do-crossref
65
66     ! Set dll paths
67     os wince? [ "windows.ce" require ] when
68     os winnt? [ "windows.nt" require ] when
69
70     "staging" get "deploy-vocab" get or [
71         "stage2: deployment mode" print
72     ] [
73         "listener" require
74         "none" require
75     ] if
76
77     [
78         load-components
79
80         millis over - core-bootstrap-time set-global
81
82         run-bootstrap-init
83     ] with-compiler-errors
84     :errors
85
86     f error set-global
87     f error-continuation set-global
88
89     millis swap - bootstrap-time set-global
90     print-report
91
92     "deploy-vocab" get [
93         "tools.deploy.shaker" run
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         "output-image" get save-image-and-exit
102     ] if
103 ] [
104     drop
105     [
106         load-help? off
107         "resource:basis/bootstrap/bootstrap-error.factor" run-file
108     ] with-scope
109 ] recover