]> gitweb.factorcode.org Git - factor.git/blob - core/bootstrap/stage2.factor
Merge branch 'master' of git://factorcode.org/git/factor
[factor.git] / core / bootstrap / stage2.factor
1 ! Copyright (C) 2004, 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors init command-line namespaces words debugger 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 ;
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 ! We time bootstrap
48 millis >r
49
50 default-image-name "output-image" set-global
51
52 "math compiler help io random tools ui ui.tools unicode handbook" "include" set-global
53 "" "exclude" set-global
54
55 parse-command-line
56
57 "-no-crossref" cli-args member? [ do-crossref ] unless
58
59 "io.thread" require
60
61 ! Set dll paths
62 os wince? [ "windows.ce" require ] when
63 os winnt? [ "windows.nt" require ] when
64
65 "deploy-vocab" get [
66     "stage2: deployment mode" print
67 ] [
68     "listener" require
69     "none" require
70 ] if
71
72 [
73     load-components
74
75     run-bootstrap-init
76 ] with-compiler-errors
77 :errors
78
79 f error set-global
80 f error-continuation set-global
81
82 "deploy-vocab" get [
83     "tools.deploy.shaker" run
84 ] [
85     [
86         boot
87         do-init-hooks
88         [
89             parse-command-line
90             run-user-init
91             "run" get run
92             output-stream get [ stream-flush ] when*
93         ] [ print-error 1 exit ] recover
94     ] set-boot-quot
95
96     millis r> - dup bootstrap-time set-global
97     print-report
98
99     "output-image" get save-image-and-exit
100 ] if