Skip to content

Commit 6f891ed

Browse files
authored
Merge branch 'master' into compiler-object
2 parents 6a90ad5 + d72d953 commit 6f891ed

File tree

12 files changed

+49
-30
lines changed

12 files changed

+49
-30
lines changed

manifest-reference.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ Every manifest file consists of the following sections:
4949
Dependencies only needed for tests
5050
- [*install*](#installation-configuration):
5151
Installation configuration
52+
- [*extra*](#additional-free-data-field):
53+
Additional free data field
5254

5355

5456
[TOML]: https://toml.io/
@@ -479,3 +481,24 @@ By default only executables are installed, library projects can set the *library
479481
[install]
480482
library = true
481483
```
484+
485+
486+
## Additional free data field
487+
488+
Third-party tools can store their configuration inside the *extra* section.
489+
This section will never be evaluated by fpm itself, the only constraint imposed is that it has to be valid TOML.
490+
491+
Since the format of this section is free, only recommendations are provided here for adding data to the *extra* section.
492+
493+
1. Only use subtables, never add configuration data to the top level of the *extra* section.
494+
Reasoning: different tools can avoid collisions of key names by placing their data in separate subtables.
495+
2. Use the concrete name of the tool rather than a generic name for the subtable.
496+
Reasoning: different formatter or linter tools might use conflicting keywords in a *format* or *lint* subtable.
497+
Also, users can tell from the table name which tool is preferred to use with the project.
498+
3. Fpm plugins should use a subtable with their plugin name in the *extra.fpm* section to store their data.
499+
Reasoning: following this convention provides the user of fpm plugins with one section to configure their used plugins.
500+
4. Use the fpm preferred style for keywords which is lowercase with dashes.
501+
Reasoning: while there is no style check in this section, a consistent style in the whole manifest will make it easier for the user to understand the whole package manifest.
502+
503+
Feedback for the recommendations above is very much welcome.
504+
If you have a tool that uses the *extra* section in the package manifest, feel free to post it in at the [fpm discussion board](https://github.com/fortran-lang/fpm/discussions).

src/fpm.f90

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module fpm
55
fpm_run_settings, fpm_install_settings, fpm_test_settings
66
use fpm_dependency, only : new_dependency_tree
77
use fpm_environment, only: run, get_env
8-
use fpm_filesystem, only: is_dir, join_path, number_of_rows, list_files, exists, basename
8+
use fpm_filesystem, only: is_dir, join_path, number_of_rows, list_files, exists, basename, filewrite, mkdir
99
use fpm_model, only: fpm_model_t, srcfile_t, show_model, &
1010
FPM_SCOPE_UNKNOWN, FPM_SCOPE_LIB, FPM_SCOPE_DEP, &
1111
FPM_SCOPE_APP, FPM_SCOPE_EXAMPLE, FPM_SCOPE_TEST
@@ -55,6 +55,11 @@ subroutine build_model(model, settings, package, error)
5555
call model%deps%add(package, error)
5656
if (allocated(error)) return
5757

58+
! build/ directory should now exist
59+
if (.not.exists("build/.gitignore")) then
60+
call filewrite(join_path("build", ".gitignore"),["*"])
61+
end if
62+
5863
call new_compiler(model%compiler, settings%compiler)
5964
call new_archiver(model%archiver)
6065

src/fpm/cmd/new.f90

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,6 @@ subroutine cmd_new(settings)
9898
! like realpath() or getcwd().
9999
bname=basename(settings%name)
100100

101-
! create NAME/.gitignore file
102-
call warnwrite(join_path(settings%name, '.gitignore'), ['build/*'])
103-
104101
littlefile=[character(len=80) :: '# '//bname, 'My cool new project!']
105102

106103
! create NAME/README.md

src/fpm/cmd/update.f90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module fpm_cmd_update
22
use fpm_command_line, only : fpm_update_settings
33
use fpm_dependency, only : dependency_tree_t, new_dependency_tree
44
use fpm_error, only : error_t, fpm_stop
5-
use fpm_filesystem, only : exists, mkdir, join_path, delete_file
5+
use fpm_filesystem, only : exists, mkdir, join_path, delete_file, filewrite
66
use fpm_manifest, only : package_config_t, get_package_data
77
implicit none
88
private
@@ -26,6 +26,7 @@ subroutine cmd_update(settings)
2626

2727
if (.not.exists("build")) then
2828
call mkdir("build")
29+
call filewrite(join_path("build", ".gitignore"),["*"])
2930
end if
3031

3132
cache = join_path("build", "cache.toml")

src/fpm/manifest/build.f90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
module fpm_manifest_build
1313
use fpm_error, only : error_t, syntax_error, fatal_error
1414
use fpm_strings, only : string_t
15-
use fpm_toml, only : toml_table, toml_key, toml_stat, get_value
15+
use fpm_toml, only : toml_table, toml_key, toml_stat, get_value, get_list
1616
implicit none
1717
private
1818

@@ -87,10 +87,10 @@ subroutine new_build_config(self, table, error)
8787
end if
8888

8989

90-
call get_value(table, "link", self%link, error)
90+
call get_list(table, "link", self%link, error)
9191
if (allocated(error)) return
9292

93-
call get_value(table, "external-modules", self%external_modules, error)
93+
call get_list(table, "external-modules", self%external_modules, error)
9494
if (allocated(error)) return
9595

9696
end subroutine new_build_config

src/fpm/manifest/example.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module fpm_manifest_example
1818
use fpm_manifest_dependency, only : dependency_config_t, new_dependencies
1919
use fpm_manifest_executable, only : executable_config_t
2020
use fpm_error, only : error_t, syntax_error, bad_name_error
21-
use fpm_toml, only : toml_table, toml_key, toml_stat, get_value
21+
use fpm_toml, only : toml_table, toml_key, toml_stat, get_value, get_list
2222
implicit none
2323
private
2424

@@ -73,7 +73,7 @@ subroutine new_example(self, table, error)
7373
if (allocated(error)) return
7474
end if
7575

76-
call get_value(table, "link", self%link, error)
76+
call get_list(table, "link", self%link, error)
7777
if (allocated(error)) return
7878

7979
end subroutine new_example

src/fpm/manifest/executable.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module fpm_manifest_executable
1414
use fpm_manifest_dependency, only : dependency_config_t, new_dependencies
1515
use fpm_error, only : error_t, syntax_error, bad_name_error
1616
use fpm_strings, only : string_t
17-
use fpm_toml, only : toml_table, toml_key, toml_stat, get_value
17+
use fpm_toml, only : toml_table, toml_key, toml_stat, get_value, get_list
1818
implicit none
1919
private
2020

@@ -84,7 +84,7 @@ subroutine new_executable(self, table, error)
8484
if (allocated(error)) return
8585
end if
8686

87-
call get_value(table, "link", self%link, error)
87+
call get_list(table, "link", self%link, error)
8888
if (allocated(error)) return
8989

9090
end subroutine new_executable

src/fpm/manifest/library.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
module fpm_manifest_library
1212
use fpm_error, only : error_t, syntax_error
1313
use fpm_strings, only: string_t, string_cat
14-
use fpm_toml, only : toml_table, toml_key, toml_stat, get_value
14+
use fpm_toml, only : toml_table, toml_key, toml_stat, get_value, get_list
1515
implicit none
1616
private
1717

@@ -59,7 +59,7 @@ subroutine new_library(self, table, error)
5959
call get_value(table, "source-dir", self%source_dir, "src")
6060
call get_value(table, "build-script", self%build_script)
6161

62-
call get_value(table, "include-dir", self%include_dir, error)
62+
call get_list(table, "include-dir", self%include_dir, error)
6363
if (allocated(error)) return
6464

6565
! Set default value of include-dir if not found in manifest

src/fpm/manifest/package.f90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
!>[[ executable ]]
3030
!>[[ example ]]
3131
!>[[ test ]]
32+
!>[extra]
3233
!>```
3334
module fpm_manifest_package
3435
use fpm_manifest_build, only: build_config_t, new_build_config
@@ -303,7 +304,7 @@ subroutine check(table, error)
303304
case("version", "license", "author", "maintainer", "copyright", &
304305
& "description", "keywords", "categories", "homepage", "build", &
305306
& "dependencies", "dev-dependencies", "test", "executable", &
306-
& "example", "library", "install")
307+
& "example", "library", "install", "extra")
307308
continue
308309

309310
end select

src/fpm/manifest/test.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module fpm_manifest_test
1818
use fpm_manifest_dependency, only : dependency_config_t, new_dependencies
1919
use fpm_manifest_executable, only : executable_config_t
2020
use fpm_error, only : error_t, syntax_error, bad_name_error
21-
use fpm_toml, only : toml_table, toml_key, toml_stat, get_value
21+
use fpm_toml, only : toml_table, toml_key, toml_stat, get_value, get_list
2222
implicit none
2323
private
2424

@@ -73,7 +73,7 @@ subroutine new_test(self, table, error)
7373
if (allocated(error)) return
7474
end if
7575

76-
call get_value(table, "link", self%link, error)
76+
call get_list(table, "link", self%link, error)
7777
if (allocated(error)) return
7878

7979
end subroutine new_test

0 commit comments

Comments
 (0)