#! /bin/bash

pip install -e /home/stm32_devcontainer/projects/vn200/Libs/cantools

COMPILER_SETTINGS_PATH=/home/stm32_devcontainer/projects/vn200/cmake/gcc-arm-none-eabi.cmake

# Build libraries
cmake \
    -DCMAKE_TOOLCHAIN_FILE=$COMPILER_SETTINGS_PATH \
    -B/home/stm32_devcontainer/projects/vn200/Libs/can-transceiver-lib/build \
    -S/home/stm32_devcontainer/projects/vn200/Libs/can-transceiver-lib \
    && make install -C /home/stm32_devcontainer/projects/vn200/Libs/can-transceiver-lib/build

cmake \
    -DCMAKE_TOOLCHAIN_FILE=$COMPILER_SETTINGS_PATH \
    -B/home/stm32_devcontainer/projects/vn200/Libs/vn-interface/build \
    -S/home/stm32_devcontainer/projects/vn200/Libs/vn-interface \
    && make install -C /home/stm32_devcontainer/projects/vn200/Libs/vn-interface/build

# Build the actual software. Does not need to be installed, since its the final product is getting flashed onto MCU
cmake \
    -DCMAKE_TOOLCHAIN_FILE=$COMPILER_SETTINGS_PATH \
    -B/home/stm32_devcontainer/projects/vn200/build \
    -S/home/stm32_devcontainer/projects/vn200 \
    && make -C /home/stm32_devcontainer/projects/vn200/build
