-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsetup_amici_model.sh
executable file
·52 lines (41 loc) · 1.5 KB
/
setup_amici_model.sh
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
#!/usr/bin/env bash
# For an AMICI-imported model, set up parPE build
set -euo pipefail
# invalid options:
if [[ $# -lt 2 ]] || [[ $# -gt 2 ]]; then
echo "For an AMICI-imported model, set up parPE build"
echo "USAGE: $(basename "$0") model_dir output_dir"
exit 1;
fi
script_path=$(realpath $(dirname "$BASH_SOURCE"))
model_dir="$1"
output_dir="$2"
template_dir="${script_path}/../templates"
model_name=$(basename "${model_dir}")
make_opts="${MAKE_OPTS:-}"
if [[ ! -d "${model_dir}" ]]; then
echo "ERROR: Model directory ${model_dir} does not exist."
exit 1
fi
if [[ -e "${output_dir}" ]]; then
echo "ERROR: Output directory ${output_dir} exists. Change or delete."
exit 1
fi
echo "Copying model to output directory ${output_dir} ..."
mkdir -p "${output_dir}"
cp -R "${model_dir}" "${output_dir}/model"
echo "Adding CMake and source files ..."
cp "${template_dir}/CMakeLists.template.txt" "${output_dir}/CMakeLists.txt"
sed -ri "s/mymodel/${model_name}/" "${output_dir}/CMakeLists.txt"
# TODO change in AMICI to avoid naming conflicts
sed -ri "s/simulate_/amici_/" "${output_dir}/model/CMakeLists.txt"
cp "${template_dir}"/main*.cpp "${output_dir}"
echo "Setting up build ..."
amici_root=${AMICI_ROOT:-${script_path}/../deps/AMICI/}
cmake -S "${output_dir}" \
-B "${output_dir}/build" \
-DCMAKE_BUILD_TYPE="Release" \
-DAmici_DIR="${amici_root}/build" \
-DParPE_DIR="${script_path}/../build"
echo "Building ..."
cmake --build "${output_dir}/build" ${make_opts} -- VERBOSE=1