-
Notifications
You must be signed in to change notification settings - Fork 9
/
rakefile
54 lines (47 loc) · 1.14 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
require "rbconfig"
require "fileutils"
include FileUtils
so_file = "ext/triez.#{RbConfig::CONFIG['DLEXT']}"
src_files = Dir.glob('ext/*.{h,c,cc}')
vendor_files = %w[hat-trie]
extconf = 'ext/extconf.rb'
vendor_lib = 'ext/build/libtries.a'
desc "glob src for gem redist"
task :glob_src => vendor_files + [:clean] do
Dir.chdir 'hat-trie' do
sh *%w"git fetch"
sh *%w"git rebase FETCH_HEAD master"
end
rm Dir.glob 'ext/hat-trie/*.{h,c}'
hat_files = Dir.glob('hat-trie/src/*.{h,c}').select do |f|
!(%w[common.h].include? File.basename(f))
end
cp hat_files, 'ext/hat-trie'
cp 'hat-trie/COPYING', 'ext/hat-trie'
end
desc "download hat source"
file 'hat-trie' do
sh 'git', 'clone', 'git://github.com/luikore/hat-trie.git'
end
desc "run tests"
task :default => so_file do
sh 'ruby', "test/triez_test.rb"
end
desc "build ext"
file so_file => src_files + [extconf, vendor_lib] do
Dir.chdir 'ext' do
sh 'ruby', 'extconf.rb'
sh 'make'
end
end
file extconf
file vendor_lib
desc "clean ext"
task :clean do
Dir.chdir 'ext' do
if File.exist?('Makefile')
sh 'make', 'clean'
end
rm Dir.glob 'build/*.{o,a}'
end
end