Compile an object with the compiler for its language
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(compiler_t), | intent(in) | :: | self |
Instance of the compiler object |
||
| integer, | intent(in) | :: | lang |
Source language: LANG_FORTRAN, LANG_C or LANG_CXX |
||
| character(len=*), | intent(in) | :: | input |
Source file input |
||
| character(len=*), | intent(in) | :: | output |
Output file of object |
||
| character(len=*), | intent(in) | :: | args |
Arguments for compiler |
||
| character(len=*), | intent(in) | :: | log_file |
Compiler output log file |
||
| integer, | intent(out) | :: | stat |
Status flag |
||
| type(compile_command_table_t), | intent(inout), | optional | :: | table |
Optional compile_commands table |
|
| logical, | intent(in), | optional | :: | dry_run |
Optional mocking |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| type(string_t), | public, | allocatable | :: | argv(:) | |||
| character(len=:), | public, | allocatable | :: | command | |||
| type(error_t), | public, | allocatable | :: | error | |||
| logical, | public | :: | mock | ||||
| character(len=:), | public, | allocatable | :: | prog | |||
| logical, | public | :: | tokenized |
subroutine compile_object(self, lang, input, output, args, log_file, stat, table, dry_run) !> Instance of the compiler object class(compiler_t), intent(in) :: self !> Source language: LANG_FORTRAN, LANG_C or LANG_CXX integer, intent(in) :: lang !> Source file input character(len=*), intent(in) :: input !> Output file of object character(len=*), intent(in) :: output !> Arguments for compiler character(len=*), intent(in) :: args !> Compiler output log file character(len=*), intent(in) :: log_file !> Status flag integer, intent(out) :: stat !> Optional compile_commands table type(compile_command_table_t), optional, intent(inout) :: table !> Optional mocking logical, optional, intent(in) :: dry_run character(len=:), allocatable :: prog, command type(string_t), allocatable :: argv(:) type(error_t), allocatable :: error logical :: mock, tokenized ! Initialize intent(out) status so the mock path with no table returns ! a defined value. stat = 0 ! Check if we're actually building this file mock = .false. if (present(dry_run)) mock = dry_run select case (lang) case (LANG_FORTRAN) prog = self%fc case (LANG_C) prog = self%cc case (LANG_CXX) prog = self%cxx case default write(stderr, '(a,i0)') '<ERROR> No compiler for language ', lang stat = -1 return end select call tool_command(prog, args, output, command, argv, tokenized, input) ! Execute command if (.not.mock) then call run_tool(command, argv, tokenized, self%echo, self%verbose, log_file, stat) if (stat/=0) return endif ! Optionally register compile command if (present(table)) then call table%register(command, get_os_type(), error) stat = merge(-1,0,allocated(error)) endif end subroutine compile_object