/
Rakefile
64 lines (46 loc) · 1.19 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
require 'rbconfig'
LIB_ZK_SO = 'lib/libzookeeper_mt_gem.la'
TARBALL = FileList['zkc-*.tar.gz'].first
raise "Where is the zkc tarball!?" unless TARBALL
namespace :zkrb do
task :clean do
if File.exists?('Makefile')
sh 'make clean'
rm 'Makefile' # yep, regenerate this
else
$stderr.puts "nothing to clean, no Makefile"
end
end
task :clobber => :clean do
rm_rf %w[Makefile c lib bin include ._c]
end
end
task :clean => 'zkrb:clean'
task :clobber => 'zkrb:clobber'
GENERATE_GVL_CODE_RB = 'generate_gvl_code.rb'
# file 'c' do
# if tarball = Dir['zkc-*.tar.gz'].first
# sh "tar -zxf #{tarball}"
# else
# raise "couldn't find the tarball! wtf?!"
# end
# end
file 'c' => TARBALL do
sh "tar -zxf #{TARBALL}"
end
file GENERATE_GVL_CODE_RB => 'c'
file 'zkrb_wrapper.c' => GENERATE_GVL_CODE_RB do
sh "ruby generate_gvl_code.rb code"
end
file 'zkrb_wrapper.h' => GENERATE_GVL_CODE_RB do
sh "ruby generate_gvl_code.rb headers"
end
ZKRB_WRAPPER = %w[zkrb_wrapper.c zkrb_wrapper.h]
task :wrappers => ZKRB_WRAPPER
file 'Makefile' do
sh "ruby extconf.rb"
end
task :build => [ZKRB_WRAPPER, 'Makefile'].flatten do
sh 'make'
end
task :default => :build