[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
This commit is contained in:
Takashi Kokubun 2022-11-26 22:30:43 -08:00 committed by git
parent ec76c9868b
commit d2c62426e5
2 changed files with 12 additions and 4 deletions

View File

@ -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

View File

@ -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)