Skip to content

Commit f088c38

Browse files
committed
Merge branch 'main' into custom-path-to-config
# Conflicts: # src/fpm.f90 # src/fpm/dependency.f90 # src/fpm_settings.f90
2 parents 5409778 + e70422f commit f088c38

File tree

2 files changed

+20
-22
lines changed

2 files changed

+20
-22
lines changed

src/fpm.f90

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -617,8 +617,10 @@ subroutine cmd_run(settings,test)
617617
call fpm_stop(stat(firsterror),'*cmd_run*:stopping due to failed executions')
618618
end if
619619

620-
endif
620+
end if
621+
621622
contains
623+
622624
subroutine compact_list_all()
623625
integer, parameter :: LINE_WIDTH = 80
624626
integer :: ii, jj, nCol
@@ -635,11 +637,9 @@ subroutine compact_list_all()
635637
exe_source => exe_target%dependencies(1)%ptr%source
636638

637639
if (exe_source%unit_scope == run_scope) then
638-
639640
write(stderr,'(A)',advance=(merge("yes","no ",modulo(jj,nCol)==0))) &
640641
& [character(len=col_width) :: basename(exe_target%output_file, suffix=.false.)]
641642
jj = jj + 1
642-
643643
end if
644644
end if
645645
end do
@@ -656,7 +656,7 @@ subroutine compact_list()
656656
write(stderr,'(A)',advance=(merge("yes","no ",modulo(jj,nCol)==0))) &
657657
& [character(len=col_width) :: basename(executables(ii)%s, suffix=.false.)]
658658
jj = jj + 1
659-
enddo
659+
end do
660660
write(stderr,*)
661661
end subroutine compact_list
662662

src/fpm_settings.f90

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ module fpm_settings
44
use fpm_environment, only: os_is_unix
55
use fpm_error, only: error_t, fatal_error
66
use fpm_toml, only: toml_table, toml_error, toml_stat, get_value, toml_load, check_keys
7-
use fpm_os, only: get_current_directory, change_directory, get_absolute_path, &
8-
convert_to_absolute_path
7+
use fpm_os, only: get_current_directory, change_directory, get_absolute_path, convert_to_absolute_path
8+
99
implicit none
1010
private
1111
public :: fpm_global_settings, get_global_settings, get_registry_settings, official_registry_base_url
@@ -21,7 +21,7 @@ module fpm_settings
2121
!> Registry configs.
2222
type(fpm_registry_settings), allocatable :: registry_settings
2323
contains
24-
procedure :: has_custom_location, full_path
24+
procedure :: has_custom_location, full_path, path_to_config_folder_or_empty
2525
end type
2626

2727
type :: fpm_registry_settings
@@ -57,8 +57,8 @@ subroutine get_global_settings(global_settings, error)
5757
! Use custom path to the config file if it was specified.
5858
if (global_settings%has_custom_location()) then
5959
! Throw error if folder doesn't exist.
60-
if (.not. exists(config_path(global_settings))) then
61-
call fatal_error(error, "Folder not found: '"//config_path(global_settings)//"'."); return
60+
if (.not. exists(global_settings%path_to_config_folder)) then
61+
call fatal_error(error, "Folder not found: '"//global_settings%path_to_config_folder//"'."); return
6262
end if
6363

6464
! Throw error if the file doesn't exist.
@@ -106,7 +106,6 @@ subroutine get_global_settings(global_settings, error)
106106
else
107107
call use_default_registry_settings(global_settings)
108108
end if
109-
110109
end
111110

112111
!> Default registry settings are typically applied if the config file doesn't exist or no registry table was found in
@@ -116,7 +115,7 @@ subroutine use_default_registry_settings(global_settings)
116115

117116
allocate (global_settings%registry_settings)
118117
global_settings%registry_settings%url = official_registry_base_url
119-
global_settings%registry_settings%cache_path = join_path(config_path(global_settings), &
118+
global_settings%registry_settings%cache_path = join_path(global_settings%path_to_config_folder_or_empty(), &
120119
& 'dependencies')
121120
end
122121

@@ -156,7 +155,7 @@ subroutine get_registry_settings(table, global_settings, error)
156155
global_settings%registry_settings%path = path
157156
else
158157
! Get canonical, absolute path on both Unix and Windows.
159-
call get_absolute_path(join_path(config_path(global_settings), path), &
158+
call get_absolute_path(join_path(global_settings%path_to_config_folder_or_empty(), path), &
160159
& global_settings%registry_settings%path, error)
161160
if (allocated(error)) return
162161

@@ -202,20 +201,20 @@ subroutine get_registry_settings(table, global_settings, error)
202201
if (.not. exists(cache_path)) call mkdir(cache_path)
203202
global_settings%registry_settings%cache_path = cache_path
204203
else
205-
cache_path = join_path(config_path(global_settings), cache_path)
204+
cache_path = join_path(global_settings%path_to_config_folder_or_empty(), cache_path)
206205
if (.not. exists(cache_path)) call mkdir(cache_path)
207206
! Get canonical, absolute path on both Unix and Windows.
208207
call get_absolute_path(cache_path, global_settings%registry_settings%cache_path, error)
209208
if (allocated(error)) return
210209
end if
211210
else if (.not. allocated(path)) then
212-
global_settings%registry_settings%cache_path = join_path(config_path(global_settings), &
213-
& 'dependencies')
211+
global_settings%registry_settings%cache_path = &
212+
join_path(global_settings%path_to_config_folder_or_empty(), 'dependencies')
214213
end if
215214
end
216215

217216
!> True if the global config file is not at the default location.
218-
pure logical function has_custom_location(self)
217+
elemental logical function has_custom_location(self)
219218
class(fpm_global_settings), intent(in) :: self
220219

221220
has_custom_location = allocated(self%path_to_config_folder) .and. allocated(self%config_file_name)
@@ -228,19 +227,18 @@ function full_path(self) result(result)
228227
class(fpm_global_settings), intent(in) :: self
229228
character(len=:), allocatable :: result
230229

231-
result = join_path(config_path(self), self%config_file_name)
230+
result = join_path(self%path_to_config_folder_or_empty(), self%config_file_name)
232231
end
233232

234233
!> The path to the global config directory.
235-
function config_path(self)
234+
pure function path_to_config_folder_or_empty(self)
236235
class(fpm_global_settings), intent(in) :: self
237-
character(len=:), allocatable :: config_path
236+
character(len=:), allocatable :: path_to_config_folder_or_empty
238237

239238
if (allocated(self%path_to_config_folder)) then
240-
config_path = self%path_to_config_folder
239+
path_to_config_folder_or_empty = self%path_to_config_folder
241240
else
242-
config_path = ""
241+
path_to_config_folder_or_empty = ""
243242
end if
244243
end
245-
246244
end

0 commit comments

Comments
 (0)