Private Library Development Process

I’ve spent the day learning how to convert some of my commonly-used modules into private libraries. I think I have it working now, but I’d like to run this by the community to see if I’m missing something, or if there’s a better way. A few of my main goals are:

  1. Keep all of my libraries under a common top-level folder
  2. Maintain a separate Github repository for each library
  3. Have a way to easily update and “unit test” each library

I started by moving the existing .h and .cpp files to a clean-sheet PIO project for each library. In the platformIO.ini file, I use lib_deps to specify the external libraries used by the new private library (if any). I used main.cpp (the usual setup() and loop() ) for my unit test code. I was able to separately compile and test each library. I used the normal methods to create a new Github repo for each library/project.

I stored each library/project in /Users/keith/Documents/PlatformIO/Projects/EFD_libraries/{library name}

For each “client” project, I added the following to the platformIO.ini file:
lib_extra_dirs =
/Users/keith/Documents/PlatformIO/Projects/EFD_libraries

I didn’t need to use lib_deps to specify each individual (private) library used, just the normal #include “{library name}”. Minor issue: PIO didn’t find the library until I quit and restarted.

So does this sound about right? I was initially confused by the fact that each library/project has its own main.cpp (which I used for test code), but this doesn’t seem to cause any problems when the library is used by a client project with the “real” main.cpp.

Thanks for any feedback!

Apart from the test suite stuff, which I don’t yet use, sadly, your process sounds the same as mine.

I’d say you are doing it right.

Did you try to compile before quitting? If all you saw was wiggly red lines, that’s “intellisense” and is Microsoft not PlatformIO. It takes a compile to get it up to date, or there’s a “rebuild intellisense” command in the command list you can use.

Mind you, intellisense never finds things like avr/interrupt.h regardless, unless I update the paths in a JSON file, which I’m not bothering about!

Cheers,
Norm.

Thanks for the feedback! Glad to hear I got it about right.
Yeah, I’m aware of the issues with Intellisense, but I think I was getting real compiler errors also. I’ll check more carefully next time through the process.

1 Like