Go Down

Topic: Questions on using Arduino IDE from command line (Read 1 time) previous topic - next topic

hichhiker

Mar 29, 2017, 08:05 pm Last Edit: Mar 29, 2017, 09:15 pm by hichhiker Reason: Clarify the subject
I am trying to set up a CI build for our code using Jenkins and Linux and run into a few questions I am having hard time resolving...

First, my setup:

I am loading arduino-1.8.2 for linux64 as my build tool. I tried using python "INO" wrapper tool but it requires re-arranging of the files in the repo (not a big deal) and even after that, I could not get it to compile as it kept not respecting the location of the IDE specified via -d parameter and using an old version :-( I could probably dig into it and fix it, but I was not sure if I needed another tool for this. Instead I am trying to use "arduino" tool in the IDE from command line.

My questions:

1 - Is there any way to tell it what the output filename is? My project is a cpp only project and even if I specify a CPP file, it seems to pick the first CPP file it finds and names the output as that filename + extension. It is annoying - although I worked around it by adding an empty .ino file and now it uses that name

2 - Is there a way to specify command line arguments to be passed to compiler? I have a number of -D's I want to specify to provide build-time info and it should be easy, but I cannot seem to figure out how to do that?

3 - Should I be using "ardiuino -verify" or "arduino-builder" to build from command line?

4 - Is there a way to emulate Arduino for sake of unit/integration testing on a linux box at build time, given that our build box does not (and cannot) have a hardware Arduino connected to it?

Thanks,

-HH





pert

1 - Is there any way to tell it what the output filename is? My project is a cpp only project and even if I specify a CPP file, it seems to pick the first CPP file it finds and names the output as that filename + extension. It is annoying - although I worked around it by adding an empty .ino file and now it uses that name
Using arduino-builder you can do this via the -prefs=build.project_name= option. Using Arduino IDE CLI it would be --pref build.project_name=

2 - Is there a way to specify command line arguments to be passed to compiler? I have a number of -D's I want to specify to provide build-time info and it should be easy, but I cannot seem to figure out how to do that?
Using arduino-builder you can do this via the -prefs=build.extra_flags= option. Using Arduino IDE CLI it would be --pref build.extra_flags=

3 - Should I be using "ardiuino -verify" or "arduino-builder" to build from command line?
If you wanted to use Arduino IDE CLI you would probably be better off to use arduino_debug instead of arduino so you will get some output to the console.

Arduino CLI seems to create the build folder and then immediately delete it so if for some reason you needed the output files from the compilation that would be undesirable. I'm not sure why you would need them but the fact you want to change the name indicates this might be the case.

I seem to remember that in previous IDE versions CLI always opened a GUI window, even when not necessary, but I could be wrong about that. I believe this has been fixed in recent IDE versions and I don't know if that would be a problem for your CI system.

I suspect that arduino-builder would be faster since the Arduino IDE is using arduino-builder anyway.

Arduino CLI does allow the extra features of installing boards via Boards Manager or libraries via Library Manager.

If you want to test for backwards compatibility with Arduino IDE versions previous to 1.6.6 then you will be using Arduino IDE CLI for those tests as arduino-builder was added in 1.6.6. I'm not sure how the CLI has evolved over the course of time or how far back that feature extends.

Go Up