Skip to content

Commit b0c855d

Browse files
committed
Update: enumeration of used modules for efficiency
Add redundancy check to recursive exploration of used modules to avoid redundant re-processing and consequent poor-scaling for large projects.
1 parent 28dcdc4 commit b0c855d

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

src/fpm_targets.f90

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,8 @@ subroutine prune_build_targets(targets, root_package)
515515

516516
end if
517517

518+
call reset_target_flags(targets)
519+
518520
exclude_target(:) = .false.
519521

520522
! Exclude purely module targets if they are not used anywhere
@@ -592,11 +594,18 @@ subroutine prune_build_targets(targets, root_package)
592594

593595
contains
594596

597+
!> Recursively collect which modules are actually used
595598
recursive subroutine collect_used_modules(target)
596-
type(build_target_t), intent(in) :: target
599+
type(build_target_t), intent(inout) :: target
597600

598601
integer :: j, k
599602

603+
if (target%touched) then
604+
return
605+
else
606+
target%touched = .true.
607+
end if
608+
600609
if (allocated(target%source)) then
601610
do j=1,size(target%source%modules_used)
602611

@@ -631,6 +640,20 @@ recursive subroutine collect_used_modules(target)
631640

632641
end subroutine collect_used_modules
633642

643+
!> Reset target flags after recursive search
644+
subroutine reset_target_flags(targets)
645+
type(build_target_ptr), intent(inout) :: targets(:)
646+
647+
integer :: i
648+
649+
do i=1,size(targets)
650+
651+
targets(i)%ptr%touched = .false.
652+
653+
end do
654+
655+
end subroutine reset_target_flags
656+
634657
end subroutine prune_build_targets
635658

636659

0 commit comments

Comments
 (0)