Nested Libraries

I am working on a set of libraries for GPS work. I plan on splitting my code into two libraries. One, GPS_Driver, handles watching serial wires for incoming text streams, storing the results, and providing the stored sentences to clients (such as the parser). The other, NMEA_Parser, is given a text buffer from somewhere (such as, but not necessarily, the driver) and parses out the relevant information and permits clients (such as the user, or other routines) to copy the information out.

I am developing the driver and parser library separately, since they are independent of each other, and combining them into a third master library as submodules of it. As such, in the third library (a single GPS library, capable of autonomously harvesting serial input and providing parsed information), the driver and parser are in its lib/ directory.

As far as I know, for other people to consume my primary GPS library, they will simply clone it into their lib/ directory, and be able to access its header via #include <GPS.hpp>. However, the GPS code and header files will themselves reference #include <GPS_Driver.hpp> and #include <NMEA_Parser.hpp> but these libraries won’t be in $PROJECT/lib/GPS_Driver/src/GPS_Driver.hpp, they’ll be in $PROJECT/lib/GPS/lib/GPS_Driver/src/GPS_Driver.hpp, and the same for the NMEA parser.

Will PlatformIO be able to handle libraries inside libraries like this, or will I need to package the master GPS library so that it has the structure GPS/src/{GPS,GPS_Driver,NMEA_Parser}.{c,h}pp so that, when cloned into another project, the end result is $PROJECT/lib/GPS/src/{GPS,GPS_Driver,NMEA_Parser}.{c,h}pp all next to each other and ready for PlatformIO to process?

All you need is PlatformIO 3.0 and extraBuildFlags from #issue 289. having it you will be able to specify extra -I lib/GPS_Driver/src/ -I lib/NMEA_Parser/src/. However, PlatformIO 3.0 has not been released yet. We look for resources how to keep PlatformIO alive and continue work on PlatformIO 3.0.

Currently, Yes. Sorry.

How about to have GPS library with dependencies to GPS_Driver and NMEA_Parser? Do these libs will be private?

I edited my platformio.ini file in the master project:

framework = arduino
platform = atmelavr
board = megaatmega2560
build_flags = -DDEBUG -Ilib/NMEA_Parser/NMEA_Parser -Ilib/GPS_Driver/GPS_Driver

This compiles correctly on PlatformIO 2.8.6, actually.

None of my three projects are yet published to the PlatformIO registry, so I can’t use dependency tracking just yet. I will likely switch to that when or if I ever get to a publishable state.

The sub-libraries are intended to be completely public; I just have them parceled out for cleanliness.

I completely didn’t think of the -Ipath/to/libs option; mea culpa on that.

Thanks again for making this; I can’t imagine writing for Arduino in the native IDE anymore. I’ll try to give back after I graduate and can afford to be altruistic:p

That is great that you love PlatformIO. Also, thanks a lot for your donations :moneybag: If students donate to PlatformIO, we are on the right way with PlatformIO ecosystem. It’s very important to us that people understand us and our efforts.

Stay tuned with @PlatformIO_Org.