Files
he/lib_src/so_src/upgrade_task/build.sh
T
2026-06-22 15:35:18 +08:00

70 lines
2.9 KiB
Bash

#!/bin/bash
cd "$(dirname "$(readlink -f "$0")")"
script_name=$(basename "$0")
#if [ "$0" = "$script_name" ]; then echo "脚本被自身调用,请检查无效路径"; exit 1 ;fi
# 显示脚本执行时间
start_time=$(date +%s); trap 'echo "$(print_execution_time $?)"' EXIT
# 计算并打印脚本执行时间函数
function print_execution_time {
end_time=$(date +%s); execution_time=$((end_time - start_time)); execution_time_formatted=$(date -u -d @$execution_time +"%T")
if [ $1 -eq 0 ];then SET_COLOR="\e[32m "; else SET_COLOR="\e[31m error at $(pwd) \n\e[1m"; fi
mydir_name="$(d=$(pwd); echo ${d##*/})"
echo -e "${SET_COLOR} [$1] 执行时间:$execution_time_formatted ( $mydir_name )\e[0m "
}
current_project_path=$(pwd)
export current_project_name=`echo ${current_project_path##*/}`
echo "current_project_path = ${current_project_path}"
echo "====================================================build shell start [ ${current_project_name} ]===================================================="
pd_complier_type=${TARGET_PRODUCT}
if [ -z ${TARGET_PRODUCT} ];then
PROJECT_ROOT=$(while [ ! -f "build/envsetup.sh" ]; do [ "$(pwd)" = "/" ] && exit 1; cd ..; done; pwd)
if [ ! -z ${PROJECT_ROOT} ];then
source ${PROJECT_ROOT}/build/envsetup.sh && lunch LAST
if [ $? -eq 255 ];then exit 0; fi
pd_complier_type=${TARGET_PRODUCT}
fi
fi
echo -e " ready to build\e[34;1m ${pd_complier_type} \e[0m target [\e[34;1m ${current_project_name}\e[0m ] ......"
unset LD_LIBRARY_PATH
export pd_complier_name="$(if [[ "${TARGET_PRODUCT}" =~ "imx"* ]]; then echo "complier_arm"; else echo "complier_x86"; fi)"
export arm_sysroot_path=${SYSROOT}
export arm_compile_flags=${CFLAGS}
echo "============================build shell start [lib${current_project_name}]===================================================="
# set obj at: platform/out/build/xxxx/build
check_dirs() { # check dir: process/ script/
local dir="$1"; if [[ -d "$dir/process" && -d "$dir/script" ]]; then echo "$dir"; exit 0;fi
local parent="${dir%/*}"; if [[ "$parent" != "$dir" ]]; then check_dirs "$parent"; else echo "$(pwd)"; fi
}
base_folder="$(echo ${PROJECT_ROOT}|tr -s '/')"
build_path=$(echo "$current_project_path" | sed "s|${base_folder}|${base_folder}/out/build/${pd_complier_type}/|g")
echo "build_path = ${build_path}"
if [[ $1 == "clean" ]] || [[ $1 == "-c" ]] || [[ $1 == "all" ]];then
rm -rvf ${build_path}
echo " clean done."
echo "====================================================build shell end [lib${current_project_name}]===================================================="
if [[ $1 != "all" ]];then exit 0; fi
fi
# build path
mkdir -p ${build_path}
cmake -B ${build_path}
echo "----------------make start----------------"
cmake --build "${build_path}" -j4 || exit $?
echo "===============================build shell end [lib${current_project_name}] [${pd_complier_type}]===================================================="