-
Notifications
You must be signed in to change notification settings - Fork 13
/
Rakefile
60 lines (51 loc) · 1.66 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
require 'rubygems'
require 'rake/testtask'
begin
require 'rcov/rcovtask'
Rcov::RcovTask.new do |t|
t.libs << "test"
t.rcov_opts << "--exclude gems"
t.test_files = FileList["test/**/*_test.rb"]
end
rescue LoadError
warn "Proceeding without Rcov. gem install rcov on supported platforms."
end
begin
require 'yard'
YARD::Rake::YardocTask.new do |t|
yardlib = File.join(File.dirname(__FILE__), "yardlib/llvm.rb")
t.options = %W[-e #{yardlib} --no-private]
t.files = Dir['lib/**/*.rb']
end
rescue LoadError
warn "Yard is not installed. `gem install yard` to build documentation."
end
Rake::TestTask.new do |t|
t.libs << "test"
t.test_files = FileList["test/**/*_test.rb"]
end
task :generate_ffi do
require 'ffi_gen'
mappings = {
["llvm-c/Core.h"] => "core_ffi.rb",
["llvm-c/Analysis.h"] => "analysis_ffi.rb",
["llvm-c/ExecutionEngine.h"] => "execution_engine_ffi.rb",
["llvm-c/Target.h"] => "target_ffi.rb",
["llvm-c/BitReader.h", "llvm-c/BitWriter.h"] => "core/bitcode_ffi.rb",
["llvm-c/Transforms/IPO.h"] => "transforms/ipo_ffi.rb",
["llvm-c/Transforms/Scalar.h"] => "transforms/scalar_ffi.rb",
}
mappings.each do |headers, ruby_file|
FFIGen.generate(
:module_name => "LLVM::C",
:ffi_lib => "LLVM-3.1",
:headers => headers,
:cflags => `llvm-config --cflags`.split(" "),
:prefixes => ["LLVM"],
:blacklist => ["LLVMGetMDNodeNumOperands", "LLVMGetMDNodeOperand",
"LLVMInitializeAllTargetInfos", "LLVMInitializeAllTargets", "LLVMInitializeNativeTarget"],
:output => "lib/llvm/#{ruby_file}"
)
end
end
task :default => [:test]