git ssb

0+

dangerousbeans / %aPBe2k3ugtjBr4rrsU1…



Tree: e21326529ba4c7d40b7c8684922ca26cc06f80f0

Files: e21326529ba4c7d40b7c8684922ca26cc06f80f0 / Rakefile

2325 bytesRaw
1require 'rspec/core/rake_task'
2require 'rubygems/package_task'
3require 'rake/extensiontask'
4require 'rake/javaextensiontask'
5require 'rake/clean'
6require 'rdoc/task'
7require 'benchmark'
8
9CLEAN.include(
10 "tmp",
11 "lib/1.8",
12 "lib/1.9",
13 "lib/2.0",
14 "lib/2.1",
15 "lib/bcrypt_ext.jar",
16 "lib/bcrypt_ext.so"
17)
18CLOBBER.include(
19 "doc",
20 "pkg"
21)
22
23GEMSPEC = Gem::Specification.load("bcrypt.gemspec")
24
25task :default => [:compile, :spec]
26
27desc "Run all specs"
28RSpec::Core::RakeTask.new do |t|
29 t.pattern = 'spec/**/*_spec.rb'
30 t.ruby_opts = '-w'
31end
32
33desc "Run all specs, with coverage testing"
34RSpec::Core::RakeTask.new(:rcov) do |t|
35 t.pattern = 'spec/**/*_spec.rb'
36 t.rcov = true
37 t.rcov_path = 'doc/coverage'
38 t.rcov_opts = ['--exclude', 'rspec,diff-lcs,rcov,_spec,_helper']
39end
40
41desc 'Generate RDoc'
42RDoc::Task.new do |rdoc|
43 rdoc.rdoc_dir = 'doc/rdoc'
44 rdoc.options += GEMSPEC.rdoc_options
45 rdoc.template = ENV['TEMPLATE'] if ENV['TEMPLATE']
46 rdoc.rdoc_files.include(*GEMSPEC.extra_rdoc_files)
47end
48
49Gem::PackageTask.new(GEMSPEC) do |pkg|
50 pkg.need_zip = true
51 pkg.need_tar = true
52end
53
54if RUBY_PLATFORM =~ /java/
55 Rake::JavaExtensionTask.new('bcrypt_ext', GEMSPEC) do |ext|
56 ext.ext_dir = 'ext/jruby'
57 end
58else
59 Rake::ExtensionTask.new("bcrypt_ext", GEMSPEC) do |ext|
60 ext.ext_dir = 'ext/mri'
61 ext.cross_compile = true
62 ext.cross_platform = ['x86-mingw32', 'x64-mingw32']
63 end
64
65 ENV['RUBY_CC_VERSION'].to_s.split(':').each do |ruby_version|
66 platforms = {
67 "x86-mingw32" => "i686-w64-mingw32",
68 "x64-mingw32" => "x86_64-w64-mingw32"
69 }
70 platforms.each do |platform, prefix|
71 task "copy:bcrypt_ext:#{platform}:#{ruby_version}" do |t|
72 %w[lib tmp/#{platform}/stage/lib].each do |dir|
73 so_file = "#{dir}/#{ruby_version[/^\d+\.\d+/]}/bcrypt_ext.so"
74 if File.exists?(so_file)
75 sh "#{prefix}-strip -S #{so_file}"
76 end
77 end
78 end
79 end
80 end
81end
82
83desc "Run a set of benchmarks on the compiled extension."
84task :benchmark do
85 TESTS = 100
86 TEST_PWD = "this is a test"
87 require File.expand_path(File.join(File.dirname(__FILE__), "lib", "bcrypt"))
88 Benchmark.bmbm do |results|
89 4.upto(10) do |n|
90 results.report("cost #{n}:") { TESTS.times { BCrypt::Password.create(TEST_PWD, :cost => n) } }
91 end
92 end
93end
94

Built with git-ssb-web