Lately I noticed that some examples in my Arduino Audio Tools library are not compiling any more. This is not a surprise, since the library is still evolving.

So I was looking for a way how to identify the broken examples automatically.

Fortunately Arduino provides a Command Line Interface and I just needed to write a simple bash script to compile all relevant examples:

#!/bin/bash
##
# We compile all examples using arduino-cli in order to identify compile errors 
# The return code is made available in the build-examples-log.txt file.
##
arduino-cli lib upgrade
arduino-cli lib linstall 
git -C .. pu
git -C ../../ESP32-A2DP pull

function compile_example {
  ARCH=$1
  FILES=$2
  for f in $FILES
  do
    echo "Processing $f ..."
    # take action on each file. $f store current file name
    arduino-cli compile -b "$ARCH" "$f"
    EC=$?
    #if [ $EC -ne 0 ]; then
      #break
      echo -e "$f -> rc=$EC" >> "build-examples-log.txt"
    #fi
  done
}

compile_example "esp32:esp32:esp32" "../examples/examples-basic-api/base*"
compile_example "esp32:esp32:esp32" "../examples/examples-player/player*"
compile_example "esp32:esp32:esp32" "../examples/examples-webserver/str*"
compile_example "esp32:esp32:esp32" "../examples/tests/test*"
compile_example "esp32:esp32:esp32" "../examples/streams*"

Categories: Arduino

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *