Hi!
I have a project where we use several own developed private libraries. All these libraries are stored in an Azure repository which unfortunately means that I am unable to link them via URLs in platformio.ini
. We tried to find a solution where we have only one copy of the source code for each library in our main project and the solution we came up with is to make the depended on libraries local libraries of one of the libraries and then make that one library a local library of the main project. In source control (Azure/git) we have one main repository which then links the depended on repositories as submodules. The directory structure looks something like this:
MainProject
|--lib
|--TheOneProject
| -- lib
|-- DependencyLib1
|-- DependencyLib2
TheOneProject
and MainProject
are both directly dependent on DependencyLib1
and DependencyLib2
.
Now if I use in platformio.ini
lib_ldf_mode = chain+
lib_extra_dirs = lib/TheOneProject/lib
then all works fine, but as we know lib_extra_dirs
is about to disappear. So I tried to use lib_deps
instead. The following works:
lib_deps =
file://lib/TheOneProject/lib/DependencyLib1
file://lib/TheOneProject/lib/DependencyLib2
This however causes a problem with changes in these libraries not reflected in the MainProject
. If I use
lib_deps =
symlink://lib/TheOneProject/lib/DependencyLib1
symlink://lib/TheOneProject/lib/DependencyLib2
Then the dependencies are found, the Library Manager crates the symlink files in the
.pio/libdeps/<env-name>
folder, but when it comes to compiling the code, header files in these libraries are not found and the build fails.
Interestingly, if I copy these libraries somewhere else, outside of lib/TheOneProject/lib
folder (and modify the symlink path accordingly), then the symlinks and compilation works, but this recreates the problem of duplication that we wanted to avoid in the first place.
So my questions are:
- How can I make symlinks work for libraries of libraires?
- If (1) is not possible, how can I set up my
MainProject
so that it “sees” the libraries of theTheOneProject
? - If (2) is not possible either, how can I link to repositories in Azure?
- Is there any other solution to the problem of wanting to use just one local copy of a library shared between multiple dependent projects without being able to link an external source?
Any help is much appreciated!
Update 1
I tried moving out TheOneProject
from the designated private library lib
folder.
lib_deps =
symlink://myprivatelib/TheOneProject
symlink://myprivatelib/TheOneProject/lib/DependencyLib1
symlink://myprivatelib/TheOneProject/lib/DependencyLib2
Same result - Library Manager installs the symlinks but the build fails. It looks like being a private library of another library makes the source files of the libraries invisible to the main project. If however DependencyLib1
and DependencyLib2
is moved out of the lib
folder from under TheOneProject
then compilation of MainProject
succeeds.
So it appeared that if I treat these common dependencies of MainProject
and TheOneProject
as external library dependencies in both projects I could do with one copy only of the source code of the dependencies. So I tried this:
lib_deps =
symlink://myprivatelib/TheOneProject
symlink://myprivatelib/TheOneProject/myprivatelib//DependencyLib1
symlink://myprivatelib/TheOneProject/myprivatelib//DependencyLib2
But this one also fails. As it appears, as soon as the symlink path to one library is included in the path to another library the build will fail.
So right now I am stuck and cannot really see a way now on how to create coherent repositories for MainProject
and TheOneProject
in a way that both will be self contained (i.e. containing all the source for successful compilation) without having a duplicate of the dependency libraries when MainProject
includes TheOneProject
.