I’m creating some libraries for a project but I’m having warnings regarding circular dependencies. Is there a way to tell pio to show the files that cause that problem? Increasing verbosity does not work and I haven’t found how to do this in the documentation.
The Library Dependency Finder might come to your rescue here. It scans all headers for includes and lists them as part of your build process. You should be able to see cyclic dependencies in the tree like this:
My personal recommendation would be to search all files for missing #ifdefs and add them as necessary. Multiple superficial #include directives are a typical source of cyclic dependency issues.
See here for more reference on this matter.
Hope I could help
I’m sorry I didn’t mention that I already can see dependencies using LDF. I run pio in verbose mode, so I can see the dependency graph as well as cyclic dependencies warnings. The LDF must know the concrete files/includes that make a dependency cyclic so it can print the warnings. My point is that I don’t see a way ask the LDF to print more specific information about that warning (I’m thinking in how GCC prints errors/warnings, with the offending file and line). In case that this cannot be done, I think that this feature could be interesting for developers.
I see your point. You mean e.g. LDF dependency tree should mark files involved in a cyclic dependency red or so? I’d have to look at the repository to see how LDF is currently working and whether that’s an option to add.
OK, I found the code segments in platformio-core/piolib.py.
It’s about two methods, one recursively gets the library dependencies (search_deps_recursive()) and the other one prints the dependency tree, privat method (_print_deps_tree()).
The target now is to identify cyclic includes in the former and mark them in the latter.
I cannot promise that I find the time to create the solution for this in the near future but I’ll definetely keep this the back of in my head.
PIO only lists dependencies on a folder level. E.g. files directly created in /lib will be ignored in the Dependency graph.
I have created a direct circle between A and B. Due to the folder structure, PIO will draw an incomplete tree in case of a dependency because this tree would have infinite branches due to the cyclic dependency (because it is really a graph.
As the Dependency tree creation doesn’t use the compiler, it will not detect cyclic dependencies as of now.
I’ll have to have a deep-dive look at why the dependency finder does not show cyclics at the moment.