#!/bin/bash
SCRIPT_DIR=$(cd "$(dirname "$0")"; pwd)
SAMPLE_NAME="tc_ge_irrun_open_api_0014"
ASCEND_INSTALL_PATH="${ASCEND_HOME_PATH:-/usr/local/Ascend/cann}"
if [ ! -f "${ASCEND_INSTALL_PATH}/set_env.sh" ]; then
echo "Error: '${ASCEND_INSTALL_PATH}/set_env.sh' not found."
echo "Please install CANN Toolkit first, or set ASCEND_HOME_PATH to your Ascend install directory."
exit 1
fi
source "${ASCEND_INSTALL_PATH}/set_env.sh"
cd "${SCRIPT_DIR}/${SAMPLE_NAME}" || exit 1
make clean
if ! make; then
echo "Error: build sample '${SAMPLE_NAME}' failed, please check the compiler output above"
echo "and the CANN install path '${ASCEND_INSTALL_PATH}'."
exit 1
fi
cd "${SCRIPT_DIR}" || exit 1
if [ ! -f "./${SAMPLE_NAME}.bin" ]; then
echo "Error: './${SAMPLE_NAME}.bin' was not generated by the build."
exit 1
fi
./"${SAMPLE_NAME}.bin"
ret=$?
if [ ${ret} -ne 0 ]; then
echo "Error: run sample '${SAMPLE_NAME}' failed with exit code ${ret}."
echo "Please check the log above and the plog logs under ~/ascend/log/ for details."
fi
exit ${ret}