manifest_key_from_files Function

public function manifest_key_from_files(settings, files) result(k)

Compute a key representing the current manifest-related configuration.

This key is used to detect when changes require rebuilding the watch list. It includes: - Selected fpm_build_settings fields - Feature list (settings%features) - The fingerprint of any watched file named fpm.toml

Arguments

Type IntentOptional Attributes Name
class(fpm_build_settings), intent(in) :: settings
type(string_t), intent(in), allocatable :: files(:)

Return Value integer(kind=int64)


Calls

proc~~manifest_key_from_files~~CallsGraph proc~manifest_key_from_files manifest_key_from_files basename basename proc~manifest_key_from_files->basename features features proc~manifest_key_from_files->features proc~file_fingerprint file_fingerprint proc~manifest_key_from_files->proc~file_fingerprint proc~fnv1a_mix_i64 fnv1a_mix_i64 proc~manifest_key_from_files->proc~fnv1a_mix_i64 proc~fnv1a_mix_str fnv1a_mix_str proc~manifest_key_from_files->proc~fnv1a_mix_str proc~hash_block hash_block proc~file_fingerprint->proc~hash_block proc~fnv1a_mix_str->proc~fnv1a_mix_i64 proc~hash_block->proc~fnv1a_mix_i64

Called by

proc~~manifest_key_from_files~~CalledByGraph proc~manifest_key_from_files manifest_key_from_files proc~handle_manifest_change handle_manifest_change proc~handle_manifest_change->proc~manifest_key_from_files proc~rebuild_watch_list rebuild_watch_list proc~handle_manifest_change->proc~rebuild_watch_list proc~rebuild_watch_list->proc~manifest_key_from_files 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~handle_manifest_change proc~watcher_run->proc~rebuild_watch_list

Source Code

   integer(int64) function manifest_key_from_files(settings, files) result(k)
      class(fpm_build_settings), intent(in) :: settings
      type(string_t), allocatable, intent(in) :: files(:)

      integer :: i
      character(len=:), allocatable :: b

      k = FNV_OFFSET

      call mix_alloc(k, settings%build_dir)
      call mix_alloc(k, settings%compiler)
      call mix_alloc(k, settings%c_compiler)
      call mix_alloc(k, settings%cxx_compiler)
      call mix_alloc(k, settings%archiver)
      call mix_alloc(k, settings%profile)
      call mix_alloc(k, settings%flag)
      call mix_alloc(k, settings%cflag)
      call mix_alloc(k, settings%cxxflag)
      call mix_alloc(k, settings%ldflag)

      if (settings%prune) then
         call fnv1a_mix_str(k, "prune=1")
      else
         call fnv1a_mix_str(k, "prune=0")
      end if

      if (settings%build_tests) then
         call fnv1a_mix_str(k, "build_tests=1")
      else
         call fnv1a_mix_str(k, "build_tests=0")
      end if

      if (allocated(settings%features)) then
         do i = 1, size(settings%features)
            call fnv1a_mix_str(k, trim(settings%features(i)%s))
         end do
      end if

      if (.not. allocated(files)) return
      do i = 1, size(files)
         b = basename(files(i)%s)
         if (b == "fpm.toml") then
            call fnv1a_mix_str(k, files(i)%s)
            call fnv1a_mix_i64(k, file_fingerprint(files(i)%s))
         end if
      end do

   contains

      subroutine mix_alloc(h, s)
         integer(int64), intent(inout) :: h
         character(len=:), allocatable, intent(in) :: s
         if (.not. allocated(s)) return
         if (len_trim(s) == 0) return
         call fnv1a_mix_str(h, trim(s))
      end subroutine mix_alloc

   end function manifest_key_from_files