#!/bin/bash
set -eu -o pipefail
# git submodule update --init lib/FreeRTOS-Kernel
# git submodule update --init lib/tinyusb
cd ./lib/tinyusb
# git submodule update --init hw/mcu/raspberry_pi/Pico-PIO-USB
# git submodule update --init lib/lwip
cd ../..
export PICO_SDK_PATH="../pico-sdk"
cp -f ./pico-sdk/tools/elf2uf2/CMakeLists.txt ${PICO_SDK_PATH}/tools/elf2uf2/CMakeLists.txt
cp -f ./pico-sdk/tools/pioasm/CMakeLists.txt ${PICO_SDK_PATH}/tools/pioasm/CMakeLists.txt
export BUILD="build"
export BOARD="PICO"
export LOG_PATH="./_log"
mkdir -p ${LOG_PATH}
DT=`date +%Y%m%d%H%M`
make V=1 DEBUG=1 BOARD=${BOARD} clean 2>&1 | tee ${LOG_PATH}/${BOARD}_build_${DT}.log
make V=1 DEBUG=1 BOARD=${BOARD}       2>&1 | tee -a ${LOG_PATH}/${BOARD}_build_${DT}.log