Skip to content

Commit

Permalink
fix: use Nokogiri's LDFLAGS to link against precompiled libs
Browse files Browse the repository at this point in the history
This is necessary on Windows where unresolved symbols aren't
allowed. We also limit compatibility with Nokogiri's precompiled libraries
to Nokogiri >= 1.11.2 on Windows for this reason.

Related to:
- #2145
- #2167
- #2202
  • Loading branch information
flavorjones committed Mar 8, 2021
1 parent 4723508 commit e0db2f7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions nokogumbo-import/ext/nokogumbo/extconf.rb
Expand Up @@ -61,15 +61,21 @@ def download_headers
have_libxml2 = false
have_ng = false

def windows?
::RUBY_PLATFORM =~ /mingw|mswin/
end

def modern_nokogiri?
nokogiri_version = Gem::Version.new(Nokogiri::VERSION)
Gem::Requirement.new(">= 1.11.0.rc4").satisfied_by?(nokogiri_version)
requirement = windows? ? ">= 1.11.2" : ">= 1.11.0.rc4"
Gem::Requirement.new(requirement).satisfied_by?(nokogiri_version)
end

if !prohibited
if modern_nokogiri?
append_cflags(Nokogiri::VERSION_INFO["nokogiri"]["cppflags"])
have_libxml2 = have_header('libxml/tree.h')
append_ldflags(Nokogiri::VERSION_INFO["nokogiri"]["ldflags"]) # may be nil for nokogiri pre-1.11.2
have_libxml2 = have_func("xmlNewDoc", "libxml/tree.h")
end

if !have_libxml2
Expand Down

0 comments on commit e0db2f7

Please sign in to comment.