arduino-cli icon indicating copy to clipboard operation
arduino-cli copied to clipboard

Build flags set in my `boards.txt` file not used in the compilation command

Open manasIU opened this issue 6 years ago • 7 comments
trafficstars

Hi, in my boards.txt file I am using my own build flags (eg. -DFLAGNAME). Arduino-cli recognises these flags but sets these to their default values (0). How do I tell arduino-cli to set certain flags?

manasIU avatar May 20 '19 06:05 manasIU

Arduino-cli recognises these flags but sets these to their default values (0).

I can't reproduce this. Could you please provide more details, including the exact line from your boards.txt file and a minimal demonstration sketch so that I can reproduce your setup exactly?

How do I tell arduino-cli to set certain flags?

You can use arduino-cli compile's --build-properties option to do things like:

arduino-cli compile --fqbn arduino:avr:uno --build-properties build.extra_flags=-DFLAGNAME SketchName

but be aware this will override the value of the build.extra_flags property that might have been set in your boards.txt.

per1234 avatar May 20 '19 08:05 per1234

I would like to make a feature request for the Arduino-CLI to explicitly support user-defined -D macros without resorting to this hack (which also happens to work in the Arduino IDE CommandLine ). You mentioned in https://forum.arduino.cc/index.php?topic=537500.0 that the Arduino devs have previously been reluctant to do this, but maybe they have changed their minds due to the ongoing work on the Arduino CLI.

bxparks avatar May 20 '19 19:05 bxparks

@per1234 My boards.txt file looks something like this :

# Dragonfly-L496RG
Dragonfly-L496RG.menu.debugOptions.none=None
Dragonfly-L496RG.menu.debugOptions.none.build.debugEnable=1

When I compile with verbose on, I see the -DDEBUGENABLE=0 in the output even after using your suggestion of using the --build-properties build.extra_flags=-DFLAGNAME

manasIU avatar May 21 '19 04:05 manasIU

Is this an existing unmodified hardware core? If so, post a link to it. If you customized it yourself, then you need to provide the full boards.txt and platform.txt.

I also need the complete arduino-cli command you're running.

per1234 avatar May 21 '19 04:05 per1234

I would like to make a feature request for the Arduino-CLI to explicitly support user-defined -D macros

We can consider https://github.com/arduino/arduino-cli/issues/159 as the dedicated issue for that feature request and use this issue to investigate @manasIU's problem.

per1234 avatar May 24 '19 09:05 per1234

It's a slightly modified Dragonfly-l496RG board with custom debug flag options added (link). Full arduino-cli command : arduino-cli compile --fqbn grumpyoldpizza:stm32l4:Dragonfly-L496RG --build-properties build.extra_flags=-DDEBUGENABLE=1 sketch_name --verbose When I run the above command, I see -DDEBUGENABLE=0 in the verbose output.

manasIU avatar May 24 '19 10:05 manasIU

How do I tell arduino-cli to set certain flags?

You can use arduino-cli compile's --build-properties option to do things like:

arduino-cli compile --fqbn arduino:avr:uno --build-properties build.extra_flags=-DFLAGNAME SketchName

but be aware this will override the value of the build.extra_flags property that might have been set in your boards.txt.

Is there a way to save the fqbn and build-properties in the global config so they don't have to be repeated on the command line? I skimmed the source but couldn't find anything obvious. For now I'm using shell aliases.

nerdralph avatar Jan 08 '20 02:01 nerdralph