Library import flattens directory structure? [WORKAROUND]

@dgarcia Have you thought about creating a script that flattens the library, so you only have to maintain one repo, and the Particle-specific repo is just a modified copy of the main repo after applying the script?

I really wish Particle could implement full support for the Arduino IDE and Builder, like the RedBear Duo, or ESP8266. I’m not sure if there is a hardware limitation preventing this, or if it’s all software.

The firmware building and IDE is currently getting some attention behind the scenes (as there was a new push for Dev a few hours ago).

Any update on this? I’m getting started with the cli after using the web IDE, attempting to use a handful of libraries, and Particle is breaking on the most basic of directory support.

$ grep include gps-electron.ino 
#include "SparkFunMAX17043/SparkFunMAX17043.h"
#include "SparkFunMicroOLED/SparkFunMicroOLED.h"
#include <TinyGPS++/TinyGPS++.h>

$ particle electron compile gps-electron.ino SparkFunMAX17043/* SparkFunMicroOLED/* TinyGPS++/*
Compiling code for electron
Including:
    gps-electron.ino
    SparkFunMAX17043/SparkFunMAX17043.cpp
    SparkFunMAX17043/SparkFunMAX17043.h
    SparkFunMicroOLED/SparkFunMicroOLED.cpp
    SparkFunMicroOLED/SparkFunMicroOLED.h
    SparkFunMicroOLED/SparkFunMicroOLEDFonts.h
    TinyGPS++/TinyGPS++.cpp
    TinyGPS++/TinyGPS++.h
attempting to compile firmware 
pushing file: gps-electron.ino
pushing file: SparkFunMAX17043/SparkFunMAX17043.cpp
pushing file: SparkFunMAX17043/SparkFunMAX17043.h
pushing file: SparkFunMicroOLED/SparkFunMicroOLED.cpp
pushing file: SparkFunMicroOLED/SparkFunMicroOLED.h
pushing file: SparkFunMicroOLED/SparkFunMicroOLEDFonts.h
pushing file: TinyGPS++/TinyGPS++.cpp
pushing file: TinyGPS++/TinyGPS++.h
Compile failed. Exiting.
gps-electron.cpp:1:47: fatal error: SparkFunMAX17043/SparkFunMAX17043.h: No such file or directory
 #include "SparkFunMAX17043/SparkFunMAX17043.h"

.

I just want to +1 this as I’m currently working on a library with a similar goal of FastLED to support multiple platforms and have arranged files in a tree of folders. The idea of a non-master branch option for community libraries and a non-flattened structure is very appealing.

1 Like

It looks like you found part of the solution I did, as far as getting the subdirectories to be included, but then you have to do the odd thing of making the call from the .ino file to not include the directory name. (Yup, that’s weird and the fix suggested above should be the final solution, but this works.
I got the sulution from another thread on this forum but I just can’t find it right now so I’'l put out my own. Every reference i have seen to particle.include says you nedd to list each item but this syntax works (I haven’t tried with multilevel nested directories but let’s see what happens:
The file “particle.include” should have this:
#particle.include
# from current dir
*.h
*.ino
*.cpp
*.c

# and from any subdirectories
 **/*.h
 **/*.ino
 **/*.cpp
 **/*.c

… But then you need to remove the directory reference from the "#include line"
I am successfully using this with the SdFat library with the library in in "SdFat/SdFat"
My “#include” line in the .ino file went from:
#include #include "SdFat/SdFat.h"
to:
#include "SdFat.h"
and it all magically works:
I’m speculating that it grabs all files referenced and drops them into a single flat virtual directory on the server and then compiles. So you can keep a directory structure locally but treat it like a flat directory for referring to the files. Obviously this leaves something to be desired, and could result in filename conflicts that are difficult to debug but it does work as a workaround.