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:
- Keep all of my libraries under a common top-level folder
- Maintain a separate Github repository for each library
- 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!