Skip to content

Commit

Permalink
Add build hook to copy .s files
Browse files Browse the repository at this point in the history
Previously, the project relied on undefined behavior of older versions of the Arduino build system, where correct file
extension case was not enforced when copying files from the sketch folder to the build folder, in order to .

This stopped working at Arduino IDE 1.8.14, meaning that users were forced to use a significantly outdated version of
the IDE; a requirement which was undocumented.

This is fixed by adding an additional build hook to platform.local.txt that copies the `.s` files from the sketch folder
to the build folder.

Due to limitations of the Arduino platform framework, it was necessary to jump through some hoops to get working
patterns for these commands:

- Windows command pattern must use `cmd /C` because `copy` is not directly usable via the os/exec Go package that
  executes the generated commands.
- Linux/macOS command patterns must use `cd` because otherwise the `*.s` glob was broken by being automatically quoted
  as part of the sketch path.
- Linux/macOS command patters must use `sh -c` because `cd` is not directly usable via the os/exec Go package that
  executes the generated commands.
  • Loading branch information
per1234 authored Nov 16, 2022
1 parent dd9def8 commit 190aa9f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions platform.local.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ compiler.c.elf.extra_flags="-L{build.path}/sketch/" -T ulp_main.ld "{build.path}
## add ulptool.h to g++
compiler.cpp.extra_flags="-I{tools.ulptool.path}/include/ulptool"

## copy '.s' (ulp) files from sketch to build folder
recipe.hooks.core.postbuild.00.pattern.windows=cmd /C copy {build.source.path}\*.s "{build.path}\sketch"
recipe.hooks.core.postbuild.00.pattern.linux=sh -c 'cd "{build.source.path}" && cp *.s "{build.path}/sketch"'
recipe.hooks.core.postbuild.00.pattern.macosx=sh -c 'cd "{build.source.path}" && cp *.s "{build.path}/sketch"'

## compile '.s' (ulp) files
recipe.hooks.core.postbuild.01.pattern={compiler.s.cmd} {compiler.cpreprocessor.flags} -b {build.path} -p {runtime.platform.path} -u {compiler.ulp.path} -x {compiler.path} -t {tools.ulptool.path} --DF_CPU={build.f_cpu} --DARDUINO={runtime.ide.version} --DARDUINO_={build.board} --DARDUINO_ARCH_={build.arch} --DARDUINO_BOARD="{build.board}" --DARDUINO_VARIANT="{build.variant}"

Expand Down

0 comments on commit 190aa9f

Please sign in to comment.