-
Notifications
You must be signed in to change notification settings - Fork 4
/
Rakefile
63 lines (54 loc) · 1.91 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
#!/usr/bin/env rake
require 'rake/testtask'
require 'rubygems'
require 'rubygems/package_task'
Rake::TestTask.new do |i|
i.libs << 'ext'
i.options = '-v'
i.verbose = true
end
require File.expand_path('../lib/bin_utils/version', __FILE__)
spec = Gem::Specification.new do |gem|
gem.name = "bin_utils"
gem.authors = ["Sokolov Yura 'funny-falcon'"]
gem.email = ["[email protected]"]
gem.description = %q{utils for extracting binary integers from binary string and packing them back}
gem.summary = %q{Faster alternative to String#unpack and Array#unpack, though not as complete as those methods}
gem.homepage = "https://github.com/funny-falcon/bin_utils"
file = FileList["lib/**/*.rb"] + FileList["test/**/*.rb"]
if RUBY_ENGINE == 'jruby'
gem.files = file + FileList["ext/**/*.jar"]
else
gem.extensions = ["ext/bin_utils/extconf.rb"]
gem.files = file + FileList["ext/**/*.c"]
end
gem.test_files = gem.files.grep(%r{^test/})
gem.require_paths = ["lib", "ext"]
gem.required_ruby_version = '>= 1.9.1'
gem.platform = Gem::Platform::RUBY
gem.add_development_dependency 'rake-compiler', '~> 0.9'
gem.version = BinUtils::VERSION
end
Gem::PackageTask.new(spec) do |pkg|
end
def precompile(t)
puts "PRECOMPILE #{t.name}"
require 'erb'
result = ERB.new(File.read(t.source), nil, "-%").result
File.open(t.name, 'w'){|fl| fl.write result }
end
rule '.java' => '.java.erb' do |t| precompile(t) end
rule '.c' => '.c.erb' do |t| precompile(t) end
if RUBY_PLATFORM =~ /java/
task :compile => ['ext/bin_utils/JavaUtils.java']
require 'rake/javaextensiontask'
Rake::JavaExtensionTask.new("bin_utils", spec) do |ext|
ext.lib_dir = 'ext/bin_utils'
end
else
require 'rake/extensiontask'
task :compile => ['ext/bin_utils/native.c']
Rake::ExtensionTask.new("bin_utils", spec) do |ext|
ext.lib_dir = 'ext/bin_utils'
end
end