#!/bin/bash
set -e
CUR_DIR=$(dirname $(readlink -f $0))
TOP_DIR=${CUR_DIR}/..
BUILD_TYPE="Release"
VERSION=""
print_help() {
cat << EOF
Usage:
bash build.sh [options]
Description:
Used for building mindstudio-profiler-tools-interface_<version>_<arch>.run
Options:
--help | -h Show this help message
Debug Build with Debug mode, only the first (and only) parameter is valid
<version> Build with specified version, only the first (and only) parameter is valid
Examples:
bash build.sh
bash build.sh Debug
bash build.sh v1.2.3
EOF
}
if [[ "$1" == "-h" || "$1" == "--help" ]]; then
print_help
exit 0
elif [ $# -gt 1 ]; then
cat << EOF
[ERROR] Invalid parameters! (only one parameter allowed)
EOF
print_help
exit 1
fi
if [ $# -eq 1 ] && [ "$1" = "Debug" ]; then
BUILD_TYPE="Debug"
elif [ $# -eq 1 ] && [ "$1" != "Debug" ]; then
VERSION=$1
fi
bash ${CUR_DIR}/download_thirdparty.sh
rm -rf ${TOP_DIR}/build
cmake -S ${TOP_DIR} -B ${TOP_DIR}/build -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DCMAKE_INSTALL_PREFIX=${TOP_DIR}/prefix -DSECUREC_LIB_DIR=${TOP_DIR}/prefix/securec_shared
cd ${TOP_DIR}/build; make -j$(nproc); make install
bash ${TOP_DIR}/scripts/make_run.sh ${VERSION}