-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
61 lines (50 loc) · 1.31 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
require "rake/extensiontask"
require "rspec/core/rake_task"
require "yard"
ROOT = File.dirname(__FILE__)
desc "Run all the tests in ./spec"
RSpec::Core::RakeTask.new(:spec)
desc "Rake the Yard (...actually, generate HTML documentation)"
YARD::Rake::YardocTask.new
Rake::ExtensionTask.new "bit_twiddle" do |ext|
ext.lib_dir = "lib"
end
def benchmarks
Dir[ROOT + '/bench/*_bench.rb']
end
def bench_task_name(file_name)
file_name.sub(ROOT+'/', '').sub(/\_bench.rb$/, '').to_s.tr('/', ':')
end
benchmarks.each do |bench_file|
name = bench_task_name(bench_file)
desc "Benchmark #{name}"
task name do
$LOAD_PATH.unshift ROOT+'/lib'
require 'benchmark/ips'
require 'bit-twiddle'
load bench_file
end
end
desc "Run all benchmarks"
task bench: benchmarks.map(&method(:bench_task_name))
desc "Perform static analysis on C code to look for possible bugs"
task :scanbuild => [:clean] do
# Show output at console, but also capture it
result = []
r,w = IO.pipe
pid = Process.fork do
$stdout.reopen(w)
r.close
exec("scan-build rake compile")
end
w.close
r.each do |line|
result << line if line =~ /^scan-build:/
puts line
end
Process.wait(pid)
if result.last =~ /Run 'scan-view ([^']*)' to examine bug reports/
exec "scan-view #{$1}"
end
end
task default: [:compile, :spec]