fpm_backend Module

Build backend

Uses a list of [[build_target_ptr]] and a valid [[fpm_model]] instance to schedule and execute the compilation and linking of package targets.

The package build process ([[build_package]]) comprises three steps:

  1. Target sorting: topological sort of the target dependency graph ([[sort_target]])
  2. Target scheduling: group targets into schedule regions based on the sorting ([[schedule_targets]])
  3. Target building: generate targets by compilation or linking

@note Note If compiled with OpenMP, targets will be build in parallel where possible.

Incremental compilation

The backend process supports incremental compilation whereby targets are not re-compiled if their corresponding dependencies have not been modified.

Targets (objects, executables and libraries) are not re-compiled if the target output file already exists AND its inputs are unmodified since it was last generated AND all of the target dependencies are not marked for re-compilation

The inputs of a target are summarised by a digest (hash) of its source file, if any, and of the digests of its dependencies. Source file digests are calculated during the source parsing phase (fpm_source_parsing); target digests are cached to disk after a target is successfully generated.



Subroutines

public subroutine build_package(targets, model, verbose, dry_run, jobs)

Top-level routine to build package described by model

Arguments

Type IntentOptional Attributes Name
type(build_target_ptr), intent(inout) :: targets(:)
type(fpm_model_t), intent(in) :: model
logical, intent(in) :: verbose
logical, intent(in) :: dry_run

If dry_run, the build process is only mocked, but the list of compile_commands is still created

integer, intent(in), optional :: jobs

Number of targets to build at once (–jobs): 0 or absent uses the OpenMP default

public subroutine schedule_targets(queue, schedule_ptr, targets)

Construct a build schedule from the sorted targets.

Read more…

Arguments

Type IntentOptional Attributes Name
type(build_target_ptr), intent(out), allocatable :: queue(:)
integer, allocatable :: schedule_ptr(:)
type(build_target_ptr), intent(in) :: targets(:)

public recursive subroutine sort_target(target, mock)

Topologically sort a target for scheduling by recursing over its dependencies.

Read more…

Arguments

Type IntentOptional Attributes Name
type(build_target_t), intent(inout), target :: target
logical, intent(in), optional :: mock

Optionally sort ALL targets if this is a dry run