脚本功能:自动编译服务;
使用方法:复制内容保存到服务根目录并命名,chmod 777 赋权, ./文件名 编译版本 运行;
已知缺陷:无法捕获编译过程中的错误中断运行;
#! /bin/bash
FILE=./build
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
project_name="$(basename "${
SCRIPT_DIR}")"
program_path="$PWD/build/install/$project_name"
if [ -d "$FILE" ];then
echo "The build folder already exists. Next, it will be deleted..."
rm -rf build
echo "Delete it successfully!"
else
echo "Next, your program will be automatically compiled..."
fi
if [[ "$1" == "EC24" ]] || [[ "$1" == "Ec24" ]] || [[ "$1" == "eC24" ]] || [[ "$1" == "ec24" ]] || [[ "$1" == "EC" ]] || [[ "$1" == "Ec" ]] || [[ "$1" == "eC" ]] || [[ "$1" == "ec" ]];then
echo "Next, the EC24 version will be compiled..."
. /opt/poky/3.3.4/environment-setup-cortexa57-poky-linux
elif [[ "$1" == "ES24" ]] || [[ "$1" == "Es24" ]] || [[ "$1" == "eS24" ]] || [[ "$1" == "es24" ]] || [[ "$1" == "ES" ]] || [[ "$1" == "Es" ]] || [[ "$1" == "eS" ]] || [[ "$1" == "es" ]];then
echo "Next, the ES24 version will be compiled..."
. /opt/poky/3.2.4/environment-setup-cortexa57-poky-linux
else
echo "Error, Please enter the compiled version: EC24 or ES24 !"
exit
fi
mkdir build && cd build
cmake -DGWM_OPENAPI_PREFIX="${program_path}" -DGWM_OPENAPI_LIB_PREFIX="${program_path}" -DCMAKE_BUILD_WITH_INSTALL_RPATH=TRUE -DCMAKE_INSTALL_RPATH="./lib" ..
make && make install
echo "Success, your program has been successfully compiled,and the compiled program is saved in: ${program_path}"