Add more external dep options
* Chicken Scheme * Node.js * Rubinius Closes Homebrew/homebrew#8466. Signed-off-by: Adam Vandenberg <flangy@gmail.com>
This commit is contained in:
		
							parent
							
								
									5d1db0e934
								
							
						
					
					
						commit
						8a4cb8c0ac
					
				@ -76,8 +76,10 @@ class UnsatisfiedExternalDependencyError < Homebrew::InstallationError
 | 
			
		||||
  def tool
 | 
			
		||||
    case type
 | 
			
		||||
      when :python then 'easy_install'
 | 
			
		||||
      when :ruby, :jruby then 'rubygems'
 | 
			
		||||
      when :ruby, :jruby, :rbx then 'rubygems'
 | 
			
		||||
      when :perl then 'cpan'
 | 
			
		||||
      when :node then 'npm'
 | 
			
		||||
      when :chicken then 'chicken-install'
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
@ -91,6 +93,12 @@ class UnsatisfiedExternalDependencyError < Homebrew::InstallationError
 | 
			
		||||
        "cpan -i"
 | 
			
		||||
      when :jruby
 | 
			
		||||
        "jruby -S gem install"
 | 
			
		||||
      when :rbx
 | 
			
		||||
        "rbx gem install"
 | 
			
		||||
      when :node
 | 
			
		||||
        "npm install"
 | 
			
		||||
      when :chicken
 | 
			
		||||
        "chicken-install"
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
@ -740,7 +740,7 @@ EOF
 | 
			
		||||
 | 
			
		||||
    def depends_on name
 | 
			
		||||
      @deps ||= []
 | 
			
		||||
      @external_deps ||= {:python => [], :perl => [], :ruby => [], :jruby => []}
 | 
			
		||||
      @external_deps ||= {:python => [], :perl => [], :ruby => [], :jruby => [], :chicken => [], :rbx => [], :node => []}
 | 
			
		||||
 | 
			
		||||
      case name
 | 
			
		||||
      when String, Formula
 | 
			
		||||
@ -748,7 +748,7 @@ EOF
 | 
			
		||||
      when Hash
 | 
			
		||||
        key, value = name.shift
 | 
			
		||||
        case value
 | 
			
		||||
        when :python, :perl, :ruby, :jruby
 | 
			
		||||
        when :python, :perl, :ruby, :jruby, :chicken, :rbx, :node
 | 
			
		||||
          @external_deps[value] << key
 | 
			
		||||
        when :optional, :recommended, :build
 | 
			
		||||
          @deps << key
 | 
			
		||||
 | 
			
		||||
@ -319,7 +319,10 @@ def external_dep_check dep, type
 | 
			
		||||
    when :python then %W{/usr/bin/env python -c import\ #{dep}}
 | 
			
		||||
    when :jruby then %W{/usr/bin/env jruby -rubygems -e require\ '#{dep}'}
 | 
			
		||||
    when :ruby then %W{/usr/bin/env ruby -rubygems -e require\ '#{dep}'}
 | 
			
		||||
    when :rbx then %W{/usr/bin/env rbx -rubygems -e require\ '#{dep}'}
 | 
			
		||||
    when :perl then %W{/usr/bin/env perl -e use\ #{dep}}
 | 
			
		||||
    when :chicken then %W{/usr/bin/env csi -e (use #{dep})}
 | 
			
		||||
    when :node then %W{/usr/bin/env node -e require('#{dep}');}
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
@ -343,7 +346,7 @@ class Formula
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def check_external_deps
 | 
			
		||||
    [:ruby, :python, :perl, :jruby].each do |type|
 | 
			
		||||
    [:ruby, :python, :perl, :jruby, :rbx, :chicken, :node].each do |type|
 | 
			
		||||
      self.external_deps[type].each do |dep|
 | 
			
		||||
        unless quiet_system(*external_dep_check(dep, type))
 | 
			
		||||
          raise UnsatisfiedExternalDependencyError.new(dep, type)
 | 
			
		||||
 | 
			
		||||
@ -73,6 +73,54 @@ class GoodJRubyBall <TestBall
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
class BadChickenBall <TestBall
 | 
			
		||||
  depends_on "notapackage" => :chicken
 | 
			
		||||
 | 
			
		||||
  def initialize name=nil
 | 
			
		||||
    super "uses_chicken_ball"
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
class GoodChickenBall <TestBall
 | 
			
		||||
  depends_on "extras" => :chicken
 | 
			
		||||
 | 
			
		||||
  def initialize name=nil
 | 
			
		||||
    super "uses_chicken_ball"
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
class BadRubiniusBall <TestBall
 | 
			
		||||
  depends_on "notapackage" => :rbx
 | 
			
		||||
 | 
			
		||||
  def initialize name=nil
 | 
			
		||||
    super "uses_rubinius_ball"
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
class GoodRubiniusBall <TestBall
 | 
			
		||||
  depends_on "date" => :rbx
 | 
			
		||||
 | 
			
		||||
  def intialize
 | 
			
		||||
    super "uses_rubinius_ball"
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
class BadNodeBall <TestBall
 | 
			
		||||
  depends_on "notapackage" => :node
 | 
			
		||||
 | 
			
		||||
  def initialize
 | 
			
		||||
    super "uses_node_ball"
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
class GoodNodeBall <TestBall
 | 
			
		||||
  depends_on "util" => :node
 | 
			
		||||
 | 
			
		||||
  def initialize
 | 
			
		||||
    super "uses_node_balls"
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class ExternalDepsTests < Test::Unit::TestCase
 | 
			
		||||
  def check_deps_fail f
 | 
			
		||||
@ -120,4 +168,31 @@ class ExternalDepsTests < Test::Unit::TestCase
 | 
			
		||||
  def test_good_jruby_deps
 | 
			
		||||
    check_deps_pass GoodJRubyBall unless `/usr/bin/which jruby`.chomp.empty?
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # Only run these next two tests if rubinius is installed.
 | 
			
		||||
  def test_bad_rubinius_deps
 | 
			
		||||
    check_deps_fail BadRubiniusBall unless `/usr/bin/which rbx`.chomp.empty?
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_good_rubinius_deps
 | 
			
		||||
    check_deps_pass GoodRubiniusBall unless `/usr/bin/which rbx`.chomp.empty?
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # Only run these next two tests if chicken scheme is installed.
 | 
			
		||||
  def test_bad_chicken_deps
 | 
			
		||||
    check_deps_fail BadChickenBall unless `/usr/bin/which csc`.chomp.empty?
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_good_chicken_deps
 | 
			
		||||
    check_deps_pass GoodChickenBall unless `/usr/bin/which csc`.chomp.empty?
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # Only run these next two tests if node.js is installed.
 | 
			
		||||
  def test_bad_node_deps
 | 
			
		||||
    check_deps_fail BadNodeBall unless `/usr/bin/which node`.chomp.empty?
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_good_node_deps
 | 
			
		||||
    check_deps_pass GoodNodeBall unless `/usr/bin/which node`.chomp.empty?
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user