7. An fpm project
A colleague writes a report generator with fpm. The lab's index serves them too: fobis add, run in a project with an fpm.toml and no fobos, writes into fpm.toml, and fpm fetches and builds the package.
toml
# a colleague's report generator, built with fpm
name = "report"
version = "0.1.0"
[build]
auto-tests = falsefortran
program report
!< A heading in upper case, with the lab's strings package.
use strings, only : upper
implicit none
print '(A)', upper('annual report')
end program reportWhat fpm can use
fpm builds only packages that have an fpm.toml. The index says which ones do:
console
$ fobis search --build fpm
lab:strings file://~/remotes/strings.git
Case conversion of stringsAdd, build, remove
console
$ cd ~/report && fobis add strings
Added strings = { git = "file://~/remotes/strings.git", tag = "v1.0.0" } in fpm.toml [dependencies]
fpm fetches it at the next fpm build.console
$ cat ~/report/fpm.toml
# a colleague's report generator, built with fpm
name = "report"
version = "0.1.0"
[build]
auto-tests = false
[dependencies]
# added by fobis add from index lab
strings = { git = "file://~/remotes/strings.git", tag = "v1.0.0" }console
$ cd ~/report && fpm run 2>/dev/null
ANNUAL REPORTA package without an fpm.toml at that version is refused, with the build systems it has:
console
$ cd ~/report && fobis add lab:kinds
Error: file://~/remotes/kinds.git has no fpm.toml at v2.0.0 (built with fobis): fpm cannot use it
[exit status 1]console
$ cd ~/report && fobis add cmath
Error: file://~/remotes/cmath.git has no fpm.toml at v1.0.0 (built with cmake): fpm cannot use it
[exit status 1]console
$ cd ~/report && fobis remove strings && cat fpm.toml
Removed strings = { git = "file://~/remotes/strings.git", tag = "v1.0.0" } from fpm.toml [dependencies]
# a colleague's report generator, built with fpm
name = "report"
version = "0.1.0"
[build]
auto-tests = false
[dependencies]- The newest tag is pinned exactly: fpm takes a
tag, arevor abranch, not a range.fobis add NAME --forcemoves to a newer one,--tagchooses another,--devwrites into[dev-dependencies]. - The name is the package's own: fpm requires the dependency's key to be the
nameof the package'sfpm.toml, soaddreads it there and refuses--as. - fpm does the rest: the package's own dependencies, its build and its lock are fpm's.
transitive,fetch,fobos.lock, mirrors andauditare FoBiS's and do not apply. - A project with both a fobos and an
fpm.tomlgets its fobos edited;--fpmchoosesfpm.toml.
This chapter needs fpm; its outputs are recorded where fpm is installed.
What you learned
fobis search --build fpm, fobis add and remove in an fpm project, why a package needs an fpm.toml for fpm. Reference: fpm projects.
This is the end of the packages track. The tutorials list the other tracks; the cookbook has a recipe for every package task.