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