11
11
12
12
module fpm_backend_output
13
13
use iso_fortran_env, only: stdout= >output_unit
14
- use fpm_filesystem, only: basename
14
+ use fpm_error, only: error_t
15
+ use fpm_filesystem, only: basename,join_path
15
16
use fpm_targets, only: build_target_ptr
16
17
use fpm_backend_console, only: console_t, LINE_RESET, COLOR_RED, COLOR_GREEN, COLOR_YELLOW, COLOR_RESET
17
18
use fpm_compile_commands, only: compile_command_t, compile_command_table_t
@@ -43,6 +44,8 @@ module fpm_backend_output
43
44
procedure :: completed_status = > output_status_complete
44
45
! > Output finished status for whole package
45
46
procedure :: success = > output_progress_success
47
+ ! > Output 'compile_commands.json' to build/ folder
48
+ procedure :: dump_commands = > output_write_compile_commands
46
49
end type build_progress_t
47
50
48
51
! > Constructor for build_progress_t
@@ -167,7 +170,7 @@ end subroutine output_status_complete
167
170
! > Output finished status for whole package
168
171
subroutine output_progress_success (progress )
169
172
class(build_progress_t), intent (inout ) :: progress
170
-
173
+
171
174
if (progress% plain_mode) then ! Plain output
172
175
173
176
write (* ,' (A)' ) ' [100%] Project compiled successfully.'
@@ -177,7 +180,21 @@ subroutine output_progress_success(progress)
177
180
write (* ,' (A)' ) LINE_RESET// COLOR_GREEN// ' [100%] Project compiled successfully.' // COLOR_RESET
178
181
179
182
end if
180
-
183
+
181
184
end subroutine output_progress_success
185
+
186
+ ! > Write compile commands table
187
+ subroutine output_write_compile_commands (progress ,error )
188
+ class(build_progress_t), intent (inout ) :: progress
189
+
190
+ character (:), allocatable :: path
191
+ type (error_t), allocatable :: error
192
+
193
+ ! Write compile commands
194
+ path = join_path(' build' ,' compile_commands.json' )
195
+
196
+ call progress% compile_commands% dump(file= path, error= error, json= .true. )
197
+
198
+ end subroutine output_write_compile_commands
182
199
183
200
end module fpm_backend_output
0 commit comments