Skip to content

Commit 1c1c450

Browse files
committed
Added option extra-arduino-cli-args - closes #22
1 parent 4b57178 commit 1c1c450

File tree

3 files changed

+48
-12
lines changed

3 files changed

+48
-12
lines changed

README.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ Sketches to be **excluded from build**. Comma or space separated list of complet
109109
```
110110

111111
### `build-properties`
112-
Build parameter like `-DDEBUG` for each example specified or for all examples, if example name is `All`. If an example specific parameter is specified, the value for All is ignored for this example. <br/>
112+
Build parameter like `-DDEBUG` for each example specified or for all examples, if example name is `All`. If an example specific parameter is specified, the value for All is ignored for this example.<br/>
113+
The content is passed to the arduino-cli commandline in 3 parameters `--build-property compiler.[cpp,c,S].extra_flags="${GCC_EXTRA_FLAGS}"`
113114

114115
In the `include:` section you may specify:
115116

@@ -143,6 +144,31 @@ with:
143144
build-properties: '{ "WhistleSwitch": "-DDEBUG -DFREQUENCY_RANGE_LOW", "SimpleFrequencyDetector": "-DINFO", "All": "-DDEBUG" }'
144145
```
145146

147+
### `extra-arduino-cli-args`
148+
This string is passed verbatim without additional quoting to the arduino-cli compile commandline as last argument before the filename.
149+
See https://arduino.github.io/arduino-cli/commands/arduino-cli_compile/ for compile parameters.<br/>
150+
Be aware, that you cannot add to `--build-property compiler.[cpp,c,S].extra_flags`, if you already specified `build-properties`, they will be overwritten by your content. See https://github.com/arduino/arduino-cli/pull/1044.
151+
152+
This example tells arduino-cli to do the lolin32 build for what the Arduino IDE calls *Tools > Partition Scheme > No OTA (Large APP)*.
153+
154+
```yaml
155+
strategy:
156+
matrix:
157+
arduino-board-fqbn:
158+
- esp32:esp32:lolin32
159+
include:
160+
- arduino-boards-fqbn: esp32:esp32:lolin32
161+
extra-arduino-cli-args: "--build-property build.partitions=no_ota --build-property upload.maximum_size=2097152"
162+
...
163+
steps:
164+
- name: Arduino build
165+
uses: ArminJo/arduino-test-compile@2e04e8c
166+
with:
167+
...
168+
arduino-board-fqbn: ${{ matrix.arduino-board-fqbn }}
169+
extra-arduino-cli-args: ${{ matrix.extra-arduino-cli-args }}
170+
```
171+
146172
### `cli-version`
147173
The version of `arduino-cli` to use.<br/>
148174
Default is `latest`.<br/>

action.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ inputs:
5555
default: ''
5656
required: false
5757

58+
extra-arduino-cli-args:
59+
description: |
60+
This string is passed verbatim without double quotes to the arduino-cli compile commandline as last argument before the filename.
61+
See https://arduino.github.io/arduino-cli/commands/arduino-cli_compile/ for compile parameters.
62+
default: ''
63+
required: false
64+
5865
set-build-path:
5966
description: 'Flag to set the build directory (arduino-cli paramer --build-path) to /build subdirectory of compiled sketches.'
6067
default: 'false'
@@ -87,6 +94,7 @@ runs:
8794
ENV_REQUIRED_LIBRARIES: ${{ inputs.required-libraries }}
8895
ENV_SKETCHES_EXCLUDE: ${{ inputs.sketches-exclude }}
8996
ENV_BUILD_PROPERTIES: ${{ inputs.build-properties }}
97+
ENV_EXTRA_ARDUINO_CLI_ARGS: ${{ inputs.extra-arduino-cli-args }}
9098
ENV_SET_BUILD_PATH: ${{ inputs.set-build-path }}
9199
ENV_DEBUG_COMPILE: ${{ inputs.debug-compile }}
92100
ENV_DEBUG_INSTALL: ${{ inputs.debug-install }}

