16
16
# You should have received a copy of the GNU Affero General Public License
17
17
# along with this program. If not, see <http://www.gnu.org/licenses/>.
18
18
19
- # This script will build rakudo for all commits that it can find
19
+ # This script will build something for all commits that it can find
20
20
21
21
use File::Temp;
22
22
use File::Directory::Tree;
23
23
24
- constant PARALLEL-COUNT = 1 ;
25
- constant COMMIT-RANGE = ‘ 2015.07^..HEAD’ ;
26
- constant TAGS-SINCE = ‘ 2014-01-01’ ;
24
+ enum Project <Rakudo-Moar Rakudo-JVM Rakudo-JS MoarVM >;
25
+ my \PROJECT = do given @ * ARGS [0 ] // ‘ ’ {
26
+ when /:i ^ ‘moarvm’ $ / { MoarVM }
27
+ default { Rakudo-Moar }
28
+ }
29
+ my \RAKUDOISH = PROJECT == Rakudo-Moar | Rakudo-JVM | Rakudo-JS;
30
+ my \DIR-BASE = PROJECT. lc ;
31
+
32
+ my \PARALLEL-COUNT = 1 ;
33
+ my \COMMIT-RANGE = ‘ 2015.07^..HEAD’ ;
34
+ my \TAGS-SINCE = ‘ 2014-01-01’ ;
35
+
36
+ my \WORKING-DIRECTORY = ‘ .’ ; # TODO not supported yet
27
37
28
- constant WORKING-DIRECTORY = ‘ .’ ; # TODO not supported yet
38
+ my \REPO-ORIGIN = RAKUDOISH
39
+ ?? ‘ https://github.com/rakudo/rakudo.git’
40
+ !! ‘ https://github.com/MoarVM/MoarVM.git’ ;
29
41
30
- constant RAKUDO-ORIGIN = ‘ https://github.com/rakudo/rakudo.git’ ;
31
- constant RAKUDO-LATEST = ‘ /tmp/whateverable/rakudo-repo’ ;
32
- constant RAKUDO-CURRENT = “ { WORKING-DIRECTORY} /rakudo” . IO . absolute;
42
+ my \REPO-LATEST = “ /tmp/whateverable/{ DIR-BASE} -repo” ;
43
+ # ↑ yes, separate cloned repo for every backend to prevent several
44
+ # instances of this script fighting with each other
45
+ my \REPO-CURRENT = “ { WORKING-DIRECTORY} /{ DIR-BASE} ” . IO . absolute;
33
46
34
- constant ARCHIVES-LOCATION = “ { WORKING-DIRECTORY} /builds/rakudo-moar ” . IO . absolute;
35
- constant BUILDS-LOCATION = ‘ /tmp/whateverable/rakudo-moar ’ ;
36
- constant BUILD-LOCK = ‘ /tmp/whateverable/ build-lock’ ;
47
+ my \ ARCHIVES-LOCATION = “ { WORKING-DIRECTORY} /builds/{ DIR-BASE } ” . IO . absolute;
48
+ my \ BUILDS-LOCATION = “ /tmp/whateverable/{ DIR-BASE } ” ;
49
+ my \ BUILD-LOCK = “ { BUILDS-LOCATION } / build-lock” ;
37
50
38
- constant GIT-REFERENCE = WORKING-DIRECTORY. IO . absolute;
51
+ my \ GIT-REFERENCE = WORKING-DIRECTORY. IO . absolute;
39
52
40
53
mkdir BUILDS-LOCATION;
41
54
mkdir ARCHIVES-LOCATION;
@@ -45,23 +58,22 @@ exit 0 unless run ‘mkdir’, :err(Nil), ‘--’, BUILD-LOCK; # only one insta
45
58
my $ locked = True ;
46
59
END BUILD-LOCK. IO . rmdir if $ locked ;
47
60
48
- # TODO should we also pull nqp/ and MoarVM/ ?
49
- if RAKUDO-LATEST. IO ~~ : d {
61
+ if REPO-LATEST. IO ~~ : d {
50
62
my $ old-dir = $ * CWD ;
51
63
LEAVE chdir $ old-dir ;
52
- chdir RAKUDO -LATEST;
64
+ chdir REPO -LATEST;
53
65
run ‘ git’ , ‘ pull’ ;
54
66
} else {
55
- exit unless run ‘ git’ , ‘ clone’ , ‘ --’ , RAKUDO -ORIGIN, RAKUDO -LATEST;
67
+ exit unless run ‘ git’ , ‘ clone’ , ‘ --’ , REPO -ORIGIN, REPO -LATEST;
56
68
}
57
69
58
- if RAKUDO -CURRENT. IO ! ~~ : d {
59
- run ‘ git’ , ‘ clone’ , ‘ --’ , RAKUDO -LATEST, RAKUDO -CURRENT;
70
+ if REPO -CURRENT. IO ! ~~ : d {
71
+ run ‘ git’ , ‘ clone’ , ‘ --’ , REPO -LATEST, REPO -CURRENT;
60
72
}
61
73
62
74
my $ channel = Channel . new ;
63
75
64
- my @ git-latest = ‘ git’ , ‘ --git-dir’ , “ { RAKUDO -LATEST} /.git” , ‘ --work-tree’ , RAKUDO -LATEST;
76
+ my @ git-latest = ‘ git’ , ‘ --git-dir’ , “ { REPO -LATEST} /.git” , ‘ --work-tree’ , REPO -LATEST;
65
77
my @ args-tags = | @ git-latest , ‘ log’ , ‘ -z’ , ‘ --pretty=%H’ , ‘ --tags’ , ‘ --no-walk’ , ‘ --since’ , TAGS-SINCE;
66
78
my @ args-latest = | @ git-latest , ‘ log’ , ‘ -z’ , ‘ --pretty=%H’ , COMMIT-RANGE;
67
79
@@ -79,8 +91,8 @@ await (for ^PARALLEL-COUNT { # TODO rewrite when .race starts working in rakudo
79
91
}
80
92
});
81
93
82
- # update rakudo repo so that bots know about latest commits
83
- run ‘ git’ , ‘ --git-dir’ , “ { RAKUDO -CURRENT} /.git” , ‘ --work-tree’ , RAKUDO -CURRENT, ‘ pull’ , ‘ --tags’ , RAKUDO -LATEST;
94
+ # update repo so that bots know about latest commits
95
+ run ‘ git’ , ‘ --git-dir’ , “ { REPO -CURRENT} /.git” , ‘ --work-tree’ , REPO -CURRENT, ‘ pull’ , ‘ --tags’ , REPO -LATEST;
84
96
85
97
sub process-commit ($ commit ) {
86
98
return if “ { ARCHIVES-LOCATION} /$ commit .zst” . IO ~~ : e; # already exists
@@ -91,7 +103,7 @@ sub process-commit($commit) {
91
103
my $ archive-path = “ { ARCHIVES-LOCATION} /$ commit .zst” . IO . absolute;
92
104
93
105
# ⚡ clone
94
- run ‘ git’ , ‘ clone’ , ‘ -q’ , ‘ --’ , RAKUDO -LATEST, $ temp-folder ;
106
+ run ‘ git’ , ‘ clone’ , ‘ -q’ , ‘ --’ , REPO -LATEST, $ temp-folder ;
95
107
# ⚡ checkout to $commit
96
108
my @ git-temp = ‘ git’ , ‘ --git-dir’ , “ $ temp-folder /.git” , ‘ --work-tree’ , $ temp-folder ;
97
109
run | @ git-temp , ‘ reset’ , ‘ -q’ , ‘ --hard’ , $ commit ;
@@ -108,10 +120,20 @@ sub process-commit($commit) {
108
120
say “ »»»»» $ commit : configure” ;
109
121
my $ configure-log-fh = open : w, “ $ log-path /configure.log” ;
110
122
my $ configure-err-fh = open : w, “ $ log-path /configure.err” ;
111
- $ config-ok = run (: out($ configure-log-fh ), : err($ configure-err-fh ),
112
- ‘ perl’ , ‘ --’ , ‘ Configure.pl’ ,
113
- ‘ --gen-moar’ , ‘ --gen-nqp’ , ‘ --backends=moar’ , “ --prefix=$ build-path” ,
114
- “ --git-reference={ GIT-REFERENCE} ” );
123
+
124
+ my @ args = do given PROJECT {
125
+ when MoarVM {
126
+ @ args = ‘ perl’ , ‘ --’ , ‘ Configure.pl’ , “ --prefix=$ build-path” ,
127
+ ‘ --debug=3’
128
+ }
129
+ when Rakudo-Moar {
130
+ @ args = ‘ perl’ , ‘ --’ , ‘ Configure.pl’ , “ --prefix=$ build-path” ,
131
+ ‘ --gen-moar’ , ‘ --gen-nqp’ , ‘ --backends=moar’ ,
132
+ “ --git-reference={ GIT-REFERENCE} ”
133
+ }
134
+ }
135
+ $ config-ok = run : out($ configure-log-fh ), : err($ configure-err-fh ), | @ args ;
136
+
115
137
$ configure-log-fh . close ;
116
138
$ configure-err-fh . close ;
117
139
say “ »»»»» Cannot configure $ commit” unless $ config-ok ;
@@ -123,8 +145,11 @@ sub process-commit($commit) {
123
145
say “ »»»»» $ commit : make” ;
124
146
my $ make-log-fh = open : w, “ $ log-path /make.log” ;
125
147
my $ make-err-fh = open : w, “ $ log-path /make.err” ;
126
- $ make-ok = run (: out($ make-log-fh ), : err($ make-err-fh ),
127
- ‘ make’ , ‘ -C’ , $ temp-folder );
148
+ my @ args = do given PROJECT {
149
+ when MoarVM { ‘ make’ , ‘ -j’ , ‘ 8’ , ‘ -C’ , $ temp-folder }
150
+ when Rakudo-Moar { ‘ make’ , ‘ -C’ , $ temp-folder }
151
+ }
152
+ $ make-ok = run : out($ make-log-fh ), : err($ make-err-fh ), | @ args ;
128
153
$ make-log-fh . close ;
129
154
$ make-err-fh . close ;
130
155
say “ »»»»» Cannot make $ commit” unless $ make-ok ;
0 commit comments