This repository has been archived by the owner on Oct 12, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 420
/
Copy pathcircleci.sh
executable file
·74 lines (62 loc) · 1.9 KB
/
circleci.sh
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
#!/bin/bash
set -uexo pipefail
HOST_DMD_VER=2.068.2 # same as in dmd/src/posix.mak
CURL_USER_AGENT="CirleCI $(curl --version | head -n 1)"
N=2
case $CIRCLE_NODE_INDEX in
0) MODEL=64 ;;
1) MODEL=32 ;;
esac
install_deps() {
if [ $MODEL -eq 32 ]; then
sudo apt-get update
sudo apt-get install g++-multilib
fi
for i in {0..4}; do
if curl -fsS -A "$CURL_USER_AGENT" --max-time 5 https://dlang.org/install.sh -O; then
break
elif [ $i -ge 4 ]; then
sleep $((1 << $i))
else
echo 'Failed to download install script' 1>&2
exit 1
fi
done
source "$(CURL_USER_AGENT=\"$CURL_USER_AGENT\" bash install.sh dmd-$HOST_DMD_VER --activate)"
$DC --version
env
}
# clone dmd
clone() {
local url="$1"
local path="$2"
local branch="$3"
for i in {0..4}; do
if git clone --depth=1 --branch "$branch" "$url" "$path"; then
break
elif [ $i -lt 4 ]; then
sleep $((1 << $i))
else
echo "Failed to clone: ${url}"
exit 1
fi
done
}
coverage() {
if [ -n "${CIRCLE_PR_NUMBER:-}" ]; then
local base_branch=$(curl -fsSL https://api.github.com/repos/dlang/$CIRCLE_PROJECT_REPONAME/pulls/$CIRCLE_PR_NUMBER | jq -r '.base.ref')
else
local base_branch=$CIRCLE_BRANCH
fi
clone https://github.com/dlang/dmd.git ../dmd $base_branch
# load environment for bootstrap compiler
source "$(CURL_USER_AGENT=\"$CURL_USER_AGENT\" bash ~/dlang/install.sh dmd-$HOST_DMD_VER --activate)"
# build dmd and druntime
make -j$N -C ../dmd/src -f posix.mak MODEL=$MODEL HOST_DMD=$DMD all
make -j$N -C ../dmd/src -f posix.mak MODEL=$MODEL HOST_DMD=$DMD dmd.conf
TEST_COVERAGE="1" make -j$N -C . -f posix.mak MODEL=$MODEL unittest-debug
}
case $1 in
install-deps) install_deps ;;
coverage) coverage ;;
esac