git ssb

0+

dangerousbeans / %aPBe2k3ugtjBr4rrsU1…



Tree: 374e18b6d5a11a7886c19da97d4c887d779f7b90

Files: 374e18b6d5a11a7886c19da97d4c887d779f7b90 / Rakefile

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

Built with git-ssb-web