Speeding up Arduino compilation

You may already have noticed that as soon as you use a couple of libs, Arduino IDE takes forever to rebuild things, even with trivial changes (i.e. a comment).

But, when using arduino-cmake, the same thing is happening.

What's going on ?

In both cases, the ino file is in fact two things :

  • C++ source file, obviously
  • Makefile generator

Makefile generator ?

Yes, the ino file is parsed to find out what libs you are using, adding the include paths and libs to link 
A corresponding makefile is generated under the hood.

It means that for every change, the makefile is regenerated and pretty much everything is recompiled, including the libs.

How to fix that ?



Split the project
In the ino file, put  the headers for the libs you need and the minimum code
The idea is that it will change as little as possible.

Put most of the flesh in external cpp files

That way, when you change one of the cpp files, only that file will be recompiled

Comments

Popular posts from this blog

Component tester with STM32 : Part 1 ADC, Resistor

Fixing the INA3221

INA3221, weird wiring