Basic Build
This example walks through building the cumbersome project — a program with nested module and include dependencies — using progressively more features of FoBiS.py.
Source tree
src/
├── cumbersome.f90
└── nested-1/
├── first_dep.f90
└── nested-2/
└── second_dep.inccumbersome.f90 uses module nested_1 (from first_dep.f90), which includes second_dep.inc. The correct compilation order is:
- Compile
first_dep.f90(which incorporatessecond_dep.inc) - Compile and link
cumbersome.f90
Step 1: Build all programs
FoBiS.py buildFoBiS.py:
- Recursively scans
./for all Fortran files - Identifies
cumbersome.f90as the program (it contains theprogramstatement) - Resolves the dependency graph
- Compiles in the correct order
Default output layout:
mod/ ← module interface files (.mod)
obj/ ← compiled object files (.o)
cumbersome ← the built executable
src/Step 2: Custom directories
FoBiS.py build -dobj my-objs -dmod my-mods -dbld my-buildThe obj and mod directories are always placed relative to the build directory:
my-build/
├── my-mods/
└── my-objs/
cumbersome ← executable placed in build_dir
src/Step 3: Specify compiler and flags
FoBiS.py build -compiler gnu -cflags " -c -O2 -Wall" -j 4Note the leading space before -c — this avoids an argparse quirk with quoted strings that start with -.
Step 4: Build a specific target
FoBiS.py build -t src/cumbersome.f90 -o myappBuilds only cumbersome.f90 (and its dependencies), naming the executable myapp.
Step 5: Clean
FoBiS.py cleanRemoves obj/, mod/, and the built executable. If you used custom directories, pass them again:
FoBiS.py clean -dobj my-objs -dmod my-mods -dbld my-buildOr clean selectively:
FoBiS.py clean -only_obj # remove objects, keep executable
FoBiS.py clean -only_target # remove executable, keep objectsUsing a fobos file
Place this fobos file in the project root to avoid repeating options:
[modes]
modes = debug release
[debug]
compiler = gnu
cflags = -c -O0 -g
mod_dir = ./mod/
obj_dir = ./obj/
build_dir = ./
src = ./src/
target = cumbersome.f90
output = cumbersome
cflags_heritage = True
[release]
compiler = gnu
cflags = -c -O3
mod_dir = ./mod/
obj_dir = ./obj/
build_dir = ./
src = ./src/
target = cumbersome.f90
output = cumbersome
cflags_heritage = TrueFoBiS.py build -mode debug
FoBiS.py build -mode release
FoBiS.py clean -mode releaseExcluding files
FoBiS.py build -e src/experimental.f90Or in fobos:
[default]
...
exclude = ./src/experimental.f90Dependency graph
Generate a graphviz .dot file to visualise dependencies:
FoBiS.py build -graph