aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fpm/src/fpm_sources.f9039
1 files changed, 29 insertions, 10 deletions
diff --git a/fpm/src/fpm_sources.f90 b/fpm/src/fpm_sources.f90
index 2c15b8c..89e0849 100644
--- a/fpm/src/fpm_sources.f90
+++ b/fpm/src/fpm_sources.f90
@@ -556,23 +556,42 @@ subroutine resolve_module_dependencies(sources)
!
type(srcfile_t), intent(inout), target :: sources(:)
- integer :: n_depend, i, j
+ type(srcfile_ptr) :: dep
+
+ integer :: n_depend, i, pass, j
do i=1,size(sources)
- n_depend = size(sources(i)%modules_used)
+ do pass=1,2
+
+ n_depend = 0
+
+ do j=1,size(sources(i)%modules_used)
+
+ if (sources(i)%modules_used(j)%s .in. sources(i)%modules_provided) then
+ ! Dependency satisfied in same file, skip
+ cycle
+ end if
- allocate(sources(i)%file_dependencies(n_depend))
+ dep%ptr => find_module_dependency(sources,sources(i)%modules_used(j)%s)
- do j=1,n_depend
+ if (.not.associated(dep%ptr)) then
+ write(*,*) '(!) Unable to find source for module dependency: ', &
+ sources(i)%modules_used(j)%s
+ write(*,*) ' for file ',sources(i)%file_name
+ ! stop
+ end if
+
+ n_depend = n_depend + 1
+
+ if (pass == 2) then
+ sources(i)%file_dependencies(n_depend) = dep
+ end if
- sources(i)%file_dependencies(j)%ptr => &
- find_module_dependency(sources,sources(i)%modules_used(j)%s)
+ end do
- if (.not.associated(sources(i)%file_dependencies(j)%ptr)) then
- write(*,*) '(!) Unable to find source for module dependency: ',sources(i)%modules_used(j)%s
- write(*,*) ' for file ',sources(i)%file_name
- ! stop
+ if (pass == 1) then
+ allocate(sources(i)%file_dependencies(n_depend))
end if
end do