JobSet#get_next_job_to_run: take into account targets still building

This commit is contained in:
Josh Holtrop 2017-05-17 10:19:43 -04:00
parent 9cc59a35f0
commit 5de52620e4
2 changed files with 36 additions and 19 deletions

View File

@ -286,9 +286,10 @@ module Rscons
begin begin
while @job_set.size > 0 while @job_set.size > 0
# TODO: get_next_job_to_run needs to take into account targets still targets_still_building = @threaded_commands.map do |tc|
# being processed. tc.build_operation[:target]
job = @job_set.get_next_job_to_run end
job = @job_set.get_next_job_to_run(targets_still_building)
# TODO: have Cache determine when checksums may be invalid based on # TODO: have Cache determine when checksums may be invalid based on
# file size and/or timestamp. # file size and/or timestamp.

View File

@ -34,28 +34,44 @@ module Rscons
# #
# This method will remove the job from the JobSet. # This method will remove the job from the JobSet.
# #
# @param targets_still_building [Array<String>]
# Targets that are not finished building. This is used to avoid returning
# a job as available to run if it depends on one of the targets that are
# still building as a source.
#
# @return [nil, Hash] # @return [nil, Hash]
# The next job to run. # The next job to run.
def get_next_job_to_run def get_next_job_to_run(targets_still_building)
if @jobs.size > 0 attempted_targets = Set.new
evaluated_targets = Set.new
attempt = lambda do |target| @jobs.keys.each do |target|
evaluated_targets << target attempted_targets << target
@jobs[target][0][:sources].each do |src| skip = false
if @jobs.include?(src) and not evaluated_targets.include?(src) @jobs[target][0][:sources].each do |src|
return attempt[src] if @jobs.include?(src) and not attempted_targets.include?(src)
end # Skip this target because it depends on another target later in
# the job set.
skip = true
break
end end
job = @jobs[target][0] if targets_still_building.include?(src)
if @jobs[target].size > 1 # Skip this target because it depends on another target that is
@jobs[target].slice!(0) # still being built.
else skip = true
@jobs.delete(target) break
end end
return job
end end
attempt[@jobs.first.first] next if skip
job = @jobs[target][0]
if @jobs[target].size > 1
@jobs[target].slice!(0)
else
@jobs.delete(target)
end
return job
end end
nil
end end
# Remove all jobs from the JobSet. # Remove all jobs from the JobSet.