Skip to content

Commit 130c5ab

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 #41 Signed-off-by: Frederic Pillon <[email protected]>
1 parent 7d1bafb commit 130c5ab

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

Diff for: platform.txt

+11-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.opt.path}
3333

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

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

80+
# Pre and post build hooks
81+
build.opt.name=build_opt.h
82+
build.opt.sourcepath={build.source.path}/{build.opt.name}
83+
build.opt.path={build.path}/sketch/{build.opt.name}
84+
85+
# Create empty {build.opt} if not exists in the sketch dir
86+
recipe.hooks.prebuild.1.pattern.windows=cmd /c "if not exist {build.opt.sourcepath} mkdir {build.path}/sketch & type NUL > {build.opt.path}"
87+
recipe.hooks.prebuild.1.pattern.linux=bash -c "[ -f {build.opt.sourcepath} ] || (mkdir -p {build.path}/sketch && touch {build.opt.path})"
88+
recipe.hooks.prebuild.1.pattern.macosx=bash -c "[ -f {build.opt.sourcepath} ] || (mkdir -p {build.path}/sketch && touch {build.opt.path})"
89+
8090
# compile patterns
8191
# ---------------------
8292

0 commit comments

Comments
 (0)