diff options
-rw-r--r-- | manifest-reference.md | 23 | ||||
-rw-r--r-- | src/fpm.f90 | 7 | ||||
-rw-r--r-- | src/fpm/cmd/new.f90 | 3 | ||||
-rw-r--r-- | src/fpm/cmd/update.f90 | 3 | ||||
-rw-r--r-- | src/fpm/manifest/build.f90 | 6 | ||||
-rw-r--r-- | src/fpm/manifest/example.f90 | 4 | ||||
-rw-r--r-- | src/fpm/manifest/executable.f90 | 4 | ||||
-rw-r--r-- | src/fpm/manifest/library.f90 | 4 | ||||
-rw-r--r-- | src/fpm/manifest/package.f90 | 3 | ||||
-rw-r--r-- | src/fpm/manifest/test.f90 | 4 | ||||
-rw-r--r-- | src/fpm/toml.f90 | 11 | ||||
-rw-r--r-- | src/fpm_command_line.f90 | 7 |
12 files changed, 49 insertions, 30 deletions
diff --git a/manifest-reference.md b/manifest-reference.md index 0a68c6a..d97f32c 100644 --- a/manifest-reference.md +++ b/manifest-reference.md @@ -49,6 +49,8 @@ Every manifest file consists of the following sections: Dependencies only needed for tests - [*install*](#installation-configuration): Installation configuration +- [*extra*](#additional-free-data-field): + Additional free data field [TOML]: https://toml.io/ @@ -479,3 +481,24 @@ By default only executables are installed, library projects can set the *library [install] library = true ``` + + +## Additional free data field + +Third-party tools can store their configuration inside the *extra* section. +This section will never be evaluated by fpm itself, the only constraint imposed is that it has to be valid TOML. + +Since the format of this section is free, only recommendations are provided here for adding data to the *extra* section. + +1. Only use subtables, never add configuration data to the top level of the *extra* section. + Reasoning: different tools can avoid collisions of key names by placing their data in separate subtables. +2. Use the concrete name of the tool rather than a generic name for the subtable. + Reasoning: different formatter or linter tools might use conflicting keywords in a *format* or *lint* subtable. + Also, users can tell from the table name which tool is preferred to use with the project. +3. Fpm plugins should use a subtable with their plugin name in the *extra.fpm* section to store their data. + Reasoning: following this convention provides the user of fpm plugins with one section to configure their used plugins. +4. Use the fpm preferred style for keywords which is lowercase with dashes. + 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. + +Feedback for the recommendations above is very much welcome. +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). diff --git a/src/fpm.f90 b/src/fpm.f90 index 36f63d8..7208abf 100644 --- a/src/fpm.f90 +++ b/src/fpm.f90 @@ -5,7 +5,7 @@ use fpm_command_line, only: fpm_build_settings, fpm_new_settings, & fpm_run_settings, fpm_install_settings, fpm_test_settings use fpm_dependency, only : new_dependency_tree use fpm_environment, only: run, get_env -use fpm_filesystem, only: is_dir, join_path, number_of_rows, list_files, exists, basename +use fpm_filesystem, only: is_dir, join_path, number_of_rows, list_files, exists, basename, filewrite, mkdir use fpm_model, only: fpm_model_t, srcfile_t, show_model, & FPM_SCOPE_UNKNOWN, FPM_SCOPE_LIB, FPM_SCOPE_DEP, & FPM_SCOPE_APP, FPM_SCOPE_EXAMPLE, FPM_SCOPE_TEST @@ -55,6 +55,11 @@ subroutine build_model(model, settings, package, error) call model%deps%add(package, error) if (allocated(error)) return + ! build/ directory should now exist + if (.not.exists("build/.gitignore")) then + call filewrite(join_path("build", ".gitignore"),["*"]) + end if + call new_compiler(model%compiler, settings%compiler) call new_archiver(model%archiver) diff --git a/src/fpm/cmd/new.f90 b/src/fpm/cmd/new.f90 index 81cf62f..0afe651 100644 --- a/src/fpm/cmd/new.f90 +++ b/src/fpm/cmd/new.f90 @@ -98,9 +98,6 @@ character(len=:,kind=tfc),allocatable :: littlefile(:) ! like realpath() or getcwd(). bname=basename(settings%name) - ! create NAME/.gitignore file - call warnwrite(join_path(settings%name, '.gitignore'), ['build/*']) - littlefile=[character(len=80) :: '# '//bname, 'My cool new project!'] ! create NAME/README.md diff --git a/src/fpm/cmd/update.f90 b/src/fpm/cmd/update.f90 index aa99ca3..a9918bf 100644 --- a/src/fpm/cmd/update.f90 +++ b/src/fpm/cmd/update.f90 @@ -2,7 +2,7 @@ module fpm_cmd_update use fpm_command_line, only : fpm_update_settings use fpm_dependency, only : dependency_tree_t, new_dependency_tree use fpm_error, only : error_t, fpm_stop - use fpm_filesystem, only : exists, mkdir, join_path, delete_file + use fpm_filesystem, only : exists, mkdir, join_path, delete_file, filewrite use fpm_manifest, only : package_config_t, get_package_data implicit none private @@ -26,6 +26,7 @@ contains if (.not.exists("build")) then call mkdir("build") + call filewrite(join_path("build", ".gitignore"),["*"]) end if cache = join_path("build", "cache.toml") diff --git a/src/fpm/manifest/build.f90 b/src/fpm/manifest/build.f90 index c9b3f44..b24cf43 100644 --- a/src/fpm/manifest/build.f90 +++ b/src/fpm/manifest/build.f90 @@ -12,7 +12,7 @@ module fpm_manifest_build use fpm_error, only : error_t, syntax_error, fatal_error use fpm_strings, only : string_t - use fpm_toml, only : toml_table, toml_key, toml_stat, get_value + use fpm_toml, only : toml_table, toml_key, toml_stat, get_value, get_list implicit none private @@ -87,10 +87,10 @@ contains end if - call get_value(table, "link", self%link, error) + call get_list(table, "link", self%link, error) if (allocated(error)) return - call get_value(table, "external-modules", self%external_modules, error) + call get_list(table, "external-modules", self%external_modules, error) if (allocated(error)) return end subroutine new_build_config diff --git a/src/fpm/manifest/example.f90 b/src/fpm/manifest/example.f90 index 3319401..0b1a5a2 100644 --- a/src/fpm/manifest/example.f90 +++ b/src/fpm/manifest/example.f90 @@ -18,7 +18,7 @@ module fpm_manifest_example use fpm_manifest_dependency, only : dependency_config_t, new_dependencies use fpm_manifest_executable, only : executable_config_t use fpm_error, only : error_t, syntax_error, bad_name_error - use fpm_toml, only : toml_table, toml_key, toml_stat, get_value + use fpm_toml, only : toml_table, toml_key, toml_stat, get_value, get_list implicit none private @@ -73,7 +73,7 @@ contains if (allocated(error)) return end if - call get_value(table, "link", self%link, error) + call get_list(table, "link", self%link, error) if (allocated(error)) return end subroutine new_example diff --git a/src/fpm/manifest/executable.f90 b/src/fpm/manifest/executable.f90 index e81ab8e..3a018ec 100644 --- a/src/fpm/manifest/executable.f90 +++ b/src/fpm/manifest/executable.f90 @@ -14,7 +14,7 @@ module fpm_manifest_executable use fpm_manifest_dependency, only : dependency_config_t, new_dependencies use fpm_error, only : error_t, syntax_error, bad_name_error use fpm_strings, only : string_t - use fpm_toml, only : toml_table, toml_key, toml_stat, get_value + use fpm_toml, only : toml_table, toml_key, toml_stat, get_value, get_list implicit none private @@ -84,7 +84,7 @@ contains if (allocated(error)) return end if - call get_value(table, "link", self%link, error) + call get_list(table, "link", self%link, error) if (allocated(error)) return end subroutine new_executable diff --git a/src/fpm/manifest/library.f90 b/src/fpm/manifest/library.f90 index c8ce049..68ccc20 100644 --- a/src/fpm/manifest/library.f90 +++ b/src/fpm/manifest/library.f90 @@ -11,7 +11,7 @@ module fpm_manifest_library use fpm_error, only : error_t, syntax_error use fpm_strings, only: string_t, string_cat - use fpm_toml, only : toml_table, toml_key, toml_stat, get_value + use fpm_toml, only : toml_table, toml_key, toml_stat, get_value, get_list implicit none private @@ -59,7 +59,7 @@ contains call get_value(table, "source-dir", self%source_dir, "src") call get_value(table, "build-script", self%build_script) - call get_value(table, "include-dir", self%include_dir, error) + call get_list(table, "include-dir", self%include_dir, error) if (allocated(error)) return ! Set default value of include-dir if not found in manifest diff --git a/src/fpm/manifest/package.f90 b/src/fpm/manifest/package.f90 index dba4d21..5cd8765 100644 --- a/src/fpm/manifest/package.f90 +++ b/src/fpm/manifest/package.f90 @@ -29,6 +29,7 @@ !>[[ executable ]] !>[[ example ]] !>[[ test ]] +!>[extra] !>``` module fpm_manifest_package use fpm_manifest_build, only: build_config_t, new_build_config @@ -303,7 +304,7 @@ contains case("version", "license", "author", "maintainer", "copyright", & & "description", "keywords", "categories", "homepage", "build", & & "dependencies", "dev-dependencies", "test", "executable", & - & "example", "library", "install") + & "example", "library", "install", "extra") continue end select diff --git a/src/fpm/manifest/test.f90 b/src/fpm/manifest/test.f90 index e689774..258d639 100644 --- a/src/fpm/manifest/test.f90 +++ b/src/fpm/manifest/test.f90 @@ -18,7 +18,7 @@ module fpm_manifest_test use fpm_manifest_dependency, only : dependency_config_t, new_dependencies use fpm_manifest_executable, only : executable_config_t use fpm_error, only : error_t, syntax_error, bad_name_error - use fpm_toml, only : toml_table, toml_key, toml_stat, get_value + use fpm_toml, only : toml_table, toml_key, toml_stat, get_value, get_list implicit none private @@ -73,7 +73,7 @@ contains if (allocated(error)) return end if - call get_value(table, "link", self%link, error) + call get_list(table, "link", self%link, error) if (allocated(error)) return end subroutine new_test diff --git a/src/fpm/toml.f90 b/src/fpm/toml.f90 index dbaafcb..3b05229 100644 --- a/src/fpm/toml.f90 +++ b/src/fpm/toml.f90 @@ -22,16 +22,11 @@ module fpm_toml private public :: read_package_file - public :: toml_table, toml_array, toml_key, toml_stat, get_value, set_value + public :: toml_table, toml_array, toml_key, toml_stat, get_value, set_value, get_list public :: new_table, add_table, add_array, len public :: toml_error, toml_serializer, toml_parse - interface get_value - module procedure :: get_child_value_string_list - end interface get_value - - contains @@ -71,7 +66,7 @@ contains end subroutine read_package_file - subroutine get_child_value_string_list(table, key, list, error) + subroutine get_list(table, key, list, error) !> Instance of the TOML data structure type(toml_table), intent(inout) :: table @@ -114,7 +109,7 @@ contains end if end if - end subroutine get_child_value_string_list + end subroutine get_list end module fpm_toml diff --git a/src/fpm_command_line.f90 b/src/fpm_command_line.f90 index 90d7198..9c2da6b 100644 --- a/src/fpm_command_line.f90 +++ b/src/fpm_command_line.f90 @@ -921,14 +921,11 @@ contains ' o runs the command "git init" in that directory ', & ' o populates the directory with the default project directories ', & ' o adds sample Fortran source files ', & - ' o adds a ".gitignore" file for ignoring the build/ directory ', & - ' (where fpm-generated output will be placed) ', & ' ', & ' The default file structure (that will be automatically scanned) is ', & ' ', & ' NAME/ ', & ' fpm.toml ', & - ' .gitignore ', & ' src/ ', & ' NAME.f90 ', & ' app/ ', & @@ -989,8 +986,8 @@ contains ' depend extensively on non-default build options. ', & ' ', & ' --bare A minimal manifest file ("fpm.toml") is created and ', & - ' a ".gitignore" and "README.md" file is created but no ', & - ' directories or sample Fortran is generated. ', & + ' "README.md" file is created but no directories or ', & + ' sample Fortran are generated. ', & ' ', & ' --help print this help and exit ', & ' --version print program version information and exit ', & |