-
Notifications
You must be signed in to change notification settings - Fork 15
/
Rakefile
64 lines (53 loc) · 1.46 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
61
62
63
64
require 'bundler/gem_tasks'
require 'bundler/setup'
require 'ffi/gen'
require 'rake/testtask'
require 'yard'
task :default => :test
task :check do
sh 'git submodule update --init' unless File.exist?('ext/leveldb/.git')
end
desc "Generates leveldb ext"
task :compile => :check do
sh 'cd ext && rake'
end
desc "Clean leveldb build"
task :clean do
sh 'cd ext/leveldb && make clean'
end
task :release => :clean
desc "Rebuild leveldb"
task :rebuild => [:clean, :compile]
default_config = -> (header, suffix="", extra={}) do
{
module_name: 'Leveldb',
ffi_lib: 'File.expand_path("../../ext/leveldb/libleveldb.#{FFI::Platform::LIBSUFFIX}", __FILE__)',
headers: [File.expand_path("../ext/leveldb/include/leveldb/#{header}", __FILE__)],
cflags: `llvm-config --cflags`.split(" "),
prefixes: ['leveldb_'],
suffixes: ['_t', '_s'],
output: "lib/native#{suffix}.rb"
}.merge(extra)
end
Rake::TestTask.new do |t|
t.libs << 'test'
t.test_files = FileList['test/test_*.rb']
end
desc 'Generates FFI bindings'
task :ffi => :check do
raise 'Please install llvm' unless system('which llvm-config')
FFI::Gen.generate(default_config["c.h"])
end
desc 'Open a console'
task :console do
ARGV.clear
require 'irb'
require 'leveldb'
IRB.start
end
YARD::Rake::YardocTask.new(:doc) do |t|
t.files = ['lib/**/*.rb']
t.options = ['--markup=markdown',
'--no-private',
'--markup-provider=redcarpet']
end