summaryrefslogtreecommitdiff
path: root/Rakefile
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2012-04-27 16:42:53 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2012-04-28 15:24:54 -0700
commit0fc5af3f29484b2f9714c1546b7973a1a7d4721e (patch)
tree0ef84df1a1ddc55caf1966f71298bad91c40c4b1 /Rakefile
parentb01bf0f960ef4a00155dd383adeb1fc031ae6940 (diff)
downloadpsych-0fc5af3f29484b2f9714c1546b7973a1a7d4721e.tar.gz
import the java implementation from JRuby
Diffstat (limited to 'Rakefile')
-rw-r--r--Rakefile24
1 files changed, 21 insertions, 3 deletions
diff --git a/Rakefile b/Rakefile
index f9aef47..03353e5 100644
--- a/Rakefile
+++ b/Rakefile
@@ -3,9 +3,15 @@
require 'rubygems'
require 'hoe'
+def java?
+ RUBY_PLATFORM =~ /java/
+end
+
class Hoe
remove_const :RUBY_FLAGS
- RUBY_FLAGS = "-I#{%w(lib ext bin test).join(File::PATH_SEPARATOR)}"
+ flags = "-I#{%w(lib ext bin test).join(File::PATH_SEPARATOR)}"
+ flags = "--1.9 " + flags if java?
+ RUBY_FLAGS = flags
end
gem 'rake-compiler', '>= 0.4.1'
@@ -28,8 +34,20 @@ $hoe = Hoe.spec 'psych' do
:required_ruby_version => '>= 1.9.2'
}
- Rake::ExtensionTask.new "psych", spec do |ext|
- ext.lib_dir = File.join(*['lib', ENV['FAT_DIR']].compact)
+ if java?
+ # TODO: clean this section up.
+ require "rake/javaextensiontask"
+ Rake::JavaExtensionTask.new("psych", spec) do |ext|
+ jruby_home = RbConfig::CONFIG['prefix']
+ ext.ext_dir = 'ext/java'
+ ext.lib_dir = 'lib/psych'
+ jars = ["#{jruby_home}/lib/jruby.jar"] + FileList['lib/*.jar']
+ ext.classpath = jars.map { |x| File.expand_path x }.join ':'
+ end
+ else
+ Rake::ExtensionTask.new "psych", spec do |ext|
+ ext.lib_dir = File.join(*['lib', ENV['FAT_DIR']].compact)
+ end
end
end