1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[ruby/digest] jruby support

https://github.com/ruby/digest/commit/2e9dc14693
This commit is contained in:
Pavel Rosický 2021-06-12 18:49:57 +02:00 committed by Hiroshi SHIBATA
parent ff1f696d30
commit 94882df3a2
No known key found for this signature in database
GPG key ID: F9CF13417264FAC2
8 changed files with 76 additions and 12 deletions

View file

@ -0,0 +1,9 @@
# frozen_string_literal: false
require 'digest'
if RUBY_ENGINE == 'jruby'
JRuby::Util.load_ext("org.jruby.ext.digest.BubbleBabble")
else
require 'digest/bubblebabble.so'
end

View file

@ -10,7 +10,11 @@ Gem::Specification.new do |spec|
spec.summary = %q{Provides a framework for message digest libraries.}
spec.description = %q{Provides a framework for message digest libraries.}
spec.homepage = "https://github.com/ruby/digest"
spec.licenses = ["Ruby", "BSD-2-Clause"]
if Gem::Platform === spec.platform and spec.platform =~ 'java' or RUBY_ENGINE == 'jruby'
spec.licenses = ["Ruby", "BSD-2-Clause", "EPL-2.0", "GPL-2.0", "LGPL-2.1"]
else
spec.licenses = ["Ruby", "BSD-2-Clause"]
end
spec.files = [
"LICENSE.txt", "README.md",
@ -46,13 +50,27 @@ Gem::Specification.new do |spec|
spec.bindir = "exe"
spec.executables = []
spec.require_paths = ["lib"]
spec.extensions = %w[
ext/digest/extconf.rb
ext/digest/bubblebabble/extconf.rb
ext/digest/md5/extconf.rb
ext/digest/rmd160/extconf.rb
ext/digest/sha1/extconf.rb
ext/digest/sha2/extconf.rb
]
if Gem::Platform === spec.platform and spec.platform =~ 'java' or RUBY_ENGINE == 'jruby'
spec.platform = 'java'
spec.files.concat [
"lib/digest.jar",
"lib/digest/md5.rb",
"lib/digest/sha1.rb",
"lib/digest/sha2.rb",
"lib/digest/rmd160.rb",
"lib/digest/bubblebabble.rb"
]
else
spec.extensions = %w[
ext/digest/extconf.rb
ext/digest/bubblebabble/extconf.rb
ext/digest/md5/extconf.rb
ext/digest/rmd160/extconf.rb
ext/digest/sha1/extconf.rb
ext/digest/sha2/extconf.rb
]
end
spec.metadata["msys2_mingw_dependencies"] = "openssl"
end

View file

@ -1,5 +1,9 @@
# frozen_string_literal: false
require 'digest.so'
if RUBY_ENGINE == 'jruby'
JRuby::Util.load_ext("org.jruby.ext.digest.DigestLibrary")
else
require 'digest.so'
end
module Digest
# A mutex for Digest().
@ -8,7 +12,7 @@ module Digest
def self.const_missing(name) # :nodoc:
case name
when :SHA256, :SHA384, :SHA512
lib = 'digest/sha2.so'
lib = 'digest/sha2'
else
lib = File.join('digest', name.to_s.downcase)
end

View file

@ -0,0 +1,9 @@
# frozen_string_literal: false
require 'digest'
if RUBY_ENGINE == 'jruby'
JRuby::Util.load_ext("org.jruby.ext.digest.MD5")
else
require 'digest/md5.so'
end

View file

@ -0,0 +1,9 @@
# frozen_string_literal: false
require 'digest'
if RUBY_ENGINE == 'jruby'
JRuby::Util.load_ext("org.jruby.ext.digest.RMD160")
else
require 'digest/rmd160.so'
end

View file

@ -0,0 +1,9 @@
# frozen_string_literal: false
require 'digest'
if RUBY_ENGINE == 'jruby'
JRuby::Util.load_ext("org.jruby.ext.digest.SHA1")
else
require 'digest/sha1.so'
end

View file

@ -11,7 +11,12 @@
# $Id$
require 'digest'
require 'digest/sha2.so'
if RUBY_ENGINE == 'jruby'
JRuby::Util.load_ext("org.jruby.ext.digest.SHA2")
else
require 'digest/sha2.so'
end
module Digest
#

View file

@ -270,6 +270,7 @@ BEGIN {
eom
args = args.dup
args.insert((Hash === args.first ? 1 : 0), "-w", "--disable=gems", *$:.map {|l| "-I#{l}"})
args << "--debug" if RUBY_ENGINE == 'jruby' # warning: tracing (e.g. set_trace_func) will not capture all events without --debug flag
stdout, stderr, status = EnvUtil.invoke_ruby(args, src, capture_stdout, true, **opt)
ensure
if res_c