Make linker errors fail the CI builds
[alexxy/gromacs.git] / admin / ci-scripts / gromacs-base-build.sh
1 #!/usr/bin/env bash
2 set -e
3 CMAKE=${CMAKE:-$(which cmake)}
4 cd $BUILD_DIR
5 $CMAKE --build . -- -j$KUBERNETES_CPU_LIMIT 2>&1 | tee buildLogFile.log
6 $CMAKE --build . --target tests -- -j$KUBERNETES_CPU_LIMIT 2>&1 | tee testBuildLogFile.log
7
8 # Find compiler warnings
9 awk '/warning/,/warning.*generated|^$/' buildLogFile.log testBuildLogFile.log \
10       | grep -v "CMake" | tee buildErrors.log || true
11 grep "cannot be built" buildLogFile.log testBuildLogFile.log | tee -a buildErrors.log || true
12
13 # Find linking errors:
14 grep "^/usr/bin/ld:" buildLogFile.log testBuildLogFile.log | tee -a buildErrors.log || true
15
16 # Install GROMACS
17 $CMAKE --build . --target install 2>&1 | tee installBuildLogFile.log
18
19 # Fail if there were warnings or errors reported
20 if [ -s buildErrors.log ] ; then echo "Found compiler warning during build"; cat buildErrors.log; exit 1; fi
21 # Remove object files to minimize artifact size
22 find . -mindepth 1 -name '*.o' ! -type l -printf '%p\n' -delete 2>&1 > remove-build-objects.log
23 cd ..