Allow requirements to specify a default formula.
This allows default resolution of requirements without user intervention. Closes Homebrew/homebrew#19627.
This commit is contained in:
parent
ba93e6d363
commit
92ccfc548e
@ -75,6 +75,11 @@ class Requirement
|
||||
end
|
||||
|
||||
class << self
|
||||
# The default formula to install to satisfy this requirement.
|
||||
def default_formula(val=nil)
|
||||
val.nil? ? @default_formula : @default_formula = val.to_s
|
||||
end
|
||||
|
||||
def fatal(val=nil)
|
||||
val.nil? ? @fatal : @fatal = val
|
||||
end
|
||||
@ -138,6 +143,13 @@ class Requirement
|
||||
|
||||
next if prune
|
||||
|
||||
# TODO: Do this in a cleaner way, perhaps with another type of
|
||||
# dependency type.
|
||||
if req.class.default_formula
|
||||
dependent.class.depends_on(req.class.default_formula)
|
||||
next
|
||||
end
|
||||
|
||||
reqs << req
|
||||
end
|
||||
end
|
||||
|
||||
@ -19,6 +19,7 @@ end
|
||||
|
||||
class MysqlDependency < Requirement
|
||||
fatal true
|
||||
default_formula 'mysql'
|
||||
|
||||
satisfy { which 'mysql_config' }
|
||||
|
||||
@ -40,6 +41,7 @@ end
|
||||
|
||||
class PostgresqlDependency < Requirement
|
||||
fatal true
|
||||
default_formula 'postgres'
|
||||
|
||||
satisfy { which 'pg_config' }
|
||||
|
||||
@ -110,6 +112,7 @@ end
|
||||
|
||||
class MercurialDependency < Requirement
|
||||
fatal true
|
||||
default_formula 'mercurial'
|
||||
|
||||
satisfy { which('hg') }
|
||||
|
||||
|
||||
@ -9,6 +9,8 @@ class MPIDependency < Requirement
|
||||
|
||||
fatal true
|
||||
|
||||
default_formula 'open-mpi'
|
||||
|
||||
env :userpaths
|
||||
|
||||
def initialize *lang_list
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user