|
| 1 | +#!/bin/sh -l |
| 2 | + |
| 3 | +echo "SU2 v7 Docker Compilation Container" |
| 4 | +usage="$(basename "$0") [-h] [-f build_flags] [-b branch_name] |
| 5 | +where: |
| 6 | + -h show this help text |
| 7 | + -f meson build flags (ignored if a directory \"docker_build\" is found at /src/SU2). |
| 8 | + -b branch name (if not given, existing SU2 directory must be mounted in /src/SU2). |
| 9 | +
|
| 10 | +Compiled binaries can be found at /install/. Mount that directory for access. |
| 11 | +Note: If you specify a working directory using the --workdir option for docker, |
| 12 | + append this directory to all paths above (e.g. use --workdir=/tmp if running in user mode)." |
| 13 | + |
| 14 | +flags="" |
| 15 | +branch="" |
| 16 | +workdir=$PWD |
| 17 | + |
| 18 | +export CCACHE_DIR=$workdir/ccache |
| 19 | + |
| 20 | +if [ "$#" -ne 0 ]; then |
| 21 | + while [ "$(echo $1 | cut -c1)" = "-" ] |
| 22 | + do |
| 23 | + case "$1" in |
| 24 | + -f) |
| 25 | + flags=$2 |
| 26 | + shift 2 |
| 27 | + ;; |
| 28 | + -b) |
| 29 | + branch=$2 |
| 30 | + shift 2 |
| 31 | + ;; |
| 32 | + *) |
| 33 | + echo "$usage" >&2 |
| 34 | + exit 1 |
| 35 | + ;; |
| 36 | + esac |
| 37 | + done |
| 38 | +fi |
| 39 | + |
| 40 | +if [ ! -z "$branch" ]; then |
| 41 | + name="SU2_$(echo $branch | sed 's/\//_/g')" |
| 42 | + echo "Branch provided. Cloning to $PWD/src/$name" |
| 43 | + if [ ! -d "src" ]; then |
| 44 | + mkdir "src" |
| 45 | + fi |
| 46 | + cd "src" |
| 47 | + git clone --recursive https://github.com/su2code/SU2 $name |
| 48 | + cd $name |
| 49 | + git config --add remote.origin.fetch '+refs/pull/*/merge:refs/remotes/origin/refs/pull/*/merge' |
| 50 | + git config --add remote.origin.fetch '+refs/heads/*:refs/remotes/origin/refs/heads/*' |
| 51 | + git fetch origin |
| 52 | + git checkout $branch |
| 53 | + git submodule update |
| 54 | +else |
| 55 | + if [ ! -d "src/SU2" ]; then |
| 56 | + echo "SU2 source directory not found. Make sure to mount existing SU2 at directory at /src/SU2. Otherwise use -b to provide a branch." |
| 57 | + exit 1 |
| 58 | + fi |
| 59 | + cd src/SU2 |
| 60 | +fi |
| 61 | + |
| 62 | +if [ ! -d "docker_build" ]; then |
| 63 | + ./meson.py docker_build --prefix=$workdir/install $flags |
| 64 | +else |
| 65 | + echo "Build Directory found. Ignoring build flags. To set new flags, remove docker_build directory." |
| 66 | + ./meson.py docker_build --reconfigure $flags |
| 67 | +fi |
| 68 | + |
| 69 | +./ninja -C docker_build install |
| 70 | + |
| 71 | + |
0 commit comments