@@ -18,7 +18,7 @@ module fpm
18
18
resolve_target_linking, build_target_t, build_target_ptr, &
19
19
FPM_TARGET_EXECUTABLE, FPM_TARGET_ARCHIVE
20
20
use fpm_manifest, only : get_package_data, package_config_t
21
- use fpm_error, only : error_t, fatal_error
21
+ use fpm_error, only : error_t, fatal_error, fpm_stop
22
22
use fpm_manifest_test, only : test_config_t
23
23
use ,intrinsic :: iso_fortran_env, only : stdin= >input_unit, &
24
24
& stdout= >output_unit, &
@@ -196,7 +196,7 @@ subroutine build_model(model, settings, package, error)
196
196
! Check for duplicate modules
197
197
call check_modules_for_duplicates(model, duplicates_found)
198
198
if (duplicates_found) then
199
- error stop ' Error: One or more duplicate module names found.'
199
+ call fpm_stop( 1 , ' *build_model*: Error: One or more duplicate module names found.' )
200
200
end if
201
201
end subroutine build_model
202
202
@@ -255,20 +255,17 @@ subroutine cmd_build(settings)
255
255
256
256
call get_package_data(package, " fpm.toml" , error, apply_defaults= .true. )
257
257
if (allocated (error)) then
258
- print ' (a)' , error% message
259
- error stop 1
258
+ call fpm_stop(1 ,' *cmd_build*:package error:' // error% message)
260
259
end if
261
260
262
261
call build_model(model, settings, package, error)
263
262
if (allocated (error)) then
264
- print ' (a)' , error% message
265
- error stop 1
263
+ call fpm_stop(1 ,' *cmd_build*:model error:' // error% message)
266
264
end if
267
265
268
266
call targets_from_sources(targets,model,error)
269
267
if (allocated (error)) then
270
- print ' (a)' , error% message
271
- error stop 1
268
+ call fpm_stop(1 ,' *cmd_build*:target error:' // error% message)
272
269
end if
273
270
274
271
if (settings% list)then
@@ -304,20 +301,17 @@ subroutine cmd_run(settings,test)
304
301
305
302
call get_package_data(package, " fpm.toml" , error, apply_defaults= .true. )
306
303
if (allocated (error)) then
307
- print ' (a)' , error% message
308
- error stop 1
304
+ call fpm_stop(1 , ' *cmd_run*:package error:' // error% message)
309
305
end if
310
306
311
307
call build_model(model, settings% fpm_build_settings, package, error)
312
308
if (allocated (error)) then
313
- print ' (a)' , error% message
314
- error stop 1
309
+ call fpm_stop(1 , ' *cmd_run*:model error:' // error% message)
315
310
end if
316
311
317
312
call targets_from_sources(targets,model,error)
318
313
if (allocated (error)) then
319
- print ' (a)' , error% message
320
- error stop 1
314
+ call fpm_stop(1 , ' *cmd_run*:targets error:' // error% message)
321
315
end if
322
316
323
317
if (test) then
@@ -373,11 +367,10 @@ subroutine cmd_run(settings,test)
373
367
! Check if any apps/tests were found
374
368
if (col_width < 0 ) then
375
369
if (test) then
376
- write (stderr, * ) ' No tests to run'
370
+ call fpm_stop( 0 , ' No tests to run' )
377
371
else
378
- write (stderr, * ) ' No executables to run'
372
+ call fpm_stop( 0 , ' No executables to run' )
379
373
end if
380
- stop
381
374
end if
382
375
383
376
! Check all names are valid
@@ -391,7 +384,7 @@ subroutine cmd_run(settings,test)
391
384
line= join(settings% name)
392
385
if (line.ne. ' .' )then ! do not report these special strings
393
386
if (any (.not. found))then
394
- write (stderr,' (A)' ,advance= " no" )' fpm::run <ERROR> specified names '
387
+ write (stderr,' (A)' ,advance= " no" )' <ERROR>*cmd_run*: specified names '
395
388
do j= 1 ,size (settings% name)
396
389
if (.not. found(j)) write (stderr,' (A)' ,advance= " no" ) ' "' // trim (settings% name (j))// ' " '
397
390
end do
@@ -406,9 +399,9 @@ subroutine cmd_run(settings,test)
406
399
call compact_list_all()
407
400
408
401
if (line.eq. ' .' .or. line.eq. ' ' )then ! do not report these special strings
409
- stop
402
+ call fpm_stop( 0 , ' ' )
410
403
else
411
- stop 1
404
+ call fpm_stop( 1 , ' ' )
412
405
endif
413
406
414
407
end if
@@ -430,18 +423,17 @@ subroutine cmd_run(settings,test)
430
423
exitstat= stat(i))
431
424
endif
432
425
else
433
- write (stderr,* )' fpm::run<ERROR>' ,executables(i)% s,' not found'
434
- stop 1
426
+ call fpm_stop(1 ,' *cmd_run*:' // executables(i)% s// ' not found' )
435
427
end if
436
428
end do
437
429
438
430
if (any (stat /= 0 )) then
439
431
do i= 1 ,size (stat)
440
432
if (stat(i) /= 0 ) then
441
- write (* , * ) ' <ERROR> Execution failed for "' ,basename(executables(i)% s),' "'
433
+ write (stderr, ' (*(g0:,1x)) ' ) ' <ERROR> Execution failed for object "' ,basename(executables(i)% s),' "'
442
434
end if
443
435
end do
444
- stop 1
436
+ call fpm_stop( 1 , ' *cmd_run*:stopping due to failed executions ' )
445
437
end if
446
438
447
439
endif
0 commit comments