forked from matsumotory/mruby-redis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mrbgem.rake
47 lines (39 loc) · 1.28 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
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.exists? hiredis_dir
Dir.chdir(build_dir) do
e = {}
run_command e, 'git clone git://github.com/redis/hiredis.git'
end
end
if ! File.exists? "#{hiredis_dir}/libhiredis.a"
Dir.chdir hiredis_dir do
e = {
'CC' => "#{spec.build.cc.command} #{spec.build.cc.flags.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
}
run_command e, "make"
run_command e, "make 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"
end