-
Notifications
You must be signed in to change notification settings - Fork 2
/
Jenkinsfile
280 lines (274 loc) · 10.7 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
def opam_installations(ocamlversions, url) {
def pwd = sh (
script: 'echo $PWD',
returnStdout: true
).trim()
def branches = [:]
for (i in ocamlversions) {
def ocamlversion = i
branches[ocamlversion] = {
node {
sh """
docker run --pull=always --rm -v $pwd/src:/clangml \
ocaml/opam:debian-11-ocaml-$ocamlversion \
/clangml/ci-scripts/opam-pin_and_install.sh $url
"""
}
}
}
parallel branches
}
pipeline {
agent {
label 'slave'
}
stages {
stage('Prepare') {
steps {
sh 'mkdir src'
sh 'mv * src/ || true'
sh '''
eval $(opam env) && \
cd src && \
rm -rf bootstrap/ && \
tar -xf ~/bootstrap.tar.xz && \
m4/download.sh && \
./autogen.sh
'''
}
}
stage('Configure') {
steps {
timeout(time: 3, unit: 'MINUTES') {
sh '''
eval $(opam env) && \
mkdir build && cd build && \
../src/configure \
--with-llvm-config=/media/llvms/17.0.0/bin/llvm-config
'''
}
}
}
stage('Build') {
steps {
timeout(time: 5, unit: 'MINUTES') {
sh 'make -C build clangml'
sh 'make -C build clangml.opam && cp build/clangml.opam src/'
sh 'make -C build tools/stubgen'
sh 'make -C build tools/norm_extractor'
sh 'make -C build tools/generate_attrs'
}
}
}
stage('Generate attributes') {
steps {
timeout(time: 5, unit: 'MINUTES') {
sh '''
eval $(opam env) && \
cd build && \
dune exec -- tools/generate_attrs/generate_attrs.exe \
--llvm-config /media/llvms/17.0.0/bin/llvm-config \
"../src/bootstrap/" && \
cp ../src/bootstrap/attributes.ml clangml && \
cp ../src/bootstrap/libclang_extensions_attrs.inc \
clangml && \
cp ../src/bootstrap/libclang_extensions_attrs_headers.inc \
clangml
'''
}
}
}
stage('Generate stubs') {
steps {
script {
def pwd = sh (
script: 'echo $PWD',
returnStdout: true
).trim()
def llvm_versions = sh (
script: 'ls -1 /media/llvms',
returnStdout: true
).split('\n').toList()
llvm_versions.retainAll { it =~ /^[0-9]+[.][0-9][.][0-9]/ }
def branches = [:]
for (i in llvm_versions) {
def llvm_version = i
def llvm_dir = "/media/llvms/$llvm_version"
def llvm_config = "$llvm_dir/bin/llvm-config"
def equivalent_llvm_version;
if (llvm_version =~ /^14[.]0[.][0-9]/) {
equivalent_llvm_version = "14.0.0"
}
else if (llvm_version =~ /^15[.]0[.][0-9]/) {
equivalent_llvm_version = "15.0.0"
}
else {
equivalent_llvm_version = llvm_version
}
def bootstrap_dir = "src/bootstrap/$equivalent_llvm_version"
def include_dir =
"$llvm_dir/lib/clang/$llvm_version/include"
def cc
def cxx
branches[llvm_version] = {
node {
sh """
eval \$(opam env) && \
cd $pwd && \
mkdir -p $bootstrap_dir && \
build/_build/default/tools/stubgen/stubgen.exe \
--cc=-I,build,-I,$include_dir \
--llvm-config=$llvm_config \
$bootstrap_dir/
"""
sh """
eval \$(opam env) && \
cd $pwd && \
mkdir $llvm_version/ && \
cd $llvm_version/ && \
../src/configure \
--with-llvm-config=$llvm_config && \
make clangml
"""
sh """
eval \$(opam env) && \
cd $pwd/$llvm_version/ && make test
"""
sh """
eval \$(opam env) && \
cd $pwd/$llvm_version/ && \
make tools/stubgen && \
mkdir current && \
_build/default/tools/stubgen/stubgen.exe \
--cc=-I,build,-I,$include_dir \
--llvm-config=$llvm_config \
current/ && \
diff clangml/clang__bindings.ml \
current/clang__bindings.ml && \
diff clangml/clang__bindings.mli \
current/clang__bindings.mli && \
diff clangml/clang_stubs.c \
current/clang_stubs.c
"""
}
}
}
parallel branches
}
sh 'cd src && tar -cf bootstrap.tar.xz bootstrap/'
archiveArtifacts artifacts: 'src/bootstrap.tar.xz',
fingerprint: true
}
}
stage('Commit to bootstrap branch') {
when { branch 'main' }
steps {
script {
def commit = sh (
script: 'git rev-parse HEAD',
returnStdout: true
).trim()
sh 'git fetch origin'
sh 'git checkout origin/bootstrap'
sh 'tar -xf src/bootstrap.tar.xz'
sh 'git add bootstrap'
sh """
git commit -m 'generated files for commit $commit' || \
true
"""
sh 'git push origin HEAD:bootstrap'
}
}
}
stage('opam installation') {
when { branch 'main' }
steps {
script {
opam_installations(
["4.08", "4.09", "4.10", "4.11", "4.12", "4.13", "4.14", "5.0"],
"file:///clangml/")
}
}
}
stage('Commit to snapshot branch') {
when { branch 'main' }
steps {
sh 'src/ci-scripts/commit-snapshot-branch.sh'
}
}
stage('opam installation from snapshot') {
steps {
script {
def repo = env.JOB_NAME == "perso/main" ? "tmartine" : "memcad"
opam_installations(
["4.13"],
"https://gitlab.inria.fr/$repo/clangml/-/archive/snapshot/clangml-snapshot.tar.gz")
}
}
}
stage('Extract norms') {
parallel {
stage('c++14') {
steps {
sh '''
path=$PWD &&
cd $HOME/cplusplus/c++14 &&
build_dir=$path/build target_dir=$path std=c++14 \
$path/src/ci-scripts/extract_norm.sh
'''
}
}
stage('c++17') {
steps {
sh '''
path=$PWD &&
cd $HOME/cplusplus/c++17 &&
build_dir=$path/build target_dir=$path std=c++17 \
$path/src/ci-scripts/extract_norm.sh
'''
}
}
stage('c++20') {
steps {
sh '''
path=$PWD &&
cd $HOME/cplusplus/c++20 &&
build_dir=$path/build target_dir=$path std=c++20 \
$path/src/ci-scripts/extract_norm.sh
'''
}
}
}
}
stage('Commit to norms branch') {
when { branch 'main' }
steps {
sh 'git fetch origin'
sh 'git checkout origin/norms'
sh 'cp build/norm_c++14.ml norms/'
sh 'cp build/norm_c++17.ml norms/'
sh 'cp build/norm_c++20.ml norms/'
sh 'git add norms/*'
sh '''
git commit -m \
"generated files for commit `git rev-parse main`" || \
true
'''
sh 'git push origin HEAD:norms'
}
}
}
post {
failure {
mail to: 'Thierry.Martinez@inria.fr',
subject: "ClangML CI failure: ${currentBuild.fullDisplayName}",
body: "Something is wrong with ${env.BUILD_URL}"
}
changed {
mail to: 'Thierry.Martinez@inria.fr',
subject:
"ClangML CI status changed: ${currentBuild.fullDisplayName}",
body: "Something changed with ${env.BUILD_URL}"
}
}
}