Skip to content

Commit a147d5e

Browse files
committed
Added recipe.hooks feature to override gcc options
It is now possible to customize some core definitions or gcc options thanks a file named "build_opt.h" in the sketch directory. (using @file gcc option) Example of file content to change F_CPU value: -UF_CPU -DF_CPU=72000000UL If the file does not exist an empty one is created. Fix stm32duino#41 Signed-off-by: Frederic Pillon <[email protected]>
1 parent 7d1bafb commit a147d5e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Diff for: platform.txt

+6-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ compiler.c.elf.cmd=arm-none-eabi-gcc
2929
compiler.objcopy.cmd=arm-none-eabi-objcopy
3030
compiler.elf2hex.cmd=arm-none-eabi-objcopy
3131

32-
compiler.extra_flags=-mcpu={build.mcu} -DF_CPU={build.f_cpu} -mthumb
32+
compiler.extra_flags=-mcpu={build.mcu} -DF_CPU={build.f_cpu} -mthumb @{build.path}/sketch/build_opt.h
3333

3434
compiler.S.flags={compiler.extra_flags} -c -x assembler-with-cpp {compiler.stm.extra_include}
3535

@@ -77,6 +77,11 @@ build.enable_usb=
7777
build.flags.optimize=
7878
build.flags.ldspecs=
7979

80+
# Pre and post build hooks
81+
recipe.hooks.prebuild.1.pattern.windows=cmd /c "if not exist {build.source.path}\build_opt.h mkdir {build.path}\sketch & type NUL > {build.path}\sketch\build_opt.h"
82+
recipe.hooks.prebuild.1.pattern.linux=bash -c "[ -f {build.source.path}/build_opt.h ] || (mkdir -p {build.path}/sketch && touch {build.path}/sketch/build_opt.h)"
83+
recipe.hooks.prebuild.1.pattern.macosx=bash -c "[ -f {build.source.path}/build_opt.h ] || (mkdir -p {build.path}/sketch && touch {build.path}/sketch/build_opt.h)"
84+
8085
# compile patterns
8186
# ---------------------
8287

0 commit comments

Comments
 (0)