I have spent this afternoon googling but I just can't find an answer.
My problem is that I am trying to create a library that will work on Arduino boards, esp, and on Linux (maybe even stm and so on in the future).
I have the following folder and files structure:
library/
examples/ (with Arduino examples)
all other Arduino files (library.json, license etc)
src/
src/arduinoWrapper/ (with Arduino specific code)
src/linuxWrapper/ (with code that runs on Linux platform)
src/{ all src files} (with common code which is the the main logic)
When I compile with my own makefile created for Linux everything compiles and it is working.
When I try to compile through Arduino IDE, it tries to compile c++ libraries like spdlog and arrrgh which are ofc not compilable. The files are not included and I just do not know what to do.
I can not modify Arduino include paths, and I can not find an option to exclude those files.
I could do #ifndef ARDUINO in all files, but I really do not like this approach.
I would also like to avoid having another repo that will contain other wrappers.
spycatcher2k:
OK - Now read your post and point out exactly where you asked any questions!
Also , Why not, it's a perfectly sound and tested method.
Hi,
You are right. I did not ask a question, but I think that it is obvious that I am asking for a help from a way that I have described a problem.
I would like to avoid #ifndef ARDUINO because I am using some external libs like arrrgh and spdlog and that would mean I have to fork them and change them in order to supply them with my repo.
spycatcher2k:
Unless the include was wrapped in a ifdef!
Includes in main.ino files are wrapped in an ifdef. The issue is in source globbing I would say. It tries to compile all .cpp files even though their headers are not included anywhere
Would it be possible for you to install those libraries somewhere outside of the src folder? That would prevent the source files from being automatically compiled and the solution of doing conditional #includes of those libraries would then work fine.
pert:
Would it be possible for you to install those libraries somewhere outside of the src folder? That would prevent the source files from being automatically compiled and the solution of doing conditional #includes of those libraries would then work fine.
It would. I will play around with different paths. Is only src folder included or are files in library folder included?
With the 1.5 Arduino library format (library.properties file in the library root folder, source files under the src subfolder), only the contents of the src folder are compiled.
pert:
With the 1.5 Arduino library format (library.properties file in the library root folder, source files under the src subfolder), only the contents of the src folder are compiled.
Thank You very much for this info. Tested it today and it is working