#!/bin/bash
#------------------------------------------------------------------------------
#
#
#
#------------------------------------------------------------------------------

set -e
set -u


PRJ=$(basename $PWD)
O="${HOME}/obj/${PRJ}-arm-Debug"
opwd="$PWD"

rm -rf $O
mkdir -p $O
cd $O


G="CodeBlocks - Unix Makefiles"
M=make

# G="Ninja"
# M=ninja

# Release
# =MinSizeRel

if [ 1 == 1 ]; then
    cmake $opwd "-G$G" \
    	-DCMAKE_BUILD_TYPE=Debug \
    	-DCMAKE_CXX_COMPILER=/opt/tcb-stm32/usr/bin/arm-none-eabi/arm-none-eabi-g++ \
    	-DCMAKE_C_COMPILER=/opt/tcb-stm32/usr/bin/arm-none-eabi/arm-none-eabi-gcc \
	-DENABLE_PRECOMPILED_HEADERS=OFF

    $M -j16
    $M candis_eval.binfiles
fi

fileSize=$(stat -c "%s" candis_eval/candis_eval.bin)
echo "Filesize: $fileSize / 69868"

$M candis_eval.flash


echo
echo "[$0] fin."

#---fin------------------------------------------------------------------------
