-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmrbgem.rake
50 lines (40 loc) · 1.52 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-clang-plugin') do |spec|
spec.author = 'Takeshi Watanabe'
spec.license = 'MIT'
spec.summary = 'clang plugin to check mruby API call mistakes.'
spec.objs = spec.objs.delete_if{|v| File.basename(v).include? 'mruby_clang_checker' }
spec.test_objs = []
unless spec.build.toolchains.include?('clang')
print "Skipping non-clang toolchain.\n"
next
end
if spec.build.kind_of? MRuby::CrossBuild
print "Skipping cross build.\n"
next
end
so_pos = File.expand_path "#{build.build_dir}/../#{build.name}/mrbgems/mruby-clang-plugin/libmruby-clang-checker.so"
plugin_flags = %W[-Xclang -load -Xclang #{so_pos} -Xclang -add-plugin -Xclang mruby-clang-checker]
if Object.const_defined? :HAS_HOST_MRUBY_CLANG_PLUGIN
build.cc.flags += plugin_flags
build.cxx.flags += plugin_flags
next
end
fail 'llvm-config not found' unless system 'llvm-config --version'
fail 'cmake not found' unless system 'cmake --version'
HAS_HOST_MRUBY_CLANG_PLUGIN = true
build.cc.flags += plugin_flags
build.cxx.flags += plugin_flags
file "#{build_dir}/CMakeCache.txt" do |t|
FileUtils.mkdir_p build_dir
Dir.chdir build_dir do
sh "cmake -DCMAKE_BUILD_TYPE=DEBUG -DMRUBY_ROOT=#{MRUBY_ROOT} #{dir}"
end
end
task "#{build.name}_clang_plugin" => "#{build_dir}/CMakeCache.txt" do |t|
sh "make -C #{build_dir} all"
end
task :test do
sh "make -C #{build_dir} test"
end
file "#{build.build_dir}/lib/libmruby.flags.mak" => "#{build.name}_clang_plugin"
end