Skip to content

Commit de1fcdd

Browse files
committed
Merge branch 'main' into custom-path-to-config
2 parents f088c38 + 16221b1 commit de1fcdd

File tree

8 files changed

+69
-76
lines changed

8 files changed

+69
-76
lines changed

.github/workflows/meta.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ on:
1414

1515
env:
1616
CI: "ON" # We can detect this in the build system and other vendors implement it
17-
HOMEBREW_NO_ANALYTICS: "ON" # Make Homebrew installation a little quicker
18-
HOMEBREW_NO_AUTO_UPDATE: "ON"
19-
HOMEBREW_NO_BOTTLE_SOURCE_FALLBACK: "ON"
20-
HOMEBREW_NO_GITHUB_API: "ON"
21-
HOMEBREW_NO_INSTALL_CLEANUP: "ON"
17+
HOMEBREW_NO_ANALYTICS: 1 # Make Homebrew installation a little quicker
18+
HOMEBREW_NO_AUTO_UPDATE: 1
19+
HOMEBREW_NO_BOTTLE_SOURCE_FALLBACK: 1
20+
HOMEBREW_NO_GITHUB_API: 1
21+
HOMEBREW_NO_INSTALL_CLEANUP: 1
22+
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
2223

2324
jobs:
2425

@@ -198,7 +199,7 @@ jobs:
198199
- name: (macOS) Install homebrew OpenMPI
199200
if: contains(matrix.mpi,'openmpi') && contains(matrix.os,'macos')
200201
run: |
201-
brew install --cc=gcc-${{ env.GCC_V }} openmpi
202+
brew install openmpi #--cc=gcc-${{ env.GCC_V }} openmpi
202203
203204
# Phase 1: Bootstrap fpm with existing version
204205
- name: Install fpm

src/fpm/cmd/publish.f90

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ subroutine cmd_publish(settings)
6565
end do
6666

