@@ -66,19 +66,15 @@ clone() {
66
66
# build dmd (incl. building and running the unittests), druntime, phobos
67
67
build () {
68
68
local unittest=${1:- 1}
69
- if [ " $OS_NAME " != " windows" ]; then
70
- source ~ /dlang/* /activate # activate host compiler, incl. setting `DMD`
71
- fi
69
+ activate_host_compiler
72
70
$DMD compiler/src/build.d -ofgenerated/build
73
71
if [ $unittest -eq 1 ]; then
74
72
generated/build -j$N MODEL=$MODEL HOST_DMD=$DMD DFLAGS=" $CI_DFLAGS " BUILD=debug unittest
75
73
fi
76
74
generated/build -j$N MODEL=$MODEL HOST_DMD=$DMD DFLAGS=" $CI_DFLAGS " ENABLE_RELEASE=${ENABLE_RELEASE:- 1} dmd
77
75
make -j$N -C druntime MODEL=$MODEL
78
76
make -j$N -C ../phobos MODEL=$MODEL
79
- if [ " $OS_NAME " != " windows" ]; then
80
- deactivate # deactivate host compiler
81
- fi
77
+ deactivate_host_compiler
82
78
}
83
79
84
80
# self-compile dmd
@@ -176,7 +172,7 @@ test_phobos() {
176
172
elif [ " $HOST_DMD " == " dmd-2.079.0" ]; then
177
173
echo " Skipping publictests with DMD v2.079 host compiler (dub too old)"
178
174
else
179
- source ~ /dlang/ * /activate # activate host compiler - need dub
175
+ activate_host_compiler # need dub
180
176
181
177
make -j$N -C ../phobos MODEL=$MODEL publictests
182
178
make -j$N -C ../phobos MODEL=$MODEL publictests NO_BOUNDSCHECKS=1
@@ -187,15 +183,13 @@ test_phobos() {
187
183
make -j$N -C ../phobos MODEL=$MODEL betterc
188
184
fi
189
185
190
- deactivate # deactivate host compiler
186
+ deactivate_host_compiler
191
187
fi
192
188
}
193
189
194
190
# test dub package
195
191
test_dub_package () {
196
- if [ " $OS_NAME " != " windows" ]; then
197
- source ~ /dlang/* /activate # activate host compiler
198
- fi
192
+ activate_host_compiler
199
193
# GDC's standard library is too old for some example scripts
200
194
if [[ " ${DMD:- dmd} " =~ " gdmd" ]] ; then
201
195
echo " Skipping DUB examples on GDC."
@@ -217,9 +211,7 @@ test_dub_package() {
217
211
# Test rdmd build
218
212
" ${build_path} /dmd" -version=NoBackend -version=GC -version=NoMain -Jgenerated/dub -Jsrc/dmd/res -Isrc -i -run test/dub_package/frontend.d
219
213
fi
220
- if [ " $OS_NAME " != " windows" ]; then
221
- deactivate
222
- fi
214
+ deactivate_host_compiler
223
215
}
224
216
225
217
# clone phobos repos if not already available
@@ -303,6 +295,30 @@ install_host_compiler() {
303
295
fi
304
296
}
305
297
298
+ # activate D host compiler (set PATH and DMD environment variables)
299
+ activate_host_compiler ()
300
+ {
301
+ if [ " $OS_NAME " == " windows" ]; then
302
+ # PATH is already set
303
+ if [ " ${HOST_DMD: 0: 4} " == " ldc-" ]; then
304
+ export DMD=" ldmd2"
305
+ else
306
+ export DMD=" dmd"
307
+ fi
308
+ else
309
+ source ~ /dlang/* /activate
310
+ fi
311
+ }
312
+
313
+ deactivate_host_compiler ()
314
+ {
315
+ if [ " $OS_NAME " == " windows" ]; then
316
+ unset DMD
317
+ else
318
+ deactivate
319
+ fi
320
+ }
321
+
306
322
# Upload coverage reports
307
323
codecov ()
308
324
{
0 commit comments