I am trying to figure out the best way to support building FORTRAN code using bazel. I have some queries about the general design of rules that came up after reviewing the existing documentation [1][2]. Some parts were not clear to me so please forgive any basic misunderstanding I might have; a github issue might be a better forum for discussion.
Initially, it seemed like I could simply write some rules with e.g. gfortran hardcoded as a basic implementation, however it seems like the use of a toolchain is more correct since there are many different FORTRAN compilers. So in the simplest case, does it at least make sense to write a toolchain provider for FORTRAN? Is it possible?
Later, reviewing crosstool_config.proto which is currently dedicated to C/C++, it seemed like it might make sense to extend that to support FORTRAN since they share similarities and often bundle together (e.g. you can actually feed FORTRAN code to gcc and it will pass it to gfortran); as well as the fact that they often are linked into the same executables.
Would it make sense to simply extend the CROSSTOOL specification to include support for a FORTRAN compiler? There is prior art in CMake for this approach
In the case of GCC, it knows to defer compilation of FORTRAN files down to gfortran when passed to it, so one could simply (theoretically) extend bazel to allow the .f and .inc extensions to the C/C++ rules (or create new rules that defer to the existing ones but restrict on the file extension). However that seems a little hacky and brittle and obviously break down once you extend beyond just gfortran/GCC.
Finally, is there anyone else who shares the need to build FORTRAN?
Ed