fpm_manifest_feature Module

Implementation of the meta data for features.

A feature is a configurable set of package properties that can be conditionally enabled. Features allow fine-grained control over dependencies, compiler flags, preprocessor definitions, and other package components based on the target compiler and operating system.

Features are similar to Rust Cargo features but adapted for Fortran package management. Each feature can specify: - Compiler-specific flags and settings - Additional dependencies - Preprocessor definitions - Source files and build configurations

A feature table can currently have the following fields:

[features.mpi]
description = "Enable MPI parallel support"
compiler = "gfortran"
os = "linux" 
flags = "-fopenmp"
preprocessor = ["WITH_MPI"]
[features.mpi.dependencies]
mpi = { git = "https://github.com/fortran-lang/mpi" }


Interfaces

public interface unique_programs

  • private subroutine unique_programs1(executable, error)

    Check whether or not the names in a set of executables are unique

    Arguments

    Type IntentOptional Attributes Name
    class(executable_config_t), intent(in) :: executable(:)

    Array of executables

    type(error_t), intent(out), allocatable :: error

    Error handling

  • private subroutine unique_programs2(executable_i, executable_j, error)

    Check whether or not the names in a set of executables are unique

    Arguments

    Type IntentOptional Attributes Name
    class(executable_config_t), intent(in) :: executable_i(:)

    Array of executables

    class(executable_config_t), intent(in) :: executable_j(:)

    Array of executables

    type(error_t), intent(out), allocatable :: error

    Error handling


Derived Types

type, public, extends(serializable_t) ::  feature_config_t

Feature configuration data

Components

Type Visibility Attributes Name Initial
type(build_config_t), public, allocatable :: build

Build configuration

character(len=:), public, allocatable :: c_flags
character(len=:), public, allocatable :: cxx_flags
logical, public :: default = .false.

Is this feature enabled by default

type(dependency_config_t), public, allocatable :: dependency(:)

Dependencies

character(len=:), public, allocatable :: description
type(dependency_config_t), public, allocatable :: dev_dependency(:)

Development dependencies

type(example_config_t), public, allocatable :: example(:)

Examples

type(executable_config_t), public, allocatable :: executable(:)

Executable configurations

character(len=:), public, allocatable :: flags

Compiler flags

type(fortran_config_t), public, allocatable :: fortran

Fortran configuration

type(install_config_t), public, allocatable :: install

Installation configuration

type(library_config_t), public, allocatable :: library

Library configuration

character(len=:), public, allocatable :: link_time_flags
type(metapackage_config_t), public :: meta

Metapackage data

character(len=:), public, allocatable :: name

Feature identity

type(platform_config_t), public :: platform

Compiler/OS targeting (consistent with profile_config_t pattern)

type(preprocess_config_t), public, allocatable :: preprocess(:)

Preprocessor configuration

type(string_t), public, allocatable :: requires_features(:)

Feature dependencies

type(test_config_t), public, allocatable :: test(:)

Tests

Type-Bound Procedures

procedure, public, nopass :: check

Check validity of the TOML table

generic, public :: dump => dump_to_toml, dump_to_file, dump_to_unit
procedure, public :: dump_to_toml
procedure, public :: info

Print information on this instance

generic, public :: load => load_from_toml, load_from_file, load_from_unit
procedure, public :: load_from_toml
procedure, public :: manifest_name

Get manifest name

generic, public :: operator(==) => serializable_is_same
procedure, public :: serializable_is_same => feature_is_same

Serialization interface

procedure, public, non_overridable :: test_serialization

Test load/write roundtrip


Subroutines

public subroutine find_feature(features, feature_name, current_platform, found, chosen_feature)

Find matching feature configuration (similar to find_profile)

Arguments

Type IntentOptional Attributes Name
type(feature_config_t), intent(in), allocatable :: features(:)
character(len=*), intent(in) :: feature_name
type(platform_config_t), intent(in) :: current_platform
logical, intent(out) :: found
type(feature_config_t), intent(out) :: chosen_feature

public subroutine init_feature_components(self, table, platform, root, error)

Initialize the feature components (shared between new_feature and new_package)

Arguments

Type IntentOptional Attributes Name
type(feature_config_t), intent(inout) :: self
type(toml_table), intent(inout) :: table
type(platform_config_t), intent(in), optional :: platform
character(len=*), intent(in), optional :: root
type(error_t), intent(out), allocatable :: error

public subroutine new_feature(self, table, root, error, name)

Construct a new feature configuration from a TOML data structure

Arguments

Type IntentOptional Attributes Name
type(feature_config_t), intent(out) :: self

Instance of the feature configuration

type(toml_table), intent(inout) :: table

Instance of the TOML data structure

character(len=*), intent(in), optional :: root

Root directory of the manifest

type(error_t), intent(out), allocatable :: error

Error handling

character(len=*), intent(in), optional :: name

Optional name override (if not provided, gets from table key)

public subroutine new_features(features, table, root, error)

Construct new feature array from a TOML data structure

Arguments

Type IntentOptional Attributes Name
type(feature_config_t), intent(out), allocatable :: features(:)

Instance of the feature configuration array

type(toml_table), intent(inout) :: table

Instance of the TOML data structure

character(len=*), intent(in), optional :: root

Root directory of the manifest

type(error_t), intent(out), allocatable :: error

Error handling