forked from translunar/nmatrix
/
Rakefile
126 lines (105 loc) · 2.81 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# -*- ruby -*-
require 'rubygems'
require 'bundler'
begin
Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
$stderr.puts e.message
$stderr.puts "Run `bundle install` to install missing gems"
exit e.status_code
end
require 'rake'
require "rake/extensiontask"
Rake::ExtensionTask.new do |ext|
ext.name = 'nmatrix'
ext.ext_dir = 'ext/nmatrix'
ext.lib_dir = 'lib/'
ext.source_pattern = "*.{c,cpp, h}"
end
require 'rspec/core/rake_task'
require 'rspec/core'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec) do |spec|
spec.pattern = FileList['spec/**/*_spec.rb']
end
BASEDIR = Pathname( __FILE__ ).dirname.relative_path_from( Pathname.pwd )
SPECDIR = BASEDIR + 'spec'
VALGRIND_OPTIONS = [
"--num-callers=50",
"--error-limit=no",
"--partial-loads-ok=yes",
"--undef-value-errors=no",
]
VALGRIND_MEMORYFILL_OPTIONS = [
"--freelist-vol=100000000",
"--malloc-fill=6D",
"--free-fill=66 ",
]
GDB_OPTIONS = []
RSpec::Core::RakeTask.new(:spec)
task :console do |task|
cmd = [ 'irb', "-r './lib/nmatrix.rb'" ]
run *cmd
end
task :pry do |task|
cmd = [ 'pry', "-r './lib/nmatrix.rb'" ]
run *cmd
end
#namespace :console do
# CONSOLE_CMD = ['irb', "-r './lib/nmatrix.rb'"]
# desc "Run console under GDB."
# task :gdb => [ :compile ] do |task|
# cmd = [ 'gdb' ] + GDB_OPTIONS
# cmd += [ '--args' ]
# cmd += CONSOLE_CMD
# run( *cmd )
# end
#
# desc "Run console under Valgrind."
# task :valgrind => [ :compile ] do |task|
# cmd = [ 'valgrind' ] + VALGRIND_OPTIONS
# cmd += CONSOLE_CMD
# run( *cmd )
# end
#end
task :default => :spec
def run *cmd
sh(cmd.join(" "))
end
namespace :spec do
# partial-loads-ok and undef-value-errors necessary to ignore
# spurious (and eminently ignorable) warnings from the ruby
# interpreter
RSPEC_CMD = [ 'ruby', '-S', 'rspec', '-Ilib:ext', SPECDIR ]
#desc "Run the spec for generator.rb"
#task :generator do |task|
# run 'rspec spec/generator_spec.rb'
#end
desc "Run specs under GDB."
task :gdb => [ :compile ] do |task|
cmd = [ 'gdb' ] + GDB_OPTIONS
cmd += [ '--args' ]
cmd += RSPEC_CMD
run( *cmd )
end
desc "Run specs under Valgrind."
task :valgrind => [ :compile ] do |task|
cmd = [ 'valgrind' ] + VALGRIND_OPTIONS
cmd += RSPEC_CMD
run( *cmd )
end
end
namespace :clean do
task :so do |task|
tmp_path = "tmp/#{RUBY_PLATFORM}/nmatrix/#{RUBY_VERSION}"
chdir tmp_path do
if RUBY_PLATFORM =~ /mswin/
`nmake soclean`
else
mkcmd = ENV['MAKE'] || %w[gmake make].find { |c| system("#{c} -v >> /dev/null 2>&1") }
`#{mkcmd} soclean`
end
end
end
end
# vim: syntax=ruby