]> gitweb.factorcode.org Git - factor.git/blob - extra/mason/common/common.factor
Merge branch 'master' into experimental (untested!)
[factor.git] / extra / mason / common / common.factor
1 ! Copyright (C) 2008 Eduardo Cavazos, Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: kernel namespaces sequences splitting system accessors
4 math.functions make io io.files io.launcher io.encodings.utf8
5 prettyprint combinators.short-circuit parser combinators
6 calendar calendar.format arrays mason.config locals ;
7 IN: mason.common
8
9 : short-running-process ( command -- )
10     #! Give network operations at most 15 minutes to complete.
11     <process>
12         swap >>command
13         15 minutes >>timeout
14     try-process ;
15
16 :: upload-safely ( local username host remote -- )
17     [let* | temp [ remote ".incomplete" append ]
18             scp-remote [ { username "@" host ":" temp } concat ]
19             scp [ scp-command get ]
20             ssh [ ssh-command get ] |
21         { scp local scp-remote } short-running-process
22         { ssh host "-l" username "mv" temp remote } short-running-process
23     ] ;
24
25 : eval-file ( file -- obj )
26     dup utf8 file-lines parse-fresh
27     [ "Empty file: " swap append throw ] [ nip first ] if-empty ;
28
29 : cat ( file -- ) utf8 file-contents print ;
30
31 : cat-n ( file n -- ) [ utf8 file-lines ] dip short tail* [ print ] each ;
32
33 : to-file ( object file -- ) utf8 [ . ] with-file-writer ;
34
35 : datestamp ( timestamp -- string )
36     [
37         {
38             [ year>> , ]
39             [ month>> , ]
40             [ day>> , ]
41             [ hour>> , ]
42             [ minute>> , ]
43         } cleave
44     ] { } make [ pad-00 ] map "-" join ;
45
46 : milli-seconds>time ( n -- string )
47     millis>timestamp
48     [ hour>> ] [ minute>> ] [ second>> floor ] tri 3array
49     [ pad-00 ] map ":" join ;
50
51 SYMBOL: stamp
52
53 : builds/factor ( -- path ) builds-dir get "factor" append-path ;
54 : build-dir ( -- path ) builds-dir get stamp get append-path ;
55
56 : prepare-build-machine ( -- )
57     builds-dir get make-directories
58     builds-dir get
59     [ { "git" "clone" "git://factorcode.org/git/factor.git" } try-process ]
60     with-directory ;
61
62 : git-id ( -- id )
63     { "git" "show" } utf8 [ readln ] with-process-reader
64     " " split second ;
65
66 : ?prepare-build-machine ( -- )
67     builds/factor exists? [ prepare-build-machine ] unless ;
68
69 : load-everything-vocabs-file "load-everything-vocabs" ;
70 : load-everything-errors-file "load-everything-errors" ;
71
72 : test-all-vocabs-file "test-all-vocabs" ;
73 : test-all-errors-file "test-all-errors" ;
74
75 : help-lint-vocabs-file "help-lint-vocabs" ;
76 : help-lint-errors-file "help-lint-errors" ;
77
78 : boot-time-file "boot-time" ;
79 : load-time-file "load-time" ;
80 : compiler-errors-file "compiler-errors" ;
81 : test-time-file "test-time" ;
82 : help-lint-time-file "help-lint-time" ;
83 : benchmark-time-file "benchmark-time" ;
84 : html-help-time-file "html-help-time" ;
85
86 : benchmarks-file "benchmarks" ;
87
88 SYMBOL: status
89
90 SYMBOL: status-error ! didn't bootstrap, or crashed
91 SYMBOL: status-dirty ! bootstrapped but not all tests passed
92 SYMBOL: status-clean ! everything good