According to Eclipse this file is properly recognized as “Include”. The problem is: foo/ClassToBeIncluded.cpp gets not compiled. In the .pioenvs folder under /lib/MyCustomLib there are only compiled .o files of the main folder - the subdirectories /foo and /bar are not existing. Seems that the subfolders are ignored.
Did I miss to insert an option to tell PIO to include all lib directories recursively?
After moving all my source files to a “src” subfolder of my common library it starts compiling the files there. But now I have another little issue: In the commons library there are source files which have to be excluded in some projects. So i tried to add a source filter:
But avr-gcc ignores the filter and tries to compile that particular cpp nevertheless. In the documentation it is written that the exclude PATH command must be relative to src_dir. So I think the pattern should be correct. Or is it impossible to exclude source files from libraries?
You are right. You can filter with src_filter only project source files but not outside libraries. If you need to filter some files from a library, see Redirecting...
So as far as I understand my common classes folder (used by many similar Arduino projects) is treated as a library by PIO and I can filter source files via library.json file - is that correct?
The result is that none of the lib classes are compiled anymore. Can you tell me what parameters are missing for a valid minimal library.json for source file filtering?
I think finally I found a better solution for my usecase.
As I do not want to maintain a proper Arduino library for several platforms, I created a symbolic link within the project src folder which points to my CommonsProject/src folder. With this construction I now can use the project specific src_filter to control which source files should be compiled or excluded.
Do you think this is a viable solution for commonly used source files?