3 SCRIPT_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5 if [[ -z "${NNAS_PROJECT_PATH}" ]]; then
6 echo "ERROR: NNAS_PROJECT_PATH is not specified"
13 # Test is enabled by default
17 while [ "$#" -ne 0 ]; do
22 NNAS_INSTALL_PREFIX="$2"
35 while [ "$#" -ne 0 ]; do
41 echo "ERROR: '${CUR}' is invalid"
47 # Q. Is it better to have the default value for NNAS_INSTALL_PREFIX?
49 if [[ -z "${NNAS_INSTALL_PREFIX}" ]]; then
50 echo "ERROR: --prefix is not specified"
54 if [[ "${DISABLE_TEST}" == "true" ]]; then
55 EXTRA_OPTIONS+=("-DENABLE_TEST=OFF")
58 PRESET_PATH="${SCRIPT_PATH}/preset/${PRESET}"
60 if [[ ! -f "${PRESET_PATH}" ]]; then
61 echo "ERROR: ${PRESET} is unavailable"
62 # TODO Show available presets
66 echo "-- Use '${PRESET}' SDK preset"
68 source "${PRESET_PATH}"
70 # Normalize to absolute path
71 if [[ "${NNAS_INSTALL_PREFIX}" != /* ]]; then
72 NNAS_INSTALL_PREFIX=${PWD}/${NNAS_INSTALL_PREFIX}
75 if [[ -z "${NNAS_BUILD_PREFIX}" ]]; then
76 # Create a temporary directory and use it!
77 NNAS_BUILD_PREFIX=$(mktemp -d)
78 trap "{ rm -rf $NNAS_BUILD_PREFIX; }" EXIT
81 # Create a release directory
82 mkdir -p "${NNAS_INSTALL_PREFIX}"
84 # Build and Install NNCC
85 NNCC_BUILD_PREFIX="${NNAS_BUILD_PREFIX}/nncc"
86 NNCC_INSTALL_PREFIX="${NNAS_INSTALL_PREFIX}"
88 mkdir -p "${NNCC_BUILD_PREFIX}"
89 cd "${NNCC_BUILD_PREFIX}"
93 local IFS="$1"; shift; echo "$*"
96 # Invoke "preset_configure" function that the preset provides
99 NPROC=${NPROC:-$(cat /proc/cpuinfo | grep -c processor)}
100 echo "[BUILD] \"make\" with -j${NPROC} option. You can specify the number of jobs by defining NPROC"
101 cmake --build . -- -j$((NPROC/2)) all
102 cmake --build . -- install
103 # Install NN Package tools
104 NNPKG_INSTALL_PREFIX="${NNAS_INSTALL_PREFIX}"
106 # Invoke "preset_install" function that the preset provides