Skip to content

Autorebuild when external linked libraries change

Stefano Zaghi edited this page Feb 18, 2015 · 3 revisions

The volatile libraries dependency

A helpful (thanks Jacob and Tomas) feature is to automatically (re-)compile your project when an external linked library changes. By default, FoBiS.py decides if the (re-)compiling is necessary only on the basis of the time-stamp correlation between sources and compiled object, but for a compiled object such as an external library this check cannot be done. However, you can trigger the automatic re-compilation setting those libraries as volatile by means of the -vlibs switch (or the equivalent fobos option).

Let us assume we have a project depending on an external library that we know it can change suddenly. We want FoBiS.py to automatically re-compile all whenever that library changes. To this aim we can run FoBiS.py as

FoBiS.py build -vlibs my_oscillating_library.a -cflags ...

The first time FoBiS.py saves into the building directory a file containing the hash of the just used library, namely .my_oscillating_library.a.md5. In the following buildings the re-compilation is automatically triggered if the my_oscillating_library.a changes because the old hash and the actual one differ. Obviously, the hash contains always the hash of the last library linked.

It is worth noting that the same volatile specification can be attributed also to the external library linked via the -L and -l switches. In this case the invocation is something similar to

FoBiS.py build -ext_vlibs my_oscillating_library --lib_dir my_library_path -cflags ...

Note that in this case the library name does not contain the extension and also that the actual name of the library contained into my_library_path must have the prefix lib, it being libmy_oscillating_library.[a|so].

It is worth noting that this auto-re-building mechanism is available also into the fobos file definition as all other command line options

[default]
cflags    = ...
vlibs     =  ./path_to/my_first_oscillating_library.a
lib_dir   = ./path_where_is_my_second_lib
ext_vlibs =  my_second_oscillating_library
...

There are some specific examples into the examples directory.

Clone this wiki locally