Skip to content

Commit 932b93b

Browse files
authored
Merge pull request #224 from awvwgk/specs
Create a reference for the package manifest
2 parents cac3954 + fcb816b commit 932b93b

File tree

2 files changed

+363
-1
lines changed

2 files changed

+363
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,5 @@ to run, as can `fpm test`; like `fpm run specific_executable`. Command line
8181
arguments can also be passed to the executable(s) or test(s) with the option
8282
`--args "some arguments"`.
8383

84-
See additional instructions in the [Packaging guide](PACKAGING.md).
84+
See additional instructions in the [Packaging guide](PACKAGING.md) or
85+
the [manifest reference](manifest-reference.md).

manifest-reference.md

Lines changed: 361 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,361 @@
1+
# Fortran package manager (fpm) manifest reference
2+
3+
The ``fpm.toml`` file for each project is called its *manifest*.
4+
It is written using the [TOML] format.
5+
Every manifest file consists of the following sections:
6+
7+
- [*name*](#project-name):
8+
The name of the project
9+
- [*version*](#project-version):
10+
The version of the project
11+
- [*license*](#project-license):
12+
The project license
13+
- [*maintainer*](#project-maintainer):
14+
Maintainer of the project
15+
- [*author*](#project-author):
16+
Author of the project
17+
- [*copyright*](#project-copyright):
18+
Copyright of the project
19+
- [*description*](#project-description):
20+
Description of the project
21+
- [*categories*](#project-categories):
22+
Categories associated with the project
23+
- [*keywords*](#project-keywords):
24+
Keywords describing the project
25+
- [*homepage*](#project-homepage):
26+
The project's homepage
27+
- Build configuration:
28+
- [*auto-tests*](#automatic-target-discovery):
29+
Toggle automatic discovery of test executables
30+
- [*auto-executables*](#automatic-target-discovery):
31+
Toggle automatic discovery of executables
32+
- Target sections:
33+
- [*library*](#library-configuration)
34+
Configuration of the library target
35+
- [*executable*](#executable-targets)
36+
Configuration of the executable targets
37+
- [*test*](#test-targets)
38+
Configuration of the test targets
39+
- Dependency sections:
40+
- [*dependencies*](#specifying-dependencies):
41+
Project library dependencies
42+
- [*dev-dependencies*](#development-dependencies):
43+
Dependencies only needed for tests
44+
45+
[TOML]: https://toml.io/
46+
47+
48+
## Project name
49+
50+
The project name identifies the package and is used to refer to it.
51+
It is used when listing the project as dependency for another package and the default name of the library and executable target.
52+
Therefore, the project name must always be present.
53+
54+
*Example:*
55+
56+
```toml
57+
name = "hello_world"
58+
```
59+
60+
61+
## Project version
62+
63+
The version number of the project is specified as string.
64+
A standardized way to manage and specify versions is the [Semantic Versioning] scheme.
65+
66+
*Example:*
67+
68+
```toml
69+
version = "1.0.0"
70+
```
71+
72+
[Semantic Versioning]: https://semver.org
73+
74+
75+
## Project license
76+
77+
The project license field contains the license identifier.
78+
A standardized way to specify licensing information are [SPDX] identifiers.
79+
80+
*Examples:*
81+
82+
Projects licensed under the [GNU Lesser General Public License](https://www.gnu.org/licenses/lgpl-3.0-standalone.html), either version 3 or any later version, is specified as
83+
84+
```toml
85+
license = "LGPL-3.0-or-later"
86+
```
87+
88+
Dual licensed project under the [Apache license, version 2.0](http://www.apache.org/licenses/LICENSE-2.0) or the [MIT license](https://opensource.org/licenses/MIT) are specified as
89+
90+
```toml
91+
license = "Apache-2.0 OR MIT"
92+
```
93+
94+
[SPDX]: https://spdx.org/licenses/
95+
96+
97+
## Project maintainer
98+
99+
Information on the project maintainer and means to reach out to them.
100+
101+
*Example:*
102+
103+
```toml
104+
maintainer = "[email protected]"
105+
```
106+
107+
108+
## Project author
109+
110+
Information on the project author.
111+
112+
*Example:*
113+
114+
```toml
115+
author = "Jane Doe"
116+
```
117+
118+
119+
## Project copyright
120+
121+
A statement clarifying the copyright status of the project.
122+
123+
*Example:*
124+
125+
```toml
126+
copyright = "Copyright 2020 Jane Doe"
127+
```
128+
129+
130+
## Project description
131+
132+
The decription provides a short summary on the project.
133+
It should be plain text and not using any markup formatting.
134+
135+
*Example:*
136+
137+
```toml
138+
description = "A short summary on this project"
139+
```
140+
141+
142+
## Project categories
143+
144+
The project can be associated with different categories.
145+
146+
*Example:*
147+
148+
```toml
149+
categories = ["io"]
150+
```
151+
152+
153+
## Project keywords
154+
155+
The keywords field is an array of strings describing the project.
156+
157+
*Example:*
158+
159+
```toml
160+
keywords = ["hdf5", "mpi"]
161+
```
162+
163+
164+
## Project homepage
165+
166+
URL to the webpage of the project.
167+
168+
*Example:*
169+
170+
```toml
171+
homepage = "https://stdlib.fortran-lang.org"
172+
```
173+
174+
175+
## Project targets
176+
177+
Every fpm project can define library, executable and test targets.
178+
Library targets are exported and useable for other projects.
179+
180+
181+
### Library configuration
182+
183+
Defines the exported library target of the project.
184+
A library is generated if the source directory is found in a project.
185+
The default source directory is ``src`` but can be modifed in the *library* section using the *source-dir* entry.
186+
Paths for the source directory are given relative to the project root and use ``/`` as path separator on all platforms.
187+
188+
*Example:*
189+
190+
```toml
191+
[library]
192+
source-dir = "lib"
193+
```
194+
195+
#### Custom build script
196+
197+
> Supported in Bootstrap fpm only
198+
199+
Projects with custom build scripts can specify those in the *build-script* entry.
200+
The custom build script will be executeted when the library build step is reached.
201+
202+
*Example:*
203+
204+
```toml
205+
[library]
206+
build-script = "build.sh"
207+
```
208+
209+
Build scripts written in ``make`` are automatically detected and executed with ``make``
210+
211+
```toml
212+
[library]
213+
build-script = "Makefile"
214+
```
215+
216+
217+
### Executable targets
218+
219+
Executable targets are Fortran programs defined as *executable* sections.
220+
If no executable section is specified the ``app`` directory is searched for program definitions.
221+
For explicitly specified executables the *name* entry must always be specified.
222+
The source directory for each executable can be adjusted in the *source-dir* entry.
223+
Paths for the source directory are given relative to the project root and use ``/`` as path separator on all platforms.
224+
The source file containing the program body can be specified in the *main* entry.
225+
226+
Executables can have their own dependencies.
227+
See [specifying dependencies](#specifying-dependencies) for more details.
228+
229+
> Dependencies supported in Bootstrap fpm only
230+
231+
*Example:*
232+
233+
```toml
234+
[[executable]]
235+
name = "app-name"
236+
source-dir = "prog"
237+
main = "program.f90"
238+
239+
[[executable]]
240+
name = "app-tool"
241+
[executable.dependencies]
242+
helloff = { git = "https://gitlab.com/everythingfunctional/helloff.git" }
243+
```
244+
245+
Specifying many separate executables can be done by using inline tables for brevity instead
246+
247+
```toml
248+
executable = [
249+
{ name = "a-prog" },
250+
{ name = "app-tool", source-dir = "tool" },
251+
]
252+
```
253+
254+
255+
### Test targets
256+
257+
Test targets are Fortran programs defined as *test* sections.
258+
They follow similar rules as the executable targets.
259+
If no test section is specified the ``test`` directory is searched for program definitions.
260+
For explicitly specified tests the *name* entry must always be specified.
261+
The source directory for each test can be adjusted in the *source-dir* entry.
262+
Paths for the source directory are given relative to the project root and use ``/`` as path separator on all platforms.
263+
The source file containing the program body can be specified in the *main* entry.
264+
265+
Tests can have their own dependencies.
266+
See [specifying dependencies](#specifying-dependencies) for more details.
267+
268+
> Dependencies supported in Bootstrap fpm only
269+
270+
*Example:*
271+
272+
```toml
273+
[[test]]
274+
name = "test-name"
275+
source-dir = "testing"
276+
main = "tester.F90"
277+
278+
[[test]]
279+
name = "tester"
280+
[test.dependencies]
281+
helloff = { git = "https://gitlab.com/everythingfunctional/helloff.git" }
282+
```
283+
284+
285+
## Automatic target discovery
286+
287+
> Supported in Fortran fpm only
288+
289+
Executables and test can be discovered automatically in their default directories.
290+
The automatic discovery recursively searches the ``app`` and ``test`` directories for ``program`` definitions and declares them as executable and test targets, respectively.
291+
The automatic discovery is enabled by default.
292+
293+
To disable the automatic discovery of targets set the *auto-executables* and *auto-tests* entry to *false*.
294+
295+
```toml
296+
[build]
297+
auto-executables = false
298+
auto-tests = false
299+
```
300+
301+
302+
## Specifying dependencies
303+
304+
Dependencies can be declared in the *dependencies* table in the manifest root or the [*executable*](#executable-targets) or [*test*](#test-targets) sections.
305+
When declared in the manifest root the dependencies are exported with the project.
306+
307+
308+
### Local dependencies
309+
310+
To declare local dependencies use the *path* entry.
311+
312+
```toml
313+
[dependencies]
314+
my-utils = { path = "utils" }
315+
```
316+
317+
Local dependency paths are given relative to the project root and use ``/`` as path separator on all platforms.
318+
319+
320+
### Dependencies from version control systems
321+
322+
Dependencies can be specified by the projects git repository.
323+
324+
```toml
325+
[dependencies]
326+
toml-f = { git = "https://github.com/toml-f/toml-f" }
327+
```
328+
329+
To use a specific upstream branch declare the *branch* name with
330+
331+
```toml
332+
[dependencies]
333+
toml-f = { git = "https://github.com/toml-f/toml-f", branch = "master" }
334+
```
335+
336+
Alternatively, reference tags by using the *tag* entry
337+
338+
```toml
339+
[dependencies]
340+
toml-f = { git = "https://github.com/toml-f/toml-f", tag = "v0.2.1" }
341+
```
342+
343+
To pin a specific revision specify the commit hash in the *rev* entry
344+
345+
```toml
346+
[dependencies]
347+
toml-f = { git = "https://github.com/toml-f/toml-f", rev = "2f5eaba" }
348+
```
349+
350+
For more verbose layout use normal tables rather than inline tables to specify dependencies
351+
352+
```toml
353+
[dependencies]
354+
[dependencies.toml-f]
355+
git = "https://github.com/toml-f/toml-f"
356+
rev = "2f5eaba864ff630ba0c3791126a3f811b6e437f3"
357+
```
358+
359+
### Development dependencies
360+
361+
Development dependencies allow to declare *dev-dependencies* in the manifest root, which are available to all tests but not exported with the project.

0 commit comments

Comments
 (0)