cmd_export Subroutine

public subroutine cmd_export(settings)

Entry point for the export subcommand Read in manifest Export manifest Export dependency tree

Generate dependency tree Export dependency tree Export full model

Arguments

Type IntentOptional Attributes Name
type(fpm_export_settings), intent(inout) :: settings

Representation of the command line arguments


Source Code

  subroutine cmd_export(settings)
    !> Representation of the command line arguments
    type(fpm_export_settings), intent(inout) :: settings
    type(package_config_t) :: package
    type(dependency_tree_t) :: deps
    type(fpm_model_t) :: model
    type(error_t), allocatable :: error

    integer :: ii
    character(len=:), allocatable :: filename

    if (len_trim(settings%dump_manifest)<=0 .and. &
        len_trim(settings%dump_model)<=0 .and. &
        len_trim(settings%dump_dependencies)<=0) then
        call fpm_stop(0,'*cmd_export* exiting: no manifest/model/dependencies keyword provided')
    end if

    !> Read in manifest
    call get_package_data(package, "fpm.toml", error, apply_defaults=.true.)
    call handle_error(error)

    !> Export manifest
    if (len_trim(settings%dump_manifest)>0) then
       filename = trim(settings%dump_manifest)
       call package%dump(filename, error, json=name_is_json(filename))
    end if

    !> Export dependency tree
    if (len_trim(settings%dump_dependencies)>0) then

        !> Generate dependency tree
        filename = join_path("build", "cache.toml")
        call new_dependency_tree(deps, cache=filename, verbosity=merge(2, 1, settings%verbose))
        call deps%add(package, error)
        call handle_error(error)

        !> Export dependency tree
        filename = settings%dump_dependencies
        call deps%dump(filename, error, json=name_is_json(filename))
        call handle_error(error)
    end if

    !> Export full model
    if (len_trim(settings%dump_model)>0) then

        call build_model(model, settings%fpm_build_settings, package, error)
        if (allocated(error)) then
            call fpm_stop(1,'*cmd_export* Model error: '//error%message)
        end if

        filename = settings%dump_model
        call model%dump(filename, error, json=name_is_json(filename))
        call handle_error(error)
    end if

  end subroutine cmd_export