Description
Describe the problem
From the Arduino Platform Specification:
https://arduino.github.io/arduino-cli/dev/platform-specification/#recipes-to-export-compiled-binary
The recipe.hooks.savehex.presavehex.NUMBER.pattern and recipe.hooks.savehex.postsavehex.NUMBER.pattern hooks
(but not recipe.output.tmp_file and recipe.output.save_file) can be built concatenating the following
automatically generated properties:
{sketch_path}
: the absolute path of the sketch folder
🐛 Arduino CLI does not generate the sketch_path
property as promised by the specification.
To reproduce
$ arduino-cli version
arduino-cli.exe Version: git-snapshot Commit: 422aa87f Date: 2023-09-26T05:56:57Z
$ export ARDUINO_DIRECTORIES_DATA="/tmp/sketch_path-property-demo" # Use a throwaway directories.data for the demo
$ arduino-cli core install arduino:[email protected] # Install an arbitrary platform to use for the demo
[...]
$ printf 'recipe.hooks.savehex.presavehex.1.pattern=echo "sketch_path in savehex.presavehex hook: {sketch_path}"\nrecipe.hooks.savehex.postsavehex.1.pattern=echo "sketch_path in savehex.postsavehex hook: {sketch_path}"' > "${ARDUINO_DIRECTORIES_DATA}/packages/arduino/hardware/avr/1.8.6/platform.local.txt" # Add the hooks to the platform
$ ./arduino-cli sketch new /tmp/FooSketch # Create an arbitrary sketch to compile
[...]
$ ./arduino-cli compile --export-binaries --fqbn arduino:avr:uno --verbose /tmp/FooSketch
[...]
sketch_path in savehex.presavehex hook: {sketch_path}
echo "sketch_path in savehex.presavehex hook: {sketch_path}"
sketch_path in savehex.postsavehex hook: {sketch_path}
echo "sketch_path in savehex.postsavehex hook: {sketch_path}"
🐛 The sketch_path
property references were not expanded because Arduino CLI never generated the property.
Expected behavior
Arduino CLI generates the sketch_path
property as promised by the specification.
Arduino CLI version
Operating system
Windows
Operating system version
11
Additional context
The bug was present from the introduction of support for the savehex
hooks in 5f73378 / #2091
Known affected platforms:
ATTinyCore:avr
DxCore:megaavr
MegaCore:avr
MegaCoreX:megaavr
megaTinyCore:megaavr
MajorCore:avr
MicroCore:avr
MightyCore:avr
MiniCore:avr
Originally reported by @Dancofra at MCUdude/MegaCore#206
Additional reports
- sketch_path used in platform.txt seems to be not longer defined in arduino-cli SpenceKonde/megaTinyCore#935
- {sketch_path} seems to be depreciated SpenceKonde/megaTinyCore#973
- arduino-cli compile with --output-dir flag set fails to build *.with_bootloader.hex file. MCUdude/MightyCore#276 (comment)
- can't export the bin file to project folder MCUdude/MiniCore#259
- Debug support MCUdude/MiniCore#266
Issue checklist
- I searched for previous reports in the issue tracker
- I verified the problem still occurs when using the nightly build
- My report contains all necessary details