aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLKedward <laurence.kedward@bristol.ac.uk>2020-09-19 11:23:10 +0100
committerLKedward <laurence.kedward@bristol.ac.uk>2020-09-19 11:23:10 +0100
commit5f7e4e5ec4fe10b7cca8aeaadb98ab376cdedfaf (patch)
treea206544381d56b87b8eefc7bd4eb66f5e005a76e
parent0f0a191051f9721d656301e92ab7024229d60c41 (diff)
downloadfpm-5f7e4e5ec4fe10b7cca8aeaadb98ab376cdedfaf.tar.gz
fpm-5f7e4e5ec4fe10b7cca8aeaadb98ab376cdedfaf.zip
Update: module resolution to ignore same file dependency
If a module dependency is satisfied in the same file, it is not added to file_dependencies. Use two-pass procedure to count the number of actual file_dependencies required for module resolution.
-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