summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorCharles Oliver Nutter <headius@headius.com>2023-02-08 21:01:46 +0100
committergit <svn-admin@ruby-lang.org>2023-02-17 17:52:48 +0000
commitbecec0001c8eff1b763bed804e48a9ab71289fdd (patch)
tree3aa7cdc9a9ee81275a3b289d4b71dd2b6ef2d340 /ext
parent36e3d46d35b6a904533e58809369054b135c33d7 (diff)
downloadruby-becec0001c8eff1b763bed804e48a9ab71289fdd.tar.gz
[ruby/bigdecimal] Stub out extension build on JRuby
JRuby currently ships its own internal bigdecimal extension as part of the core libraries. In order for users to be able to add bigdecimal to their Gemfile or gem dependencies, we need to stub out the C extension and just load the extension shipped with JRuby. In the future we will try to move our BigDecimal implementation into the gem, but for now this is the simplest way to make it installable on JRuby. See #169 https://github.com/ruby/bigdecimal/commit/829956c643
Diffstat (limited to 'ext')
-rw-r--r--ext/bigdecimal/bigdecimal.gemspec24
-rw-r--r--ext/bigdecimal/lib/bigdecimal.rb6
2 files changed, 20 insertions, 10 deletions
diff --git a/ext/bigdecimal/bigdecimal.gemspec b/ext/bigdecimal/bigdecimal.gemspec
index d215757188..b05b2b0891 100644
--- a/ext/bigdecimal/bigdecimal.gemspec
+++ b/ext/bigdecimal/bigdecimal.gemspec
@@ -12,17 +12,8 @@ Gem::Specification.new do |s|
s.licenses = ["Ruby", "bsd-2-clause"]
s.require_paths = %w[lib]
- s.extensions = %w[ext/bigdecimal/extconf.rb]
s.files = %w[
bigdecimal.gemspec
- ext/bigdecimal/bigdecimal.c
- ext/bigdecimal/bigdecimal.h
- ext/bigdecimal/bits.h
- ext/bigdecimal/feature.h
- ext/bigdecimal/missing.c
- ext/bigdecimal/missing.h
- ext/bigdecimal/missing/dtoa.c
- ext/bigdecimal/static_assert.h
lib/bigdecimal.rb
lib/bigdecimal/jacobian.rb
lib/bigdecimal/ludcmp.rb
@@ -33,6 +24,21 @@ Gem::Specification.new do |s|
sample/nlsolve.rb
sample/pi.rb
]
+ if Gem::Platform === s.platform and s.platform =~ 'java' or RUBY_ENGINE == 'jruby'
+ s.platform = 'java'
+ else
+ s.extensions = %w[ext/bigdecimal/extconf.rb]
+ s.files += %w[
+ ext/bigdecimal/bigdecimal.c
+ ext/bigdecimal/bigdecimal.h
+ ext/bigdecimal/bits.h
+ ext/bigdecimal/feature.h
+ ext/bigdecimal/missing.c
+ ext/bigdecimal/missing.h
+ ext/bigdecimal/missing/dtoa.c
+ ext/bigdecimal/static_assert.h
+ ]
+ end
s.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
end
diff --git a/ext/bigdecimal/lib/bigdecimal.rb b/ext/bigdecimal/lib/bigdecimal.rb
index 8fd2587c84..82b3e1b7b9 100644
--- a/ext/bigdecimal/lib/bigdecimal.rb
+++ b/ext/bigdecimal/lib/bigdecimal.rb
@@ -1 +1,5 @@
-require 'bigdecimal.so'
+if RUBY_ENGINE == 'jruby'
+ JRuby::Util.load_ext("org.jruby.ext.bigdecimal.BigDecimalLibrary")
+else
+ require 'bigdecimal.so'
+end