propane 3.4.2-java → 3.5.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.mvn/wrapper/MavenWrapperDownloader.java +1 -1
- data/.travis.yml +1 -1
- data/CHANGELOG.md +5 -1
- data/Gemfile +2 -0
- data/README.md +15 -3
- data/Rakefile +9 -10
- data/bin/propane +3 -1
- data/lib/propane.rb +2 -1
- data/lib/propane/app.rb +2 -1
- data/lib/propane/creators/sketch_class.rb +7 -1
- data/lib/propane/creators/sketch_factory.rb +4 -2
- data/lib/propane/creators/sketch_writer.rb +1 -0
- data/lib/propane/helper_methods.rb +22 -22
- data/lib/propane/helpers/numeric.rb +2 -0
- data/lib/propane/helpers/version_error.rb +1 -0
- data/lib/propane/library.rb +5 -1
- data/lib/propane/library_loader.rb +2 -0
- data/lib/propane/native_folder.rb +10 -9
- data/lib/propane/native_loader.rb +3 -0
- data/lib/propane/runner.rb +11 -5
- data/lib/propane/version.rb +2 -1
- data/library/boids/boids.rb +21 -11
- data/library/color_group/color_group.rb +2 -0
- data/library/control_panel/control_panel.rb +8 -5
- data/library/dxf/dxf.rb +2 -0
- data/library/file_chooser/chooser.rb +10 -9
- data/library/file_chooser/file_chooser.rb +10 -9
- data/library/library_proxy/library_proxy.rb +2 -0
- data/library/net/net.rb +2 -0
- data/library/simplex_noise/simplex_noise.rb +2 -0
- data/library/slider/slider.rb +23 -22
- data/library/vector_utils/vector_utils.rb +4 -0
- data/library/video_event/video_event.rb +2 -0
- data/pom.rb +46 -45
- data/pom.xml +4 -4
- data/propane.gemspec +8 -7
- data/src/main/java/monkstone/ColorUtil.java +1 -3
- data/src/main/java/monkstone/MathToolModule.java +1 -1
- data/src/main/java/monkstone/PropaneLibrary.java +2 -2
- data/src/main/java/monkstone/fastmath/Deglut.java +1 -1
- data/src/main/java/monkstone/filechooser/Chooser.java +1 -1
- data/src/main/java/monkstone/noise/SimplexNoise.java +2 -2
- data/src/main/java/monkstone/slider/CustomHorizontalSlider.java +1 -1
- data/src/main/java/monkstone/slider/CustomVerticalSlider.java +1 -1
- data/src/main/java/monkstone/slider/SimpleHorizontalSlider.java +1 -1
- data/src/main/java/monkstone/slider/SimpleVerticalSlider.java +1 -1
- data/src/main/java/monkstone/slider/SliderBar.java +1 -1
- data/src/main/java/monkstone/slider/SliderGroup.java +1 -1
- data/src/main/java/monkstone/slider/WheelHandler.java +1 -1
- data/src/main/java/monkstone/vecmath/package-info.java +1 -1
- data/src/main/java/monkstone/vecmath/vec2/Vec2.java +1 -1
- data/src/main/java/monkstone/vecmath/vec3/Vec3.java +1 -2
- data/src/main/java/monkstone/videoevent/CaptureEvent.java +1 -1
- data/src/main/java/monkstone/videoevent/MovieEvent.java +1 -1
- data/src/main/java/monkstone/videoevent/package-info.java +1 -1
- data/src/main/java/processing/awt/PGraphicsJava2D.java +788 -283
- data/src/main/java/processing/awt/PImageAWT.java +260 -0
- data/src/main/java/processing/awt/PShapeJava2D.java +56 -53
- data/src/main/java/processing/awt/PSurfaceAWT.java +309 -211
- data/src/main/java/processing/awt/ShimAWT.java +580 -0
- data/src/main/java/processing/core/PApplet.java +2877 -2098
- data/src/main/java/processing/core/PConstants.java +477 -447
- data/src/main/java/processing/core/PFont.java +930 -884
- data/src/main/java/processing/core/PGraphics.java +337 -309
- data/src/main/java/processing/core/PImage.java +1689 -1689
- data/src/main/java/processing/core/PMatrix.java +172 -159
- data/src/main/java/processing/core/PMatrix2D.java +456 -410
- data/src/main/java/processing/core/PMatrix3D.java +755 -735
- data/src/main/java/processing/core/PShape.java +2910 -2656
- data/src/main/java/processing/core/PShapeOBJ.java +97 -94
- data/src/main/java/processing/core/PShapeSVG.java +1656 -1462
- data/src/main/java/processing/core/PStyle.java +40 -37
- data/src/main/java/processing/core/PSurface.java +134 -97
- data/src/main/java/processing/core/PSurfaceNone.java +292 -218
- data/src/main/java/processing/core/PVector.java +991 -966
- data/src/main/java/processing/core/ThinkDifferent.java +12 -8
- data/src/main/java/processing/data/DoubleDict.java +756 -710
- data/src/main/java/processing/data/DoubleList.java +749 -696
- data/src/main/java/processing/data/FloatDict.java +748 -702
- data/src/main/java/processing/data/FloatList.java +751 -697
- data/src/main/java/processing/data/IntDict.java +720 -673
- data/src/main/java/processing/data/IntList.java +699 -633
- data/src/main/java/processing/data/JSONArray.java +931 -873
- data/src/main/java/processing/data/JSONObject.java +1262 -1165
- data/src/main/java/processing/data/JSONTokener.java +351 -341
- data/src/main/java/processing/data/LongDict.java +710 -663
- data/src/main/java/processing/data/LongList.java +701 -635
- data/src/main/java/processing/data/Sort.java +37 -41
- data/src/main/java/processing/data/StringDict.java +525 -486
- data/src/main/java/processing/data/StringList.java +626 -580
- data/src/main/java/processing/data/Table.java +3693 -3513
- data/src/main/java/processing/data/TableRow.java +182 -183
- data/src/main/java/processing/data/XML.java +954 -880
- data/src/main/java/processing/event/Event.java +87 -67
- data/src/main/java/processing/event/KeyEvent.java +48 -41
- data/src/main/java/processing/event/MouseEvent.java +87 -113
- data/src/main/java/processing/event/TouchEvent.java +10 -6
- data/src/main/java/processing/javafx/PSurfaceFX.java +26 -0
- data/src/main/java/processing/net/Client.java +20 -20
- data/src/main/java/processing/net/Server.java +9 -9
- data/src/main/java/processing/opengl/FontTexture.java +286 -266
- data/src/main/java/processing/opengl/FrameBuffer.java +390 -376
- data/src/main/java/processing/opengl/LinePath.java +130 -91
- data/src/main/java/processing/opengl/LineStroker.java +593 -582
- data/src/main/java/processing/opengl/PGL.java +645 -579
- data/src/main/java/processing/opengl/PGraphics2D.java +408 -315
- data/src/main/java/processing/opengl/PGraphics3D.java +107 -72
- data/src/main/java/processing/opengl/PGraphicsOpenGL.java +12287 -12030
- data/src/main/java/processing/opengl/PJOGL.java +1743 -1672
- data/src/main/java/processing/opengl/PShader.java +345 -416
- data/src/main/java/processing/opengl/PShapeOpenGL.java +4601 -4543
- data/src/main/java/processing/opengl/PSurfaceJOGL.java +1113 -1029
- data/src/main/java/processing/opengl/Texture.java +1489 -1401
- data/src/main/java/processing/opengl/VertexBuffer.java +57 -55
- data/test/create_test.rb +21 -20
- data/test/deglut_spec_test.rb +4 -2
- data/test/helper_methods_test.rb +49 -20
- data/test/math_tool_test.rb +39 -32
- data/test/native_folder.rb +47 -0
- data/test/respond_to_test.rb +3 -2
- data/test/sketches/key_event.rb +2 -2
- data/test/sketches/library/my_library/my_library.rb +3 -0
- data/test/test_helper.rb +2 -0
- data/test/vecmath_spec_test.rb +35 -22
- data/vendors/Rakefile +28 -22
- metadata +13 -13
- data/src/main/java/processing/opengl/shaders/LightVert-brcm.glsl +0 -154
- data/src/main/java/processing/opengl/shaders/LightVert-vc4.glsl +0 -154
- data/src/main/java/processing/opengl/shaders/TexLightVert-brcm.glsl +0 -160
- data/src/main/java/processing/opengl/shaders/TexLightVert-vc4.glsl +0 -160
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7837b349f30c7e79ee7e90b36eb7603174a0228d49fcaa8ec321ea5db24ae112
|
4
|
+
data.tar.gz: 38d0c0cc6972e111fe2bb7a81cf3f5bbe20cbb795b31f880acfaaff8a1008023
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f2f530ad672d28338340409760883e5bec5ce735a07fac5b76e9fba5e8965c37674410eb54c6aeec46d78e3568850719765738c71b359cdb37a0b30d6060af5
|
7
|
+
data.tar.gz: b0f30134fb858c2dbbc3a40eb9772e9788e1bca09f3cb2c893139bf690cef294d9dc5a30cf3667fd73016144807f6778b2cb5d13a02111f85ae56c91e5a64a17
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
|
+
**v3.5.0** Rebase processing core code around Sam Pottinhgers latest fixes for JOGL an image save, does mean breaking some of Diwis and Joshua Davis examples, but one hopes codeanticode knows what he's doing.
|
2
|
+
|
3
|
+
**v3.4.3** Use Map.of to initialize HashMap bump processing version in build bump to jruby-9.2.11.0
|
4
|
+
|
1
5
|
**v3.4.2** Fix native library bug on windows (thanks to Jay Scott). Add minim library examples
|
2
6
|
|
3
|
-
**v3.4.1** Update to
|
7
|
+
**v3.4.1** Update to jruby-9.2.9.0
|
4
8
|
|
5
9
|
**v3.4.0** Experimental refactoring of ThinkDifferent, and some other processing classes
|
6
10
|
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -11,7 +11,7 @@ adjust above for your OS/distro setup.
|
|
11
11
|
There may be a linker issue with P2D or P3D sketches with stock openjdk with some linux distros, in which case you might find [Adopt open jdk binaries][adopt] will work for you.
|
12
12
|
|
13
13
|
- `jdk-11.0.3+`
|
14
|
-
- `jruby-9.2.
|
14
|
+
- `jruby-9.2.11.1`
|
15
15
|
|
16
16
|
Currently you can ignore `illegal reflective access` warnings, see [here how to suppress them][warning].
|
17
17
|
|
@@ -27,10 +27,10 @@ rake javadoc
|
|
27
27
|
|
28
28
|
```bash
|
29
29
|
jgem install propane # from rubygems
|
30
|
-
jgem install propane-3.4.
|
30
|
+
jgem install propane-3.4.3-java.gem # local install
|
31
31
|
# Alternative
|
32
32
|
jruby -S gem install propane # from rubygems
|
33
|
-
jruby -S gem install propane-3.4.
|
33
|
+
jruby -S gem install propane-3.4.3-java.gem # local install
|
34
34
|
```
|
35
35
|
|
36
36
|
## Check Install
|
@@ -40,6 +40,18 @@ To check version and confirm gem bin files are on your path (also checks JDK ver
|
|
40
40
|
propane --version
|
41
41
|
```
|
42
42
|
|
43
|
+
## Suppressing Reflective Access warnings
|
44
|
+
|
45
|
+
Since propane-3.4.3 it is possible to suppress reflective access warnings by including a `~/.jruby.java_opts` file with following contents:-
|
46
|
+
|
47
|
+
```bash
|
48
|
+
--add-opens java.base/java.lang=ALL-UNNAMED
|
49
|
+
--add-opens java.desktop/java.awt=ALL-UNNAMED
|
50
|
+
--add-opens java.desktop/sun.awt=ALL-UNNAMED
|
51
|
+
--add-opens java.desktop/sun.java2d.opengl=ALL-UNNAMED
|
52
|
+
```
|
53
|
+
Mainly needed for opengl sketches.
|
54
|
+
|
43
55
|
## Usage
|
44
56
|
|
45
57
|
A propane sketch:-
|
data/Rakefile
CHANGED
@@ -1,18 +1,17 @@
|
|
1
1
|
# frozen_string_literal: false
|
2
|
+
|
2
3
|
require_relative 'lib/propane/version'
|
3
4
|
|
4
|
-
task default: [
|
5
|
+
task default: %i[init compile install test gem]
|
5
6
|
|
6
|
-
# depends on
|
7
|
+
# Currently depends on local jogl-2.4.0 jars on path ~/jogl24
|
7
8
|
desc 'Copy Jars'
|
8
9
|
task :init do
|
9
|
-
|
10
|
-
|
11
|
-
jar_dir = File.join(processing_root, 'core', 'library')
|
12
|
-
opengl = Dir.entries(jar_dir).grep(/amd64|macosx-universal/)
|
10
|
+
jogl24 = File.join(ENV['HOME'], 'jogl24')
|
11
|
+
opengl = Dir.entries(jogl24).grep(/amd64|universal/).select { |jar| jar =~ /linux|windows|macosx/ }
|
13
12
|
opengl.concat %w[jogl-all.jar gluegen-rt.jar]
|
14
13
|
opengl.each do |gl|
|
15
|
-
FileUtils.cp(File.join(
|
14
|
+
FileUtils.cp(File.join(jogl24, gl), File.join('.', 'lib'))
|
16
15
|
end
|
17
16
|
end
|
18
17
|
|
@@ -28,12 +27,12 @@ end
|
|
28
27
|
|
29
28
|
desc 'Document'
|
30
29
|
task :javadoc do
|
31
|
-
|
30
|
+
sh './mvnw javadoc:javadoc'
|
32
31
|
end
|
33
32
|
|
34
33
|
desc 'Compile'
|
35
34
|
task :compile do
|
36
|
-
|
35
|
+
sh './mvnw package'
|
37
36
|
end
|
38
37
|
|
39
38
|
desc 'JRuby-Complete'
|
@@ -53,7 +52,7 @@ end
|
|
53
52
|
|
54
53
|
desc 'clean'
|
55
54
|
task :clean do
|
56
|
-
Dir[
|
55
|
+
Dir['./**/*.{jar,gem}'].each do |path|
|
57
56
|
puts "Deleting #{path} ..."
|
58
57
|
File.delete(path)
|
59
58
|
end
|
data/bin/propane
CHANGED
data/lib/propane.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'java'
|
3
4
|
unless defined? PROPANE_ROOT
|
4
5
|
$LOAD_PATH << File.dirname(__dir__)
|
5
6
|
PROPANE_ROOT = File.dirname(__dir__)
|
6
7
|
end
|
7
|
-
Dir["#{PROPANE_ROOT}/lib/*.jar"].each do |jar|
|
8
|
+
Dir["#{PROPANE_ROOT}/lib/*.jar"].sort.each do |jar|
|
8
9
|
require jar
|
9
10
|
end
|
10
11
|
require_relative 'propane/app'
|
data/lib/propane/app.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: false
|
2
2
|
|
3
|
+
require 'jruby'
|
3
4
|
require_relative 'helper_methods'
|
4
5
|
require_relative 'library_loader'
|
5
6
|
|
@@ -132,7 +133,7 @@ module Propane
|
|
132
133
|
@width ||= w
|
133
134
|
@height ||= h
|
134
135
|
@render_mode ||= mode
|
135
|
-
import_opengl if /opengl
|
136
|
+
import_opengl if /opengl/.match?(mode)
|
136
137
|
super(*args)
|
137
138
|
end
|
138
139
|
|
@@ -5,7 +5,10 @@ class SketchClass
|
|
5
5
|
attr_reader :name, :width, :height, :mode
|
6
6
|
|
7
7
|
def initialize(name:, width: 150, height: 150, mode: nil)
|
8
|
-
@name
|
8
|
+
@name = name
|
9
|
+
@width = width
|
10
|
+
@height = height
|
11
|
+
@mode = mode
|
9
12
|
end
|
10
13
|
|
11
14
|
def class_sketch
|
@@ -26,6 +29,7 @@ class SketchClass
|
|
26
29
|
|
27
30
|
def size
|
28
31
|
return format(' size %d, %d', width.to_i, height.to_i) unless mode
|
32
|
+
|
29
33
|
format(' size %d, %d, %s', width.to_i, height.to_i, mode.upcase)
|
30
34
|
end
|
31
35
|
|
@@ -36,6 +40,7 @@ class SketchClass
|
|
36
40
|
|
37
41
|
def method_lines(name, content = nil)
|
38
42
|
return [format(' def %s', name), '', ' end'] unless content
|
43
|
+
|
39
44
|
[format(' def %s', name), content, ' end', '']
|
40
45
|
end
|
41
46
|
|
@@ -43,6 +48,7 @@ class SketchClass
|
|
43
48
|
lines = [
|
44
49
|
'#!/usr/bin/env jruby',
|
45
50
|
'# frozen_string_literal: false',
|
51
|
+
'',
|
46
52
|
"require 'propane'",
|
47
53
|
'',
|
48
54
|
class_sketch
|
@@ -1,8 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'sketch_writer'
|
2
4
|
|
3
5
|
class SketchFactory
|
4
|
-
NAMES = %w[One Two Three]
|
5
|
-
def initialize(
|
6
|
+
NAMES = %w[One Two Three].freeze
|
7
|
+
def initialize(_argc)
|
6
8
|
NAMES.each do |name|
|
7
9
|
SketchWriter.new(File.basename(name, '.rb'), width: 300, height: 300).write
|
8
10
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: false
|
2
|
+
|
2
3
|
# processing module wrapper
|
3
4
|
require_relative 'helpers/numeric'
|
4
5
|
module Propane
|
@@ -52,6 +53,7 @@ module Propane
|
|
52
53
|
|
53
54
|
def color(*args)
|
54
55
|
return super(*args) unless args.length == 1
|
56
|
+
|
55
57
|
super(hex_color(args[0]))
|
56
58
|
end
|
57
59
|
|
@@ -66,11 +68,8 @@ module Propane
|
|
66
68
|
# Overrides Processing convenience function thread, which takes a String
|
67
69
|
# arg (for a function) to more rubylike version, takes a block...
|
68
70
|
def thread(&block)
|
69
|
-
|
70
|
-
|
71
|
-
else
|
72
|
-
raise ArgumentError, 'thread must be called with a block', caller
|
73
|
-
end
|
71
|
+
warn 'A Block is Needed' unless block_given?
|
72
|
+
Java::JavaLang::Thread.new(&block).start
|
74
73
|
end
|
75
74
|
|
76
75
|
# explicitly provide 'processing.org' min instance method
|
@@ -94,9 +93,9 @@ module Propane
|
|
94
93
|
def dist(*args)
|
95
94
|
case args.length
|
96
95
|
when 4
|
97
|
-
|
96
|
+
dist2d(*args)
|
98
97
|
when 6
|
99
|
-
|
98
|
+
dist3d(*args)
|
100
99
|
else
|
101
100
|
raise ArgumentError, 'takes 4 or 6 parameters'
|
102
101
|
end
|
@@ -111,13 +110,13 @@ module Propane
|
|
111
110
|
# Here's a convenient way to look for them.
|
112
111
|
def find_method(method_name)
|
113
112
|
reg = Regexp.new(method_name.to_s, true)
|
114
|
-
methods.sort.select { |meth| reg.match(meth) }
|
113
|
+
methods.sort.select { |meth| reg.match?(meth) }
|
115
114
|
end
|
116
115
|
|
117
116
|
# Proxy over a list of Java declared fields that have the same name as
|
118
117
|
# some methods. Add to this list as needed.
|
119
118
|
def proxy_java_fields
|
120
|
-
fields = %w
|
119
|
+
fields = %w[key frameRate mousePressed keyPressed]
|
121
120
|
methods = fields.map { |field| java_class.declared_field(field) }
|
122
121
|
@declared_fields = Hash[fields.zip(methods)]
|
123
122
|
end
|
@@ -163,6 +162,7 @@ module Propane
|
|
163
162
|
# frame_rate needs to support reading and writing
|
164
163
|
def frame_rate(fps = nil)
|
165
164
|
return @declared_fields['frameRate'].value(java_self) unless fps
|
165
|
+
|
166
166
|
super(fps)
|
167
167
|
end
|
168
168
|
|
@@ -178,21 +178,19 @@ module Propane
|
|
178
178
|
|
179
179
|
private
|
180
180
|
|
181
|
-
INTEGER_COL = -> (x) { x.is_a?(Integer) }
|
182
|
-
STRING_COL = -> (x) { x.is_a?(String) }
|
183
|
-
FLOAT_COL = -> (x) { x.is_a?(Float) }
|
184
181
|
# parse single argument color int/double/String
|
185
|
-
def hex_color(
|
186
|
-
case
|
187
|
-
when
|
188
|
-
Java::Monkstone::ColorUtil.colorLong(
|
189
|
-
when
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
182
|
+
def hex_color(arg)
|
183
|
+
case arg
|
184
|
+
when Integer
|
185
|
+
Java::Monkstone::ColorUtil.colorLong(arg)
|
186
|
+
when String
|
187
|
+
raise 'Dodgy Hexstring' unless /#\h{6}$/.match?(arg)
|
188
|
+
|
189
|
+
Java::Monkstone::ColorUtil.colorString(arg)
|
190
|
+
when Float
|
191
|
+
Java::Monkstone::ColorUtil.colorDouble(arg)
|
194
192
|
else
|
195
|
-
raise
|
193
|
+
raise 'Dodgy Color Conversion'
|
196
194
|
end
|
197
195
|
end
|
198
196
|
|
@@ -200,6 +198,7 @@ module Propane
|
|
200
198
|
dx = args[0] - args[2]
|
201
199
|
dy = args[1] - args[3]
|
202
200
|
return 0 if dx.abs < EPSILON && dy.abs < EPSILON
|
201
|
+
|
203
202
|
Math.hypot(dx, dy)
|
204
203
|
end
|
205
204
|
|
@@ -208,6 +207,7 @@ module Propane
|
|
208
207
|
dy = args[1] - args[4]
|
209
208
|
dz = args[2] - args[5]
|
210
209
|
return 0 if dx.abs < EPSILON && dy.abs < EPSILON && dz.abs < EPSILON
|
210
|
+
|
211
211
|
Math.sqrt(dx * dx + dy * dy + dz * dz)
|
212
212
|
end
|
213
213
|
end
|
data/lib/propane/library.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'native_folder'
|
2
4
|
require_relative 'native_loader'
|
3
5
|
require 'pathname'
|
@@ -18,6 +20,7 @@ class Library
|
|
18
20
|
return if (@path = Pathname.new(
|
19
21
|
File.join(PROPANE_ROOT, 'library', name, "#{name}.rb")
|
20
22
|
)).exist?
|
23
|
+
|
21
24
|
locate_java
|
22
25
|
end
|
23
26
|
|
@@ -46,10 +49,11 @@ class Library
|
|
46
49
|
end
|
47
50
|
|
48
51
|
def load_jars
|
49
|
-
Dir.glob("#{dir}/*.jar").each do |jar|
|
52
|
+
Dir.glob("#{dir}/*.jar").sort.each do |jar|
|
50
53
|
require jar
|
51
54
|
end
|
52
55
|
return true unless native_binaries?
|
56
|
+
|
53
57
|
add_binaries_to_classpath
|
54
58
|
end
|
55
59
|
|
@@ -33,10 +33,12 @@ module Propane
|
|
33
33
|
|
34
34
|
def loader(name)
|
35
35
|
return true if @loaded_libraries.include?(name)
|
36
|
+
|
36
37
|
fname = name.to_s
|
37
38
|
library = Library.new(fname)
|
38
39
|
library.locate
|
39
40
|
return require_library(library, name) if library.ruby?
|
41
|
+
|
40
42
|
warn("Not found library: #{fname}") unless library.exist?
|
41
43
|
load_jars(library, name)
|
42
44
|
end
|
@@ -1,11 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rbconfig'
|
2
4
|
|
3
5
|
# Utility to load native binaries on Java CLASSPATH
|
4
6
|
class NativeFolder
|
5
7
|
attr_reader :os, :bit
|
6
8
|
|
7
|
-
WIN_FORMAT = 'windows%d'
|
8
|
-
LINUX_FORMAT = 'linux%d'
|
9
|
+
WIN_FORMAT = 'windows%d'
|
10
|
+
LINUX_FORMAT = 'linux%d'
|
9
11
|
WIN_PATTERNS = [
|
10
12
|
/bccwin/i,
|
11
13
|
/cygwin/i,
|
@@ -17,22 +19,21 @@ class NativeFolder
|
|
17
19
|
|
18
20
|
def initialize
|
19
21
|
@os = RbConfig::CONFIG['host_os'].downcase
|
20
|
-
@bit = java.lang.System.get_property('os.arch')
|
22
|
+
@bit = /64/.match?(java.lang.System.get_property('os.arch')) ? 64 : 32
|
21
23
|
end
|
22
24
|
|
23
25
|
def name
|
24
26
|
return 'macosx' if /darwin|mac/.match?(os)
|
25
|
-
return format(LINUX_FORMAT, bit) if
|
26
|
-
if WIN_PATTERNS.any? { |pat| pat
|
27
|
-
|
28
|
-
return format(WIN_FORMAT, '32') if /32/.match?(bit)
|
29
|
-
end
|
27
|
+
return format(LINUX_FORMAT, bit) if /linux/.match?(os)
|
28
|
+
return format(WIN_FORMAT, bit) if WIN_PATTERNS.any? { |pat| pat.match?(os) }
|
29
|
+
|
30
30
|
raise 'Unsupported Architecture'
|
31
31
|
end
|
32
32
|
|
33
33
|
def extension
|
34
34
|
return '*.so' if /linux/.match?(os)
|
35
|
-
return '*.dll' if WIN_PATTERNS.any? { |pat| pat
|
35
|
+
return '*.dll' if WIN_PATTERNS.any? { |pat| pat.match?(os) }
|
36
|
+
|
36
37
|
'*.dylib' # MacOS
|
37
38
|
end
|
38
39
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# This class knows how to dynamically set the 'java' native library path
|
2
4
|
# It might not work with java 9?
|
3
5
|
class NativeLoader
|
@@ -21,6 +23,7 @@ class NativeLoader
|
|
21
23
|
field = JC::Class.for_name('java.lang.ClassLoader')
|
22
24
|
.get_declared_field('sys_paths')
|
23
25
|
return unless field
|
26
|
+
|
24
27
|
field.accessible = true # some jruby magic
|
25
28
|
field.set(JC::Class.for_name('java.lang.System').get_class_loader, nil)
|
26
29
|
end
|