#!/bin/bash set -x # ./build.sh -t DESKTOP -p "vins_estimator" -b RelWithDebInfo # ./build.sh -t RK3588 -p "depthai_examples" -b RelWithDebInfo # ./build.sh -t DESKTOP -p "device_manager" -b RelWithDebInfo # ./build.sh -t RK3588 -p "depthai_examples vins_estimator" -b Release # ./build.sh -t RK3588 -p "svo_ros" -b Release # ./build.sh -t DESKTOP -p "ov_core ov_init ov_msckf" -b RelWithDebInfo -l 1 # export WORKSPACE="$(dirname "$(realpath "$BASH_SOURCE")")" # export WORKSPACE="$(realpath "$BASH_SOURCE")" export WORKSPACE="$(dirname "$0")" TARGET_PLATFORM="" BUILD_TYPE=Release PACKAGE_UP_TO="" TOOLCHAIN_FILE="" INSTALL_METHOD="--merge-install" CMAKE_FORCE_CONFIG="" CMAKE_ARGS='-DBUILD_TESTING=OFF -DDEPTHAI_ENABLE_CURL=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON' # if number of arguments is less than 2, add -h to list of args if [ $# -lt 2 ]; then set -- "$@" -h fi usage() { echo "Usage: build.bash [-h] [-b ] -t -p [-c] " echo "Options:" echo " -h : show this help text" echo " -b : build type to use (default is RelWithDebInfo for platform=PC and Release for others)" echo " -t : platform to build for (DESKTOP/RK3588)" echo " -p : Build select package" echo " -c : Do a clean build" echo " -f : Force cmake configure" exit 0 } # Parse the build options. while getopts ":hb:t:p:m:f:d:l:c" opt; do case $opt in h) usage;; b) BUILD_TYPE="$OPTARG";; t) TARGET_PLATFORM="$OPTARG";; p) PACKAGE_UP_TO="--packages-up-to $OPTARG";; d) PRODUCT="$OPTARG";; c) CLEAN_BUILD="true";; f) CMAKE_FORCE_CONFIG="--cmake-force-configure";; l) INSTALL_METHOD='--symlink-install';; ?) usage;; esac done if [[ "${TARGET_PLATFORM}" = "" ]]; then echo "Please specify the platform to build for" exit 1 fi CMAKE_ARGS+=" -DCMAKE_EXPORT_COMPILE_COMMANDS=ON " if [[ "${BUILD_TYPE}" = "" ]];then if [[ "${TARGET_PLATFORM}" = "PC" ]]; then BUILD_TYPE=RelWithDebInfo else BUILD_TYPE=Release fi fi CMAKE_ARGS+=" -DCMAKE_BUILD_TYPE=${BUILD_TYPE}" if [[ ${CLEAN_BUILD} = "true" ]]; then rm -rf ${WORKSPACE}/output/${TARGET_PLATFORM} fi if [[ "${TARGET_PLATFORM}" = "RK3588" ]]; then # in rk3588_dev container TOOLCHAIN_FILE=/opt/cmake/rk3588.toolchain.cmake CMAKE_ARGS+=" -DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_FILE}" export ARM_ARCHITECTURE=arm64 fi export TARGET=${TARGET_PLATFORM} INSTALL_DIR=${WORKSPACE}/output/${TARGET_PLATFORM}/install BUILD_DIR=${WORKSPACE}/output/${TARGET_PLATFORM}/build LOG_DIR=${WORKSPACE}/output/${TARGET_PLATFORM}/log # CMAKE_ARGS+=" -DCMAKE_FIND_USE_CMAKE_SYSTEM_PATH=OFF" CMAKE_ARGS+=" -DCMAKE_EXE_LINKER_FLAGS="-Wl,-rpath-link,/workspace/output/RK3588/install/lib"" echo "TARGET: ${TARGET_PLATFORM}" echo "TOOLCHAIN_FILE: ${TOOLCHAIN_FILE}" echo "PACKAGE_UP_TO: ${PACKAGE_UP_TO}" MAKEFLAGS="-j8" colcon --log-base ${LOG_DIR} build \ --build-base ${BUILD_DIR} \ --install-base ${INSTALL_DIR} \ --parallel-workers 8 \ ${INSTALL_METHOD} \ ${PACKAGE_UP_TO} \ ${CMAKE_FORCE_CONFIG} \ --cmake-args \ --no-warn-unused-cli \ ${CMAKE_ARGS} if [ $? -eq 0 ]; then mkdir -p "${INSTALL_DIR}" echo "Build: $(date "+%Y-%m-%d %H:%M:%S")" > "${INSTALL_DIR}/version" fi