6767
tmp_file = get_temp_filename()
68-
call git_archive('.', tmp_file, error)
68+
call git_archive('.', tmp_file, 'HEAD', settings%verbose, error)
6969
if (allocated(error)) call fpm_stop(1, '*cmd_publish* Archive error: '//error%message)
7070

7171
upload_data = [ &
@@ -91,7 +91,6 @@ subroutine cmd_publish(settings)
9191
end if
9292

9393
if (settings%verbose) then
94-
print *, ''
9594
call print_upload_data(upload_data)
9695
print *, ''
9796
end if
@@ -102,7 +101,7 @@ subroutine cmd_publish(settings)
102101
print *, 'Dry run successful. Generated tarball: ', tmp_file; return
103102
end if
104103

105-
call downloader%upload_form(official_registry_base_url//'/packages', upload_data, error)
104+
call downloader%upload_form(official_registry_base_url//'/packages', upload_data, settings%verbose, error)
106105
call delete_file(tmp_file)
107106
if (allocated(error)) call fpm_stop(1, '*cmd_publish* Upload error: '//error%message)
108107
end

src/fpm/downloader.f90

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module fpm_downloader
22
use fpm_error, only: error_t, fatal_error
3-
use fpm_filesystem, only: which
3+
use fpm_filesystem, only: which, run
44
use fpm_versioning, only: version_t
55
use jonquil, only: json_object, json_value, json_error, json_load, cast_to_object
66
use fpm_strings, only: string_t
@@ -76,9 +76,14 @@ subroutine get_file(url, tmp_pkg_file, error)
7676
end
7777

7878
!> Perform an http post request with form data.
79-
subroutine upload_form(endpoint, form_data, error)
79+
subroutine upload_form(endpoint, form_data, verbose, error)
80+
!> Endpoint to upload to.
8081
character(len=*), intent(in) :: endpoint
82+
!> Form data to upload.
8183
type(string_t), intent(in) :: form_data(:)
84+
!> Print additional information if true.
85+
logical, intent(in) :: verbose
86+
!> Error handling.
8287
type(error_t), allocatable, intent(out) :: error
8388

8489
integer :: stat, i
@@ -91,8 +96,8 @@ subroutine upload_form(endpoint, form_data, error)
9196

9297
if (which('curl') /= '') then
9398
print *, 'Uploading package ...'
94-
call execute_command_line('curl -X POST -H "Content-Type: multipart/form-data" ' &
95-
& //form_data_str//endpoint, exitstat=stat)
99+
call run('curl -X POST -H "Content-Type: multipart/form-data" '// &
100+
& form_data_str//endpoint, exitstat=stat, echo=verbose)
96101
else
97102
call fatal_error(error, "'curl' not installed."); return
98103
end if
@@ -104,8 +109,11 @@ subroutine upload_form(endpoint, form_data, error)
104109

105110
!> Unpack a tarball to a destination.
106111
subroutine unpack(tmp_pkg_file, destination, error)
112+
!> Path to tarball.
107113
character(*), intent(in) :: tmp_pkg_file
114+
!> Destination to unpack to.
108115
character(*), intent(in) :: destination
116+
!> Error handling.
109117
type(error_t), allocatable, intent(out) :: error
110118

111119
integer :: stat

src/fpm/git.f90

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
!> Implementation for interacting with git repositories.
22
module fpm_git
33
use fpm_error, only: error_t, fatal_error
4-
use fpm_filesystem, only : get_temp_filename, getline, join_path, execute_and_read_output
4+
use fpm_filesystem, only : get_temp_filename, getline, join_path, execute_and_read_output, run
5+
56
implicit none
67

78
public :: git_target_t, git_target_default, git_target_branch, git_target_tag, git_target_revision, git_revision, &
@@ -308,18 +309,22 @@ subroutine info(self, unit, verbosity)
308309
end subroutine info
309310

310311
!> Archive a folder using `git archive`.
311-
subroutine git_archive(source, destination, error)
312+
subroutine git_archive(source, destination, ref, verbose, error)
312313
!> Directory to archive.
313314
character(*), intent(in) :: source
314315
!> Destination of the archive.
315316
character(*), intent(in) :: destination
317+
!> (Symbolic) Reference to be archived.
318+
character(*), intent(in) :: ref
319+
!> Print additional information if true.
320+
logical, intent(in) :: verbose
316321
!> Error handling.
317322
type(error_t), allocatable, intent(out) :: error
318323

319324
integer :: stat
320325
character(len=:), allocatable :: cmd_output, archive_format
321326

322-
call execute_and_read_output('git archive -l', cmd_output, error)
327+
call execute_and_read_output('git archive -l', cmd_output, error, verbose)
323328
if (allocated(error)) return
324329

325330
if (index(cmd_output, 'tar.gz') /= 0) then
@@ -328,11 +333,10 @@ subroutine git_archive(source, destination, error)
328333
call fatal_error(error, "Cannot find a suitable archive format for 'git archive'."); return
329334
end if
330335

331-
call execute_command_line('git archive HEAD --format='//archive_format//' -o '//destination, exitstat=stat)
336+
call run('git archive '//ref//' --format='//archive_format//' -o '//destination, echo=verbose, exitstat=stat)
332337
if (stat /= 0) then
333338
call fatal_error(error, "Error packing '"//source//"'."); return
334339
end if
335340
end
336341

337-
338342
end module fpm_git

src/fpm_compiler.F90

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
module fpm_compiler
2929
use,intrinsic :: iso_fortran_env, only: stderr=>error_unit
3030
use fpm_environment, only: &
31-
get_env, &
3231
get_os_type, &
3332
OS_LINUX, &
3433
OS_MACOS, &

src/fpm_filesystem.F90

Lines changed: 27 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ module fpm_filesystem
1414
public :: basename, canon_path, dirname, is_dir, join_path, number_of_rows, list_files, get_local_prefix, &
1515
mkdir, exists, get_temp_filename, windows_path, unix_path, getline, delete_file, fileopen, fileclose, &
1616
filewrite, warnwrite, parent_dir, is_hidden_file, read_lines, read_lines_expanded, which, run, &
17-
os_delete_dir, is_absolute_path, env_variable, get_home, execute_and_read_output, &
18-
get_dos_path
17+
os_delete_dir, is_absolute_path, get_home, execute_and_read_output, get_dos_path
1918

2019
#ifndef FPM_BOOTSTRAP
2120
interface
@@ -53,32 +52,7 @@ end function c_is_dir
5352

5453
contains
5554

56-
57-
!> return value of environment variable
58-
subroutine env_variable(var, name)
59-
character(len=:), allocatable, intent(out) :: var
60-
character(len=*), intent(in) :: name
61-
integer :: length, stat
62-
63-
call get_environment_variable(name, length=length, status=stat)
64-
if (stat /= 0) return
65-
66-
allocate(character(len=length) :: var)
67-
68-
if (length > 0) then
69-
call get_environment_variable(name, var, status=stat)
70-
if (stat /= 0) then
71-
deallocate(var)
72-
return
73-
end if
74-
end if
75-
76-
end subroutine env_variable
77-
78-
79-
!> Extract filename from path with or without suffix.
80-
!>
81-
!> The suffix is included by default.
55+
!> Extract filename from path with/without suffix
8256
function basename(path,suffix) result (base)
8357

8458
character(*), intent(In) :: path
@@ -710,7 +684,6 @@ subroutine getline(unit, line, iostat, iomsg)
710684
integer :: size
711685
integer :: stat
712686

713-
714687
allocate(character(len=0) :: line)
715688
do
716689
read(unit, '(a)', advance='no', iostat=stat, iomsg=msg, size=size) &
@@ -1079,15 +1052,15 @@ function get_local_prefix(os) result(prefix)
10791052
character(len=:), allocatable :: home
10801053

10811054
if (os_is_unix(os)) then
1082-
call env_variable(home, "HOME")
1083-
if (allocated(home)) then
1055+
home=get_env('HOME','')
1056+
if (home /= '' ) then
10841057
prefix = join_path(home, ".local")
10851058
else
10861059
prefix = default_prefix_unix
10871060
end if
10881061
else
1089-
call env_variable(home, "APPDATA")
1090-
if (allocated(home)) then
1062+
home=get_env('APPDATA','')
1063+
if (home /= '' ) then
10911064
prefix = join_path(home, "local")
10921065
else
10931066
prefix = default_prefix_win
@@ -1130,39 +1103,45 @@ subroutine get_home(home, error)
11301103
type(error_t), allocatable, intent(out) :: error
11311104

11321105
if (os_is_unix()) then
1133-
call env_variable(home, 'HOME')
1134-
if (.not. allocated(home)) then
1106+
home=get_env('HOME','')
1107+
if ( home == '' ) then
11351108
call fatal_error(error, "Couldn't retrieve 'HOME' variable")
11361109
return
11371110
end if
11381111
else
1139-
call env_variable(home, 'USERPROFILE')
1140-
if (.not. allocated(home)) then
1112+
home=get_env('USERPROFILE','')
1113+
if ( home == '' ) then
11411114
call fatal_error(error, "Couldn't retrieve '%USERPROFILE%' variable")
11421115
return
11431116
end if
11441117
end if
11451118
end subroutine get_home
11461119

11471120
!> Execute command line and return output as a string.
1148-
subroutine execute_and_read_output(cmd, output, error, exitstat)
1121+
subroutine execute_and_read_output(cmd, output, error, verbose)
11491122
!> Command to execute.
11501123
character(len=*), intent(in) :: cmd
11511124
!> Command line output.
11521125
character(len=:), allocatable, intent(out) :: output
11531126
!> Error to handle.
11541127
type(error_t), allocatable, intent(out) :: error
1155-
!> Can optionally used for error handling.
1156-
integer, intent(out), optional :: exitstat
1128+
!> Print additional information if true.
1129+
logical, intent(in), optional :: verbose
11571130

1158-
integer :: cmdstat, unit, stat = 0
1159-
character(len=:), allocatable :: cmdmsg, tmp_file
1160-
character(len=:),allocatable :: output_line
1131+
integer :: exitstat, unit, stat
1132+
character(len=:), allocatable :: cmdmsg, tmp_file, output_line
1133+
logical :: is_verbose
1134+
1135+
if (present(verbose)) then
1136+
is_verbose = verbose
1137+
else
1138+
is_verbose = .false.
1139+
end if
11611140

11621141
tmp_file = get_temp_filename()
11631142

1164-
call execute_command_line(cmd//' > '//tmp_file, exitstat=exitstat, cmdstat=cmdstat)
1165-
if (cmdstat /= 0) call fatal_error(error, '*run*: '//"Command failed: '"//cmd//"'. Message: '"//trim(cmdmsg)//"'.")
1143+
call run(cmd//' > '//tmp_file, exitstat=exitstat, echo=is_verbose)
1144+
if (exitstat /= 0) call fatal_error(error, '*run*: '//"Command failed: '"//cmd//"'. Message: '"//trim(cmdmsg)//"'.")
11661145

11671146
open(newunit=unit, file=tmp_file, action='read', status='old')
11681147
output = ''
@@ -1171,8 +1150,9 @@ subroutine execute_and_read_output(cmd, output, error, exitstat)
11711150
if (stat /= 0) exit
11721151
output = output//output_line//' '
11731152
end do
1174-
close(unit, status='delete',iostat=stat)
1175-
end subroutine execute_and_read_output
1153+
if (is_verbose) print *, output
1154+
close(unit, status='delete')
1155+
end
11761156

11771157
!> Ensure a windows path is converted to an 8.3 DOS path if it contains spaces
11781158
function get_dos_path(path,error)

src/fpm_meta.f90

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@
33
!> This is a wrapper data type that encapsulate all pre-processing information
44
!> (compiler flags, linker libraries, etc.) required to correctly enable a package
55
!> to use a core library.
6+
!>
67
!>
7-
!>
8-
!>### Available core libraries
8+
!>### Available core libraries
99
!>
1010
!> - OpenMP
11+
!> - MPI
12+
!> - fortran-lang stdlib
13+
!> - fortran-lang minpack
14+
!>
1115
!>
1216
!> @note Core libraries are enabled in the [build] section of the fpm.toml manifest
1317
!>

test/fpm_test/test_os.f90

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module test_os
22
use testsuite, only: new_unittest, unittest_t, error_t, test_failed
3-
use fpm_filesystem, only: env_variable, join_path, mkdir, os_delete_dir, is_dir, get_local_prefix, get_home
4-
use fpm_environment, only: os_is_unix
3+
use fpm_filesystem, only: join_path, mkdir, os_delete_dir, is_dir, get_local_prefix, get_home
4+
use fpm_environment, only: os_is_unix, get_env
55
use fpm_os, only: get_absolute_path, get_absolute_path_by_cd, get_current_directory
66

77
implicit none
@@ -134,7 +134,7 @@ subroutine abs_path_nonexisting(error)
134134
subroutine abs_path_root(error)
135135
type(error_t), allocatable, intent(out) :: error
136136

137-
character(len=:), allocatable :: home_drive, home_path, result
137+
character(len=:), allocatable :: home_path, result
138138

139139
if (os_is_unix()) then
140140
call get_absolute_path('/', result, error)
@@ -144,8 +144,7 @@ subroutine abs_path_root(error)
144144
call test_failed(error, "Result '"//result//"' doesn't equal input value: '/'"); return
145145
end if
146146
else
147-
call env_variable(home_drive, 'HOMEDRIVE')
148-
home_path = home_drive//'\'
147+
home_path = get_env('HOMEDRIVE','') //'\'
149148

150149
call get_absolute_path(home_path, result, error)
151150
if (allocated(error)) return
@@ -177,7 +176,7 @@ subroutine abs_path_home(error)
177176
subroutine abs_path_cd_root(error)
178177
type(error_t), allocatable, intent(out) :: error
179178

180-
character(len=:), allocatable :: home_drive, home_path, current_dir_before, current_dir_after, result
179+
character(len=:), allocatable :: home_path, current_dir_before, current_dir_after, result
181180

182181
call get_current_directory(current_dir_before, error)
183182
if (allocated(error)) return
@@ -189,8 +188,7 @@ subroutine abs_path_cd_root(error)
189188
call test_failed(error, "Result '"//result//"' doesn't equal input value: '/'"); return
190189
end if
191190
else
192-
call env_variable(home_drive, 'HOMEDRIVE')
193-
home_path = home_drive//'\'
191+
home_path = get_env('HOMEDRIVE','')//'\'
194192

195193
call get_absolute_path_by_cd(home_path, result, error)
196194

0 commit comments

Comments
 (0)