Pass extra flags to Arduino CLI

Hello,

I have my own Makefile which calls the Arduino CLI to compile my sketches.

I would like to pass extra flags to gcc, so this is what I'm using now:

arduino --pref build.extra_flags="-DSOME_OPTION"

This is working fine.

The problem is that I'm now using a new board (Arduino Zero) which defines "build.extra_flags" inside its "boards.txt".
So, my Makefile is now overriding this value and all compilations fail.

I also tried an append, but it doesn't work as expected:

arduino --pref build.extra_flags="{build.extra_flags} -DSOME_OPTION"

Is there a robust way to do what I'm trying to accomplish?

If not, wouldn't be the case to support a new option "build.cli_flags" (or "build.user_flags") that is guaranteed to be empty to the CLI?

Thanks,
Francisco
http://www.ceu-lang.org/

You can also use these:
compiler.c.extra_flags
compiler.c.elf.extra_flags
compiler.S.extra_flags
compiler.cpp.extra_flags
compiler.ar.extra_flags
compiler.objcopy.eep.extra_flags
compiler.elf2hex.extra_flags

According to the comment in Arduino's platform.txt, build.extra_flags is specifically intended to be used in boards.txt. The comment for the compiler.*.extra_flags properties says they are intended to be used in platform.local.txt but that file is supposed to be for the user to make customizations so I don't think there is so much of a conflict between the CLI usage and the platform.local.txt usage with those properties as there is between CLI usage and boards.txt usage with the build.extra_flags property where you have two separate entities trying to use it (hardware package author and end user).

They way they have specialized these properties makes them maybe a bit less convenient to use but also more flexible. I think there might be a reasonable argument for adding a universal property that is intended for the end user.

An annoyance for me is that these only work for purely CLI usage. I'd like to be able to set these properties via CLI and then have that also apply to compilations in the IDE's GUI but I haven't found a way to do that. Arduino has been very resistant to facilitating this sort of advanced usage because they feel it will lead to less user friendly library interfaces. In fact I somewhat suspect that this working with the CLI is only by accident.

Thank you.
That solved the issue ("compiler.cpp.extra_flags").
Hope they improve support for these kinds of customizations.