Build: docker for gcc-11.1.0
[marnav.git] / bin / docker-build.sh
bloba673abc18f92e28b4d92254446eee04dfecb54d4
1 #!/bin/bash -e
3 export SCRIPT_BASE=$(dirname `readlink -f $0`)
4 export BASE=${SCRIPT_BASE}/..
5 export BUILD=${BASE}/build
7 supported_compilers=(
8 "gcc-4.9.4"
9 "gcc-5.5.0"
10 "gcc-6.5.0"
11 "gcc-7.4.0"
12 "gcc-8.3.0"
13 "gcc-9.1.0"
14 "gcc-9.2.0"
15 "gcc-9.3.0"
16 "gcc-10.1.0"
17 "gcc-10.2.0"
18 "gcc-10.3.0"
19 "gcc-11.1.0"
20 "clang-5.0.2"
21 "clang-6.0.0"
22 "clang-7.1.0"
23 "clang-8.0.0"
24 "clang-9.0.0"
25 "clang-10.0.0"
26 "clang-10.0.0"
27 #"clang-11.0.0"
28 #"clang-12.0.0"
30 supported_build_types=("Debug" "Release")
31 name=marnav
32 account=mariokonrad/
34 export NUM_PROC=${NUM_PROC:-$(nproc --ignore=2)}
37 function docker_run()
39 dockerid=$1
40 cmd="$2"
42 docker run \
43 --rm \
44 --read-only \
45 --volume $(pwd):$(pwd) \
46 --workdir $(pwd) \
47 --env HOME=$(pwd) \
48 --user $(id -u):$(id -g) \
49 ${dockerid} \
50 bash -c "${cmd}"
53 function build()
55 compiler=$1
56 build_type=$2
57 dockerid=${account}${name}:${compiler}
58 builddir=${BUILD_DIR:-${BUILD}/$(echo "${dockerid}_${build_type}" | tr '/:' '__')}
60 if [ ! -d ${builddir} ] ; then
61 mkdir -p ${builddir}
64 docker_run ${dockerid} "cmake -B ${builddir} -DCMAKE_BUILD_TYPE=${build_type} ${BASE}"
65 docker_run ${dockerid} "cmake --build ${builddir} -j ${NUM_PROC}"
66 docker_run ${dockerid} "cmake --build ${builddir} --target unittest"
67 docker_run ${dockerid} "cmake --build ${builddir} --target test"
70 function usage()
72 echo "usage: $(basename $0) compiler build-type"
73 echo ""
74 echo " supported compilers:"
75 for v in ${supported_compilers[@]} ; do
76 echo " - $v"
77 done
78 echo ""
79 echo " supported build types:"
80 for v in ${supported_build_types[@]} ; do
81 echo " - $v"
82 done
83 echo ""
86 function check_supported_compilers()
88 compiler=$1
89 for v in ${supported_compilers[@]} ; do
90 if [ "${v}" == "${compiler}" ] ; then
91 return
93 done
94 echo "error: specified compiler not supported: ${compiler}"
95 exit -1
98 function check_supported_build_types()
100 build_type=$1
101 for v in ${supported_build_types[@]} ; do
102 if [ "${v}" == "${build_type}" ] ; then
103 return
105 done
106 echo "error: specified build type not supported: ${build_type}"
107 exit -1
110 if [ $# -ne 2 ] ; then
111 usage
112 exit 1
115 check_supported_compilers $1
116 check_supported_build_types $2
117 build $1 $2