From ce260a07aba18370485f2176823015d2e53dc107 Mon Sep 17 00:00:00 2001
From: Eduardo Cavazos <dharmatech@finkelstein.stackeffects.info>
Date: Thu, 31 Jan 2008 00:25:06 -0600
Subject: [PATCH] Add builder vocab

---
 extra/builder/builder.factor | 113 +++++++++++++++++++++++++++++++++++
 1 file changed, 113 insertions(+)
 create mode 100644 extra/builder/builder.factor

diff --git a/extra/builder/builder.factor b/extra/builder/builder.factor
new file mode 100644
index 0000000000..a2b5dffb4d
--- /dev/null
+++ b/extra/builder/builder.factor
@@ -0,0 +1,113 @@
+
+USING: kernel io io.files io.launcher
+       system namespaces sequences splitting math.parser
+       unix prettyprint tools.time calendar bake vars ;
+
+IN: builder
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: datestamp ( -- string )
+  now `{ ,[ dup timestamp-year   ]
+      	 ,[ dup timestamp-month	 ]
+	 ,[ dup timestamp-day	 ]
+	 ,[ dup timestamp-hour	 ]
+	 ,[     timestamp-minute ] }
+  [ number>string 2 CHAR: 0 pad-left ] map "-" join ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+SYMBOL: builder-recipients
+
+: quote ( str -- str ) "'" swap "'" 3append ;
+
+: email-file ( subject file -- )
+  `{
+     "cat"       ,
+     "| mutt -s" ,[ quote ]
+     "-x"        %[ builder-recipients get ]
+   }
+   " " join system drop ;
+  
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: boot-image ( -- filename ) `{ "boot" ,[ cpu ] "image" } "." join ;
+
+: target ( -- target ) `{ ,[ os ] %[ cpu "." split ] } "-" join ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+VAR: stamp
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: build ( -- )
+
+datestamp >stamp
+
+"/builds/factor" cd
+"git pull git://factorcode.org/git/factor.git" system
+0 =
+[ ]
+[
+  "builder: git pull" "/dev/null" email-file
+  "builder: git pull" throw
+]
+if
+
+"/builds/" stamp> append make-directory
+"/builds/" stamp> append cd
+"git clone /builds/factor" system drop
+
+"factor" cd
+
+{ "/usr/bin/git" "show" } <process-stream>
+[ readln ] with-stream
+" " split second
+"../git-id" <file-writer> [ print ] with-stream
+
+"make clean" system drop
+
+"make " target " > ../compile-log" 3append system
+0 =
+[ ]
+[
+  "builder: vm compile" "../compile-log" email-file
+  "builder: vm compile" throw
+] if
+
+"wget http://factorcode.org/images/latest/" boot-image append system
+0 =
+[ ]
+[
+  "builder: image download" "/dev/null" email-file
+  "builder: image download" throw
+] if
+
+[ "./factor -i=" boot-image " -no-user-init > ../boot-log" 3append system ]
+benchmark nip
+"../boot-time" <file-writer> [ . ] with-stream
+0 =
+[ ]
+[
+  "builder: bootstrap" "../boot-log" email-file
+  "builder: bootstrap" throw
+] if
+
+[
+  "./factor -e='USE: tools.browser load-everything' > ../load-everything-log"
+  system
+] benchmark nip
+"../load-everything-time" <file-writer> [ . ] with-stream
+0 =
+[ ]
+[
+  "builder: load-everything" "../load-everything-log" email-file
+  "builder: load-everything" throw
+] if
+
+;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+MAIN: build
\ No newline at end of file