-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-all
executable file
·153 lines (123 loc) · 4.02 KB
/
build-all
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#!/bin/bash
set -eu
# Defaults
mode=dev
dryrun=0
allow_dirty_release=0
# In release mode, all destination directories have a version
# appended. This is not done in dev mode
args=()
# Parse arguments
while [ $# -gt 0 ]; do
if [[ $1 =~ --.* ]]; then
case "$1" in
--mode)
mode="$2"
if [[ "$mode" != "dev" && "$mode" != "release" ]]; then
echo "$0: --mode MODE; MODE should be either 'dev' or 'release'" >&2
exit 1
fi
shift 2
;;
--dry-run)
dryrun=1
shift 1
;;
--allow-dirty-release)
allow_dirty_release=1
shift 1
;;
--*)
echo "Unrecognized option $1" >&2
exit 1
;;
esac
else
args+=($1)
shift
fi
done
if [ -z "${args+1}" ]; then
nargs=0
else
nargs=${#args[@]}
fi
if [ $nargs = 0 ]; then
echo "$0: ERROR; please provide a destination directory argument" >&2
exit 1
elif [ $nargs -gt 1 ]; then
echo "$0: ERROR; too many arguments" >&2
exit 1
else
destdir=${args[0]}
fi
csluma_version=$(git describe --tags --dirty)
if [[ "$csluma_version" =~ dirty && $mode != dev && $allow_dirty_release = 0 ]]; then
echo "Cannot build a release version with a dirty cs-luma-archer repository" >&2
exit 1
fi
csluma_version=$(git describe --tags)
if [ csluma_version[0] = "v" ]; then
csluma_version=${csluma_version:1} # strip leading v
fi
if [ "$mode" = "release" ]; then
destdir="${destdir}-$csluma_version"
fi
builddir=$PWD/var/build
mkdir -p $destdir
if [ $dryrun = 1 ]; then
installer_prefix=echo
echo "Commands that would be run:"
else
installer_prefix=""
fi
# METIS
metis_version=5.1.0
export METIS_DIR=$destdir/metis-${metis_version}
$installer_prefix bin/build-metis "http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis/metis-${metis_version}.tar.gz" $builddir/metis $METIS_DIR
# VTK
vtk_version=9.2.2
export VTK_DIR=$destdir/vtk-${vtk_version}
$installer_prefix bin/build-vtk "https://www.vtk.org/files/release/${vtk_version%.*}/VTK-${vtk_version}.tar.gz" $builddir/vtk-${vtk_version} $VTK_DIR
# Code_Saturne
cs_version=$(git --git-dir components/code_saturne/.git --work-tree components/code_saturne describe --tags --dirty)
cs_version=$(git --git-dir components/code_saturne/.git --work-tree components/code_saturne describe --tags)
if [[ "$cs_version" =~ dirty && $mode != dev ]]; then
echo "Cannot build a release version with a dirty Code_Saturne repository" >&2
exit 1
fi
if [ cs_version[0] = "v" ]; then
cs_version=${cs_version:1} # strip leading v
fi
export CODE_SATURNE_DIR=$destdir/Code_Saturne
if [ "$mode" = "release" ]; then
CODE_SATURNE_DIR="${CODE_SATURNE_DIR}-$cs_version"
fi
$installer_prefix bin/build-cs $PWD/components/code_saturne $builddir/code_saturne $CODE_SATURNE_DIR
# LUMA
luma_version=$(git --git-dir components/LUMA/.git --work-tree components/LUMA describe --tags --dirty)
if [[ "$luma_version" =~ dirty && $mode != dev ]]; then
echo "Cannot build a release version with a dirty LUMA repository" >&2
exit 1
fi
luma_version=$(git --git-dir components/LUMA/.git --work-tree components/LUMA describe --tags)
luma_version=${luma_version/Release_v/}
LUMA_DIR=$destdir/LUMA
if [ "$mode" = "release" ]; then
LUMA_DIR="${LUMA_DIR}-$luma_version"
fi
$installer_prefix bin/install-luma $PWD/components/LUMA $builddir/luma $LUMA_DIR
# Case definitions
$installer_prefix rsync -a cases/ $destdir/cases/
# Setup script (TODO: maybe make into a module?)
$installer_prefix cat >$destdir/setup.sh <<EOF
module load PrgEnv-gnu
module load cray-python/3.8.5.0
export CS_LUMA_DIR=$destdir
export CODE_SATURNE_DIR=$CODE_SATURNE_DIR
export LUMA_DIR=$LUMA_DIR
export PATH=$destdir/bin:\$LUMA_DIR/bin:\$CODE_SATURNE_DIR/bin:\$PATH
EOF
# Scripts
$installer_prefix mkdir -p "$destdir/bin"
$installer_prefix cp -a bin/update-latest-symlinks "$destdir/bin"