forked from luikore/triez
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rakefile
50 lines (43 loc) · 1.02 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
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
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
require_relative "test/triez_test.rb"
end
desc "build ext"
file so_file => src_files + [extconf, vendor_lib] do
cd 'ext'
sh 'ruby extconf.rb'
sh 'make'
cd '..'
end
file extconf
file vendor_lib
desc "clean ext"
task :clean do
cd 'ext'
if File.exist?('Makefile')
sh 'make clean'
end
rm Dir.glob 'build/*.{o,a}'
cd '..'
end