factor/extra/builder/builder.factor

239 lines
6.0 KiB
Factor
Raw Normal View History

2008-01-31 01:25:06 -05:00
2008-02-16 04:43:51 -05:00
USING: kernel namespaces sequences splitting system combinators continuations
parser io io.files io.launcher io.sockets prettyprint threads
bootstrap.image benchmark vars bake smtp builder.util accessors
2008-03-07 09:52:23 -05:00
io.encodings.utf8
2008-02-22 18:48:20 -05:00
calendar
2008-03-14 02:17:17 -04:00
tools.test
builder.common
builder.benchmark
builder.release ;
2008-01-31 01:25:06 -05:00
IN: builder
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2008-03-28 00:22:19 -04:00
: cd ( path -- ) set-current-directory ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
: prepare-build-machine ( -- )
builds make-directory
builds cd
{ "git" "clone" "git://factorcode.org/git/factor.git" } run-process drop ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
: builds-check ( -- ) builds exists? not [ prepare-build-machine ] when ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2008-02-10 02:04:14 -05:00
: git-clone ( -- desc ) { "git" "clone" "../factor" } ;
2008-02-04 22:26:59 -05:00
2008-02-12 06:38:09 -05:00
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2008-02-10 02:04:14 -05:00
: enter-build-dir ( -- )
datestamp >stamp
builds cd
2008-02-10 02:04:14 -05:00
stamp> make-directory
stamp> cd ;
2008-02-04 22:26:59 -05:00
2008-02-12 06:38:09 -05:00
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2008-02-11 15:59:02 -05:00
: git-id ( -- id )
2008-03-07 09:52:23 -05:00
{ "git" "show" } utf8 <process-stream>
[ readln ] with-stream " " split second ;
2008-02-11 15:59:02 -05:00
2008-03-07 09:52:23 -05:00
: record-git-id ( -- ) git-id "../git-id" utf8 [ . ] with-file-writer ;
2008-02-04 22:26:59 -05:00
2008-03-30 16:39:13 -04:00
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
: gnu-make ( -- string )
os { "freebsd" "openbsd" "netbsd" } member?
[ "gmake" ]
[ "make" ]
if ;
: do-make-clean ( -- ) { gnu-make "clean" } to-strings try-process ;
2008-02-08 21:09:59 -05:00
2008-02-14 02:01:09 -05:00
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2008-02-14 01:43:50 -05:00
: make-vm ( -- desc )
2008-03-07 09:52:23 -05:00
<process>
2008-03-30 16:39:13 -04:00
{ gnu-make } to-strings >>command
"../compile-log" >>stdout
+stdout+ >>stderr ;
2008-02-14 01:43:50 -05:00
2008-03-01 08:13:22 -05:00
: do-make-vm ( -- )
make-vm [ "vm compile error" print "../compile-log" cat ] run-or-bail ;
2008-02-14 02:01:09 -05:00
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
: copy-image ( -- )
builds "factor" append-path my-boot-image-name append-path ".." copy-file-into
builds "factor" append-path my-boot-image-name append-path "." copy-file-into ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2008-02-14 01:43:50 -05:00
: bootstrap-cmd ( -- cmd )
{ "./factor" { "-i=" my-boot-image-name } "-no-user-init" } to-strings ;
2008-02-04 22:26:59 -05:00
2008-02-10 02:04:14 -05:00
: bootstrap ( -- desc )
2008-03-07 09:52:23 -05:00
<process>
bootstrap-cmd >>command
2008-02-14 06:20:38 -05:00
+closed+ >>stdin
2008-02-14 01:43:50 -05:00
"../boot-log" >>stdout
+stdout+ >>stderr
60 minutes >>timeout ;
2008-02-14 01:43:50 -05:00
2008-03-01 08:13:22 -05:00
: do-bootstrap ( -- )
bootstrap [ "Bootstrap error" print "../boot-log" cat ] run-or-bail ;
: builder-test-cmd ( -- cmd )
{ "./factor" "-run=builder.test" } to-strings ;
: builder-test ( -- desc )
2008-03-07 09:52:23 -05:00
<process>
builder-test-cmd >>command
+closed+ >>stdin
"../test-log" >>stdout
+stdout+ >>stderr
2008-03-20 01:33:17 -04:00
120 minutes >>timeout ;
2008-03-01 08:13:22 -05:00
: do-builder-test ( -- )
builder-test [ "Test error" print "../test-log" 100 cat-n ] run-or-bail ;
2008-02-12 00:42:21 -05:00
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2008-02-15 04:17:30 -05:00
SYMBOL: build-status
: (build) ( -- )
2008-02-16 10:05:01 -05:00
builds-check
2008-02-15 04:17:30 -05:00
build-status off
enter-build-dir
"report" utf8
2008-03-01 08:13:22 -05:00
[
2008-04-04 13:26:39 -04:00
"Build machine: " write host-name print
"CPU: " write cpu print
"OS: " write os print
"Build directory: " write current-directory get print
2008-02-14 06:20:38 -05:00
2008-03-01 08:13:22 -05:00
git-clone [ "git clone failed" print ] run-or-bail
2008-03-01 08:13:22 -05:00
"factor"
[
record-git-id
do-make-clean
do-make-vm
copy-image
do-bootstrap
do-builder-test
]
with-directory
2008-02-19 15:37:33 -05:00
2008-03-01 08:13:22 -05:00
"test-log" delete-file
2008-02-12 05:42:47 -05:00
2008-03-03 06:02:59 -05:00
"git id: " write "git-id" eval-file print nl
2008-03-01 08:13:22 -05:00
"Boot time: " write "boot-time" eval-file milli-seconds>time print
"Load time: " write "load-time" eval-file milli-seconds>time print
"Test time: " write "test-time" eval-file milli-seconds>time print nl
2008-02-12 05:42:47 -05:00
2008-03-01 08:13:22 -05:00
"Did not pass load-everything: " print "load-everything-vocabs" cat
2008-03-14 02:17:17 -04:00
2008-03-01 08:13:22 -05:00
"Did not pass test-all: " print "test-all-vocabs" cat
2008-03-14 12:54:20 -04:00
"test-failures" cat
! "test-failures" eval-file test-failures.
2008-03-14 02:17:17 -04:00
"help-lint results:" print "help-lint" cat
2008-02-13 06:50:45 -05:00
2008-03-01 08:13:22 -05:00
"Benchmarks: " print "benchmarks" eval-file benchmarks.
2008-02-18 18:16:37 -05:00
2008-03-01 08:13:22 -05:00
nl
2008-02-25 19:39:27 -05:00
2008-03-01 08:13:22 -05:00
show-benchmark-deltas
2008-02-25 19:39:27 -05:00
2008-03-01 08:13:22 -05:00
"benchmarks" ".." copy-file-into
2008-02-18 18:16:37 -05:00
2008-03-01 08:13:22 -05:00
maybe-release
]
with-file-writer
2008-02-15 04:17:30 -05:00
build-status on ;
2008-02-14 02:01:09 -05:00
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
SYMBOL: builder-from
2008-02-14 02:01:09 -05:00
SYMBOL: builder-recipients
: tag-subject ( str -- str ) { "builder@" host-name* ": " , } bake to-string ;
: subject ( -- str ) build-status get [ "report" ] [ "error" ] if tag-subject ;
2008-02-15 04:17:30 -05:00
: send-builder-email ( -- )
2008-02-14 01:43:50 -05:00
<email>
builder-from get >>from
2008-02-14 01:43:50 -05:00
builder-recipients get >>to
2008-02-15 04:17:30 -05:00
subject >>subject
2008-02-25 19:39:27 -05:00
"./report" file>string >>body
2008-03-11 04:39:50 -04:00
send-email ;
2008-02-12 05:42:47 -05:00
2008-02-18 18:16:37 -05:00
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2008-02-19 16:32:53 -05:00
: compress-image ( -- )
{ "bzip2" my-boot-image-name } to-strings run-process drop ;
: build ( -- )
2008-02-25 19:39:27 -05:00
[ (build) ] failsafe
builds cd stamp> cd
2008-02-18 18:16:37 -05:00
[ send-builder-email ] [ drop "not sending mail" . ] recover
2008-02-25 19:39:27 -05:00
{ "rm" "-rf" "factor" } run-process drop
[ compress-image ] failsafe ;
2008-02-12 05:42:47 -05:00
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
USE: bootstrap.image.download
2008-02-14 02:01:09 -05:00
: git-pull ( -- desc )
{
"git"
"pull"
"--no-summary"
"git://factorcode.org/git/factor.git"
"master"
} ;
2008-02-11 15:59:02 -05:00
: updates-available? ( -- ? )
git-id
git-pull run-process drop
git-id
= not ;
: new-image-available? ( -- ? )
2008-02-18 18:16:37 -05:00
my-boot-image-name need-new-image?
[ download-my-image t ]
[ f ]
if ;
2008-02-11 15:59:02 -05:00
: build-loop ( -- )
2008-02-15 06:54:19 -05:00
builds-check
2008-02-11 15:59:02 -05:00
[
2008-02-15 07:04:53 -05:00
builds "/factor" append cd
updates-available? new-image-available? or
2008-02-11 15:59:02 -05:00
[ build ]
when
]
2008-02-25 19:39:27 -05:00
failsafe
2008-02-22 18:48:20 -05:00
5 minutes sleep
2008-02-11 15:59:02 -05:00
build-loop ;
2008-01-31 01:25:06 -05:00
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2008-04-02 19:25:33 -04:00
MAIN: build-loop