Rakefile 2.17 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
require 'rake'
require 'rake/testtask'
require 'rdoc/task'

begin
  require 'rake/extensiontask'
  Rake::ExtensionTask.new('openssl')
rescue LoadError
  warn "rake-compiler not installed. Run 'rake install_dependencies' to " \
    "install testing dependency gems."
end

Rake::TestTask.new do |t|
  t.libs << 'test'
  t.warning = true
end

RDoc::Task.new do |rdoc|
  rdoc.main = "README.md"
  rdoc.rdoc_files.include("*.md", "lib/**/*.rb", "ext/**/*.c")
end

23
task :test => [:compile, :debug]
24 25 26 27 28 29 30 31 32 33 34 35 36
task :debug do
  ruby "-I./lib -ropenssl -ve'puts OpenSSL::OPENSSL_VERSION, OpenSSL::OPENSSL_LIBRARY_VERSION'"
end

task :install_dependencies do
  if ENV["USE_HTTP_RUBYGEMS_ORG"] == "1"
    Gem.sources.replace([Gem::Source.new("http://rubygems.org")])
  end

  Gem.configuration.verbose = false
  gemspec = eval(File.read("openssl.gemspec"))
  gemspec.development_dependencies.each do |dep|
    print "Installing #{dep.name} (#{dep.requirement}) ... "
37 38 39 40 41 42 43
    installed = dep.matching_specs
    if installed.empty?
      installed = Gem.install(dep.name, dep.requirement)
      puts "#{installed[0].version}"
    else
      puts "(found #{installed[0].version})"
    end
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
  end
end

namespace :sync do
  task :from_ruby do
    sh "./tool/sync-with-trunk"
  end

  task :to_ruby do
    trunk_path = ENV.fetch("RUBY_TRUNK_PATH", "../ruby")

    rsync = "rsync -av --delete"
    excludes = %w{Makefile extconf.h mkmf.log depend *.o *.so *.bundle}
    excludes.each { |name| rsync << " --exclude #{name}" }

    paths = [
      ["ext/openssl/", "ext/openssl/"],
61 62 63
      ["lib/", "ext/openssl/lib/"],
      ["sample/", "sample/openssl/"],
      ["test/fixtures/", "test/openssl/fixtures/"],
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
      ["test/utils.rb", "test/openssl/"],
      ["test/ut_eof.rb", "test/openssl/"],
      ["test/test_*", "test/openssl/"],
      ["History.md", "ext/openssl/"],
    ]
    paths.each do |src, dst|
      sh "#{rsync} #{src} #{trunk_path}/#{dst}"
    end

    gemspec_file = File.expand_path("../openssl.gemspec", __FILE__)
    gemspec = eval(File.read(gemspec_file), binding, gemspec_file)
    File.write("#{trunk_path}/ext/openssl/openssl.gemspec", gemspec.to_ruby)

    puts "Don't forget to update ext/openssl/depend"
  end
end
80 81

task :default => :test