aboutsummaryrefslogtreecommitdiff
path: root/src/fpm_backend.f90
diff options
context:
space:
mode:
authorLaurence Kedward <laurence.kedward@bristol.ac.uk>2021-06-05 13:44:15 +0100
committerGitHub <noreply@github.com>2021-06-05 13:44:15 +0100
commit6fc695ffb7549444b36353c920aeb4f6820b14b8 (patch)
treecb17a4e6179cc59690a5404fed74e7491bbe4e59 /src/fpm_backend.f90
parent831ab078d07b2881c5d7fb4318185f3a06192722 (diff)
parent845217f13a23de91021ba393ef432d68683af282 (diff)
downloadfpm-6fc695ffb7549444b36353c920aeb4f6820b14b8.tar.gz
fpm-6fc695ffb7549444b36353c920aeb4f6820b14b8.zip
Merge branch 'master' into master
Diffstat (limited to 'src/fpm_backend.f90')
-rw-r--r--src/fpm_backend.f9032
1 files changed, 28 insertions, 4 deletions
diff --git a/src/fpm_backend.f90 b/src/fpm_backend.f90
index 51861b4..99b6be8 100644
--- a/src/fpm_backend.f90
+++ b/src/fpm_backend.f90
@@ -27,12 +27,12 @@
!>
module fpm_backend
-use fpm_environment, only: run
-use fpm_filesystem, only: dirname, join_path, exists, mkdir
+use fpm_environment, only: run, get_os_type, OS_WINDOWS
+use fpm_filesystem, only: dirname, join_path, exists, mkdir, unix_path
use fpm_model, only: fpm_model_t
use fpm_targets, only: build_target_t, build_target_ptr, FPM_TARGET_OBJECT, &
FPM_TARGET_C_OBJECT, FPM_TARGET_ARCHIVE, FPM_TARGET_EXECUTABLE
-use fpm_strings, only: string_cat
+use fpm_strings, only: string_cat, string_t
implicit none
@@ -250,7 +250,16 @@ subroutine build_target(model,target)
//" "//target%link_flags// " -o " // target%output_file)
case (FPM_TARGET_ARCHIVE)
- call run(model%archiver // target%output_file // " " // string_cat(target%link_objects," "))
+
+ select case (get_os_type())
+ case (OS_WINDOWS)
+ call write_response_file(target%output_file//".resp" ,target%link_objects)
+ call run(model%archiver // target%output_file // " @" // target%output_file//".resp")
+
+ case default
+ call run(model%archiver // target%output_file // " " // string_cat(target%link_objects," "))
+
+ end select
end select
@@ -262,4 +271,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)') unix_path(argv(iarg)%s)
+ end do
+ close(io)
+end subroutine write_response_file
+
end module fpm_backend