aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Ehlert <28669218+awvwgk@users.noreply.github.com>2021-04-17 13:01:18 +0200
committerSebastian Ehlert <28669218+awvwgk@users.noreply.github.com>2021-04-17 13:01:18 +0200
commitc58584e725b904d74743c6eb2b07e372fc539b39 (patch)
treea09d7ea5de9d89a46fb389a5b0cf29cdcb0a706e
parent4cbf9194e47991a208cd61b1f3a0a55f0ae16573 (diff)
downloadfpm-c58584e725b904d74743c6eb2b07e372fc539b39.tar.gz
fpm-c58584e725b904d74743c6eb2b07e372fc539b39.zip
Allow usage of response files with ar
-rw-r--r--src/fpm_backend.f9020
1 files changed, 18 insertions, 2 deletions
diff --git a/src/fpm_backend.f90 b/src/fpm_backend.f90
index 74cef61..4b19e25 100644
--- a/src/fpm_backend.f90
+++ b/src/fpm_backend.f90
@@ -33,7 +33,7 @@ use fpm_model, only: fpm_model_t
use fpm_targets, only: build_target_t, build_target_ptr, &
FPM_TARGET_OBJECT, FPM_TARGET_ARCHIVE, FPM_TARGET_EXECUTABLE
-use fpm_strings, only: string_cat
+use fpm_strings, only: string_t
implicit none
@@ -247,7 +247,8 @@ subroutine build_target(model,target)
//" "//target%link_flags// " -o " // target%output_file)
case (FPM_TARGET_ARCHIVE)
- call run("ar -rs " // target%output_file // " " // string_cat(target%link_objects," "))
+ call write_response_file(target%output_file//".resp" ,target%link_objects)
+ call run("ar -rs " // target%output_file // " @" // target%output_file//".resp")
end select
@@ -259,4 +260,19 @@ subroutine build_target(model,target)
end subroutine build_target
+!> Response files allow to read command line options from files.
+!> Whitespace is used to separate the arguments, we will use newlines
+!> as separator to create readable response files which can be inspected
+!> in case of errors.
+subroutine write_response_file(name, argv)
+ character(len=*), intent(in) :: name
+ type(string_t), intent(in) :: argv(:)
+ integer :: iarg, io
+ open(file=name, newunit=io)
+ do iarg = 1, size(argv)
+ write(io, '(a)') argv(iarg)%s
+ end do
+ close(io)
+end subroutine write_response_file
+
end module fpm_backend