-
Notifications
You must be signed in to change notification settings - Fork 35
Autorebuild with interdependent projects
A helpful (thanks Jacob and Tomas) feature is to automatically (re-)compile your project when an external project, upon which the main project depends, changes.
This feature relies on the concept of interdependent
projects. Let us assume we have 4 projects:
- a first library project having its own fobos file;
- a second library project having its own fobos file;
- a third library project having its own fobos file;
- a program project that relies on the above libraries.
To correctly build the program project we must ensure that the libraries are update themselves. It is useful that when we build the program project the eventually necessity of the library (re-)building is automatically accomplished. This can be done setting a dependon
option when building the program project
FoBiS.py build --target program.f90 -dependon ' ./path_to_library_1/fobos_lib:static((direct)) ./path_to_library_2/fobos_lib:static((INdirecT)) ./path_to_library_3/fobos_lib' -o prog ...
The dependon
option value has a simple syntax: it contains a list of dependencies definition that must contain the relative path to the fobos file of the dependency project and optionally the mode (static in the example) to be used (separated by :
symbol) and the linking mechanism (direct or indirect). For the syntax of dependon
the following rules are applied:
- the complete
dependon
value has the syntax:relative_path_to_library/fobos_file[:fobos_mode_to_be_used][((direct|indirect))]
;- the
fobos_mode_to_be_used
is optional and, if present, must be a mode defined into thefobos_file
; in case the mode is not specified thedefault
mode or the first defined mode is used; - the
((direct))
or((indirect))
flags are optional and are case insensitive: they represent the mechanism by means the dependency library is linked when building the main program; in case it is not specified, the((direct))
linking is used;-
((direct))
means that the dependency library is linked directly, i.e. with its full path, e.g. it is equivalent to setlibs = relative_path_to_library/build/libfoo.a
in case the fobos of the library definesbuild_dir = build
andoutput = libfoo.a
ortarget = foo.f90
andmklib = static
; themod_dir
path defined into the fobos of the library is added to the include files search paths of the main project (for serching eventual.mod
files associated to the dependency library; -
((indirect))
means that the dependency library is linked indirectly, i.e. by means of the library base-name, e.g. it is equivalent to setext_libs = foo
andlib_dir = relative_path_to_library/build/
in case the fobos of the library definesbuild_dir = build
andoutput = libfoo.a
ortarget = foo.f90
andmklib = static
; themod_dir
path defined into the fobos of the library is added to the include files search paths of the main project (for serching eventual.mod
files associated to the dependency library;
-
- the
- examples of valid
dependon
values are:-
-dependon ' ./path_to_library/fobos_lib:static((direct))
; -
-dependon ' ./path_to_library/fobos_lib((direct)):static
; -
-dependon ' ./path_to_library/fobos_lib((Indirect))
, thedefault
or the first defined mode is used; -
-dependon ' ./path_to_library/fobos_lib:static
, the direct linking is assumed; -
-dependon ' ./path_to_library/fobos_lib
, thedefault
or the first defined mode is used and the direct linking is assumed;
-
The algorithm of the dependon
building is simple
- for each dependency:
- FoBiS.py goes to the path where the dependency fobos is;
- FoBiS.py is auto-executed using the dependency fobos file with mode selected;
- FoBiS.py come back to the original directory and it continues to build the main project in the standard way, having the dependencies paths automatically added to the main program building set-up.
In this way the building of the main program automatically handles the eventual necessity of the dependency library rebuilding. It is worth noting that each dependency project (the libraries in this example) must have its own fobos file. Secondly, the dependon
option can be also defined into an eventual fobos file of the main program project, e.g.
[main-program]
cflags = ...
dependon = ./relative_path_to_lib_foo/fobos:my_foo_mode ./relative_path_to_lib_bar/fobos:my_bar_mode
...
Note that there is an example into the examples directory.
-
Getting-Started
- A Taste of FoBiS.py
- fobos: the FoBiS.py makefile
- FoBiS.py in action
- FAQ