forked from methodmissing/hwia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
73 lines (58 loc) · 1.49 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
require 'rake'
require 'rake/testtask'
require 'rake/clean'
HWIA_ROOT = 'ext/hwia'
desc 'Default: test'
task :default => :test
desc 'Run hwia tests.'
Rake::TestTask.new(:test) do |t|
t.libs = [HWIA_ROOT]
t.pattern = 'test/test_*.rb'
t.verbose = true
end
task :test => :build
namespace :build do
file "#{HWIA_ROOT}/hwia.c"
file "#{HWIA_ROOT}/extconf.rb"
file "#{HWIA_ROOT}/Makefile" => %W(#{HWIA_ROOT}/hwia.c #{HWIA_ROOT}/extconf.rb) do
Dir.chdir(HWIA_ROOT) do
ruby 'extconf.rb'
end
end
desc "generate makefile"
task :makefile => %W(#{HWIA_ROOT}/Makefile #{HWIA_ROOT}/hwia.c)
dlext = Config::CONFIG['DLEXT']
file "#{HWIA_ROOT}/hwia.#{dlext}" => %W(#{HWIA_ROOT}/Makefile #{HWIA_ROOT}/hwia.c) do
Dir.chdir(HWIA_ROOT) do
sh 'make' # TODO - is there a config for which make somewhere?
end
end
desc "compile hwia extension"
task :compile => "#{HWIA_ROOT}/hwia.#{dlext}"
task :clean do
Dir.chdir(HWIA_ROOT) do
sh 'make clean'
end if File.exists?("#{HWIA_ROOT}/Makefile")
end
CLEAN.include("#{HWIA_ROOT}/Makefile")
CLEAN.include("#{HWIA_ROOT}/hwia.#{dlext}")
end
task :clean => %w(build:clean)
desc "compile"
task :build => %w(build:compile)
task :install do |t|
Dir.chdir(HWIA_ROOT) do
sh 'sudo make install'
end
end
desc "clean build install"
task :setup => %w(clean build install)
desc "run benchmarks"
task :bench do
ruby "bench/bench.rb"
end
task :bench => :build
desc "build gem"
task :gem do
sh "gem build hwia.gemspec"
end