Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 90 lines (72 sloc) 2.774 kb
2ef92e4 Martin Bosslet Add infrastructure
authored
1 require 'rake'
2 require 'rake/extensiontask'
8d01bbc Hiroshi Nakamura Add coverage task with gcov and lcov
nahi authored
3 require 'rspec/core/rake_task'
8d3fd96 Hiroshi Nakamura Add doc target for RDoc generation
nahi authored
4 require 'rdoc/task'
5 require_relative 'lib/krypt-core/version'
8d01bbc Hiroshi Nakamura Add coverage task with gcov and lcov
nahi authored
6
e43a323 Hiroshi Nakamura Use spec in krypt/spec/krypt-core
nahi authored
7 KRYPT_HOME = '../krypt'
8
8d01bbc Hiroshi Nakamura Add coverage task with gcov and lcov
nahi authored
9 $config_options = []
2ef92e4 Martin Bosslet Add infrastructure
authored
10
16015a1 Hiroshi Nakamura Bundlerize
nahi authored
11 task :default => :compile
12
8d01bbc Hiroshi Nakamura Add coverage task with gcov and lcov
nahi authored
13 task :clean do
14 rm_f FileList['*.gcov']
15 end
2ef92e4 Martin Bosslet Add infrastructure
authored
16
8d01bbc Hiroshi Nakamura Add coverage task with gcov and lcov
nahi authored
17 Rake::ExtensionTask.new('kryptcore') do |ext|
2ef92e4 Martin Bosslet Add infrastructure
authored
18 ext.ext_dir = "ext/krypt/core"
19 ext.lib_dir = "lib"
8d01bbc Hiroshi Nakamura Add coverage task with gcov and lcov
nahi authored
20 ext.config_options = $config_options
8bb5101 Martin Bosslet Add support for cross-compilation. Simplify some parts of krypt_missing
authored
21 ext.cross_compile = true
22 ext.cross_platform = 'i386-mswin32'
8d01bbc Hiroshi Nakamura Add coverage task with gcov and lcov
nahi authored
23 end
24
18477b4 Hiroshi Nakamura Make sure to compile before spec run
nahi authored
25 RSpec::Core::RakeTask.new('spec-run') do |spec|
e43a323 Hiroshi Nakamura Use spec in krypt/spec/krypt-core
nahi authored
26 spec.pattern = File.join(KRYPT_HOME, 'spec/**/*_spec.rb')
6217ca3 Hiroshi Nakamura Make spec task not fail on error for coverage
nahi authored
27 spec.fail_on_error = false
e43a323 Hiroshi Nakamura Use spec in krypt/spec/krypt-core
nahi authored
28 end
8d01bbc Hiroshi Nakamura Add coverage task with gcov and lcov
nahi authored
29
30 task 'enable-coverage' do
31 # ugly, but we cannot define 2 ExtensionTasks for the same ext.name.
32 $config_options << '-g'
2ef92e4 Martin Bosslet Add infrastructure
authored
33 end
34
85d4806 Martin Bosslet Integrate gperftools profiling.
authored
35 task 'enable-profiler' do
36 #to enable profiling run
37 #rake build:profiler -- --with-profiler-dir=<path_to>/gperftools/'
38 $config_options << '-p'
39 end
40
8d01bbc Hiroshi Nakamura Add coverage task with gcov and lcov
nahi authored
41 desc 'requires gcov and lcov in $PATH'
42 task 'report-coverage' do
43 outdir = File.dirname(Dir['tmp/**/Makefile'].first)
46a2a82 Martin Bosslet Improve coverage by adding spec for ASN1Data.
authored
44 curdir = Dir.pwd
45 Dir.chdir(outdir) do
46 sh "lcov -c -i -d . -o kryptcore_base.info"
47 Dir.entries("#{curdir}/ext/krypt/core").each do |f|
48 next if File.directory? f || f !~ /\.[hc]$/
49 # See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=535755
50 sh "gcov -o . #{f}"
51 end
52 sh "lcov -c -d . -o kryptcore.info"
53 sh "lcov -a kryptcore.info -a kryptcore_base.info -o kryptcore_total.info"
54 sh "lcov -r kryptcore_total.info ruby.h --output-file kryptcore_total.info"
55 sh "lcov -r kryptcore_total.info '*include*' --output-file kryptcore_total.info"
56 sh "genhtml -o coverage kryptcore_total.info"
57 end
8d01bbc Hiroshi Nakamura Add coverage task with gcov and lcov
nahi authored
58 end
2ef92e4 Martin Bosslet Add infrastructure
authored
59
8d01bbc Hiroshi Nakamura Add coverage task with gcov and lcov
nahi authored
60 desc 'Build ext for coverage and generate a coverage report of spec.'
18477b4 Hiroshi Nakamura Make sure to compile before spec run
nahi authored
61 task 'coverage' => ['clean', 'enable-coverage', 'compile', 'spec-run', 'report-coverage']
62
63 desc 'Build and run RSpec code examples'
64 task 'spec' => ['compile', 'spec-run']
b50f65f Hiroshi Nakamura Add :build task as an alias of :compile
nahi authored
65
3a6d491 Martin Bosslet Valgrindify.
authored
66 task 'build' => 'compile'
8d3fd96 Hiroshi Nakamura Add doc target for RDoc generation
nahi authored
67
3a6d491 Martin Bosslet Valgrindify.
authored
68 task 'build-debug' => ['enable-coverage', 'build']
69 task 'build-profiler' => ['enable-profiler', 'build']
6854430 Martin Bosslet Add full PEM support. Revisit C namespaces again.
authored
70
8d3fd96 Hiroshi Nakamura Add doc target for RDoc generation
nahi authored
71 Rake::RDocTask.new("doc") do |rdoc|
72 rdoc.rdoc_dir = 'doc'
73 rdoc.title = "Krypt-Core API: Version #{Krypt::CORE_VERSION}"
74 rdoc.rdoc_files.include('README.rdoc')
75 rdoc.rdoc_files.include('ext/**/*')
76 end
3a6d491 Martin Bosslet Valgrindify.
authored
77
78 desc 'Ensure that bundle is installed for spec run'
79 task 'bundler-install' do
80 sh 'bundle install'
81 end
82
83 desc 'Run the specs for valgrind analysis'
84 task 'valgrind-spec-run' do
84222b7 Martin Bosslet Fix bugs indicated by Valgrind (Issue #45)
authored
85 sh 'valgrind --suppressions=.ruby.supp --leak-check=full --num-callers=50 --partial-loads-ok=yes --undef-value-errors=no --trace-children=yes bundle exec rake spec'
3a6d491 Martin Bosslet Valgrindify.
authored
86 end
87
88 desc 'Build from scratch with debug symbols and run valgrind on a spec run (requires valgrind on PATH)'
89 task 'valgrind' => ['clean', 'build-debug', 'bundler-install', 'valgrind-spec-run']
Something went wrong with that request. Please try again.