File tree 3 files changed +25
-8
lines changed
3 files changed +25
-8
lines changed Original file line number Diff line number Diff line change @@ -238,7 +238,11 @@ if defined?(RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
238
238
task :release => :build
239
239
else
240
240
desc "Compiling extension"
241
- task :compile => [ EXT_PARSER_DL , EXT_GENERATOR_DL ]
241
+ if RUBY_ENGINE == 'truffleruby'
242
+ task :compile => [ EXT_PARSER_DL ]
243
+ else
244
+ task :compile => [ EXT_PARSER_DL , EXT_GENERATOR_DL ]
245
+ end
242
246
243
247
file EXT_PARSER_DL => EXT_PARSER_SRC do
244
248
cd EXT_PARSER_DIR do
Original file line number Diff line number Diff line change 1
1
require 'mkmf'
2
2
3
- $defs << "-DJSON_GENERATOR"
4
- create_makefile 'json/ext/generator'
3
+ if RUBY_ENGINE == 'truffleruby'
4
+ # The pure-Ruby generator is faster on TruffleRuby, so skip compiling the generator extension
5
+ File . write ( 'Makefile' , dummy_makefile ( "" ) . join )
6
+ else
7
+ $defs << "-DJSON_GENERATOR"
8
+ create_makefile 'json/ext/generator'
9
+ end
Original file line number Diff line number Diff line change @@ -4,11 +4,19 @@ module JSON
4
4
# This module holds all the modules/classes that implement JSON's
5
5
# functionality as C extensions.
6
6
module Ext
7
- require 'json/ext/parser'
8
- require 'json/ext/generator'
9
- $DEBUG and warn "Using Ext extension for JSON."
10
- JSON . parser = Parser
11
- JSON . generator = Generator
7
+ if RUBY_ENGINE == 'truffleruby'
8
+ require 'json/ext/parser'
9
+ require 'json/pure'
10
+ $DEBUG and warn "Using Ext extension for JSON parser and Pure library for JSON generator."
11
+ JSON . parser = Parser
12
+ JSON . generator = JSON ::Pure ::Generator
13
+ else
14
+ require 'json/ext/parser'
15
+ require 'json/ext/generator'
16
+ $DEBUG and warn "Using Ext extension for JSON."
17
+ JSON . parser = Parser
18
+ JSON . generator = Generator
19
+ end
12
20
end
13
21
14
22
JSON_LOADED = true unless defined? ( ::JSON ::JSON_LOADED )
You can’t perform that action at this time.
0 commit comments