Skip to content

Commit

Permalink
Added recipe.hooks feature to override gcc options
Browse files Browse the repository at this point in the history
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 <frederic.pillon@st.com>
  • Loading branch information
fpistm committed Dec 14, 2017
1 parent df0f42f commit c5180bc
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion platform.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ compiler.c.elf.cmd=arm-none-eabi-gcc
compiler.objcopy.cmd=arm-none-eabi-objcopy
compiler.elf2hex.cmd=arm-none-eabi-objcopy

compiler.extra_flags=-mcpu={build.mcu} -DF_CPU={build.f_cpu} -mthumb
compiler.extra_flags=-mcpu={build.mcu} -DF_CPU={build.f_cpu} -mthumb @{build.opt.path}

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

Expand Down Expand Up @@ -77,6 +77,16 @@ build.enable_usb=
build.flags.optimize=
build.flags.ldspecs=

# Pre and post build hooks
build.opt.name=build_opt.h
build.opt.sourcepath={build.source.path}/{build.opt.name}
build.opt.path={build.path}/sketch/{build.opt.name}

# Create empty {build.opt} if not exists in the sketch dir
recipe.hooks.prebuild.1.pattern.windows=cmd /c "if not exist {build.opt.sourcepath} mkdir {build.path}/sketch & type NUL > {build.opt.path}"
recipe.hooks.prebuild.1.pattern.linux=bash -c "[ -f {build.opt.sourcepath} ] || (mkdir -p {build.path}/sketch && touch {build.opt.path})"
recipe.hooks.prebuild.1.pattern.macosx=bash -c "[ -f {build.opt.sourcepath} ] || (mkdir -p {build.path}/sketch && touch {build.opt.path})"

# compile patterns
# ---------------------

Expand Down

0 comments on commit c5180bc

Please sign in to comment.