summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2022-11-26 22:30:43 -0800
committergit <svn-admin@ruby-lang.org>2022-11-27 06:30:48 +0000
commitd2c62426e5f5a53fd17e07e789a92994be4351ed (patch)
treeaecdb86c59200431236f614855cb2daf214ad52a
parentec76c9868b9b707aa657b59b8bb9e737c7ff91e7 (diff)
[ruby/erb] Skip using the extension for truffleruby as well
(https://github.com/ruby/erb/pull/39) * Skip using the extension for truffleruby as well * Just skip building the C extension for TruffleRuby * Skip rake compile for truffleruby * Use resolve_feature_path * Revert "Use resolve_feature_path" This reverts commit https://github.com/ruby/erb/commit/acc1e0c0ffaf. * Use resolve_feature_path with LoadError guard https://github.com/ruby/erb/commit/85dcb08439
-rw-r--r--ext/erb/escape/extconf.rb7
-rw-r--r--lib/erb/util.rb9
2 files changed, 12 insertions, 4 deletions
diff --git a/ext/erb/escape/extconf.rb b/ext/erb/escape/extconf.rb
index 9dec05f2c6..c1002548ad 100644
--- a/ext/erb/escape/extconf.rb
+++ b/ext/erb/escape/extconf.rb
@@ -1,2 +1,7 @@
require 'mkmf'
-create_makefile 'erb/escape'
+
+if RUBY_ENGINE == 'truffleruby'
+ File.write('Makefile', dummy_makefile($srcdir).join)
+else
+ create_makefile 'erb/escape'
+end
diff --git a/lib/erb/util.rb b/lib/erb/util.rb
index c24a175199..0c1e7482a8 100644
--- a/lib/erb/util.rb
+++ b/lib/erb/util.rb
@@ -4,10 +4,13 @@
# A subset of ERB::Util. Unlike ERB::Util#html_escape, we expect/hope
# Rails will not monkey-patch ERB::Escape#html_escape.
begin
- require 'erb/escape'
-rescue LoadError # JRuby can't load .so
+ # We don't build the C extension for JRuby, TruffleRuby, and WASM
+ if $LOAD_PATH.resolve_feature_path('erb/escape')
+ require 'erb/escape'
+ end
+rescue LoadError # resolve_feature_path raises LoadError on TruffleRuby 22.3.0
end
-unless defined?(ERB::Escape) # JRuby
+unless defined?(ERB::Escape)
module ERB::Escape
def html_escape(s)
CGI.escapeHTML(s.to_s)