lib/dake/resolver.rb
# check if a step needs to be executed to produce the given targets
check if a step needs to be executed to produce the given targets
check if a step needs to be executed to produce the given targets
def need_execute?(targets, step)
    max_mtime = nil
    targets.each do |target|
      return true if target.tag
      return true unless target.scheme.exist?
      target_mtime = target.scheme.mtime
      if max_mtime
        max_mtime = target_mtime if target_mtime > max_mtime
      else
        max_mtime = target_mtime
      end
    end
    files = step.prerequisites.reject { |dep| dep.tag }
    files.each do |file|
      next if file.flag == '?'
      if file.scheme.exist?
        file_mtime = file.scheme.mtime
        return true if file_mtime > max_mtime
      else
        return true
      end
    end
    false
  end
def need_execute? ( targets , step ) max_mtime = nil targets . each do | target | return true if target . tag return true unless target . scheme . exist? target_mtime = target . scheme . mtime if max_mtime max_mtime = target_mtime if target_mtime > max_mtime else max_mtime = target_mtime end end files = step . prerequisites . reject { | dep | dep . tag } files . each do | file | next if file . flag == '?' if file . scheme . exist? file_mtime = file . scheme . mtime return true if file_mtime > max_mtime else return true end end false end
check if a step needs to be executed to produce the given targets
check if a step needs to be executed to produce the given targets
# a tag target can be thought as newer than any prerequisite, # the step should always be executed to produce the tag target # if a target doesn't exist, the step should always be executed to produce it # find the newest modification time in all targets # if any required file is newer than the newest target, # the step should be executed to update the target # if a required file doesn't exist, # it means a step should be executed to produce the file, # and the newly produced file will be newer than all the targets, # therefore this step should also be executed # if not in any case above, the step doesn't need to be executed
targets
<not_specific>
step
<not_specific>