Skip to content

Commit

Permalink
feat: expose LIBXML_THREAD_ENABLED in version info
Browse files Browse the repository at this point in the history
Because libxml2 2.11 changed how it does thread support detection and
we're about to monkey with it in a patch.

For context, see:

- https://gitlab.gnome.org/GNOME/libxml2/-/issues/427
- oracle/truffleruby#3031
  • Loading branch information
flavorjones committed May 2, 2023
1 parent 47401f4 commit 068c406
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ext/nokogiri/nokogiri.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,12 @@ Init_nokogiri(void)
rb_const_set(mNokogiri, rb_intern("LIBXSLT_COMPILED_VERSION"), NOKOGIRI_STR_NEW2(LIBXSLT_DOTTED_VERSION));
rb_const_set(mNokogiri, rb_intern("LIBXSLT_LOADED_VERSION"), NOKOGIRI_STR_NEW2(xsltEngineVersion));

#ifdef LIBXML_THREAD_ENABLED
rb_const_set(mNokogiri, rb_intern("LIBXML_THREAD_ENABLED"), Qtrue);
#else
rb_const_set(mNokogiri, rb_intern("LIBXML_THREAD_ENABLED"), Qfalse);
#endif

#ifdef NOKOGIRI_PACKAGED_LIBRARIES
rb_const_set(mNokogiri, rb_intern("PACKAGED_LIBRARIES"), Qtrue);
# ifdef NOKOGIRI_PRECOMPILED_LIBRARIES
Expand Down
1 change: 1 addition & 0 deletions lib/nokogiri/version/info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ def to_hash
libxml["source"] = "system"
end
libxml["memory_management"] = Nokogiri::LIBXML_MEMORY_MANAGEMENT
libxml["thread_enabled"] = Nokogiri::LIBXML_THREAD_ENABLED
libxml["iconv_enabled"] = libxml2_has_iconv?
libxml["compiled"] = compiled_libxml_version.to_s
libxml["loaded"] = loaded_libxml_version.to_s
Expand Down
3 changes: 3 additions & 0 deletions test/test_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ def test_version_info_for_libxml
assert_equal(Nokogiri::LIBXML_COMPILED_VERSION, version_info["libxml"]["compiled"])
assert_match(VERSION_MATCH, version_info["libxml"]["compiled"])

# i _think_ we always expect this to be true, regardless of system or packaged
assert(version_info["libxml"]["thread_enabled"])

assert_match(VERSION_MATCH, version_info["libxml"]["loaded"])
Nokogiri::LIBXML_LOADED_VERSION =~ /(\d)(\d{2})(\d{2})/
major = Regexp.last_match(1).to_i
Expand Down

0 comments on commit 068c406

Please sign in to comment.