Open ndmitchell opened 9 years ago
Perhaps a curated list of stack overflow questions would be better? If the FAQ linked to a list they might offer a better format.
I was looking at this more. Fortran dependencies seem like they require a multi-phase build, or a module detector. Say we have a file foo.f90
that needs a module bar.mod
. Fortran imposes no restrictions on file naming or search paths, so bar.mod
might be generated by baz.f90
, in another directory.
As a multi-phase build, the solution is to just keep running shake in staunch and forward-dependencies mode over every Fortran file. On the first build, foo.f90
will fail, due to the missing bar.mod
, but baz.f90
will successfully compile and generate bar.mod
. On the next build, foo.f90
will succeed and add bar.mod
as a dependency, while baz.f90
will be skipped because it's up to date. This can continue through however deep the module dependency graph is (it's not allowed to be cyclic because the fortran compiler doesn't support that).
Using the module detector, you run a program which outputs all modules in a file, once for each file, to foo.f90.mods
. Then you create a ModMap
rule which depends on all the f90.mods
files and concatenates them together, and finally a ModLookup
rule which looks the module up in the ModMap
and then depends on building the file containing the module. Then you scan each file for module usages and run ModLookup
for each one. The only hard part is specifying the file list given to ModMap
; I'm not sure where it would be constructed or how it would be passed around.
For example, how to do depends on Fortran. Perhaps should be bundled rules, if we can figure out what the general form looks like?
http://lagrange.mechse.illinois.edu/f90_mod_deps/