arduino-test-compile.sh

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ SKETCHES_EXCLUDE="$9"
2121
EXAMPLES_EXCLUDE="${10}"
2222
BUILD_PROPERTIES="${11}"
2323
EXAMPLES_BUILD_PROPERTIES="${12}"
24-
SET_BUILD_PATH="${13}"
25-
DEBUG_COMPILE="${14}"
26-
DEBUG_INSTALL="${15}" # not yet implemented for action
24+
EXTRA_ARDUINO_CLI_ARGS="${13}"
25+
SET_BUILD_PATH="${14}"
26+
DEBUG_COMPILE="${15}"
27+
DEBUG_INSTALL="${16}"
2728

2829
readonly RED='\033[0;31m'
2930
readonly GREEN='\033[0;32m'
@@ -45,6 +46,7 @@ if [[ -n $ENV_SKETCHES_EXCLUDE ]]; then SKETCHES_EXCLUDE=$ENV_SKETCHES_EXCLUDE;
4546
if [[ -n $ENV_EXAMPLES_EXCLUDE ]]; then EXAMPLES_EXCLUDE=$ENV_EXAMPLES_EXCLUDE; fi #deprecated
4647
if [[ -n $ENV_BUILD_PROPERTIES ]]; then BUILD_PROPERTIES=$ENV_BUILD_PROPERTIES; fi
4748
if [[ -n $ENV_EXAMPLES_BUILD_PROPERTIES ]]; then EXAMPLES_BUILD_PROPERTIES=$ENV_EXAMPLES_BUILD_PROPERTIES; fi #deprecated
49+
if [[ -n $ENV_EXTRA_ARDUINO_CLI_ARGS ]]; then EXTRA_ARDUINO_CLI_ARGS=$ENV_EXTRA_ARDUINO_CLI_ARGS; fi
4850
if [[ -n $ENV_SET_BUILD_PATH ]]; then SET_BUILD_PATH=$ENV_SET_BUILD_PATH; fi
4951

5052
if [[ -n $ENV_DEBUG_COMPILE ]]; then DEBUG_COMPILE=$ENV_DEBUG_COMPILE; fi
@@ -82,7 +84,8 @@ echo PLATFORM_URL=$PLATFORM_URL
8284
echo REQUIRED_LIBRARIES=$REQUIRED_LIBRARIES
8385
echo SKETCHES_EXCLUDE=$SKETCHES_EXCLUDE
8486
echo BUILD_PROPERTIES=$BUILD_PROPERTIES
85-
echo ENV_SET_BUILD_PATH=$SET_BUILD_PATH
87+
echo EXTRA_ARDUINO_CLI_ARGS=$EXTRA_ARDUINO_CLI_ARGS
88+
echo SET_BUILD_PATH=$SET_BUILD_PATH
8689

8790
echo DEBUG_COMPILE=$DEBUG_COMPILE
8891
echo DEBUG_INSTALL=$DEBUG_INSTALL
@@ -98,7 +101,6 @@ fi
98101
# Show calling parameters
99102
declare -p BASH_ARGV
100103

