Deduplicate requirements
Because of some quirks in how formulae are loaded, DSL methods invoked in the class definition are called multiple times. This results in, for example, duplicate dependencies and requirements. Code that iterates over requirements and takes some action for each can thus repeat things that shouldn't be repeated, like appending to environment variables. Make DependencyCollector's external_deps a Set, and define eql? and hash on Requirement to prevent these duplicates. Signed-off-by: Jack Nagel <jacknagel@gmail.com>
This commit is contained in:
parent
5a62582b39
commit
96ee0e90cc
@ -1,3 +1,5 @@
|
|||||||
|
require 'set'
|
||||||
|
|
||||||
## This file defines dependencies and requirements.
|
## This file defines dependencies and requirements.
|
||||||
##
|
##
|
||||||
## A dependency is a formula that another formula needs to install.
|
## A dependency is a formula that another formula needs to install.
|
||||||
@ -21,7 +23,7 @@ class DependencyCollector
|
|||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@deps = Dependencies.new
|
@deps = Dependencies.new
|
||||||
@external_deps = []
|
@external_deps = Set.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def add spec
|
def add spec
|
||||||
@ -119,6 +121,14 @@ class Requirement
|
|||||||
def fatal?; false; end
|
def fatal?; false; end
|
||||||
def message; ""; end
|
def message; ""; end
|
||||||
def modify_build_environment; nil end
|
def modify_build_environment; nil end
|
||||||
|
|
||||||
|
def eql?(other)
|
||||||
|
other.is_a? self.class and hash == other.hash
|
||||||
|
end
|
||||||
|
|
||||||
|
def hash
|
||||||
|
@message.hash
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user