gather_files_with_mask Subroutine

private subroutine gather_files_with_mask(targets, visited, target_mask, files, file_mask, build_dir, dep_dirs)

Arguments

Type IntentOptional Attributes Name
type(build_target_ptr), intent(in) :: targets(:)
logical, intent(in) :: visited(:)
integer(kind=int64), intent(in), optional, allocatable :: target_mask(:)
type(string_t), intent(out), allocatable :: files(:)
integer(kind=int64), intent(out), allocatable :: file_mask(:)
character(len=*), intent(in) :: build_dir
type(string_t), intent(in), optional, allocatable :: dep_dirs(:)

Calls

proc~~gather_files_with_mask~~CallsGraph proc~gather_files_with_mask gather_files_with_mask include_dependencies include_dependencies proc~gather_files_with_mask->include_dependencies proc~vec_push_unique vec_push_unique proc~gather_files_with_mask->proc~vec_push_unique exists exists proc~vec_push_unique->exists proc~is_ignored_path is_ignored_path proc~vec_push_unique->proc~is_ignored_path proc~is_in_dep_dirs is_in_dep_dirs proc~vec_push_unique->proc~is_in_dep_dirs proc~normalize_path normalize_path proc~vec_push_unique->proc~normalize_path proc~vec_grow vec_grow proc~vec_push_unique->proc~vec_grow proc~is_ignored_path->proc~normalize_path proc~contains_path_fragment contains_path_fragment proc~is_ignored_path->proc~contains_path_fragment proc~starts_with starts_with proc~is_ignored_path->proc~starts_with proc~is_in_dep_dirs->proc~normalize_path proc~is_in_dep_dirs->proc~starts_with proc~ends_with ends_with proc~contains_path_fragment->proc~ends_with

Called by

proc~~gather_files_with_mask~~CalledByGraph proc~gather_files_with_mask gather_files_with_mask proc~compute_watch_files_from_settings compute_watch_files_from_settings proc~compute_watch_files_from_settings->proc~gather_files_with_mask proc~rebuild_watch_list rebuild_watch_list proc~rebuild_watch_list->proc~compute_watch_files_from_settings proc~handle_manifest_change handle_manifest_change proc~handle_manifest_change->proc~rebuild_watch_list proc~watcher_init watcher_t%watcher_init proc~watcher_init->proc~rebuild_watch_list proc~watcher_run watcher_t%watcher_run proc~watcher_run->proc~rebuild_watch_list proc~watcher_run->proc~handle_manifest_change

Source Code

   subroutine gather_files_with_mask(targets, visited, target_mask, files, file_mask, build_dir, dep_dirs)
      type(build_target_ptr), intent(in) :: targets(:)
      logical, intent(in) :: visited(:)
      integer(int64), allocatable, intent(in), optional :: target_mask(:)
      type(string_t), allocatable, intent(out) :: files(:)
      integer(int64), allocatable, intent(out) :: file_mask(:)
      character(len=*), intent(in) :: build_dir
      type(string_t), allocatable, intent(in), optional :: dep_dirs(:)

      type(string_t), allocatable :: buf(:)
      integer(int64), allocatable :: mbuf(:)
      integer :: n, cap
      integer :: i, j
      integer(int64) :: m

      n = 0
      cap = 256
      allocate(buf(cap), mbuf(cap))

      do i = 1, size(targets)
         if (.not. visited(i)) cycle
         if (.not. allocated(targets(i)%ptr%source)) cycle

         m = 0_int64
         if (present(target_mask)) then
            if (allocated(target_mask)) m = target_mask(i)
         end if

         if (present(dep_dirs)) then
            call vec_push_unique(buf, mbuf, n, cap, targets(i)%ptr%source%file_name, build_dir, m, dep_dirs)
         else
            call vec_push_unique(buf, mbuf, n, cap, targets(i)%ptr%source%file_name, build_dir, m)
         end if

         if (allocated(targets(i)%ptr%source%include_dependencies)) then
            do j = 1, size(targets(i)%ptr%source%include_dependencies)
               if (present(dep_dirs)) then
                  call vec_push_unique(buf, mbuf, n, cap, targets(i)%ptr%source%include_dependencies(j)%s, build_dir, m, dep_dirs)
               else
                  call vec_push_unique(buf, mbuf, n, cap, targets(i)%ptr%source%include_dependencies(j)%s, build_dir, m)
               end if
            end do
         end if
      end do

      call finalize_vec(buf, mbuf, n, files, file_mask)

   contains

      subroutine finalize_vec(buf, mbuf, n, files, file_mask)
         type(string_t), allocatable, intent(inout) :: buf(:)
         integer(int64), allocatable, intent(inout) :: mbuf(:)
         integer, intent(in) :: n
         type(string_t), allocatable, intent(out) :: files(:)
         integer(int64), allocatable, intent(out) :: file_mask(:)
         integer :: k

         if (n <= 0) then
            allocate(files(0), file_mask(0))
            deallocate(buf, mbuf)
            return
         end if

         allocate(files(n), file_mask(n))
         do k = 1, n
            call move_alloc(buf(k)%s, files(k)%s)
            file_mask(k) = mbuf(k)
         end do
         deallocate(buf, mbuf)
      end subroutine finalize_vec

   end subroutine gather_files_with_mask