build.sh 829 Bytes
Newer Older
one's avatar
one committed
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
#!/usr/bin/env bash
set -euo pipefail

mode="${1:?usage: build.sh hip|fastpt-C}"
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
root="$(cd "${script_dir}/.." && pwd)"

source_dtk="${root}/../source_dtk_library_path.sh"
if [[ -f "${source_dtk}" ]]; then
    # shellcheck disable=SC1091
    source "${source_dtk}"
fi

if [[ "${mode}" == "fastpt-C" ]]; then
    set +u
    # shellcheck disable=SC1091
    source /usr/local/bin/fastpt -C >/dev/null
    set -u
    backend="cuda"
elif [[ "${mode}" == "hip" ]]; then
    backend="hip"
else
    echo "usage: build.sh hip|fastpt-C" >&2
    exit 2
fi

build_dir="${root}/build-${mode}"
cmake -S "${root}" -B "${build_dir}" \
    -DBACKEND="${backend}" \
    -DCMAKE_BUILD_TYPE=Release

cmake --build "${build_dir}" -j"${JOBS:-$(nproc)}"
echo "BUILD_DONE,${mode},${build_dir}"