diff --git a/.github/workflows/arduino-release.yml b/.github/workflows/arduino-release.yml index 9041750b..f35cb254 100644 --- a/.github/workflows/arduino-release.yml +++ b/.github/workflows/arduino-release.yml @@ -4,7 +4,7 @@ name: Arduino CI Build (2 of 4) Release Arduino wolfSSL for Local Examples # # Known to fail on current 5.8.2 wolfSSL Arduino Release # -# See ardduino.yml - Arduino CI Build (3 of 4) Latest wolfSSL for Local Examples +# See arduino.yml - Arduino CI Build (3 of 4) Latest wolfSSL for Local Examples # # Test local Arduino examples with published Arduino wolfssl @@ -44,7 +44,7 @@ name: Arduino CI Build (2 of 4) Release Arduino wolfSSL for Local Examples # # To test locally: # cd [your WOLFSSL_ROOT], e.g. cd /mnt/c/workspace/wolfssl-$USER -# [optional checkout] e.g. git checkout tags/v5.8.2-stable +# [optional checkout] e.g. git checkout tags/v5.8.4-stable # pushd ./IDE/ARDUINO # export ARDUINO_ROOT="$HOME/Arduino/libraries" # ./wolfssl-arduino.sh INSTALL @@ -56,28 +56,73 @@ on: push: branches: [ '**', 'master', 'main', 'release/**' ] paths: + # Specific to this Arduino CI Build (2 of 4) - 'Arduino/**' - - '!Arduino/sketches/board_list.txt' # Not triggered on arduino.yml file. TODO remove this line after next Arduino wolfssl release - '.github/workflows/arduino-release.yml' pull_request: branches: [ '**' ] paths: + # Specific to this Arduino CI Build (2 of 4) - 'Arduino/**' - - '!Arduino/sketches/board_list.txt' # Not triggered on arduino.yml file. TODO remove this line after next Arduino wolfssl release - '.github/workflows/arduino-release.yml' workflow_dispatch: concurrency: - group: ${{ github.workflow }}-${{ github.ref }} + # Same branch push cancels other jobs. Other PR branches untouched + + group: ${{ github.workflow }}-${{ github.ref_name }} cancel-in-progress: true + # END OF COMMON SECTION jobs: build: - # if: github.repository_owner == 'wolfssl' + name: on FQBN (${{ matrix.fqbn }}) + if: github.repository_owner == 'wolfssl' runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + fqbn: + # When editing this list, be sure to also edit file: board_list.txt + # The compile-all-examples.sh optionally takes a FQBN parameter to + # optionally compile all examples ONLY for the respective fully qualified board name. + # See https://github.com/wolfSSL/wolfssl-examples/blob/master/Arduino/sketches/board_list.txt + + - arduino:avr:ethernet + - arduino:avr:leonardoeth + - arduino:avr:mega + - arduino:avr:nano + - arduino:avr:uno + - arduino:avr:yun + - arduino:samd:mkrwifi1010 + - arduino:samd:mkr1000 + - arduino:samd:mkrfox1200 + - arduino:mbed_edge:edge_control + - arduino:mbed_nano:nanorp2040connect + - arduino:mbed_portenta:envie_m7 + - arduino:mbed_portenta:portenta_x8 + - arduino:renesas_uno:unor4wifi + - arduino:sam:arduino_due_x + - arduino:samd:arduino_zero_native + - arduino:samd:tian + - esp32:esp32:esp32 + - esp32:esp32:esp32s2 + - esp32:esp32:esp32s3 + - esp32:esp32:esp32c3 + - esp32:esp32:esp32c6 + - esp32:esp32:esp32h2 + - esp8266:esp8266:generic + - teensy:avr:teensy40 + + # Not yet supported, not in standard library + # - esp32:esp32:nano_nora + + # End strategy matrix env: REPO_OWNER: ${{ github.repository_owner }} + steps: - name: Checkout Repository uses: actions/checkout@v4 @@ -86,7 +131,7 @@ jobs: run: | # Script to fetch and run install.sh from arduino/arduino-cli - # The install script will test to see if the recently installed apps in in the path + # The install script will test to see if the recently installed apps in the path # So set it up in advance: mkdir -p "${PWD}/bin" echo "${PWD}/bin" >> $GITHUB_PATH @@ -97,7 +142,7 @@ jobs: # Ensures that BINDIR exists before the installer runs mkdir -p "$ROOT_BIN" - # Save as a lobal environment variable + # Save as a global environment variable echo "$ROOT_BIN" >> "$GITHUB_PATH" # Download and run install script from Arduino: @@ -128,34 +173,53 @@ jobs: echo "Alternative install script not needed." fi - - name: Confirm Arduino CLI install + - name: Confirm Arduino CLI Install run: arduino-cli version + - name: Derive CORE_ID (vendor:arch from FQBN) + run: | + CORE_ID="$(echo '${{ matrix.fqbn }}' | cut -d: -f1-2)" + echo "CORE_ID=$CORE_ID" >> "$GITHUB_ENV" + - name: Setup Arduino CLI run: | arduino-cli config init - arduino-cli core update-index + + # wait 10 minutes for big downloads (or use 0 for no limit) + arduino-cli config set network.connection_timeout 600s + arduino-cli config add board_manager.additional_urls https://www.pjrc.com/teensy/package_teensy_index.json - arduino-cli core update-index arduino-cli config add board_manager.additional_urls https://arduino.esp8266.com/stable/package_esp8266com_index.json arduino-cli core update-index - arduino-cli core install esp32:esp32 # ESP32 - arduino-cli core install arduino:avr # Arduino Uno, Mega, Nano - arduino-cli core install arduino:sam # Arduino Due - arduino-cli core install arduino:samd # Arduino Zero - arduino-cli core install teensy:avr # PJRC Teensy - arduino-cli core install esp8266:esp8266 # ESP8266 - arduino-cli core install arduino:mbed_nano # nanorp2040connect - arduino-cli core install arduino:mbed_portenta # portenta_h7_m7 - arduino-cli core install arduino:mbed_edge + + echo "CORE_ID: $CORE_ID" + arduino-cli core install "$CORE_ID" + + # The above is instead of: + # arduino-cli core install esp32:esp32 # ESP32 + # arduino-cli core install arduino:avr # Arduino Uno, Mega, Nano + # arduino-cli core install arduino:sam # Arduino Due + # arduino-cli core install arduino:samd # Arduino Zero + # arduino-cli core install teensy:avr # PJRC Teensy + # arduino-cli core install esp8266:esp8266 # ESP8266 + # arduino-cli core install arduino:mbed_nano # nanorp2040connect + # arduino-cli core install arduino:mbed_portenta # portenta_h7_m7 + # arduino-cli core install arduino:mbed_edge + # arduino-cli core install arduino:renesas_uno + + # For reference: + + # mbed nano not yet tested # sudo "/home/$USER/.arduino15/packages/arduino/hardware/mbed_nano/4.2.4/post_install.sh" - arduino-cli core install arduino:renesas_uno + + # Always install networking (not part of FQBN matrix) + # The first one also creates directory: /home/runner/Arduino/libraries arduino-cli lib install "ArduinoJson" # Example dependency arduino-cli lib install "WiFiNINA" # ARDUINO_SAMD_NANO_33_IOT arduino-cli lib install "Ethernet" # Install Ethernet library arduino-cli lib install "Bridge" # Pseudo-network for things like arduino:samd:tian - - name: Set job environment variables + - name: Set Job Environment Variables run: | # Script to assign some common environment variables after everything is installed @@ -181,6 +245,26 @@ jobs: # WOLFSSL_EXAMPLES_ROOT is the report root, not example location echo "WOLFSSL_EXAMPLES_ROOT = $WOLFSSL_EXAMPLES_ROOT" + - name: Cache Arduino Packages + uses: actions/cache@v4 + with: + path: | + ~/.arduino15 + ~/.cache/arduino + ~/.arduino15/staging + + # Arduino libraries + # Specific to Arduino CI Build (2 of 4) Arduinbo Release wolfSSL for Local Examples + # Include all libraries, as the latest Arduino-wolfSSL will only change upon release. + ~/Arduino/libraries + # Ensure wolfssl is not cached, we're always using the latest. See separate cache. + !~/Arduino/libraries/wolfssl + key: arduino-${{ runner.os }}-${{ env.CORE_ID }}-${{ hashFiles('Arduino/sketches/board_list.txt') }} + + restore-keys: | + arduino-${{ runner.os }}-${{ env.CORE_ID }}- + arduino-${{ runner.os }}- + - name: Show wolfssl-examples run: | # The examples are local in this wolfssl-example repo, but should have been copied to library, above @@ -188,6 +272,7 @@ jobs: # end Show wolfssl-examples + # Specific to Arduino CI Build (3 of 4) Arduinbo Release wolfSSL for Local Examples # - name: Shallow clone wolfssl # # not used here, we'll install with arduino-cli in next step @@ -220,22 +305,25 @@ jobs: echo "Current directory = $PWD" echo "ARDUINO_ROOT = $ARDUINO_ROOT" echo "WOLFSSL_EXAMPLES_ROOT = $WOLFSSL_EXAMPLES_ROOT" + echo "FQBN = ${{ matrix.fqbn }}" + echo "Change directory to Arduino examples..." pushd ./Arduino/sketches chmod +x ./compile-all-examples.sh # The script expects all the examples to be in the current directory. - # So copy from local directory to newly instlled wolfssl arduino library to compile there. + # So copy from local directory to newly installed wolfssl arduino library to compile there. cp ./compile-all-examples.sh "$ARDUINO_ROOT/wolfssl/examples/compile-all-examples.sh" cp ./board_list.txt "$ARDUINO_ROOT/wolfssl/examples/board_list.txt" # TODO Use standard board_list.txt after next release of wolfSSL + # Remove this line and edit parameter to /compile-all-examples.sh board_list.txt cp ./board_list_v5.8.2.txt "$ARDUINO_ROOT/wolfssl/examples/board_list_v5.8.2.txt" # Compile the Arduino library examples in-place pushd "$ARDUINO_ROOT/wolfssl/examples/" echo "PWD=$PWD" - ./compile-all-examples.sh board_list_v5.8.2.txt + ./compile-all-examples.sh board_list_v5.8.2.txt "${{ matrix.fqbn }}" popd popd diff --git a/.github/workflows/arduino.yml b/.github/workflows/arduino.yml index ab714acd..d2df41ef 100644 --- a/.github/workflows/arduino.yml +++ b/.github/workflows/arduino.yml @@ -38,7 +38,7 @@ name: Arduino CI Build (3 of 4) Latest wolfSSL for Local Examples # # To test locally: # cd [your WOLFSSL_ROOT], e.g. cd /mnt/c/workspace/wolfssl-$USER -# [optional checkout] e.g. git checkout tags/v5.8.2-stable +# [optional checkout] e.g. git checkout tags/v5.8.4-stable # pushd ./IDE/ARDUINO # export ARDUINO_ROOT="$HOME/Arduino/libraries" # ./wolfssl-arduino.sh INSTALL @@ -50,28 +50,73 @@ on: push: branches: [ '**', 'master', 'main', 'release/**' ] paths: + # Specific to this Arduino CI Build (3 of 4) - 'Arduino/**' - - '!Arduino/sketches/board_list_v5.8.2.txt' # Not triggered on arduino-release.yml file. TODO remove this line after next Arduino wolfssl release - '.github/workflows/arduino.yml' pull_request: branches: [ '**' ] paths: + # Specific to this Arduino CI Build (3 of 4) - 'Arduino/**' - - '!Arduino/sketches/board_list_v5.8.2.txt' # Not triggered on arduino-release.yml file. TODO remove this line after next Arduino wolfssl release - '.github/workflows/arduino.yml' workflow_dispatch: concurrency: - group: ${{ github.workflow }}-${{ github.ref }} + # Same branch push cancels other jobs. Other PR branches untouched + + group: ${{ github.workflow }}-${{ github.ref_name }} cancel-in-progress: true + # END OF COMMON SECTION jobs: build: - # if: github.repository_owner == 'wolfssl' + name: on FQBN (${{ matrix.fqbn }}) + if: github.repository_owner == 'wolfssl' runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + fqbn: + # When editing this list, be sure to also edit file: board_list.txt + # The compile-all-examples.sh optionally takes a FQBN parameter to + # optionally compile all examples ONLY for the respective fully qualified board name. + # See https://github.com/wolfSSL/wolfssl-examples/blob/master/Arduino/sketches/board_list.txt + + - arduino:avr:ethernet + - arduino:avr:leonardoeth + - arduino:avr:mega + - arduino:avr:nano + - arduino:avr:uno + - arduino:avr:yun + - arduino:samd:mkrwifi1010 + - arduino:samd:mkr1000 + - arduino:samd:mkrfox1200 + - arduino:mbed_edge:edge_control + - arduino:mbed_nano:nanorp2040connect + - arduino:mbed_portenta:envie_m7 + - arduino:mbed_portenta:portenta_x8 + - arduino:renesas_uno:unor4wifi + - arduino:sam:arduino_due_x + - arduino:samd:arduino_zero_native + - arduino:samd:tian + - esp32:esp32:esp32 + - esp32:esp32:esp32s2 + - esp32:esp32:esp32s3 + - esp32:esp32:esp32c3 + - esp32:esp32:esp32c6 + - esp32:esp32:esp32h2 + - esp8266:esp8266:generic + - teensy:avr:teensy40 + + # Not yet supported, not in standard library + # - esp32:esp32:nano_nora + + # End strategy matrix env: REPO_OWNER: ${{ github.repository_owner }} + steps: - name: Checkout Repository uses: actions/checkout@v4 @@ -80,7 +125,7 @@ jobs: run: | # Script to fetch and run install.sh from arduino/arduino-cli - # The install script will test to see if the recently installed apps in in the path + # The install script will test to see if the recently installed apps in the path # So set it up in advance: mkdir -p "${PWD}/bin" echo "${PWD}/bin" >> $GITHUB_PATH @@ -91,7 +136,7 @@ jobs: # Ensures that BINDIR exists before the installer runs mkdir -p "$ROOT_BIN" - # Save as a lobal environment variable + # Save as a global environment variable echo "$ROOT_BIN" >> "$GITHUB_PATH" # Download and run install script from Arduino: @@ -122,34 +167,53 @@ jobs: echo "Alternative install script not needed." fi - - name: Confirm Arduino CLI install + - name: Confirm Arduino CLI Install run: arduino-cli version + - name: Derive CORE_ID (vendor:arch from FQBN) + run: | + CORE_ID="$(echo '${{ matrix.fqbn }}' | cut -d: -f1-2)" + echo "CORE_ID=$CORE_ID" >> "$GITHUB_ENV" + - name: Setup Arduino CLI run: | arduino-cli config init - arduino-cli core update-index + + # wait 10 minutes for big downloads (or use 0 for no limit) + arduino-cli config set network.connection_timeout 600s + arduino-cli config add board_manager.additional_urls https://www.pjrc.com/teensy/package_teensy_index.json - arduino-cli core update-index arduino-cli config add board_manager.additional_urls https://arduino.esp8266.com/stable/package_esp8266com_index.json arduino-cli core update-index - arduino-cli core install esp32:esp32 # ESP32 - arduino-cli core install arduino:avr # Arduino Uno, Mega, Nano - arduino-cli core install arduino:sam # Arduino Due - arduino-cli core install arduino:samd # Arduino Zero - arduino-cli core install teensy:avr # PJRC Teensy - arduino-cli core install esp8266:esp8266 # ESP8266 - arduino-cli core install arduino:mbed_nano # nanorp2040connect - arduino-cli core install arduino:mbed_portenta # portenta_h7_m7 - arduino-cli core install arduino:mbed_edge + + echo "CORE_ID: $CORE_ID" + arduino-cli core install "$CORE_ID" + + # The above is instead of: + # arduino-cli core install esp32:esp32 # ESP32 + # arduino-cli core install arduino:avr # Arduino Uno, Mega, Nano + # arduino-cli core install arduino:sam # Arduino Due + # arduino-cli core install arduino:samd # Arduino Zero + # arduino-cli core install teensy:avr # PJRC Teensy + # arduino-cli core install esp8266:esp8266 # ESP8266 + # arduino-cli core install arduino:mbed_nano # nanorp2040connect + # arduino-cli core install arduino:mbed_portenta # portenta_h7_m7 + # arduino-cli core install arduino:mbed_edge + # arduino-cli core install arduino:renesas_uno + + # For reference: + + # mbed nano not yet tested # sudo "/home/$USER/.arduino15/packages/arduino/hardware/mbed_nano/4.2.4/post_install.sh" - arduino-cli core install arduino:renesas_uno + + # Always install networking (not part of FQBN matrix) + # The first one also creates directory: /home/runner/Arduino/libraries arduino-cli lib install "ArduinoJson" # Example dependency arduino-cli lib install "WiFiNINA" # ARDUINO_SAMD_NANO_33_IOT arduino-cli lib install "Ethernet" # Install Ethernet library arduino-cli lib install "Bridge" # Pseudo-network for things like arduino:samd:tian - - name: Set job environment variables + - name: Set Job Environment Variables run: | # Script to assign some common environment variables after everything is installed @@ -175,6 +239,26 @@ jobs: # WOLFSSL_EXAMPLES_ROOT is the report root, not example location echo "WOLFSSL_EXAMPLES_ROOT = $WOLFSSL_EXAMPLES_ROOT" + - name: Cache Arduino Packages + uses: actions/cache@v4 + with: + path: | + ~/.arduino15 + ~/.cache/arduino + ~/.arduino15/staging + + # Arduino libraries + # Specific to Arduino CI Build (2 of 4) Arduinbo Release wolfSSL for Local Examples + # Include all libraries, as the latest Arduino-wolfSSL will only change upon release. + ~/Arduino/libraries + # Ensure wolfssl is not cached, we're always using the latest. See separate cache. + !~/Arduino/libraries/wolfssl + key: arduino-${{ runner.os }}-${{ env.CORE_ID }}-${{ hashFiles('Arduino/sketches/board_list.txt') }} + + restore-keys: | + arduino-${{ runner.os }}-${{ env.CORE_ID }}- + arduino-${{ runner.os }}- + - name: Show wolfssl-examples run: | # The examples are local in this wolfssl-example repo, but should have been copied to library, above @@ -182,9 +266,9 @@ jobs: # end Show wolfssl-examples - - name: Shallow clone wolfssl + - name: Shallow Clone wolfssl run: | - # Clone the wolfssl to use for example build + # Clone the latest wolfssl to use for building examples git clone --depth 1 https://github.com/$REPO_OWNER/wolfssl.git @@ -206,10 +290,25 @@ jobs: fi # end wolfssl source + - name: Get wolfSSL Commit + id: wolfsha + run: echo "sha=$(git -C wolfssl rev-parse --short HEAD)" >> "$GITHUB_OUTPUT" + + - name: Cache wolfSSL Arduino library + id: cache-wolfssl + uses: actions/cache@v4 + with: + path: ${{ env.ARDUINO_ROOT }}/wolfssl + key: wolfssl-lib-${{ runner.os }}-${{ steps.wolfsha.outputs.sha }}-${{ hashFiles('wolfssl/IDE/ARDUINO/wolfssl-arduino.sh') }}-${{ hashFiles('Arduino/sketches/**') }} + - name: Install wolfSSL Arduino library + if: steps.cache-wolfssl.outputs.cache-hit != 'true' run: | # Install wolfssl via wolfssl-arduino.sh install script + echo "Installing wolfSSL Arduino library (no cache hit)." + rm -rf "$ARDUINO_ROOT/wolfssl" + # Even though the examples are in this library, we'll test as installed for library publishing. # When WOLFSSL_EXAMPLES_ROOT is set, the examples will be copied from that path to the published library. # WOLFSSL_EXAMPLES_ROOT is the repo root, not example directory location (./Arduino/sketches) within. @@ -251,19 +350,22 @@ jobs: echo "Current directory = $PWD" echo "ARDUINO_ROOT = $ARDUINO_ROOT" echo "WOLFSSL_EXAMPLES_ROOT = $WOLFSSL_EXAMPLES_ROOT" + echo "FQBN = ${{ matrix.fqbn }}" + echo "Change directory to Arduino examples..." pushd ./Arduino/sketches chmod +x ./compile-all-examples.sh # The script expects all the examples to be in the current directory. - # So copy from local directory to newly instlled wolfssl arduino library to compile there. + # So copy from local directory to newly installed wolfssl arduino library to compile there. cp ./compile-all-examples.sh "$ARDUINO_ROOT/wolfssl/examples/compile-all-examples.sh" cp ./board_list.txt "$ARDUINO_ROOT/wolfssl/examples/board_list.txt" - # Compile the Arduino library examples in-place + # Compile the Arduino library examples in-place. All examples compiled for FQBN + # The respective FQBN board, examples, and optional exclusions must be in board_list.txt pushd "$ARDUINO_ROOT/wolfssl/examples/" echo "PWD=$PWD" - ./compile-all-examples.sh ./board_list.txt + ./compile-all-examples.sh ./board_list.txt "${{ matrix.fqbn }}" popd popd diff --git a/Arduino/sketches/board_list.txt b/Arduino/sketches/board_list.txt index 52c78b41..91b97abc 100644 --- a/Arduino/sketches/board_list.txt +++ b/Arduino/sketches/board_list.txt @@ -28,7 +28,11 @@ # To view available boards: # arduino-cli board listall | grep '^esp32:esp32:' # - +# When updating this list: +# +# >>>>> Update arduino-release.yml and arduino.yml <<<<< +# +# arduino:avr:leonardoeth # Ethernet Leonardo ETH (ATmega32u4 + W5500 Ethernet), only 2K RAM --no-wolfssl_AES_CTR # Global variables use 4973 bytes (194%) of dynamic memory, leaving -2413 bytes for local variables. Maximum is 2560 bytes. diff --git a/Arduino/sketches/compile-all-examples.sh b/Arduino/sketches/compile-all-examples.sh index 72536021..50bf78ab 100644 --- a/Arduino/sketches/compile-all-examples.sh +++ b/Arduino/sketches/compile-all-examples.sh @@ -4,6 +4,23 @@ # export ARDUINO_ROOT=/home/$USER/Arduino/libraries # # ./wolfssl-arduino.sh INSTALL /mnt/c/Users/gojimmypi/Documents/Arduino/libraries +# +# usage: +# +# ./compile_all_examples.sh board_list.txt [FQBN] +# +# example: compile all FQBN items in board_list.txt +# +# ./compile_all_examples.sh board_list.txt +# +# example: compile just the teensy:avr:teensy40 board in board_list.txt +# +# ./compile_all_examples.sh board_list.txt teensy:avr:teensy40 +# +# >>>>>>>>>>>>> EDIT WITH CAUTION <<<<<<<<<<<<< +# +# This script is pulled in by https://github.com/wolfSSL/wolfssl/blob/master/.github/workflows/arduino.yml +# # Run shell check to ensure this a good script. # Specify the executable shell checker you want to use: @@ -31,6 +48,7 @@ ARDUINO_ROOT="$HOME/Arduino/libraries" # Used for column alignment; e.g. len(wolfssl_client_dtls) + 2 MAX_FQBN_LEN=21 +unset TARGET_FQBN # default board list is board_list.txt, may be overridden BOARD_LIST="./board_list.txt" @@ -50,9 +68,17 @@ if [ $# -gt 0 ]; then echo "Error: Parameter specified for board list file does not exist: $1" exit 1 fi +else + echo "Usage:" + echo " $0 board_list.txt [FQBN]" fi -# Internal variabled +if [ $# -gt 1 ]; then + TARGET_FQBN="$2" + echo "Looking for $TARGET_FQBN" +fi + +# Internal variables BOARD_CT=0 BOARD_COMPILE_CT=0 BOARD_SKIP_CT=0 @@ -63,7 +89,7 @@ THIS_FOUND_FLAG=0 # Assume success unless proven otherwise SUCCESS="true" -# Same example names, initialized later +# Some example names, re-initialized later EXAMPLES=(wolfssl_client wolfssl_client_dtls server) # associative array, where the keys are arbitrary strings @@ -336,12 +362,14 @@ while :; do BOARD="${line//$'\r'/}" # Remove carriage returns from the line - echo "" - echo "*************************************************************************************" - echo "Testing board: $BOARD" - echo "*************************************************************************************" + if [[ -z ${TARGET_FQBN:-} || "$TARGET_FQBN" == "$BOARD" ]]; then + echo "" + echo "*************************************************************************************" + echo "Testing board: $BOARD" + echo "*************************************************************************************" + echo "Checking flags..." + fi - echo "Checking flags..." clear_flags # collect any --no- lines under this FQBN @@ -356,10 +384,13 @@ while :; do # echo " checking [$next] is like --no" if [[ $LINE_VALUE == --no-* ]]; then - if [[ -n "$LINE_COMMENT" ]]; then - echo "$LINE_VALUE: $LINE_COMMENT" - else - echo "$LINE_VALUE: (No comment provided; Consider adding reason in $BOARD_LIST)" + if [[ -z ${TARGET_FQBN:-} || "$TARGET_FQBN" == "$BOARD" ]]; then + # Only print if we are compiling this FQBN + if [[ -n "$LINE_COMMENT" ]]; then + echo "$LINE_VALUE: $LINE_COMMENT" + else + echo "$LINE_VALUE: (No comment provided; Consider adding reason in $BOARD_LIST)" + fi fi set_flag "$LINE_VALUE" "$LINE_COMMENT" THIS_FOUND_FLAG=1 @@ -371,9 +402,6 @@ while :; do peek=$next break done - if [[ $THIS_FOUND_FLAG -ne 0 ]]; then - echo "-------------------------------------------------------------------------------------" - fi # echo "Flags done..." @@ -382,53 +410,63 @@ while :; do # echo "Continue, skipping blank line..." # continue # fi - echo "Begin Board: $BOARD" - - echo "-------------------------------------------------------------------------------------" - ((BOARD_CT++)) - THIS_EXAMPLE_CT=0 - for EXAMPLE in "${EXAMPLES[@]}"; do - start_time=$(date +%s) # record start time (epoch seconds) - echo "Checking $EXAMPLE for $BOARD" - if is_disabled "$EXAMPLE"; then - echo "Skipped" - ((BOARD_SKIP_CT++)) - - if has_comment "$EXAMPLE"; then - this_comment=$(comment_for "$EXAMPLE") - echo "Comment: $this_comment" - else - echo "No comment in $BOARD_LIST for disable reason on $EXAMPLE example." - fi - else - # If otherwise not excluded, compile this $EXAMPLE for this $BOARD - ((BOARD_COMPILE_CT++)) - echo "arduino-cli compile --fqbn \"$BOARD\" \"$EXAMPLE\"" - arduino-cli compile --fqbn "$BOARD" "$EXAMPLE" - EXIT_CODE=$? - if [ $EXIT_CODE -ne 0 ]; then - echo "$ICON_FAIL Compilation failed for $EXAMPLE on $BOARD (Exit code: $EXIT_CODE)" - ((BOARD_FAIL_CT++)) - SUCCESS=false - SUMMARY_STATUS+=("$ICON_FAIL") - else - echo "$ICON_OK Compilation succeeded for $EXAMPLE on $BOARD" - SUMMARY_STATUS+=("$ICON_OK") - fi # exit code - - SUMMARY_BOARD+=("$BOARD") - SUMMARY_EXAMPLE+=("$EXAMPLE") - fi # is_disabled check - end_time=$(date +%s) # record end time - elapsed=$(( end_time - start_time )) - echo "Block took ${elapsed} seconds" - if [[ $THIS_EXAMPLE_CT -lt $EXAMPLE_CT ]]; then + # Only print divider if we are testing multiple FQBN, not just the specified parameter + if [[ -z ${TARGET_FQBN:-} || "$TARGET_FQBN" == "$BOARD" ]]; then + if [[ $THIS_FOUND_FLAG -ne 0 ]]; then echo "-------------------------------------------------------------------------------------" fi - ((THIS_EXAMPLE_CT++)) - done # for each example + echo "Begin Board: $BOARD" + + echo "-------------------------------------------------------------------------------------" + ((BOARD_CT++)) + THIS_EXAMPLE_CT=0 + for EXAMPLE in "${EXAMPLES[@]}"; do + start_time=$(date +%s) # record start time (epoch seconds) + echo "Checking $EXAMPLE for $BOARD" + if is_disabled "$EXAMPLE"; then + echo "Skipped" + ((BOARD_SKIP_CT++)) + + if has_comment "$EXAMPLE"; then + this_comment=$(comment_for "$EXAMPLE") + echo "Comment: $this_comment" + else + echo "No comment in $BOARD_LIST for disable reason on $EXAMPLE example." + fi + else + # If otherwise not excluded, compile this $EXAMPLE for this $BOARD + ((BOARD_COMPILE_CT++)) + echo "arduino-cli compile --fqbn \"$BOARD\" \"$EXAMPLE\"" + arduino-cli compile --fqbn "$BOARD" "$EXAMPLE" + EXIT_CODE=$? + if [ $EXIT_CODE -ne 0 ]; then + echo "$ICON_FAIL Compilation failed for $EXAMPLE on $BOARD (Exit code: $EXIT_CODE)" + ((BOARD_FAIL_CT++)) + SUCCESS=false + SUMMARY_STATUS+=("$ICON_FAIL") + else + echo "$ICON_OK Compilation succeeded for $EXAMPLE on $BOARD" + SUMMARY_STATUS+=("$ICON_OK") + fi # exit code + + SUMMARY_BOARD+=("$BOARD") + SUMMARY_EXAMPLE+=("$EXAMPLE") + fi # is_disabled check + + end_time=$(date +%s) # record end time + elapsed=$(( end_time - start_time )) + echo "Block took ${elapsed} seconds" + + if [[ $THIS_EXAMPLE_CT -lt $EXAMPLE_CT ]]; then + echo "-------------------------------------------------------------------------------------" + fi + ((THIS_EXAMPLE_CT++)) + done # for each example + else + echo "Skipped $BOARD, looking for only $TARGET_FQBN" + fi done < "$BOARD_LIST" # for each BOARD