git ssb

0+

dangerousbeans / %aPBe2k3ugtjBr4rrsU1…



Tree: 6f2637c0f63c49f473b4e5167c1ed53c79623dc2

Files: 6f2637c0f63c49f473b4e5167c1ed53c79623dc2 / Rakefile

2290 bytesRaw
1require 'rspec/core/rake_task'
2require 'rubygems/package_task'
3require 'rake/extensiontask'
4require 'rake/javaextensiontask'
5require 'rake/contrib/rubyforgepublisher'
6require 'rake/clean'
7require 'rdoc/task'
8require 'benchmark'
9
10CLEAN.include(
11 "ext/mri/*.o",
12 "ext/mri/*.bundle",
13 "ext/mri/*.so",
14 "ext/jruby/bcrypt_jruby/*.class"
15)
16CLOBBER.include(
17 "ext/mri/Makefile",
18 "doc/coverage",
19 "pkg"
20)
21GEMSPEC = eval(File.read(File.expand_path("../bcrypt-ruby.gemspec", __FILE__)))
22
23task :default => [:compile, :spec]
24
25desc "Run all specs"
26RSpec::Core::RakeTask.new do |t|
27 t.pattern = 'spec/**/*_spec.rb'
28 t.ruby_opts = '-w'
29end
30
31desc "Run all specs, with coverage testing"
32RSpec::Core::RakeTask.new(:rcov) do |t|
33 t.pattern = 'spec/**/*_spec.rb'
34 t.rcov = true
35 t.rcov_path = 'doc/coverage'
36 t.rcov_opts = ['--exclude', 'rspec,diff-lcs,rcov,_spec,_helper']
37end
38
39desc 'Generate RDoc'
40RDoc::Task.new do |rdoc|
41 rdoc.rdoc_dir = 'doc/rdoc'
42 rdoc.options += GEMSPEC.rdoc_options
43 rdoc.template = ENV['TEMPLATE'] if ENV['TEMPLATE']
44 rdoc.rdoc_files.include(*GEMSPEC.extra_rdoc_files)
45end
46
47Gem::PackageTask.new(GEMSPEC) do |pkg|
48 pkg.need_zip = true
49 pkg.need_tar = true
50end
51
52if RUBY_PLATFORM =~ /java/
53 Rake::JavaExtensionTask.new('bcrypt_ext', GEMSPEC) do |ext|
54 ext.ext_dir = 'ext/jruby'
55 end
56else
57 Rake::ExtensionTask.new("bcrypt_ext", GEMSPEC) do |ext|
58 ext.ext_dir = 'ext/mri'
59 ext.cross_compile = true
60 ext.cross_platform = ['x86-mingw32', 'x86-mswin32-60']
61
62 # inject 1.8/1.9 pure-ruby entry point
63 ext.cross_compiling do |spec|
64 spec.files += ["lib/#{ext.name}.rb"]
65 end
66 end
67end
68
69# Entry point for fat-binary gems on win32
70file("lib/bcrypt_ext.rb") do |t|
71 File.open(t.name, 'wb') do |f|
72 f.write <<-eoruby
73RUBY_VERSION =~ /(\\d+.\\d+)/
74require "\#{$1}/#{File.basename(t.name, '.rb')}"
75 eoruby
76 end
77 at_exit{ FileUtils.rm t.name if File.exists?(t.name) }
78end
79
80desc "Run a set of benchmarks on the compiled extension."
81task :benchmark do
82 TESTS = 100
83 TEST_PWD = "this is a test"
84 require File.expand_path(File.join(File.dirname(__FILE__), "lib", "bcrypt"))
85 Benchmark.bmbm do |results|
86 4.upto(10) do |n|
87 results.report("cost #{n}:") { TESTS.times { BCrypt::Password.create(TEST_PWD, :cost => n) } }
88 end
89 end
90end
91

Built with git-ssb-web