-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathmrbgem.rake
50 lines (43 loc) · 1.63 KB
/
mrbgem.rake
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
MRuby::Gem::Specification.new('mruby-redis') do |spec|
spec.license = 'MIT'
spec.authors = 'MATSUMOTO Ryosuke'
spec.version = '0.0.1'
# for expire test
require 'open3'
hiredis_dir = "#{build_dir}/hiredis"
def run_command env, command
STDOUT.sync = true
puts "build: [exec] #{command}"
Open3.popen2e(env, command) do |stdin, stdout, thread|
print stdout.read
fail "#{command} failed" if thread.value != 0
end
end
FileUtils.mkdir_p build_dir
if ! File.exist? hiredis_dir
Dir.chdir(build_dir) do
e = {}
run_command e, 'git clone https://github.com/redis/hiredis.git'
# Latest HIREDIS is not compatible for OS X
run_command e, "git --git-dir=#{hiredis_dir}/.git --work-tree=#{hiredis_dir} checkout v0.13.3" if `uname` =~ /Darwin/
end
end
if ! File.exist? "#{hiredis_dir}/libhiredis.a"
Dir.chdir hiredis_dir do
e = {
'CC' => "#{spec.build.cc.command} #{spec.build.cc.flags.reject {|flag| flag == '-fPIE'}.join(' ')}",
'CXX' => "#{spec.build.cxx.command} #{spec.build.cxx.flags.join(' ')}",
'LD' => "#{spec.build.linker.command} #{spec.build.linker.flags.join(' ')}",
'AR' => spec.build.archiver.command,
'PREFIX' => hiredis_dir
}
make_command = `uname` =~ /BSD/ ? "gmake" : "make"
run_command e, "#{make_command}"
run_command e, "#{make_command} install"
end
end
spec.cc.include_paths << "#{hiredis_dir}/include"
spec.linker.flags_before_libraries << "#{hiredis_dir}/lib/libhiredis.a"
spec.add_dependency "mruby-sleep"
spec.add_dependency "mruby-pointer", :github => 'matsumotory/mruby-pointer'
end