aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurence Kedward <laurence.kedward@bristol.ac.uk>2021-11-22 16:11:26 +0000
committerLaurence Kedward <laurence.kedward@bristol.ac.uk>2021-11-22 16:22:31 +0000
commit30d730f51fea587574a922f8763f3c7988198029 (patch)
treea3dc07cc1d1788a4875086db2995f1939ac05ec5
parent2654623adea742b2e10a85aa90706f20f8b87b88 (diff)
downloadfpm-30d730f51fea587574a922f8763f3c7988198029.tar.gz
fpm-30d730f51fea587574a922f8763f3c7988198029.zip
Update: backend with verbose argument
-rw-r--r--src/fpm.f904
-rw-r--r--src/fpm/cmd/install.f902
-rw-r--r--src/fpm_backend.f9023
-rw-r--r--src/isatty.c13
4 files changed, 34 insertions, 8 deletions
diff --git a/src/fpm.f90 b/src/fpm.f90
index 6084a11..0fec0ed 100644
--- a/src/fpm.f90
+++ b/src/fpm.f90
@@ -284,7 +284,7 @@ if(settings%list)then
else if (settings%show_model) then
call show_model(model)
else
- call build_package(targets,model)
+ call build_package(targets,model,verbose=settings%verbose)
endif
end subroutine cmd_build
@@ -415,7 +415,7 @@ subroutine cmd_run(settings,test)
end if
- call build_package(targets,model)
+ call build_package(targets,model,verbose=settings%verbose)
if (settings%list) then
call compact_list()
diff --git a/src/fpm/cmd/install.f90 b/src/fpm/cmd/install.f90
index 099a0e5..46f24a7 100644
--- a/src/fpm/cmd/install.f90
+++ b/src/fpm/cmd/install.f90
@@ -54,7 +54,7 @@ contains
end if
if (.not.settings%no_rebuild) then
- call build_package(targets,model)
+ call build_package(targets,model,verbose=settings%verbose)
end if
call new_installer(installer, prefix=settings%prefix, &
diff --git a/src/fpm_backend.f90 b/src/fpm_backend.f90
index e0c6d73..731763f 100644
--- a/src/fpm_backend.f90
+++ b/src/fpm_backend.f90
@@ -40,12 +40,20 @@ implicit none
private
public :: build_package, sort_target, schedule_targets
+interface
+ function c_isatty() bind(C, name = 'c_isatty')
+ use, intrinsic :: iso_c_binding, only: c_int
+ integer(c_int) :: c_isatty
+ end function
+end interface
+
contains
!> Top-level routine to build package described by `model`
-subroutine build_package(targets,model)
+subroutine build_package(targets,model,verbose)
type(build_target_ptr), intent(inout) :: targets(:)
type(fpm_model_t), intent(in) :: model
+ logical, intent(in) :: verbose
integer :: i, j
type(build_target_ptr), allocatable :: queue(:)
@@ -54,6 +62,8 @@ subroutine build_package(targets,model)
type(string_t), allocatable :: build_dirs(:)
type(string_t) :: temp
+ logical :: plain_output
+
! Need to make output directory for include (mod) files
allocate(build_dirs(0))
do i = 1, size(targets)
@@ -65,7 +75,7 @@ subroutine build_package(targets,model)
end do
do i = 1, size(build_dirs)
- call mkdir(build_dirs(i)%s)
+ call mkdir(build_dirs(i)%s,verbose)
end do
! Perform depth-first topological sort of targets
@@ -83,6 +93,8 @@ subroutine build_package(targets,model)
stat(:) = 0
build_failed = .false.
+ ! Set output mode
+ plain_output = (.not.(c_isatty()==1)) .or. verbose
! Loop over parallel schedule regions
do i=1,size(schedule_ptr)-1
@@ -95,7 +107,7 @@ subroutine build_package(targets,model)
skip_current = build_failed
if (.not.skip_current) then
- call build_target(model,queue(j)%ptr,stat(j))
+ call build_target(model,queue(j)%ptr,verbose,stat(j))
end if
! Set global flag if this target failed to build
@@ -261,16 +273,17 @@ end subroutine schedule_targets
!>
!> If successful, also caches the source file digest to disk.
!>
-subroutine build_target(model,target,stat)
+subroutine build_target(model,target,verbose,stat)
type(fpm_model_t), intent(in) :: model
type(build_target_t), intent(in), target :: target
+ logical, intent(in) :: verbose
integer, intent(out) :: stat
integer :: fh
!$omp critical
if (.not.exists(dirname(target%output_file))) then
- call mkdir(dirname(target%output_file))
+ call mkdir(dirname(target%output_file),verbose)
end if
!$omp end critical
diff --git a/src/isatty.c b/src/isatty.c
new file mode 100644
index 0000000..bd0f74a
--- /dev/null
+++ b/src/isatty.c
@@ -0,0 +1,13 @@
+#include <unistd.h> //for isatty()
+#include <stdio.h> //for fileno()
+
+int c_isatty(void)
+{
+
+ if (isatty(fileno(stdin))){
+ return 1;
+ } else {
+ return 0;
+ }
+
+} \ No newline at end of file