Leveraging fpm's dependency graph to initialise linter

I have had this thought in the back of my head for a while but reading this thread Newbie question: How did fpm figure the dependency graph? - #5 by awvwgk reminded me again. Could we expose the fpm source parsing module and specifically the dependency graph to an API to be queried by VS Code so that we can deduce the correct lint order and allow for project initialisation, even in projects that do not use fpm.

Currently, I implemented an extremely naive algorithm of searching via glob patterns for all Fortran sources and then running them through the linter, which is a hit or miss way of initialising since you can easily lint files out of order.

The functionality that I am suggesting is something along the lines of:

  1. Give a list of Fortran files to fpm/Let fpm find all Fortran files in a directory
  2. Run fpm and deduce the dependency graph of the Fortran files
  3. Return a list of Fortran files, to be run by the linter in the correct order/ Allow fpm to run with the linter arguments (would allow for easy parallel linting if fpm is configured with OpenMP)

It was in the plans. It would facilitate auto-generating CMake and Make files for incorporation into other projects (possibly via an fpm plugin); easy generation of dependency graphics independent of ford and doxygen; and so on. Have not heard much about whether that is active at the moment though.
There are discussion and issue features at the github site that help make tracking the issues easier
that you might want to open something on as well.

 fpm build --show-model

shows how close it is to providing this.


Thanks for the heads up @urbanjost. Do you know if the output of --show-model is formatted in some sort of serialisation language e.g. JSON, YAML, TOML etc.

In general I propose we make a new subcommand called tools for performing such tasks. I originally proposed this in point 3.1 in FPM Integration with Visual Studio Code - Discussion · Discussion #768 · fortran-lang/fpm · GitHub

I think this is doable, there is Allow serialization of the fpm model to TOML · Issue #541 · fortran-lang/fpm · GitHub for serialization to TOML, if JSON is preferred we now also have a JSON frontend for TOML Fortran, which could be used here.

The current format is pretty much based on Lisp, I think.

Yeah, that would be great. I think JSON is easier for JS/TS parsing since it is natively supported. I can add it to my TODO list and have a look today.