Skip to content

Commit ae27097

Browse files
committed
Add option for clearing the registry cache
1 parent e64753c commit ae27097

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

src/fpm.f90

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ module fpm
2626
& stderr => error_unit
2727
use iso_c_binding, only: c_char, c_ptr, c_int, c_null_char, c_associated, c_f_pointer
2828
use fpm_environment, only: os_is_unix
29+
use fpm_settings, only: fpm_global_settings, get_global_settings
2930

3031
implicit none
3132
private
@@ -684,15 +685,23 @@ subroutine cmd_clean(settings)
684685
class(fpm_clean_settings), intent(in) :: settings
685686

686687
character :: user_response
688+
type(fpm_global_settings) :: global_settings
689+
type(error_t), allocatable :: error
690+
691+
! Clear registry cache
692+
if (settings%registry_cache) then
693+
call get_global_settings(global_settings, error)
694+
if (allocated(error)) return
695+
696+
call os_delete_dir(os_is_unix(), global_settings%registry_settings%cache_path)
697+
end if
687698

688699
if (is_dir('build')) then
689700
! Remove the entire build directory
690701
if (settings%clean_all) then
691702
call os_delete_dir(os_is_unix(), 'build'); return
692-
end if
693-
694703
! Remove the build directory but skip dependencies
695-
if (settings%clean_skip) then
704+
else if (settings%clean_skip) then
696705
call delete_skip(os_is_unix()); return
697706
end if
698707

src/fpm_command_line.f90

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ module fpm_command_line
114114
type, extends(fpm_cmd_settings) :: fpm_clean_settings
115115
logical :: clean_skip = .false.
116116
logical :: clean_all = .false.
117+
logical :: registry_cache = .false.
117118
end type
118119

119120
type, extends(fpm_build_settings) :: fpm_publish_settings
@@ -603,6 +604,7 @@ subroutine get_command_line_settings(cmd_settings)
603604

604605
case('clean')
605606
call set_args(common_args // &
607+
& ' --registry-cache' // &
606608
& ' --skip' // &
607609
& ' --all', &
608610
help_clean, version_text)
@@ -618,8 +620,9 @@ subroutine get_command_line_settings(cmd_settings)
618620
end if
619621

620622
allocate(fpm_clean_settings :: cmd_settings)
621-
cmd_settings=fpm_clean_settings( &
622-
& clean_skip=skip, &
623+
cmd_settings = fpm_clean_settings( &
624+
& registry_cache=lget('registry-cache'), &
625+
& clean_skip=skip, &
623626
& clean_all=clean_all)
624627
end block
625628

0 commit comments

Comments
 (0)