! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays assocs bootstrap.image calendar cli.git
combinators combinators.short-circuit concurrency.combinators
-environment formatting http.client io io.directories io.launcher
-io.pathnames kernel math.parser memory modern.paths namespaces
-parser.notes prettyprint regexp.classes sequences
-sequences.extras sets splitting system system-info threads
-tools.test tools.test.private vocabs vocabs.hierarchy
-vocabs.hierarchy.private vocabs.loader vocabs.metadata zealot ;
+environment formatting http.client io io.directories
+io.encodings.utf8 io.launcher io.pathnames kernel math.parser
+memory modern.paths namespaces parser.notes prettyprint
+regexp.classes sequences sequences.extras sets splitting system
+system-info threads tools.test tools.test.private vocabs
+vocabs.hierarchy vocabs.hierarchy.private vocabs.loader
+vocabs.metadata zealot ;
IN: zealot.factor
+! XXX: Could check if it's a branch instead with a git command
: git-checksum? ( str -- ? )
{ [ length 40 = ] [ [ hex-digit? ] all? ] } 1&& ;
[ download-boot-checksum-branch ] if ;
: download-boot-image ( path url -- )
- '[ _ download ] with-directory ;
+ '[ _ my-arch-name "boot.%s.image" sprintf download-to ] with-directory ;
: arch-git-boot-image-path ( arch git-id -- str )
"https://downloads.factorcode.org/images/build/boot.%s.image.%s" sprintf ;
download-boot-image ;
HOOK: compile-factor-command os ( -- array )
+M: macosx compile-factor-command ( -- array )
+ { "arch" "-x86_64" "make" "-j" } cpus number>string suffix ;
M: unix compile-factor-command ( -- array )
{ "make" "-j" } cpus number>string suffix ;
M: windows compile-factor-command ( -- array )
: bootstrap-factor ( path -- )
[
<process>
- factor-path "-i=" my-boot-image-name append "-no-user-init" 3array >>command
+ factor-path "-i=" my-boot-image-name append "-no-user-init" 3array
+ os macosx = [ { "arch" "-x86_64" } prepend ] when
+ >>command
+closed+ >>stdin
"./bootstrap-log" >>stdout
+stdout+ >>stderr
: zealot-test-commands ( path -- )
[
32 <iota> [
- load-and-test-command
+ load-and-test-command
] map [ try-process ] parallel-each
] with-directory ;
[ try-process ] parallel-each
] with-directory ;
-: build-new-factor ( branch/checksum -- )
+: checkout-new-factor ( branch/checksum -- path branch/checksum )
"factor" "factor" zealot-github-ensure drop
[ "factor" "factor" zealot-github-clone-paths nip ] dip
[ drop "factor" "factor" zealot-github-add-build-remote drop ]
[ drop [ git-fetch-all* ] with-directory drop ]
[ zealot-build-checkout drop ]
+ [ ]
+ } 2cleave ;
+
+: bootstrap-new-factor ( path branch/checksum -- path branch/checksum )
+ {
[ "ZEALOT DOWNLOADING BOOT IMAGE" print flush download-my-boot-image ]
[ "ZEALOT DOWNLOADING CHECKSUMS" print flush download-boot-checksums ]
[ "ZEALOT COMPILING" print flush drop compile-factor ]
[ "ZEALOT BOOTSTRAPPING" print flush drop bootstrap-factor ]
+ [ ]
+ } 2cleave ;
+
+: test-new-factor ( path branch/checksum -- )
+ {
[ "ZEALOT LOADING ROOTS" print flush drop zealot-load-commands ]
[ "ZEALOT TESTING ROOTS" print flush drop zealot-test-commands ]
} 2cleave ;
+: check-new-factor ( path branch/checksum cmd -- out )
+ nip [ factor-path "-i=factor.image" ] dip "-e=%s" sprintf 3array
+ "./test-bisect-log" zealot-test-command
+ '[ _ utf8 [ read-contents ] with-process-reader ] with-directory ;
+
+: build-new-factor ( branch/checksum -- )
+ checkout-new-factor bootstrap-new-factor test-new-factor ;
+
+: bisect-new-factor ( branch/checksum cmd -- out )
+ [ checkout-new-factor bootstrap-new-factor ] dip check-new-factor ;
+
: factor-clean-branch ( -- str )
os cpu [ name>> ] bi@ { { CHAR: . CHAR: - } } substitute
"-" glue "origin/clean-" prepend ;