-
Notifications
You must be signed in to change notification settings - Fork 6
/
mrbgem.rake
67 lines (58 loc) · 2.02 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
MRuby::Gem::Specification.new('mruby-http2') do |spec|
spec.license = 'MIT'
spec.authors = 'MATSUMOTO Ryosuke'
spec.version = '0.0.1'
spec.summary = 'HTTP/2 Client and Server Module'
spec.linker.libraries << ['ssl', 'crypto', 'z', 'event', 'event_openssl', 'curl']
spec.add_dependency('mruby-simplehttp')
if RUBY_PLATFORM =~ /darwin/i
spec.cc.flags << "-I/usr/local/include"
spec.linker.library_paths << "/usr/local/lib"
end
require 'open3'
nghttp2_dir = "#{build_dir}/nghttp2"
nghttp2_lib = "#{build_dir}/nghttp2/lib/.libs"
libnghttp2a = "#{nghttp2_lib}/libnghttp2.a"
if ENV['NGHTTP2_CURRENT'] != "true"
nghttp2_ver = "ec519f22dcad42a06b968e24a8ee8f651464016a"
end
def run_command env, command
STDOUT.sync = true
puts "mruby-http2 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? nghttp2_dir
Dir.chdir(build_dir) do
e = {}
run_command e, 'git clone https://github.com/nghttp2/nghttp2.git'
end
end
if ! File.exists? libnghttp2a
Dir.chdir nghttp2_dir do
e = {}
if ENV['NGHTTP2_CURRENT'] != "true"
run_command e, "git checkout #{nghttp2_ver} ."
end
run_command e, 'git submodule init'
run_command e, 'git submodule update'
run_command e, 'autoreconf -i'
run_command e, 'automake'
run_command e, 'autoconf'
if RUBY_PLATFORM =~ /darwin/i
run_command e, './configure --enable-lib-only --disable-threads --enable-shared=no'
elsif ENV['NGHTTP2_CURRENT']
# for travis CI
run_command e, './configure --enable-app --enable-shared=no CFLAGS="-g -O2 -fPIC"'
else
run_command e, './configure --enable-lib-only --enable-shared=no CFLAGS="-g -O2 -fPIC"'
end
run_command e, 'make'
end
end
spec.cc.include_paths << "#{nghttp2_dir}/lib/includes"
spec.linker.flags_before_libraries << libnghttp2a
end