101-
102104
#
103105
# Download and install arduino IDE, if not already cached
104106
#
@@ -371,16 +373,16 @@ for sketch_name in "${SKETCH_NAMES_ARRAY[@]}"; do # Loop over all sketch names
371373
GCC_EXTRA_FLAGS=
372374
fi
373375
if [[ -z $GCC_EXTRA_FLAGS ]]; then
374-
build_stdout=$(arduino-cli compile --verbose --warnings all --fqbn ${ARDUINO_BOARD_FQBN%|*} $BUILD_PATH_PARAMETER $SKETCH_PATH 2>&1)
376+
build_stdout=$(arduino-cli compile --verbose --warnings all --fqbn ${ARDUINO_BOARD_FQBN%|*} $BUILD_PATH_PARAMETER $EXTRA_ARDUINO_CLI_ARGS $SKETCH_PATH 2>&1)
375377
else
376-
build_stdout=$(arduino-cli compile --verbose --warnings all --fqbn ${ARDUINO_BOARD_FQBN%|*} $BUILD_PATH_PARAMETER --build-property compiler.cpp.extra_flags="${GCC_EXTRA_FLAGS}" --build-property compiler.c.extra_flags="${GCC_EXTRA_FLAGS}" --build-property compiler.S.extra_flags="${GCC_EXTRA_FLAGS}" $SKETCH_PATH 2>&1)
378+
build_stdout=$(arduino-cli compile --verbose --warnings all --fqbn ${ARDUINO_BOARD_FQBN%|*} $BUILD_PATH_PARAMETER --build-property compiler.cpp.extra_flags="${GCC_EXTRA_FLAGS}" --build-property compiler.c.extra_flags="${GCC_EXTRA_FLAGS}" --build-property compiler.S.extra_flags="${GCC_EXTRA_FLAGS}" $EXTRA_ARDUINO_CLI_ARGS $SKETCH_PATH 2>&1)
377379
fi
378380
if [[ $? -ne 0 ]]; then
379381
echo -e ""${RED}"\xe2\x9c\x96" # If ok output a green checkmark else a red X and the command output.
380382
if [[ -z $GCC_EXTRA_FLAGS ]]; then
381-
echo "arduino-cli compile --verbose --warnings all --fqbn ${ARDUINO_BOARD_FQBN%|*} $BUILD_PATH_PARAMETER $SKETCH_PATH"
383+
echo "arduino-cli compile --verbose --warnings all --fqbn ${ARDUINO_BOARD_FQBN%|*} $BUILD_PATH_PARAMETER $EXTRA_ARDUINO_CLI_ARGS $SKETCH_PATH"
382384
else
383-
echo "arduino-cli compile --verbose --warnings all --fqbn ${ARDUINO_BOARD_FQBN%|*} $BUILD_PATH_PARAMETER --build-property compiler.cpp.extra_flags=\"${GCC_EXTRA_FLAGS}\" --build-property compiler.c.extra_flags=\"${GCC_EXTRA_FLAGS}\" --build-property compiler.S.extra_flags=\"${GCC_EXTRA_FLAGS}\" $SKETCH_PATH"
385+
echo "arduino-cli compile --verbose --warnings all --fqbn ${ARDUINO_BOARD_FQBN%|*} $BUILD_PATH_PARAMETER --build-property compiler.cpp.extra_flags=\"${GCC_EXTRA_FLAGS}\" --build-property compiler.c.extra_flags=\"${GCC_EXTRA_FLAGS}\" --build-property compiler.S.extra_flags=\"${GCC_EXTRA_FLAGS}\" $EXTRA_ARDUINO_CLI_ARGS $SKETCH_PATH"
384386
fi
385387
echo "::error::Compile of $SKETCH_BASENAME ${GCC_EXTRA_FLAGS} failed"
386388
echo -e "$build_stdout \n"
@@ -390,9 +392,9 @@ for sketch_name in "${SKETCH_NAMES_ARRAY[@]}"; do # Loop over all sketch names
390392
else
391393
echo -e "${GREEN}\xe2\x9c\x93"
392394
if [[ -z $GCC_EXTRA_FLAGS ]]; then
393-
echo "arduino-cli compile --verbose --warnings all --fqbn ${ARDUINO_BOARD_FQBN%|*} $BUILD_PATH_PARAMETER $SKETCH_PATH"
395+
echo "arduino-cli compile --verbose --warnings all --fqbn ${ARDUINO_BOARD_FQBN%|*} $BUILD_PATH_PARAMETER $EXTRA_ARDUINO_CLI_ARGS $SKETCH_PATH"
394396
else
395-
echo "arduino-cli compile --verbose --warnings all --fqbn ${ARDUINO_BOARD_FQBN%|*} $BUILD_PATH_PARAMETER --build-property compiler.cpp.extra_flags=\"${GCC_EXTRA_FLAGS}\" --build-property compiler.c.extra_flags=\"${GCC_EXTRA_FLAGS}\" --build-property compiler.S.extra_flags=\"${GCC_EXTRA_FLAGS}\" $SKETCH_PATH"
397+
echo "arduino-cli compile --verbose --warnings all --fqbn ${ARDUINO_BOARD_FQBN%|*} $BUILD_PATH_PARAMETER --build-property compiler.cpp.extra_flags=\"${GCC_EXTRA_FLAGS}\" --build-property compiler.c.extra_flags=\"${GCC_EXTRA_FLAGS}\" --build-property compiler.S.extra_flags=\"${GCC_EXTRA_FLAGS}\" $EXTRA_ARDUINO_CLI_ARGS $SKETCH_PATH"
396398
fi
397399
if [[ $DEBUG_COMPILE == true || $SET_BUILD_PATH == true ]]; then
398400
echo "Debug mode enabled => compile output will be printed also for successful compilation and sketch directory is listed after compilation"

0 commit comments

Comments
 (0)