From c5180bcf6b9e655908d97e1fe5bb4135b00f8558 Mon Sep 17 00:00:00 2001 From: "Frederic.Pillon" Date: Thu, 14 Dec 2017 10:28:22 +0100 Subject: [PATCH] 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 --- platform.txt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/platform.txt b/platform.txt index f8a73d199e..f8822e9064 100644 --- a/platform.txt +++ b/platform.txt @@ -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} @@ -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 # ---------------------