simplify JobSet logic a little
This commit is contained in:
parent
7cfd23e16f
commit
ee1640008c
@ -1,5 +1,3 @@
|
|||||||
require "set"
|
|
||||||
|
|
||||||
module Rscons
|
module Rscons
|
||||||
# Class to keep track of a set of jobs that need to be performed.
|
# Class to keep track of a set of jobs that need to be performed.
|
||||||
class JobSet
|
class JobSet
|
||||||
@ -41,31 +39,27 @@ module Rscons
|
|||||||
# a job as available to run if it depends on one of the targets that are
|
# a job as available to run if it depends on one of the targets that are
|
||||||
# still building as a source.
|
# still building as a source.
|
||||||
#
|
#
|
||||||
# @return [nil, Hash]
|
# @return [nil, Builder]
|
||||||
# The next job to run.
|
# The next job to run.
|
||||||
def get_next_job_to_run(targets_still_building)
|
def get_next_job_to_run(targets_still_building)
|
||||||
targets_not_built_yet = targets_still_building + @jobs.keys
|
not_built_yet = targets_still_building + @jobs.keys
|
||||||
side_effects = targets_not_built_yet.map do |target|
|
not_built_yet += not_built_yet.reduce([]) do |result, target|
|
||||||
@side_effects[target] || []
|
result + (@side_effects[target] || [])
|
||||||
end.flatten
|
end
|
||||||
targets_not_built_yet += side_effects
|
|
||||||
|
|
||||||
@jobs.keys.each do |target|
|
target_to_build = @jobs.keys.find do |target|
|
||||||
skip = false
|
deps = @jobs[target][0].sources + (@build_dependencies[target] || []).to_a
|
||||||
(@jobs[target][0].sources + (@build_dependencies[target] || []).to_a).each do |src|
|
!deps.find {|dep| not_built_yet.include?(dep)}
|
||||||
if targets_not_built_yet.include?(src)
|
end
|
||||||
skip = true
|
|
||||||
break
|
if target_to_build
|
||||||
end
|
builder = @jobs[target_to_build][0]
|
||||||
end
|
if @jobs[target_to_build].size > 1
|
||||||
next if skip
|
@jobs[target_to_build].slice!(0)
|
||||||
job = @jobs[target][0]
|
|
||||||
if @jobs[target].size > 1
|
|
||||||
@jobs[target].slice!(0)
|
|
||||||
else
|
else
|
||||||
@jobs.delete(target)
|
@jobs.delete(target_to_build)
|
||||||
end
|
end
|
||||||
return job
|
return builder
|
||||||
end
|
end
|
||||||
|
|
||||||
# If there is a job to run, and nothing is still building, but we did
|
# If there is a job to run, and nothing is still building, but we did
|
||||||
|
Loading…
x
Reference in New Issue
Block a user