Skip to content

Commit c58584e

Browse files
committed
Allow usage of response files with ar
1 parent 4cbf919 commit c58584e

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/fpm_backend.f90

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ module fpm_backend
3333
use fpm_targets, only: build_target_t, build_target_ptr, &
3434
FPM_TARGET_OBJECT, FPM_TARGET_ARCHIVE, FPM_TARGET_EXECUTABLE
3535

36-
use fpm_strings, only: string_cat
36+
use fpm_strings, only: string_t
3737

3838
implicit none
3939

@@ -247,7 +247,8 @@ subroutine build_target(model,target)
247247
//" "//target%link_flags// " -o " // target%output_file)
248248

249249
case (FPM_TARGET_ARCHIVE)
250-
call run("ar -rs " // target%output_file // " " // string_cat(target%link_objects," "))
250+
call write_response_file(target%output_file//".resp" ,target%link_objects)
251+
call run("ar -rs " // target%output_file // " @" // target%output_file//".resp")
251252

252253
end select
253254

@@ -259,4 +260,19 @@ subroutine build_target(model,target)
259260

260261
end subroutine build_target
261262

263+
!> Response files allow to read command line options from files.
264+
!> Whitespace is used to separate the arguments, we will use newlines
265+
!> as separator to create readable response files which can be inspected
266+
!> in case of errors.
267+
subroutine write_response_file(name, argv)
268+
character(len=*), intent(in) :: name
269+
type(string_t), intent(in) :: argv(:)
270+
integer :: iarg, io
271+
open(file=name, newunit=io)
272+
do iarg = 1, size(argv)
273+
write(io, '(a)') argv(iarg)%s
274+
end do
275+
close(io)
276+
end subroutine write_response_file
277+
262278
end module fpm_backend

0 commit comments

Comments
 (0)