.fab configuration mode
Zero-configuration mode offers the great user-experience of being able to simple type fab and watch your code build, but it lacks the full customisability that fab offers. Likewise custom build scripts lack the nice UX features of being able to type fab in a new project and know that it's going to build.
This issue proposes a middle ground: the fab CLI will first look for a .fab directory in the current working directory, which will hold custom configuration and build scripts which will be evaluated by fab.
Hi Ed, thank you for the ticket. Are you aware of our work on BAF (Build Architecture with Fab - https://github.com/MetOffice/lfric-baf). While this is initially targeted at building LFRic, it is aimed to have a generic base class to be used by other applications (and might end up to be part of Fab at some stage).
It is fully command line driven, and an application could easily define its own defaults. It also supports site-specific customisation scripts (where each site can specify compilers, command line options, linker details, ...). That would be similar (though a bit more generic) to your .fab directory.
This is very active work-in-progress, and the documentation is admittedly lacking (while we finish the design of important other features).
A build script can then be invoked as:
./fab_gungho_model.py --site ncas --platform ex -fc mpif90-gfortran -ld linker-mpif90-gfortran
You can use the existing features of BAF to set e.g. these command line options as default. Without any work, it will do a zero-config (e.g. it will find a compiler that works that has the appropriate features, e.g. if you are doing an MPI build, it will only consider Fortran compilers that support mpi).
Hi Joerg,
Yes I'm aware of the work being done in lfric-baf. In my mind this would be completely tangential, simply a way to invoke more complex custom build configs in a way that retains some of the nice CLI usability that someone coming from using something like cargo, fpm, poetry or even make might expect. Also this would be completely non-site specific, the reason I wanted to develop this was for a different, non-Met Office project where I think the functionality would be useful
Ah great that you know of that. Can I still recommend you look at that? Outside of any side-specific setup:
baf will read a file default/config.py (and obviously the name could be configured to be e.g. .fab), and we have already added a few methods that are being called at various stages during the setup. While I am focussing on LFRic, I am more than happy to make sure this base class is configurable enough for other (your :) ) purposes.
I would actually be interested in your (close-to) 'zero config' use case (e.g. how do you expect the compiler and compilation flags to be determined?)
I believe this functionality is included in PR #448. This implements a new top-level fab command which, by default, checks for the existence of a file called FabFile in the current working directory. If the file exists, the command imports it, checks for a specific class definition, and then executes some specific methods to configure and run the build process.
If FabFile does not exist and the user has not specified an alternate file with the --file option, the command picks up a zero-config recipe. If the user has specified an alternate file and it either doesn't exist or cannot be imported, the command exits with an error.
I'm going to mark this as closed - but let me know if it isn't and I'll re-open it.