diff options
author | Kouhei Sutou <kou@cozmixng.org> | 2019-01-04 07:16:18 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-04 07:16:18 +0900 |
commit | 17064c7756621071e12a9dad409252f567afa457 (patch) | |
tree | a8d475d0df1933be5a2c573445d8c55312cf461e /lib | |
parent | 498ba0d45372f882957cb0c72446c88ecca60a2a (diff) | |
parent | e69e7c0d6a02ed19a7edfa185eb7d0de9a69fbd2 (diff) | |
download | rake-compiler-17064c7756621071e12a9dad409252f567afa457.tar.gz |
Merge pull request #151 from prashantvithani/cross-platform-compilation
Fix cross-platform compilation for Java extensions
Patch by Prashant Vithani. Thanks!!!
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rake/javaextensiontask.rb | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/lib/rake/javaextensiontask.rb b/lib/rake/javaextensiontask.rb index 15cc2f7..592da3a 100644 --- a/lib/rake/javaextensiontask.rb +++ b/lib/rake/javaextensiontask.rb @@ -212,13 +212,34 @@ execute the Rake compilation task using the JRuby interpreter. rescue => e end end + + # jruby_cpath might not be present from Java-9 onwards as it removes + # sun.boot.class.path. Check if JRUBY_HOME is set as env variable and try + # to find jruby.jar under JRUBY_HOME + unless jruby_cpath + jruby_home = ENV['JRUBY_HOME'] + if jruby_home + candidate = File.join(jruby_home, 'lib', 'jruby.jar') + jruby_cpath = candidate if File.exist? candidate + end + end + + # JRUBY_HOME is not necessarily set in JRuby-9.x + # Find the libdir from RbConfig::CONFIG and find jruby.jar under the + # found lib path unless jruby_cpath libdir = RbConfig::CONFIG['libdir'] - if libdir.start_with? "classpath:" - raise 'Cannot build with jruby-complete' + if libdir.start_with? "uri:classloader:" + raise 'Cannot build with jruby-complete from Java 9 onwards' end - jruby_cpath = File.join(libdir, "jruby.jar") + candidate = File.join(libdir, "jruby.jar") + jruby_cpath = candidate if File.exist? candidate end + + unless jruby_cpath + raise "Could not find jruby.jar. Please set JRUBY_HOME or Use jruby in rvm" + end + jruby_cpath += File::PATH_SEPARATOR + args.join(File::PATH_SEPARATOR) unless args.empty? jruby_cpath ? "-cp \"#{jruby_cpath}\"" : "" end |