Skip to content

Commit

Permalink
(maint) Use packaged libxml to build nokogiri on MacOS
Browse files Browse the repository at this point in the history
This PR changes the gem install command for the Nokogiri gem.
Currently when building nokogiri it uses the system libxml2 and libxslt.
We now will pass in an option in the `gem install` command to use the expected
libraries.
  • Loading branch information
cthorn42 committed Apr 19, 2024
1 parent 71e0463 commit 100e1b5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
8 changes: 5 additions & 3 deletions configs/components/_base-rubygem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
pkg.url("https://rubygems.org/downloads/#{name}-#{version}.gem")
pkg.mirror("#{settings[:buildsources_url]}/#{name}-#{version}.gem")

pkg.install do
"#{settings[:gem_install]} #{name}-#{version}.gem"
end
unless name =~ /nokogiri/
pkg.install do
"#{settings[:gem_install]} #{name}-#{version}.gem"
end
end
15 changes: 9 additions & 6 deletions configs/components/rubygem-nokogiri.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@

gem_home = settings[:gem_home]
pkg.environment "GEM_HOME", gem_home

# When cross compiling nokogiri native extensions on macOS 11/12 ARM, there is a 94M tmp
# directory that's not needed
if platform.is_macos? && platform.architecture == 'arm64'
install do
"rm -r #{gem_home}/gems/nokogiri-#{pkg.get_version}/ext/nokogiri/tmp"
if platform.is_macos?
pkg.environment "PKG_CONFIG_PATH", "#{settings[:libdir]}/pkgconfig"
pkg.install do
"#{settings[:gem_install]} nokogiri --platform=ruby -- --use-system-libraries --with-opt-dir=/opt/puppetlabs/puppet"
end
if platform.is_cross_compiled?
pkg.install do
"rm -r #{gem_home}/gems/nokogiri-#{pkg.get_version}/ext/nokogiri/tmp"
end
end
end
end

0 comments on commit 100e1b5

Please sign in to comment.