link_shared Subroutine

public subroutine link_shared(self, output, args, log_file, stat, dry_run)

Link a shared library

Type Bound

compiler_t

Arguments

Type IntentOptional Attributes Name
class(compiler_t), intent(in) :: self

Instance of the compiler object

character(len=*), intent(in) :: output

Output file of shared library object

character(len=*), intent(in) :: args

Arguments for the compiler

character(len=*), intent(in) :: log_file

Compiler output log file

integer, intent(out) :: stat

Status flag

logical, intent(in), optional :: dry_run

Optional mocking


Variables

Type Visibility Attributes Name Initial
type(string_t), public, allocatable :: argv(:)
character(len=:), public, allocatable :: command
logical, public :: mock
character(len=:), public, allocatable :: shared_flag
logical, public :: tokenized

Source Code

subroutine link_shared(self, output, args, log_file, stat, dry_run)
    !> Instance of the compiler object
    class(compiler_t), intent(in) :: self
    !> Output file of shared library object
    character(len=*), intent(in) :: output
    !> Arguments for the compiler
    character(len=*), intent(in) :: args
    !> Compiler output log file
    character(len=*), intent(in) :: log_file
    !> Status flag
    integer, intent(out) :: stat
    !> Optional mocking
    logical, optional, intent(in) :: dry_run

    character(len=:), allocatable :: command
    type(string_t), allocatable :: argv(:)
    logical :: mock, tokenized
    character(len=:), allocatable :: shared_flag

    ! Initialize intent(out) status so the mock path returns a defined value.
    stat = 0

    mock = .false.
    if (present(dry_run)) mock = dry_run

    if (mock) return

    shared_flag = get_shared_flag(self)

    call tool_command(self%fc, shared_flag // " " // args, output, command, argv, tokenized)
    call run_tool(command, argv, tokenized, self%echo, self%verbose, log_file, stat)

end subroutine link_shared