-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
36 lines (32 loc) · 1.2 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
desc 'libtrusterd.dylib'
MRUBY_ROOT = "./mruby"
LIB_NAME = "libtrusterd"
if RUBY_PLATFORM =~ /darwin/i
LIB_EXT = "dylib"
end
if RUBY_PLATFORM =~ /linux/i
LIB_EXT = "so"
end
LIB_FULL_NAME = LIB_NAME + "." + LIB_EXT
task :default => "all"
task :all do
cflags=`#{MRUBY_ROOT}/bin/mruby-config --cflags`
cflags.chomp!()
ldflags=`#{MRUBY_ROOT}/bin/mruby-config --ldflags`
ldflags.chomp!()
ldflags_before_libs=`#{MRUBY_ROOT}/bin/mruby-config --ldflags-before-libs`
ldflags_before_libs.chomp!()
libs=`#{MRUBY_ROOT}/bin/mruby-config --libs`
libs.gsub!("-lmruby","#{MRUBY_ROOT}/build/host/lib/libmruby.a")
libs.chomp!()
sh "#{MRUBY_ROOT}/bin/mrbc -BcheckFile checkFile.rb"
sh "#{MRUBY_ROOT}/bin/mrbc -BcommonUtil common.rb"
if RUBY_PLATFORM =~ /darwin/i
sh "gcc #{cflags} -shared -fPIC trusterdBoot.c checkFile.c common.c #{ldflags} #{ldflags_before_libs} #{libs} -o #{LIB_FULL_NAME}"
end
if RUBY_PLATFORM =~ /linux/i
sh "#{MRUBY_ROOT}/bin/mrbc -BwatchFileLinux watchFileLinux.rb"
ldflags_before_libs.gsub!("libnghttp2.a","")
sh "clang -shared #{cflags} -fPIC trusterdBoot.c watchFileLinux.c common.c #{ldflags} -L#{ldflags_before_libs} #{libs} -lnghttp2 -o #{LIB_FULL_NAME}"
end
end