fix circular build dependency detection logic
This commit is contained in:
parent
60b3fdbcac
commit
7f7e6ef3da
@ -47,24 +47,18 @@ module Rscons
|
||||
# @return [nil, Hash]
|
||||
# The next job to run.
|
||||
def get_next_job_to_run(targets_still_building)
|
||||
targets_skipped = Set.new
|
||||
@jobs.keys.each do |target|
|
||||
skip = false
|
||||
(@jobs[target][0][:sources] + (@build_dependencies[target] || []).to_a).each do |src|
|
||||
if @jobs.include?(src)
|
||||
if targets_skipped.include?(src) or (src == target)
|
||||
# We have encountered a circular dependency.
|
||||
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 this target because it depends on another target not yet
|
||||
# built.
|
||||
skip = true
|
||||
break
|
||||
end
|
||||
if targets_still_building.include?(src)
|
||||
# Skip this target because it depends on another target that is
|
||||
# still being built.
|
||||
# currently being built.
|
||||
skip = true
|
||||
break
|
||||
end
|
||||
@ -79,7 +73,12 @@ module Rscons
|
||||
return job
|
||||
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
|
||||
|
||||
# Remove all jobs from the JobSet.
|
||||
|
@ -735,14 +735,14 @@ EOF
|
||||
it "raises an error for a circular dependency" do
|
||||
test_dir("simple")
|
||||
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
|
||||
end
|
||||
|
||||
it "raises an error for a circular dependency where a build target contains itself in its source list" do
|
||||
test_dir("simple")
|
||||
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
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user