From 190aa9fc88395dfdce34e991aedbbd7057f1b440 Mon Sep 17 00:00:00 2001 From: per1234 Date: Wed, 16 Nov 2022 03:45:23 -0800 Subject: [PATCH] Add build hook to copy `.s` files 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. --- platform.local.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/platform.local.txt b/platform.local.txt index f7ae1e1..bbdbaab 100644 --- a/platform.local.txt +++ b/platform.local.txt @@ -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}"