How to pass preprocessor macro during Arduino command line build?

I am building using Arduino IDE command line from a script using a command like this:

"${ARDUINO_HOME}/arduino" \
         --verify -v \
         --board arduino:avr:mega:cpu=atmega2560 \
         --pref sketchbook.path=$(pwd) \
         --pref build.path=$(pwd)/Release \

I am trying to figure out how to pass a preprocessor macro at build time. for straight up gcc it is just -DMACRO=VALUE command line option, but since Arduino IDE sits several layers above avr-gcc, it is hard to tell what I need to do to accomplish this?

Any ideas short of abandoning Arduino IDE and making my own makefile?



Try using “.build.extra_flags=” in the “arduino-1.x.x/hardware/arduino/avr/boards.txt” file. It is used in that file to add some defines, take a look.