1#!/bin/bash
2##############################################################################
3# Copyright (c) 2017-2021, Lawrence Livermore National Security, LLC and
4# other Axom Project Developers. See the top-level LICENSE file for details.
5#
6# SPDX-License-Identifier: (BSD-3-Clause)
7##############################################################################
8
9set -x
10
11function or_die () {
12    "$@"
13    local status=$?
14    if [[ $status != 0 ]] ; then
15        echo ERROR $status command: $@
16        exit $status
17    fi
18}
19
20or_die cd axom
21git submodule init
22git submodule update
23
24echo HOST_CONFIG
25echo $HOST_CONFIG
26
27export BUILD_TYPE=${BUILD_TYPE:-Debug}
28
29
30if [[ "$DO_BUILD" == "yes" ]] ; then
31    echo "~~~~~~ RUNNING CMAKE ~~~~~~~~"
32    or_die ./config-build.py -hc /home/axom/axom/host-configs/docker/${HOST_CONFIG}.cmake -bt ${BUILD_TYPE} -DENABLE_GTEST_DEATH_TESTS=ON ${CMAKE_EXTRA_FLAGS}
33    or_die cd build-$HOST_CONFIG-${BUILD_TYPE,,}
34    echo "~~~~~~ BUILDING ~~~~~~~~"
35    if [[ ${CMAKE_EXTRA_FLAGS} == *COVERAGE* ]] ; then
36        or_die make -j 10
37    else
38        or_die make -j 10 VERBOSE=1
39    fi
40    if [[ "${DO_TEST}" == "yes" ]] ; then
41        echo "~~~~~~ RUNNING TESTS ~~~~~~~~"
42        make CTEST_OUTPUT_ON_FAILURE=1 test ARGS='-T Test -VV -j8'
43    fi
44    if [[ "${DO_MEMCHECK}" == "yes" ]] ; then
45        echo "~~~~~~ RUNNING MEMCHECK ~~~~~~~~"
46        or_die ctest -T memcheck
47    fi
48fi
49
50find ./axom/sidre -type d -exec chmod 755 {} \;
51find ./axom/sidre -type f -exec chmod 644 {} \;
52
53if [[ "$DO_CLEAN" == "yes" ]] ; then
54    echo "~~~~~~ CLEANING BUILD DIRECTORY ~~~~~~~~"
55    make clean
56fi
57
58exit 0
59