Skip to content

Commit 3c950a8

Browse files
committed
dump compile_commands to toml table
1 parent dd42e2d commit 3c950a8

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

src/fpm_compile_commands.F90

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ module fpm_compile_commands
2525

2626
type, extends(serializable_t) :: compile_command_table_t
2727

28+
2829
type(compile_command_t), allocatable :: command(:)
2930

3031
contains
@@ -116,13 +117,32 @@ subroutine cct_dump_toml(self, table, error)
116117

117118
!> Error handling
118119
type(error_t), allocatable, intent(out) :: error
119-
120-
! call set_string(table, "directory", self%directory, error, 'compile_command_table_t')
121-
! if (allocated(error)) return
122-
! call set_list(table, "arguments", self%arguments, error)
123-
! if (allocated(error)) return
124-
! call set_string(table, "file", self%file, error, 'compile_command_table_t')
125-
! if (allocated(error)) return
120+
121+
integer :: ii
122+
type(toml_table), pointer :: ptr
123+
character(64) :: name
124+
125+
if (.not.allocated(self%command)) return
126+
127+
do ii = 1, size(self%command)
128+
associate (cmd => self%command(ii))
129+
130+
! Set node for this command
131+
write(name,1) ii
132+
call add_table(table, trim(name), ptr)
133+
if (.not. associated(ptr)) then
134+
call fatal_error(error, "compile_command_table_t cannot create entry for "//trim(name))
135+
return
136+
end if
137+
138+
! Dump node
139+
call cmd%dump_to_toml(ptr, error)
140+
if (allocated(error)) return
141+
142+
endassociate
143+
end do
144+
145+
1 format('compile_command_',i0)
126146

127147
end subroutine cct_dump_toml
128148

0 commit comments

Comments
 (0)