#!/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}"