aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Vandenberg2012-07-03 07:49:30 -0700
committerAdam Vandenberg2012-07-10 08:54:55 -0700
commitd17e3b4aede3ddf5ae5bab5e0825a3bbfdf51fd7 (patch)
tree6225efbed4a0ed602f15ae6b69fa9068176617d5
parent7dadb80d1336649e189c5f268eaaf89d410601a8 (diff)
downloadhomebrew-d17e3b4aede3ddf5ae5bab5e0825a3bbfdf51fd7.tar.bz2
Refactor dependencies in preparation for autotools symbol support
-rw-r--r--Library/Homebrew/dependencies.rb26
1 files changed, 21 insertions, 5 deletions
diff --git a/Library/Homebrew/dependencies.rb b/Library/Homebrew/dependencies.rb
index 1ca1298fb..adcd4f4ed 100644
--- a/Library/Homebrew/dependencies.rb
+++ b/Library/Homebrew/dependencies.rb
@@ -28,11 +28,20 @@ class DependencyCollector
tag = nil
spec, tag = spec.shift if spec.is_a? Hash
- dep = case spec
- when :x11, :libpng
- X11Dependency.new(tag)
+ dep = parse_spec(spec, tag)
+ # Some symbol specs are conditional, and resolve to nil if there is no
+ # dependency needed for the current platform.
+ return if dep.nil?
+ # Add dep to the correct bucket
+ (dep.is_a?(Requirement) ? @external_deps : @deps) << dep
+ end
+
+private
+
+ def parse_spec spec, tag
+ case spec
when Symbol
- raise "Unsupported special dependency #{spec}"
+ parse_symbol_spec(spec, tag)
when String
if LANGUAGE_MODULES.include? tag
LanguageModuleDependency.new(tag, spec)
@@ -46,8 +55,15 @@ class DependencyCollector
else
raise "Unsupported type #{spec.class} for #{spec}"
end
+ end
- (dep.is_a?(Requirement) ? @external_deps : @deps) << dep
+ def parse_symbol_spec spec, tag
+ case spec
+ when :x11, :libpng
+ X11Dependency.new(tag)
+ else
+ raise "Unsupported special dependency #{spec}"
+ end
end
end