2013-04-02 15:33:35 -05:00
|
|
|
require 'requirement'
|
2013-04-02 16:18:51 -05:00
|
|
|
require 'extend/set'
|
2013-04-02 15:33:35 -05:00
|
|
|
|
|
|
|
class X11Dependency < Requirement
|
|
|
|
include Comparable
|
|
|
|
attr_reader :min_version
|
|
|
|
|
|
|
|
fatal true
|
|
|
|
|
|
|
|
env { ENV.x11 }
|
|
|
|
|
2013-05-06 16:08:50 -05:00
|
|
|
def initialize(name="x11", tags=[])
|
2013-04-02 15:33:35 -05:00
|
|
|
@name = name
|
|
|
|
@min_version = tags.shift if /(\d\.)+\d/ === tags.first
|
|
|
|
super(tags)
|
|
|
|
end
|
|
|
|
|
|
|
|
satisfy :build_env => false do
|
|
|
|
MacOS::XQuartz.installed? && (@min_version.nil? || @min_version <= MacOS::XQuartz.version)
|
|
|
|
end
|
|
|
|
|
|
|
|
def message; <<-EOS.undent
|
|
|
|
Unsatisfied dependency: XQuartz #{@min_version}
|
|
|
|
Homebrew does not package XQuartz. Installers may be found at:
|
|
|
|
https://xquartz.macosforge.org
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
|
|
|
def <=> other
|
|
|
|
unless other.is_a? X11Dependency
|
|
|
|
raise TypeError, "expected X11Dependency"
|
|
|
|
end
|
|
|
|
|
|
|
|
if min_version.nil? && other.min_version.nil?
|
|
|
|
0
|
|
|
|
elsif other.min_version.nil?
|
|
|
|
1
|
|
|
|
elsif @min_version.nil?
|
|
|
|
-1
|
|
|
|
else
|
|
|
|
@min_version <=> other.min_version
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# When X11Dependency is subclassed, the new class should
|
|
|
|
# also inherit the information specified in the DSL above.
|
|
|
|
def self.inherited(mod)
|
|
|
|
instance_variables.each do |ivar|
|
|
|
|
mod.instance_variable_set(ivar, instance_variable_get(ivar))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# X11Dependency::Proxy is a base class for the X11 pseudo-deps.
|
|
|
|
# Rather than instantiate it directly, a separate class is built
|
|
|
|
# for each of the packages that we proxy to X11Dependency.
|
|
|
|
class Proxy < self
|
|
|
|
PACKAGES = [:libpng, :freetype, :fontconfig]
|
|
|
|
|
|
|
|
class << self
|
|
|
|
def defines_const?(const)
|
|
|
|
if ::RUBY_VERSION >= "1.9"
|
|
|
|
const_defined?(const, false)
|
|
|
|
else
|
|
|
|
const_defined?(const)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-05-06 16:08:50 -05:00
|
|
|
def for(name, tags=[])
|
2013-04-02 15:33:35 -05:00
|
|
|
constant = name.capitalize
|
|
|
|
|
|
|
|
if defines_const?(constant)
|
|
|
|
klass = const_get(constant)
|
|
|
|
else
|
|
|
|
klass = Class.new(self) do
|
2013-05-06 16:08:50 -05:00
|
|
|
def initialize(name, tags) super end
|
2013-04-02 15:33:35 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
const_set(constant, klass)
|
|
|
|
end
|
2013-05-06 16:08:50 -05:00
|
|
|
klass.new(name, tags)
|
2013-04-02 15:33:35 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|