diff --git a/CMakeLists.txt b/CMakeLists.txt index dcce0ab..a629cbf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,11 +42,19 @@ else() message(SEND_ERROR "CAN_PROTOCOL is unknown.") endif() -# Set build dir based on hardware version and protocol -set(BUILD_ROOT_DIR ${ROOT_DIR}/build) -set(BUILD_TARGET_DIR ${BUILD_ROOT_DIR}/${CAN_PROTOCOL}_${PLATFORM_NAME}) -set(BUILD_SRC_DIR ${BUILD_TARGET_DIR}/src) -set(BUILD_OBJ_DIR ${BUILD_TARGET_DIR}/obj) +# Set build dir based on the hardware version and protocol +if(DEFINED BUILD_OBJ_DIR) + cmake_path(GET BUILD_OBJ_DIR PARENT_PATH BUILD_TARGET_DIR) + set(BUILD_SRC_DIR ${BUILD_TARGET_DIR}/src) +else() + set(BUILD_TARGET_DIR ${ROOT_DIR}/build/${CAN_PROTOCOL}_${PLATFORM_NAME}) + set(BUILD_SRC_DIR ${BUILD_TARGET_DIR}/src) + set(BUILD_OBJ_DIR ${BUILD_TARGET_DIR}/obj) +endif() + +message(STATUS "BUILD_TARGET_DIR is set to ${BUILD_TARGET_DIR}") +message(STATUS "BUILD_OBJ_DIR is set to ${BUILD_OBJ_DIR}") +message(STATUS "BUILD_SRC_DIR is set to ${BUILD_SRC_DIR}") if(USE_PLATFORM_UBUNTU) add_definitions(-DLIBPARAMS_PARAMS_DIR="${BUILD_SRC_DIR}") diff --git a/Makefile b/Makefile index b44e9ad..1d598a3 100644 --- a/Makefile +++ b/Makefile @@ -48,6 +48,30 @@ v3: checks generate_dsdl clean mkdir -p ${BUILD_DIR}/both_v3/obj cd ${BUILD_DIR}/both_v3/obj && cmake -DCAN_PROTOCOL=both -DUSE_PLATFORM_NODE_V3=ON -G "Unix Makefiles" ../../.. && make +# Bootloader +bootloader: bootloader_v3 +bootloader_v3: generate_dsdl + mkdir -p ${BUILD_DIR}/bootloader_v3/libs/kocherga && \ + cd ${BUILD_DIR}/bootloader_v3/libs/kocherga && \ + if [ ! -d .git ]; then \ + git clone https://github.com/Zubax/kocherga.git . && \ + git checkout d806ba1; \ + else \ + echo "Repository already exists, skipping clone."; \ + fi + + mkdir -p ${BUILD_DIR}/bootloader_v3/libs/bootloader-ioc && \ + cd ${BUILD_DIR}/bootloader_v3/libs/bootloader-ioc && \ + if [ ! -d .git ]; then \ + git clone https://github.com/RaccoonLabHardware/v3-software-template.git . && \ + git checkout dc90159; \ + else \ + echo "Repository already exists, skipping clone."; \ + fi + + mkdir -p ${BUILD_DIR}/bootloader_v3/obj + cd ${BUILD_DIR}/bootloader_v3/obj && cmake -DCAN_PROTOCOL=both -DUSE_PLATFORM_NODE_V3=ON -DBUILD_OBJ_DIR=`pwd` -G "Unix Makefiles" ../../.. && make + # Common: checks: @python scripts/prebuild_check.py || (echo "Requirements verification failed. Stopping build." && exit 1) diff --git a/cmake/create_binary_with_meaningful_name.cmake b/cmake/create_binary_with_meaningful_name.cmake index 460a2f2..ddd8d6d 100644 --- a/cmake/create_binary_with_meaningful_name.cmake +++ b/cmake/create_binary_with_meaningful_name.cmake @@ -12,7 +12,7 @@ set(SOURCE_BIN "${BUILD_OBJ_DIR}/example.bin") # message(FATAL_ERROR "${SOURCE_BIN}") # Define the source and destination paths -set(DESTINATION_DIR "${BUILD_ROOT_DIR}/release") +set(DESTINATION_DIR "${BUILD_RELEASE_DIR}") set(DESTINATION_BIN "${DESTINATION_DIR}/node_${PLATFORM_NAME}_${CAN_PROTOCOL}_${LATEST_COMMIT_DATE}_v${APP_VERSION_MAJOR}.${APP_VERSION_MINOR}.${APP_VERSION_PATCH}_${GIT_HASH_SHORT_8_DIGITS}.bin") # Create the release directory if it doesn't exist