Delete the build directory including or excluding dependencies. Can be used to clear the registry cache.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(fpm_clean_settings), | intent(inout) | :: | settings |
Settings for the clean command. |
subroutine cmd_clean(settings) !> Settings for the clean command. class(fpm_clean_settings), intent(inout) :: settings character :: user_response type(fpm_global_settings) :: global_settings type(error_t), allocatable :: error ! Clear registry cache if (settings%registry_cache) then call get_global_settings(global_settings, error) if (allocated(error)) return call os_delete_dir(os_is_unix(), global_settings%registry_settings%cache_path) end if ! Handle target-specific cleaning if (any([settings%clean_test, settings%clean_apps, settings%clean_examples])) then if (.not. is_dir(settings%build_dir)) then write (stdout, '(A)') "fpm: No build directory found: "//settings%build_dir return end if call delete_targets(settings, error) if (allocated(error)) then write(stderr, '(A)') 'Error: ' // error%message return end if return end if if (is_dir(settings%build_dir)) then ! fpm writes a .gitignore into every build directory: never delete a directory without one if (.not. exists(join_path(settings%build_dir, '.gitignore'))) then call fpm_stop(1, '"'//settings%build_dir//'" is not an fpm build directory (no .gitignore), not deleting it.') end if ! Remove the entire build directory if (settings%clean_all) then call os_delete_dir(os_is_unix(), settings%build_dir); return ! Remove the build directory but skip dependencies else if (settings%clean_skip) then call delete_skip(os_is_unix(), settings%build_dir); return end if ! Prompt to remove the build directory but skip dependencies write(stdout, '(A)', advance='no') "Delete "//settings%build_dir//", excluding dependencies (y/n)? " read(stdin, '(A1)') user_response if (lower(user_response) == 'y') call delete_skip(os_is_unix(), settings%build_dir) else write (stdout, '(A)') "fpm: No build directory found: "//settings%build_dir end if end subroutine cmd_clean