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.pathnames io.directories
5 io.directories.hierarchy io.launcher io.encodings.utf8 prettyprint
6 combinators.short-circuit parser combinators calendar
7 calendar.format arrays mason.config locals system debugger fry
8 continuations strings ;
11 SYMBOL: current-git-id
13 : short-running-process ( command -- )
14 #! Give network operations and shell commands at most
15 #! 15 minutes to complete, to catch hangs.
21 HOOK: really-delete-tree os ( path -- )
23 M: windows really-delete-tree
24 #! Workaround: Cygwin GIT creates read-only files for
26 [ { "chmod" "ug+rw" "-R" } swap (normalize-path) suffix short-running-process ]
30 M: unix really-delete-tree delete-tree ;
33 '[ drop @ f ] attempt-all drop ; inline
35 :: upload-safely ( local username host remote -- )
36 [let* | temp [ remote ".incomplete" append ]
37 scp-remote [ { username "@" host ":" temp } concat ]
38 scp [ scp-command get ]
39 ssh [ ssh-command get ] |
40 5 [ { scp local scp-remote } short-running-process ] retry
41 5 [ { ssh host "-l" username "mv" temp remote } short-running-process ] retry
44 : eval-file ( file -- obj )
45 dup utf8 file-lines parse-fresh
46 [ "Empty file: " swap append throw ] [ nip first ] if-empty ;
48 : cat ( file -- ) utf8 file-contents print ;
50 : cat-n ( file n -- ) [ utf8 file-lines ] dip short tail* [ print ] each ;
52 : to-file ( object file -- ) utf8 [ . ] with-file-writer ;
54 : datestamp ( timestamp -- string )
63 ] { } make [ pad-00 ] map "-" join ;
65 : milli-seconds>time ( n -- string )
67 [ hour>> ] [ minute>> ] [ second>> floor ] tri 3array
68 [ pad-00 ] map ":" join ;
72 : builds/factor ( -- path ) builds-dir get "factor" append-path ;
73 : build-dir ( -- path ) builds-dir get stamp get append-path ;
75 : prepare-build-machine ( -- )
76 builds-dir get make-directories
78 [ { "git" "clone" "git://factorcode.org/git/factor.git" } try-output-process ]
82 { "git" "show" } utf8 [ lines ] with-process-reader
83 first " " split second ;
85 : ?prepare-build-machine ( -- )
86 builds/factor exists? [ prepare-build-machine ] unless ;
88 CONSTANT: load-all-vocabs-file "load-everything-vocabs"
89 CONSTANT: load-all-errors-file "load-everything-errors"
91 CONSTANT: test-all-vocabs-file "test-all-vocabs"
92 CONSTANT: test-all-errors-file "test-all-errors"
94 CONSTANT: help-lint-vocabs-file "help-lint-vocabs"
95 CONSTANT: help-lint-errors-file "help-lint-errors"
97 CONSTANT: compiler-errors-file "compiler-errors"
98 CONSTANT: compiler-error-messages-file "compiler-error-messages"
100 CONSTANT: boot-time-file "boot-time"
101 CONSTANT: load-time-file "load-time"
102 CONSTANT: test-time-file "test-time"
103 CONSTANT: help-lint-time-file "help-lint-time"
104 CONSTANT: benchmark-time-file "benchmark-time"
105 CONSTANT: html-help-time-file "html-help-time"
107 CONSTANT: benchmarks-file "benchmarks"
108 CONSTANT: benchmark-error-messages-file "benchmark-error-messages"
109 CONSTANT: benchmark-error-vocabs-file "benchmark-error-vocabs"
111 SYMBOL: status-error ! didn't bootstrap, or crashed
112 SYMBOL: status-dirty ! bootstrapped but not all tests passed
113 SYMBOL: status-clean ! everything good