File: build.sh

package info (click to toggle)
ecbuild 3.13.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,068 kB
  • sloc: sh: 1,404; perl: 732; f90: 472; cpp: 466; python: 383; ansic: 304; fortran: 43; makefile: 15
file content (37 lines) | stat: -rwxr-xr-x 655 bytes parent folder | download | duplicates (4)
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
#!/bin/bash
set -e -o pipefail

{ set +x; } 2>/dev/null
HERE="$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )"

function cleanup {
  EXIT_CODE=$?
  { set +ex; } 2>/dev/null
  if [[ -n $BUILD_DIR ]]; then
    set -x
    rm -Rf $BUILD_DIR
  fi
  exit $EXIT_CODE
}

trap cleanup EXIT

function build() {
    echo "build"
  export ecbuild_DIR=${HERE}/../..

  _NAME="$1"
  _SRC="$2"
  _CMAKE_FLAGS="$3"

  echo Building project ${_NAME}

  TMPDIR="${TMPDIR:-$(pwd)}"
  BUILD_DIR="${TMPDIR}/build_${_NAME}_$(date +%Y-%m-%d_%H-%M-%S)"

  set -x
  mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR}
  cmake ${_CMAKE_FLAGS} ${HERE}/${_SRC}
  make ${MAKE_ARGS}
  ctest
}