-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathRakefile
More file actions
105 lines (86 loc) · 2.18 KB
/
Rakefile
File metadata and controls
105 lines (86 loc) · 2.18 KB
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
require 'rake'
require 'rake/extensiontask'
require 'bundler/gem_tasks'
require 'rake/testtask'
require 'fileutils'
require 'xnd/version.rb'
gemspec = eval(IO.read("xnd.gemspec"))
ext_name = "ruby_xnd"
Rake::ExtensionTask.new(ext_name, gemspec) do |ext|
ext.ext_dir = "ext/#{ext_name}"
ext.source_pattern = "**/*.{c,h}"
end
Rake::TestTask.new(:test) do |t|
t.libs << "test"
t.libs << "lib"
t.test_files = FileList['test/**/test_*.rb']
end
def run *cmd
sh(cmd.join(" "))
end
task :console do
cmd = ['irb', "-r './lib/xnd.rb'"]
run(*cmd)
end
task :pry do
cmd = ['pry', "-r './lib/xnd.rb'"]
run(*cmd)
end
BASEDIR = Pathname( __FILE__ ).dirname.relative_path_from( Pathname.pwd )
SPECDIR = BASEDIR + 'spec'
VALGRIND_OPTIONS = [
"--tool=memcheck",
#"--leak-check=yes",
"--num-callers=15",
#"--error-limit=no",
"--partial-loads-ok=yes",
"--undef-value-errors=no" #,
#"--dsymutil=yes"
]
CALLGRIND_OPTIONS = [
"--tool=callgrind",
"--dump-instr=yes",
"--simulate-cache=yes",
"--collect-jumps=yes"
]
VALGRIND_MEMORYFILL_OPTIONS = [
"--freelist-vol=100000000",
"--malloc-fill=6D",
"--free-fill=66 ",
]
# partial-loads-ok and undef-value-errors necessary to ignore
# spurious (and eminently ignorable) warnings from the ruby
# interpreter
desc "Run specs under Valgrind."
task :valgrind => [ :compile ] do |task|
cmd = [ 'valgrind' ] + VALGRIND_OPTIONS
cmd += [" rake test "]
run( *cmd )
end
LEAKCHECK_CMD = [ 'ruby', '-Ilib:ext', "#{SPECDIR}/leakcheck.rb" ]
task :clobber do |task|
[
"ext/#{ext_name}/include",
"ext/#{ext_name}/share",
"ext/#{ext_name}/lib",
].each do |f|
puts "deleting folder #{f}..."
FileUtils.rm_rf(f)
end
Dir.chdir("ext/#{ext_name}/xnd/libxnd/") do
system("make clean")
end
end
task :develop do
ext_xnd = "ext/ruby_xnd/xnd"
puts "deleting previously created #{ext_xnd} directory..."
FileUtils.rm_rf(ext_xnd)
Dir.mkdir(ext_xnd)
puts "cloning xnd repo into ext/ folder..."
system("git clone https://github.com/plures/xnd #{ext_xnd}")
Dir.chdir(ext_xnd) do
system("git checkout #{RubyXND::COMMIT}")
end
puts "building gem with rake build..."
system("rake build")
end