Skip to content

Commit

Permalink
[GR-25734] Remove patches for Nokogiri native extension
Browse files Browse the repository at this point in the history
PullRequest: truffleruby/4321
  • Loading branch information
andrykonchin committed Jul 26, 2024
2 parents 3cd4224 + 3c93412 commit a9674ee
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 126 deletions.
5 changes: 2 additions & 3 deletions doc/contributor/cexts.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,10 @@ natively.

### Compilation

We compile C extensions using the standard `mkmf` tool, and `clang` compilers
which have flags set to generate bitcode alongside machine code.
We compile C extensions using the standard `mkmf` tool, and `gcc`/`clang` compilers.

We pipe C source code through a pre-processor `lib/cext/preprocess.rb` before it
goes to `clang` to workaround some limitations.
goes to `gcc`/`clang` to work around some limitations.

### API functions

Expand Down
2 changes: 0 additions & 2 deletions lib/truffle/truffle/cext_preprocessor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
# rubocop:disable TruffleRuby/*

require_relative 'patches/json_patches'
require_relative 'patches/nokogiri_patches'
require_relative 'patches/oci8_patches'
require_relative 'patches/pg_patches'
require_relative 'patches/tk_patches'
Expand Down Expand Up @@ -42,7 +41,6 @@ def self.add_gem_patches(patch_hash, gem_patches)
end

add_gem_patches(PATCHED_FILES, ::JsonPatches::PATCHES)
add_gem_patches(PATCHED_FILES, ::NokogiriPatches::PATCHES)
add_gem_patches(PATCHED_FILES, ::OCI8Patches::PATCHES)
add_gem_patches(PATCHED_FILES, ::PgPatches::PATCHES)
add_gem_patches(PATCHED_FILES, ::TkPatches::PATCHES)
Expand Down
102 changes: 0 additions & 102 deletions lib/truffle/truffle/patches/nokogiri_patches.rb

This file was deleted.

23 changes: 4 additions & 19 deletions test/truffle/cexts/test_preprocess.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,6 @@ def test_patch(file, directory, input, expected)
abort "expected\n#{expected}\ngot\n#{got}" unless got == expected
end

original = <<-EOF
static int dealloc_node_i(xmlNodePtr key, xmlNodePtr node, xmlDocPtr doc)
{
}
EOF

modified = <<-EOF
static int dealloc_node_i(st_data_t a, st_data_t b, st_data_t c, int errorState)
{
xmlNodePtr key = (xmlNodePtr)a;
xmlNodePtr node = (xmlNodePtr)b;
xmlDocPtr doc = (xmlDocPtr)c;}
EOF

json_original = <<-EOF
# else
rb_str_resize(*result, RSTRING_LEN(*result));
Expand All @@ -39,10 +25,9 @@ def test_patch(file, directory, input, expected)
# endif
EOF

test_patch 'xml_document.c', 'ext/nokogiri', original, modified
# Should not patch other files or other gems
test_patch 'other_file.c', 'ext/nokogiri', original, original
test_patch 'xml_sax_parser.c', 'ext/other_gem', original, original

# Tests an empty replacement
test_patch 'parser.c', 'ext/json/ext/parser', json_original, json_patched

# Should not patch other files or other gems
test_patch 'other_file.c', 'ext/json/ext/parser', json_original, json_original
test_patch 'parser.c', 'ext/other_gem', json_original, json_original

0 comments on commit a9674ee

Please sign in to comment.