2. A fobos file
Command-line options are fine for one build; a project needs several (a debug build with run-time checks, an optimised one) and should not depend on remembering their flags. The fobos file, in the project's root, holds them as named modes:
[modes]
modes = debug release
[debug]
help = Checks on, no optimisation
compiler = gnu
cflags = -c -O0 -g -fcheck=all -Wall
src = ./src/
build_dir = ./build/debug/
target = src/integrate.F90
[release]
help = Optimised
compiler = gnu
cflags = -c -O2
src = ./src/
build_dir = ./build/release/
target = src/integrate.F90[modes]lists the modes; the first one is the default.- A mode's keys are the long options of
fobis buildwithout the dashes:compiler,cflags,src,build_dir,target... Every option is documented in the build reference. targetnames the program to build: only it and what it depends on are compiled.helpdescribes the mode in the list:
$ fobis build --lmodes
The fobos file defines the following modes:
- "debug" Checks on, no optimisation
- "release" OptimisedBuilding a mode
Without --mode, the default mode:
$ fobis build
Builder options
Directories
Root of source files directory: "src"
Building directory: "build/debug"
Compiled-objects .o directory: "build/debug/obj"
Compiled-objects .mod directory: "build/debug/mod"
Compiler options
Vendor: "gnu"
Compiler command: "gfortran"
Module directory switch: "-J"
Compiling flags: "-c -O0 -g -fcheck=all -Wall"
Linking flags: ""
Preprocessing flags: ""
Coverage: False
Profile: False
Archiver: ar -rcs
Ranlib: ranlib
Preprocessor used: None
Preprocessor args:
Preprocessor output directory: None
Preprocessor extensions processed: []
Building src/integrate.F90
Compiling src/quad_rules.F90 serially
Compiling src/integrands.F90 serially
Compiling src/integrate.F90 serially
Linking build/debug/integrate
Target src/integrate.F90 has been successfully built$ fobis build --mode release --quiet
Building src/integrate.F90
Compiling src/quad_rules.F90 serially
Compiling src/integrands.F90 serially
Compiling src/integrate.F90 serially
Linking build/release/integrate
Target src/integrate.F90 has been successfully builtEach mode builds in its own directory, so switching from one to the other never recompiles the other's objects:
$ find build -type f | sort
build/debug/integrate
build/debug/mod/integrands.mod
build/debug/mod/quad_rules.mod
build/debug/obj/.fobis-compiler.json
build/debug/obj/integrands.o
build/debug/obj/integrate.o
build/debug/obj/quad_rules.o
build/release/integrate
build/release/mod/integrands.mod
build/release/mod/quad_rules.mod
build/release/obj/.fobis-compiler.json
build/release/obj/integrands.o
build/release/obj/integrate.o
build/release/obj/quad_rules.o
Recorded on a small demo project, not quad.
Running
fobis run builds the mode's target when needed, then runs it:
$ fobis run --mode release
Builder options
Directories
Root of source files directory: "src"
Building directory: "build/release"
Compiled-objects .o directory: "build/release/obj"
Compiled-objects .mod directory: "build/release/mod"
Compiler options
Vendor: "gnu"
Compiler command: "gfortran"
Module directory switch: "-J"
Compiling flags: "-c -O2"
Linking flags: ""
Preprocessing flags: ""
Coverage: False
Profile: False
Archiver: ar -rcs
Ranlib: ranlib
Preprocessor used: None
Preprocessor args:
Preprocessor output directory: None
Preprocessor extensions processed: []
Building src/integrate.F90
Nothing to compile, all objects are up-to-date
Linking build/release/integrate
Target src/integrate.F90 has been successfully built
n trapezoid error simpson error
4 1.0388E-01 4.5598E-03
8 2.5768E-02 2.6917E-04
16 6.4297E-03 1.6591E-05
32 1.6066E-03 1.0334E-06
64 4.0161E-04 6.4530E-08Arguments after the options go to the program: fobis run --mode release -- ARG....
Cleaning a mode
Now that the mode names its target, fobis clean removes the executable too:
$ fobis clean --mode debug
Removing all *.(s)mod files into "build/debug/mod"
Removing all *.o files into "build/debug/obj"
Removing build/debug/integrateWhat you learned
A fobos file with modes; --mode, --lmodes; per-mode build directories; fobis run. Reference: the fobos file, run.
Next: 3. A library.