Skip to content

Commit 2ba3478

Browse files
authored
Merge pull request #489 from awvwgk/ar-output
Redirect output when searching for archiver
2 parents 87a2cbf + 5651c74 commit 2ba3478

File tree

3 files changed

+26
-25
lines changed

3 files changed

+26
-25
lines changed

src/fpm.f90

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ module fpm
44
use fpm_command_line, only: fpm_build_settings, fpm_new_settings, &
55
fpm_run_settings, fpm_install_settings, fpm_test_settings
66
use fpm_dependency, only : new_dependency_tree
7-
use fpm_environment, only: run, get_env, get_archiver
7+
use fpm_environment, only: run, get_env
88
use fpm_filesystem, only: is_dir, join_path, number_of_rows, list_files, exists, basename
99
use fpm_model, only: fpm_model_t, srcfile_t, show_model, &
1010
FPM_SCOPE_UNKNOWN, FPM_SCOPE_LIB, FPM_SCOPE_DEP, &
1111
FPM_SCOPE_APP, FPM_SCOPE_EXAMPLE, FPM_SCOPE_TEST
12-
use fpm_compiler, only: get_module_flags, is_unknown_compiler, get_default_c_compiler
12+
use fpm_compiler, only: get_module_flags, is_unknown_compiler, get_default_c_compiler, &
13+
get_archiver
1314

1415

1516
use fpm_sources, only: add_executable_sources, add_sources_from_dir

src/fpm_compiler.f90

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
! Unisys ? ? ? ? ? discontinued
2828
module fpm_compiler
2929
use fpm_model, only: fpm_model_t
30-
use fpm_filesystem, only: join_path, basename
30+
use fpm_filesystem, only: join_path, basename, get_temp_filename
3131
use fpm_environment, only: &
3232
get_os_type, &
3333
OS_LINUX, &
@@ -36,13 +36,15 @@ module fpm_compiler
3636
OS_CYGWIN, &
3737
OS_SOLARIS, &
3838
OS_FREEBSD, &
39-
OS_OPENBSD
39+
OS_OPENBSD, &
40+
OS_UNKNOWN
4041
implicit none
4142
public :: is_unknown_compiler
4243
public :: get_module_flags
4344
public :: get_default_compile_flags
4445
public :: get_debug_compile_flags
4546
public :: get_release_compile_flags
47+
public :: get_archiver
4648

4749
enum, bind(C)
4850
enumerator :: &
@@ -464,4 +466,23 @@ function is_unknown_compiler(compiler) result(is_unknown)
464466
is_unknown = get_compiler_id(compiler) == id_unknown
465467
end function is_unknown_compiler
466468

469+
470+
function get_archiver() result(archiver)
471+
character(:), allocatable :: archiver
472+
integer :: estat, os_type
473+
474+
os_type = get_os_type()
475+
if (os_type /= OS_WINDOWS .and. os_type /= OS_UNKNOWN) then
476+
archiver = "ar -rs "
477+
else
478+
call execute_command_line("ar --version > "//get_temp_filename()//" 2>&1", &
479+
& exitstat=estat)
480+
if (estat /= 0) then
481+
archiver = "lib /OUT:"
482+
else
483+
archiver = "ar -rs "
484+
end if
485+
end if
486+
end function
487+
467488
end module fpm_compiler

src/fpm_environment.f90

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ module fpm_environment
1212
public :: os_is_unix
1313
public :: run
1414
public :: get_env
15-
public :: get_archiver
1615
public :: get_command_arguments_quoted
1716
public :: separator
1817

@@ -195,26 +194,6 @@ function get_env(NAME,DEFAULT) result(VALUE)
195194
if(VALUE.eq.''.and.present(DEFAULT))VALUE=DEFAULT
196195
end function get_env
197196

198-
function get_archiver() result(archiver)
199-
character(:), allocatable :: archiver
200-
201-
associate(os_type => get_os_type())
202-
if (os_type /= OS_WINDOWS .and. os_type /= OS_UNKNOWN) then
203-
archiver = "ar -rs "
204-
else
205-
block
206-
integer :: estat
207-
208-
call execute_command_line("ar --version", exitstat=estat)
209-
if (estat /= 0) then
210-
archiver = "lib /OUT:"
211-
else
212-
archiver = "ar -rs "
213-
end if
214-
end block
215-
end if
216-
end associate
217-
end function
218197
function get_command_arguments_quoted() result(args)
219198
character(len=:),allocatable :: args
220199
character(len=:),allocatable :: arg

0 commit comments

Comments
 (0)