-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
70 lines (60 loc) · 1.45 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# frozen_string_literal: true
require 'rdoc/task'
$LOAD_PATH.unshift(File.expand_path('ext', __dir__))
task default: :test
task compile: 'extconf:compile'
desc 'Run all tests'
task test: :compile do
Dir["#{File.dirname(__FILE__)}/test/**/*_test.rb"].each do |file|
ruby file
end
end
namespace :profile do
desc 'Profile memory'
task memory: :compile do
sh(
'valgrind --tool=memcheck --leak-check=yes --num-callers=10 ' \
'--track-fds=yes ruby test/profile/memory.rb'
)
end
end
task :clean do
crap = '*.{bundle,so,o,obj,log}'
['*.gem', "ext/**/#{crap}", 'ext/**/Makefile'].each do |glob|
Dir.glob(glob).each do |file|
rm(file)
end
end
end
namespace :extconf do
task :makefile do
Dir.chdir('ext') do
ruby 'extconf.rb'
end
end
task make: :makefile do
Dir.chdir('ext') do
sh(RUBY_PLATFORM.match?(/win32/) ? 'nmake' : 'make') do |ok, _res|
unless ok
require 'fileutils'
FileUtils.rm_rf(Dir.glob('*.{so,o,dll,bundle}'))
end
end
end
end
desc 'Compile the Ruby extension'
task compile: :make do
if Dir.glob('ext/*.{o,so,dll}').empty?
warn('Failed to build ext.')
exit(1)
end
end
end
namespace :docs do
Rake::RDocTask.new('generate') do |rdoc|
rdoc.title = 'Tedrahcu'
rdoc.main = 'README.md'
rdoc.rdoc_files.include('README.md', 'ext/tedrahcu.c')
rdoc.options << '--all' << '--charset' << 'utf-8'
end
end