Skip to content

Commit

Permalink
VERSION_INFO["libxml"]["source"] now indicates whether libxml2 comes …
Browse files Browse the repository at this point in the history
…from "system" or "packaged" libraries.
  • Loading branch information
flavorjones committed Apr 14, 2013
1 parent b79a4fe commit e811c08
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ext/nokogiri/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@
$LDFLAGS << " -Wl,-rpath,#{libxml2_recipe.path}/lib"
$LDFLAGS << " -Wl,-rpath,#{libxslt_recipe.path}/lib"

$CFLAGS << " -DNOKOGIRI_USE_PACKAGED_LIBRARIES"

HEADER_DIRS = [libxml2_recipe, libxslt_recipe].map { |_| File.join(_.path, "include") }
LIB_DIRS = [libxml2_recipe, libxslt_recipe].map { |_| File.join(_.path, "lib") }
XML2_HEADER_DIRS = HEADER_DIRS + [File.join(libxml2_recipe.path, "include", "libxml2")]
Expand Down
6 changes: 6 additions & 0 deletions ext/nokogiri/nokogiri.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ void Init_nokogiri()
NOKOGIRI_STR_NEW2(xmlParserVersion)
);

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

#ifdef LIBXML_ICONV_ENABLED
rb_const_set(mNokogiri, rb_intern("LIBXML_ICONV_ENABLED"), Qtrue);
#else
Expand Down
9 changes: 9 additions & 0 deletions lib/nokogiri/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ def libxml2?
defined?(LIBXML_VERSION)
end

def libxml2_using_system?
! libxml2_using_packaged?
end

def libxml2_using_packaged?
NOKOGIRI_USE_PACKAGED_LIBRARIES
end

def warnings
return [] unless libxml2?

Expand All @@ -49,6 +57,7 @@ def to_hash
if libxml2?
hash_info['libxml'] = {}
hash_info['libxml']['binding'] = 'extension'
hash_info['libxml']['source'] = libxml2_using_packaged? ? "packaged" : "system"
hash_info['libxml']['compiled'] = compiled_parser_version
hash_info['libxml']['loaded'] = loaded_parser_version
hash_info['warnings'] = warnings
Expand Down

0 comments on commit e811c08

Please sign in to comment.