-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRakefile
58 lines (49 loc) · 1.3 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
# -*- ruby -*-
require 'rake/testtask'
Rake::TestTask.new(:test) do |t|
t.test_files = FileList["test/**/test_*.rb"]
end
gem 'rake-compiler', '>= 0.4.1'
def java?
/java/ === RUBY_PLATFORM
end
def jruby?
Object.const_defined?(:RUBY_ENGINE) and 'jruby' == RUBY_ENGINE
end
file 'lib/racc/parser-text.rb' => ['lib/racc/parser.rb'] do |t|
source = 'lib/racc/parser.rb'
open(t.name, 'wb') { |io|
io.write(<<-eorb)
module Racc
PARSER_TEXT = <<'__end_of_file__'
#{File.read(source)}
__end_of_file__
end
eorb
}
end
if jruby?
# JRUBY
require "rake/javaextensiontask"
Rake::JavaExtensionTask.new("cparse") do |ext|
jruby_home = RbConfig::CONFIG['prefix']
ext.lib_dir = File.join 'lib', 'racc'
ext.ext_dir = File.join 'ext', 'racc'
# source/target jvm
ext.source_version = '1.6'
ext.target_version = '1.6'
jars = ["#{jruby_home}/lib/jruby.jar"] + FileList['lib/*.jar']
ext.classpath = jars.map { |x| File.expand_path x }.join( ':' )
ext.name = 'cparse-jruby'
end
task :compile => ['lib/racc/parser-text.rb']
else
# MRI
require "rake/extensiontask"
Rake::ExtensionTask.new "cparse" do |ext|
ext.lib_dir = File.join 'lib', 'racc'
ext.ext_dir = File.join 'ext', 'racc', 'cparse'
end
task :compile => 'lib/racc/parser-text.rb'
end
task :test => :compile