2015-11-17 20:49:10 +08:00
|
|
|
require "dependency_collector"
|
|
|
|
|
|
|
|
class DependencyCollector
|
2017-12-23 16:38:06 +00:00
|
|
|
alias _parse_string_spec parse_string_spec
|
|
|
|
|
|
|
|
# Define the languages that we can handle as external dependencies.
|
|
|
|
LANGUAGE_MODULES = Set[
|
|
|
|
:lua, :lua51, :perl, :python, :python3, :ruby
|
|
|
|
].freeze
|
|
|
|
|
|
|
|
def parse_string_spec(spec, tags)
|
|
|
|
if (tag = tags.first) && LANGUAGE_MODULES.include?(tag)
|
2018-01-09 19:52:34 +00:00
|
|
|
odeprecated "'depends_on :#{tag}'"
|
2017-12-23 16:38:06 +00:00
|
|
|
LanguageModuleRequirement.new(tag, spec, tags[1])
|
|
|
|
else
|
|
|
|
_parse_string_spec(spec, tags)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-09-23 18:13:48 +02:00
|
|
|
alias _parse_symbol_spec parse_symbol_spec
|
2015-11-17 20:49:10 +08:00
|
|
|
|
2015-11-16 23:18:31 +08:00
|
|
|
def parse_symbol_spec(spec, tags)
|
|
|
|
case spec
|
|
|
|
when :clt
|
2016-07-16 22:14:55 +01:00
|
|
|
odeprecated "'depends_on :clt'"
|
2017-12-30 18:58:30 +00:00
|
|
|
when :tex
|
2018-01-09 19:52:34 +00:00
|
|
|
odeprecated "'depends_on :tex'"
|
2017-12-30 18:58:30 +00:00
|
|
|
TeXRequirement.new(tags)
|
2015-11-16 23:18:31 +08:00
|
|
|
when :autoconf, :automake, :bsdmake, :libtool
|
2016-07-16 22:14:55 +01:00
|
|
|
output_deprecation(spec, tags)
|
2015-11-16 23:18:31 +08:00
|
|
|
autotools_dep(spec, tags)
|
|
|
|
when :cairo, :fontconfig, :freetype, :libpng, :pixman
|
2016-07-16 22:14:55 +01:00
|
|
|
output_deprecation(spec, tags)
|
2015-11-16 23:18:31 +08:00
|
|
|
Dependency.new(spec.to_s, tags)
|
2017-12-30 18:58:30 +00:00
|
|
|
when :ant, :expat
|
|
|
|
# output_deprecation(spec, tags)
|
|
|
|
Dependency.new(spec.to_s, tags)
|
2015-11-16 23:18:31 +08:00
|
|
|
when :libltdl
|
|
|
|
tags << :run
|
2016-07-16 22:14:55 +01:00
|
|
|
output_deprecation("libtool", tags)
|
2015-11-16 23:18:31 +08:00
|
|
|
Dependency.new("libtool", tags)
|
2017-12-30 18:58:30 +00:00
|
|
|
when :apr
|
2018-01-09 19:52:34 +00:00
|
|
|
output_deprecation(spec, tags, "apr-util")
|
2017-12-30 18:58:30 +00:00
|
|
|
Dependency.new("apr-util", tags)
|
|
|
|
when :fortran
|
|
|
|
# output_deprecation(spec, tags, "gcc")
|
|
|
|
FortranRequirement.new(tags)
|
|
|
|
when :gpg
|
|
|
|
# output_deprecation(spec, tags, "gnupg")
|
|
|
|
GPG2Requirement.new(tags)
|
|
|
|
when :hg
|
|
|
|
# output_deprecation(spec, tags, "mercurial")
|
|
|
|
MercurialRequirement.new(tags)
|
|
|
|
when :mpi
|
|
|
|
# output_deprecation(spec, tags, "open-mpi")
|
|
|
|
MPIRequirement.new(*tags)
|
|
|
|
when :emacs
|
|
|
|
# output_deprecation(spec, tags)
|
|
|
|
EmacsRequirement.new(tags)
|
2017-12-23 16:38:06 +00:00
|
|
|
when :mysql
|
2017-12-30 18:58:30 +00:00
|
|
|
# output_deprecation(spec, tags)
|
2017-12-23 16:38:06 +00:00
|
|
|
MysqlRequirement.new(tags)
|
2017-12-30 18:58:30 +00:00
|
|
|
when :perl
|
|
|
|
# output_deprecation(spec, tags)
|
|
|
|
PerlRequirement.new(tags)
|
2017-12-23 16:38:06 +00:00
|
|
|
when :postgresql
|
2017-12-30 18:58:30 +00:00
|
|
|
# output_deprecation(spec, tags)
|
2017-12-23 16:38:06 +00:00
|
|
|
PostgresqlRequirement.new(tags)
|
2017-12-30 18:58:30 +00:00
|
|
|
when :python, :python2
|
|
|
|
# output_deprecation(spec, tags)
|
|
|
|
PythonRequirement.new(tags)
|
|
|
|
when :python3
|
|
|
|
# output_deprecation(spec, tags)
|
|
|
|
Python3Requirement.new(tags)
|
2017-12-23 16:38:06 +00:00
|
|
|
when :rbenv
|
2017-12-30 18:58:30 +00:00
|
|
|
# output_deprecation(spec, tags)
|
2017-12-23 16:38:06 +00:00
|
|
|
RbenvRequirement.new(tags)
|
2017-12-30 18:58:30 +00:00
|
|
|
when :ruby
|
|
|
|
# output_deprecation(spec, tags)
|
|
|
|
RubyRequirement.new(tags)
|
2015-11-16 23:18:31 +08:00
|
|
|
else
|
2015-11-17 20:49:10 +08:00
|
|
|
_parse_symbol_spec(spec, tags)
|
2015-11-16 23:18:31 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def autotools_dep(spec, tags)
|
|
|
|
tags << :build unless tags.include? :run
|
|
|
|
Dependency.new(spec.to_s, tags)
|
|
|
|
end
|
2016-07-16 22:14:55 +01:00
|
|
|
|
2016-10-12 15:37:33 +01:00
|
|
|
def output_deprecation(dependency, tags, new_dependency = dependency)
|
2016-07-16 22:14:55 +01:00
|
|
|
tags_string = if tags.length > 1
|
|
|
|
" => [:#{tags.join ", :"}]"
|
|
|
|
elsif tags.length == 1
|
|
|
|
" => :#{tags.first}"
|
|
|
|
end
|
|
|
|
odeprecated "'depends_on :#{dependency}'",
|
2016-10-12 15:37:33 +01:00
|
|
|
"'depends_on \"#{new_dependency}\"#{tags_string}'"
|
2016-07-16 22:14:55 +01:00
|
|
|
end
|
2015-11-16 23:18:31 +08:00
|
|
|
end
|