-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
make-wrapper-dlang
executable file
·55 lines (46 loc) · 1.63 KB
/
make-wrapper-dlang
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
#!/bin/sh
# Copyright dunnhumby Germany GmbH 2017.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
# This script can be used as a wrapper for make. It will check if beaver is
# present as a submodule and if it is it will call make insider docker using
# the dlang commands to build.
#
# Also the .travis.yml file is read to look for env variables, including
# matrixes. By default the last element of the matrix is built, but you can
# chose a different index by passing the environment variable MATRIX (negative
# indexes can be used to count backwards). If MATRIX has the special value `*`
# all matrix cells are built.
#
# This script requires Python3 and jq.
BEAVER_PATH=${BEAVER_PATH:-$(git config -f .gitmodules submodule.beaver.path)}
set -eu
beaver="${BEAVER_PATH}/bin/beaver"
# No beaver? Just regular make
if test ! -x "$beaver" || grep -q include: .travis.yml 2>/dev/null
then
exec /usr/bin/make "$@"
fi
alias yaml2json='python3 -c "import sys, yaml, json; print(json.dumps(yaml.load(sys.stdin)))"'
# Build one matrix cell
build()
{
eval export $(eval echo eval $(yaml2json < .travis.yml | jq ".env.global | .[]"))
eval export $(eval echo eval $matrix)
eval echo "+ MATRIX: "$matrix >&2
export DIST=${DIST:-$(lsb_release -cs)} DMD="${DMD:-dmd1}" TRAVIS=1
"$beaver" dlang install
"$beaver" dlang make "$@"
}
MATRIX=${MATRIX:-0}
if test "$MATRIX" = "*"
then
yaml2json < .travis.yml | jq ".env.matrix | .[]" | while read matrix
do
build "$@"
done
else
matrix="$(yaml2json < .travis.yml | jq ".env.matrix | .[$MATRIX]")"
build "$@"
fi