Skip to content

Commit f9068e6

Browse files
authored
Merge pull request puppetlabs#832 from cthorn42/maint/main/nokogiri_gem_install_patch
(maint) Use packaged libxml to build nokogiri on MacOS
2 parents 76548a0 + 5f202ab commit f9068e6

File tree

2 files changed

+25
-10
lines changed

2 files changed

+25
-10
lines changed

configs/components/_base-rubygem.rb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@
3737
pkg.url("https://rubygems.org/downloads/#{name}-#{version}.gem")
3838
pkg.mirror("#{settings[:buildsources_url]}/#{name}-#{version}.gem")
3939

40-
pkg.install do
41-
"#{settings[:gem_install]} #{name}-#{version}.gem"
40+
# If a gem needs more command line options to install set the :gem_install_options
41+
# in its component file rubygem-<compoment>, before the instance_eval of this file.
42+
if settings[:gem_install_options].nil?
43+
pkg.install do
44+
"#{settings[:gem_install]} #{name}-#{version}.gem"
45+
end
46+
else
47+
pkg.install do
48+
"#{settings[:gem_install]} #{name}-#{version}.gem #{settings[:gem_install_options]}"
49+
end
4250
end
51+
Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
11
component 'rubygem-nokogiri' do |pkg, _settings, _platform|
22
pkg.version '1.14.2'
33
pkg.sha256sum 'c765a74aac6cf430a710bb0b6038b8ee11f177393cd6ae8dadc7a44a6e2658b6'
4+
# On macOS when we are not cross compiling we need to use runtime's libxml2 and libxslt
5+
if platform.is_macos? && !platform.is_cross_compiled?
6+
settings[:gem_install_options] = "-- --use-system-libraries \
7+
--with-xml2-lib=#{settings[:libdir]} \
8+
--with-xml2-include=#{settings[:includedir]}/libxml2 \
9+
--with-xslt-lib=#{settings[:libdir]} \
10+
--with-xslt-include=#{settings[:includedir]}"
11+
end
412
instance_eval File.read('configs/components/_base-rubygem.rb')
5-
613
pkg.build_requires 'rubygem-mini_portile2'
7-
814
gem_home = settings[:gem_home]
915
pkg.environment "GEM_HOME", gem_home
10-
11-
# When cross compiling nokogiri native extensions on macOS 11/12 ARM, there is a 94M tmp
12-
# directory that's not needed
13-
if platform.is_macos? && platform.architecture == 'arm64'
14-
install do
15-
"rm -r #{gem_home}/gems/nokogiri-#{pkg.get_version}/ext/nokogiri/tmp"
16+
if platform.is_macos?
17+
pkg.environment "PKG_CONFIG_PATH", "#{settings[:libdir]}/pkgconfig"
18+
if platform.is_cross_compiled?
19+
pkg.install do
20+
"rm -r #{gem_home}/gems/nokogiri-#{pkg.get_version}/ext/nokogiri/tmp"
21+
end
1622
end
1723
end
1824
end

0 commit comments

Comments
 (0)