aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/compat/dependency_collector.rb
blob: fbcf1c2a0f788a7babf0c8a729af92011ef98e29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
require "dependency_collector"

class DependencyCollector
  alias _parse_symbol_spec parse_symbol_spec

  def parse_symbol_spec(spec, tags)
    case spec
    when :clt
      odeprecated "'depends_on :clt'"
    when :autoconf, :automake, :bsdmake, :libtool
      output_deprecation(spec, tags)
      autotools_dep(spec, tags)
    when :cairo, :fontconfig, :freetype, :libpng, :pixman
      output_deprecation(spec, tags)
      Dependency.new(spec.to_s, tags)
    when :apr
      # output_deprecation(spec, tags, "apr-util")
      Dependency.new("apr-util", tags)
    when :libltdl
      tags << :run
      output_deprecation("libtool", tags)
      Dependency.new("libtool", tags)
    else
      _parse_symbol_spec(spec, tags)
    end
  end

  def autotools_dep(spec, tags)
    tags << :build unless tags.include? :run
    Dependency.new(spec.to_s, tags)
  end

  def output_deprecation(dependency, tags, new_dependency = dependency)
    tags_string = if tags.length > 1
      " => [:#{tags.join ", :"}]"
    elsif tags.length == 1
      " => :#{tags.first}"
    end
    odeprecated "'depends_on :#{dependency}'",
                "'depends_on \"#{new_dependency}\"#{tags_string}'"
  end
end