2

I want to have a define from my sketch be picked up by a library. Here is a similar question for references: Using #define and multiple classes

I have a CI server that compiles my arduino sketchs on commmit. It pulls all my personal libs from an other repository and compiles the sketch using arduino-builder.

Now i want it to also make a debug build. (Some of my library's have debugstatments in them i enable using a #define debugsomething.

Is there any way i can get the compiler to pickup the #define in the sketch or am i better off making a very complex build script that modifies the headers between builds?

Pimmetje
  • 103
  • 8

1 Answers1

2

You need a common place that the building of all the places can get the definition from.

That isn't the sketch. The sketch is one of the things that would have to look at that common place.

That can either be a single shared header that everything else (that needs it) includes, or it can be a -D flag added to the compilation command.

For instance, adding:

-DDEBUG=1

to your compilation command is the same as adding

#define DEBUG 1

to every single file you compile.

Majenko
  • 105,095
  • 5
  • 79
  • 137
  • Thanks for the replay. The -D options looks great for my purpose. Do you have any clue how to do this with https://github.com/arduino/arduino-builder? – Pimmetje Apr 29 '16 at 07:33
  • I haven't a clue. Never used arduino-builder, and I don't speak "go", so I can't even work out what it's supposed to be doing. The lack of documentation makes it impossible to know how to actually use it, as well. – Majenko Apr 29 '16 at 10:25
  • I made a issue over there. Hope they can help me : https://github.com/arduino/arduino-builder/issues/138 – Pimmetje Apr 29 '16 at 15:23
  • Can i also do multiple defines with one -D argument? Looks to me something does wrong when i try multiple -D arguments see issue 138 – Pimmetje May 01 '16 at 14:43
  • You can use as many -Dxxx=yyy arguments as you like. – Majenko May 01 '16 at 14:44
  • There is no way to hack it into one argument? As the builder currently fails to give me the second one. – Pimmetje May 01 '16 at 14:58
  • Nope. Not unless you want to re-program the AVR GCC compiler - which you don't. – Majenko May 01 '16 at 14:59
  • Wow your fast. Indeed i won't. I rather fix the arduino-builder :). I hope i get a response there. – Pimmetje May 01 '16 at 15:01