fix circular build dependency detection logic
This commit is contained in:
parent
60b3fdbcac
commit
7f7e6ef3da
@ -47,24 +47,18 @@ module Rscons
|
|||||||
# @return [nil, Hash]
|
# @return [nil, Hash]
|
||||||
# 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_skipped = Set.new
|
|
||||||
@jobs.keys.each do |target|
|
@jobs.keys.each do |target|
|
||||||
skip = false
|
skip = false
|
||||||
(@jobs[target][0][:sources] + (@build_dependencies[target] || []).to_a).each do |src|
|
(@jobs[target][0][:sources] + (@build_dependencies[target] || []).to_a).each do |src|
|
||||||
if @jobs.include?(src)
|
if @jobs.include?(src)
|
||||||
if targets_skipped.include?(src) or (src == target)
|
# Skip this target because it depends on another target not yet
|
||||||
# We have encountered a circular dependency.
|
# built.
|
||||||
raise "Circular build dependency for #{src}"
|
|
||||||
end
|
|
||||||
# Skip this target because it depends on another target later in
|
|
||||||
# the job set.
|
|
||||||
targets_skipped << target
|
|
||||||
skip = true
|
skip = true
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
if targets_still_building.include?(src)
|
if targets_still_building.include?(src)
|
||||||
# Skip this target because it depends on another target that is
|
# Skip this target because it depends on another target that is
|
||||||
# still being built.
|
# currently being built.
|
||||||
skip = true
|
skip = true
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
@ -79,7 +73,12 @@ module Rscons
|
|||||||
return job
|
return job
|
||||||
end
|
end
|
||||||
|
|
||||||
nil
|
# If there is a job to run, and nothing is still building, but we did
|
||||||
|
# not find a job to run above, then there might be a circular dependency
|
||||||
|
# introduced by the user.
|
||||||
|
if (@jobs.size > 0) and targets_still_building.empty?
|
||||||
|
raise "Could not find a runnable job. Possible circular dependency for #{@jobs.keys.first}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Remove all jobs from the JobSet.
|
# Remove all jobs from the JobSet.
|
||||||
|
@ -735,14 +735,14 @@ EOF
|
|||||||
it "raises an error for a circular dependency" do
|
it "raises an error for a circular dependency" do
|
||||||
test_dir("simple")
|
test_dir("simple")
|
||||||
result = run_test(rsconsfile: "error_circular_dependency.rb")
|
result = run_test(rsconsfile: "error_circular_dependency.rb")
|
||||||
expect(result.stderr).to match /Circular build dependency for (foo|bar|baz)/
|
expect(result.stderr).to match /Possible circular dependency for (foo|bar|baz)/
|
||||||
expect(result.status).to_not eq 0
|
expect(result.status).to_not eq 0
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raises an error for a circular dependency where a build target contains itself in its source list" do
|
it "raises an error for a circular dependency where a build target contains itself in its source list" do
|
||||||
test_dir("simple")
|
test_dir("simple")
|
||||||
result = run_test(rsconsfile: "error_circular_dependency2.rb")
|
result = run_test(rsconsfile: "error_circular_dependency2.rb")
|
||||||
expect(result.stderr).to match /Circular build dependency for foo/
|
expect(result.stderr).to match /Possible circular dependency for foo/
|
||||||
expect(result.status).to_not eq 0
|
expect(result.status).to_not eq 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user