Respresentation of a projects dependencies
The dependencies are stored in a simple array for now, this can be replaced with a binary-search tree or a hash table in the future.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
character(len=:), | public, | allocatable | :: | cache |
Cache file |
||
type(dependency_node_t), | public, | allocatable | :: | dep(:) |
Flattend list of all dependencies |
||
character(len=:), | public, | allocatable | :: | dep_dir |
Installation prefix for dependencies |
||
integer, | public | :: | ndep | = | 0 |
Number of currently registered dependencies |
|
integer, | public | :: | unit | = | output_unit |
Unit for IO |
|
integer, | public | :: | verbosity | = | 1 |
Verbosity of printout |
Overload procedure to add new dependencies to the tree
Add project dependencies, each depth level after each other.
We implement this algorithm in an interative rather than a recursive fashion as a choice of design.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(dependency_tree_t), | intent(inout) | :: | self |
Instance of the dependency tree |
||
type(package_config_t), | intent(in) | :: | package |
Project configuration to add |
||
type(error_t), | intent(out), | allocatable | :: | error |
Error handling |
Add a project and its dependencies to the dependency tree
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(dependency_tree_t), | intent(inout) | :: | self |
Instance of the dependency tree |
||
type(package_config_t), | intent(in) | :: | package |
Project configuration to add |
||
character(len=*), | intent(in) | :: | root |
Current project root directory |
||
logical, | intent(in) | :: | main |
Is the main project |
||
type(error_t), | intent(out), | allocatable | :: | error |
Error handling |
Add a list of dependencies to the dependency tree
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(dependency_tree_t), | intent(inout) | :: | self |
Instance of the dependency tree |
||
type(dependency_config_t), | intent(in) | :: | dependency(:) |
Dependency configuration to add |
||
type(error_t), | intent(out), | allocatable | :: | error |
Error handling |
Add a single dependency to the dependency tree
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(dependency_tree_t), | intent(inout) | :: | self |
Instance of the dependency tree |
||
type(dependency_config_t), | intent(in) | :: | dependency |
Dependency configuration to add |
||
type(error_t), | intent(out), | allocatable | :: | error |
Error handling |
Add a single dependency node to the dependency tree Dependency nodes contain additional information (version, git, revision)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(dependency_tree_t), | intent(inout) | :: | self |
Instance of the dependency tree |
||
type(dependency_node_t), | intent(in) | :: | dependency |
Dependency configuration to add |
||
type(error_t), | intent(out), | allocatable | :: | error |
Error handling |
Writing of dependency tree
Write dependency tree to file
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(dependency_tree_t), | intent(inout) | :: | self |
Instance of the dependency tree |
||
character(len=*), | intent(in) | :: | file |
File name |
||
type(error_t), | intent(out), | allocatable | :: | error |
Error handling |
Write dependency tree to file
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(dependency_tree_t), | intent(inout) | :: | self |
Instance of the dependency tree |
||
integer, | intent(in) | :: | unit |
Formatted unit |
||
type(error_t), | intent(out), | allocatable | :: | error |
Error handling |
Write dependency tree to TOML datastructure
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(dependency_tree_t), | intent(inout) | :: | self |
Instance of the dependency tree |
||
type(toml_table), | intent(inout) | :: | table |
Data structure |
||
type(error_t), | intent(out), | allocatable | :: | error |
Error handling |
Find a dependency in the tree
Find a dependency in the dependency tree
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(dependency_tree_t), | intent(in) | :: | self |
Instance of the dependency tree |
||
character(len=*), | intent(in) | :: | name |
Dependency configuration to add |
Index of the dependency
Depedendncy resolution finished
Check if we are done with the dependency resolution
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(dependency_tree_t), | intent(in) | :: | self |
Instance of the dependency tree |
All dependencies are updated
True if entity can be found
True if dependency is part of the tree
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(dependency_tree_t), | intent(in) | :: | self |
Instance of the dependency tree |
||
class(dependency_node_t), | intent(in) | :: | dependency |
Dependency configuration to check |
Reading of dependency tree
Read dependency tree from file
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(dependency_tree_t), | intent(inout) | :: | self |
Instance of the dependency tree |
||
character(len=*), | intent(in) | :: | file |
File name |
||
type(error_t), | intent(out), | allocatable | :: | error |
Error handling |
Read dependency tree from file
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(dependency_tree_t), | intent(inout) | :: | self |
Instance of the dependency tree |
||
integer, | intent(in) | :: | unit |
File name |
||
type(error_t), | intent(out), | allocatable | :: | error |
Error handling |
Read dependency tree from TOML data structure
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(dependency_tree_t), | intent(inout) | :: | self |
Instance of the dependency tree |
||
type(toml_table), | intent(inout) | :: | table |
Data structure |
||
type(error_t), | intent(out), | allocatable | :: | error |
Error handling |
Resolve dependencies
Resolve all dependencies in the tree
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(dependency_tree_t), | intent(inout) | :: | self |
Instance of the dependency tree |
||
character(len=*), | intent(in) | :: | root |
Current installation prefix |
||
type(error_t), | intent(out), | allocatable | :: | error |
Error handling |
Resolve a single dependency node
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(dependency_tree_t), | intent(inout) | :: | self |
Instance of the dependency tree |
||
type(dependency_node_t), | intent(inout) | :: | dependency |
Dependency configuration to add |
||
type(fpm_global_settings), | intent(in) | :: | global_settings |
Global configuration settings. |
||
character(len=*), | intent(in) | :: | root |
Current installation prefix |
||
type(error_t), | intent(out), | allocatable | :: | error |
Error handling |
Update dependency tree
Update dependency tree
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(dependency_tree_t), | intent(inout) | :: | self |
Instance of the dependency tree |
||
character(len=*), | intent(in) | :: | name |
Name of the dependency to update |
||
type(error_t), | intent(out), | allocatable | :: | error |
Error handling |
Update whole dependency tree
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(dependency_tree_t), | intent(inout) | :: | self |
Instance of the dependency tree |
||
type(error_t), | intent(out), | allocatable | :: | error |
Error handling |
type :: dependency_tree_t
!> Unit for IO
integer :: unit = output_unit
!> Verbosity of printout
integer :: verbosity = 1
!> Installation prefix for dependencies
character(len=:), allocatable :: dep_dir
!> Number of currently registered dependencies
integer :: ndep = 0
!> Flattend list of all dependencies
type(dependency_node_t), allocatable :: dep(:)
!> Cache file
character(len=:), allocatable :: cache
contains
!> Overload procedure to add new dependencies to the tree
generic :: add => add_project, add_project_dependencies, add_dependencies, &
add_dependency, add_dependency_node
!> Main entry point to add a project
procedure, private :: add_project
!> Add a project and its dependencies to the dependency tree
procedure, private :: add_project_dependencies
!> Add a list of dependencies to the dependency tree
procedure, private :: add_dependencies
!> Add a single dependency to the dependency tree
procedure, private :: add_dependency
!> Add a single dependency node to the dependency tree
procedure, private :: add_dependency_node
!> Resolve dependencies
generic :: resolve => resolve_dependencies, resolve_dependency
!> Resolve dependencies
procedure, private :: resolve_dependencies
!> Resolve dependency
procedure, private :: resolve_dependency
!> True if entity can be found
generic :: has => has_dependency
!> True if dependency is part of the tree
procedure, private :: has_dependency
!> Find a dependency in the tree
generic :: find => find_name
!> Find a dependency by its name
procedure, private :: find_name
!> Depedendncy resolution finished
procedure :: finished
!> Reading of dependency tree
generic :: load => load_from_file, load_from_unit, load_from_toml
!> Read dependency tree from file
procedure, private :: load_from_file
!> Read dependency tree from formatted unit
procedure, private :: load_from_unit
!> Read dependency tree from TOML data structure
procedure, private :: load_from_toml
!> Writing of dependency tree
generic :: dump => dump_to_file, dump_to_unit, dump_to_toml
!> Write dependency tree to file
procedure, private :: dump_to_file
!> Write dependency tree to formatted unit
procedure, private :: dump_to_unit
!> Write dependency tree to TOML data structure
procedure, private :: dump_to_toml
!> Update dependency tree
generic :: update => update_dependency, update_tree
!> Update a list of dependencies
procedure, private :: update_dependency
!> Update all dependencies in the tree
procedure, private :: update_tree
end type dependency_tree_t