nokogiri 1.11.3 → 1.13.8

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of nokogiri might be problematic. Click here for more details.

Files changed (179) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -0
  3. data/LICENSE-DEPENDENCIES.md +243 -22
  4. data/LICENSE.md +1 -1
  5. data/README.md +14 -11
  6. data/bin/nokogiri +63 -50
  7. data/dependencies.yml +13 -64
  8. data/ext/nokogiri/depend +35 -34
  9. data/ext/nokogiri/extconf.rb +237 -133
  10. data/ext/nokogiri/gumbo.c +584 -0
  11. data/ext/nokogiri/{html_document.c → html4_document.c} +8 -8
  12. data/ext/nokogiri/{html_element_description.c → html4_element_description.c} +21 -19
  13. data/ext/nokogiri/{html_entity_lookup.c → html4_entity_lookup.c} +7 -7
  14. data/ext/nokogiri/{html_sax_parser_context.c → html4_sax_parser_context.c} +8 -8
  15. data/ext/nokogiri/{html_sax_push_parser.c → html4_sax_push_parser.c} +4 -4
  16. data/ext/nokogiri/libxml2_backwards_compat.c +30 -30
  17. data/ext/nokogiri/nokogiri.c +70 -38
  18. data/ext/nokogiri/nokogiri.h +27 -9
  19. data/ext/nokogiri/xml_attr.c +2 -2
  20. data/ext/nokogiri/xml_attribute_decl.c +3 -3
  21. data/ext/nokogiri/xml_cdata.c +1 -1
  22. data/ext/nokogiri/xml_document.c +50 -50
  23. data/ext/nokogiri/xml_document_fragment.c +0 -2
  24. data/ext/nokogiri/xml_dtd.c +10 -10
  25. data/ext/nokogiri/xml_element_content.c +2 -0
  26. data/ext/nokogiri/xml_element_decl.c +3 -3
  27. data/ext/nokogiri/xml_encoding_handler.c +31 -12
  28. data/ext/nokogiri/xml_entity_decl.c +5 -5
  29. data/ext/nokogiri/xml_namespace.c +4 -2
  30. data/ext/nokogiri/xml_node.c +833 -492
  31. data/ext/nokogiri/xml_node_set.c +24 -24
  32. data/ext/nokogiri/xml_reader.c +90 -11
  33. data/ext/nokogiri/xml_sax_parser.c +6 -6
  34. data/ext/nokogiri/xml_sax_parser_context.c +12 -3
  35. data/ext/nokogiri/xml_schema.c +5 -3
  36. data/ext/nokogiri/xml_text.c +1 -1
  37. data/ext/nokogiri/xml_xpath_context.c +110 -85
  38. data/ext/nokogiri/xslt_stylesheet.c +109 -10
  39. data/gumbo-parser/CHANGES.md +63 -0
  40. data/gumbo-parser/Makefile +101 -0
  41. data/gumbo-parser/THANKS +27 -0
  42. data/gumbo-parser/src/Makefile +34 -0
  43. data/gumbo-parser/src/README.md +41 -0
  44. data/gumbo-parser/src/ascii.c +75 -0
  45. data/gumbo-parser/src/ascii.h +115 -0
  46. data/gumbo-parser/src/attribute.c +42 -0
  47. data/gumbo-parser/src/attribute.h +17 -0
  48. data/gumbo-parser/src/char_ref.c +22225 -0
  49. data/gumbo-parser/src/char_ref.h +29 -0
  50. data/gumbo-parser/src/char_ref.rl +2154 -0
  51. data/gumbo-parser/src/error.c +626 -0
  52. data/gumbo-parser/src/error.h +148 -0
  53. data/gumbo-parser/src/foreign_attrs.c +104 -0
  54. data/gumbo-parser/src/foreign_attrs.gperf +27 -0
  55. data/gumbo-parser/src/gumbo.h +943 -0
  56. data/gumbo-parser/src/insertion_mode.h +33 -0
  57. data/gumbo-parser/src/macros.h +91 -0
  58. data/gumbo-parser/src/parser.c +4875 -0
  59. data/gumbo-parser/src/parser.h +41 -0
  60. data/gumbo-parser/src/replacement.h +33 -0
  61. data/gumbo-parser/src/string_buffer.c +103 -0
  62. data/gumbo-parser/src/string_buffer.h +68 -0
  63. data/gumbo-parser/src/string_piece.c +48 -0
  64. data/gumbo-parser/src/svg_attrs.c +174 -0
  65. data/gumbo-parser/src/svg_attrs.gperf +77 -0
  66. data/gumbo-parser/src/svg_tags.c +137 -0
  67. data/gumbo-parser/src/svg_tags.gperf +55 -0
  68. data/gumbo-parser/src/tag.c +222 -0
  69. data/gumbo-parser/src/tag_lookup.c +382 -0
  70. data/gumbo-parser/src/tag_lookup.gperf +169 -0
  71. data/gumbo-parser/src/tag_lookup.h +13 -0
  72. data/gumbo-parser/src/token_buffer.c +79 -0
  73. data/gumbo-parser/src/token_buffer.h +71 -0
  74. data/gumbo-parser/src/token_type.h +17 -0
  75. data/gumbo-parser/src/tokenizer.c +3463 -0
  76. data/gumbo-parser/src/tokenizer.h +112 -0
  77. data/gumbo-parser/src/tokenizer_states.h +339 -0
  78. data/gumbo-parser/src/utf8.c +245 -0
  79. data/gumbo-parser/src/utf8.h +164 -0
  80. data/gumbo-parser/src/util.c +68 -0
  81. data/gumbo-parser/src/util.h +30 -0
  82. data/gumbo-parser/src/vector.c +111 -0
  83. data/gumbo-parser/src/vector.h +45 -0
  84. data/lib/nokogiri/class_resolver.rb +67 -0
  85. data/lib/nokogiri/css/node.rb +9 -8
  86. data/lib/nokogiri/css/parser.rb +361 -342
  87. data/lib/nokogiri/css/parser.y +250 -245
  88. data/lib/nokogiri/css/parser_extras.rb +22 -20
  89. data/lib/nokogiri/css/syntax_error.rb +2 -1
  90. data/lib/nokogiri/css/tokenizer.rb +4 -3
  91. data/lib/nokogiri/css/tokenizer.rex +3 -2
  92. data/lib/nokogiri/css/xpath_visitor.rb +179 -82
  93. data/lib/nokogiri/css.rb +49 -17
  94. data/lib/nokogiri/decorators/slop.rb +8 -7
  95. data/lib/nokogiri/extension.rb +8 -3
  96. data/lib/nokogiri/gumbo.rb +15 -0
  97. data/lib/nokogiri/html.rb +37 -27
  98. data/lib/nokogiri/{html → html4}/builder.rb +3 -2
  99. data/lib/nokogiri/{html → html4}/document.rb +92 -81
  100. data/lib/nokogiri/{html → html4}/document_fragment.rb +13 -9
  101. data/lib/nokogiri/{html → html4}/element_description.rb +2 -1
  102. data/lib/nokogiri/html4/element_description_defaults.rb +578 -0
  103. data/lib/nokogiri/{html → html4}/entity_lookup.rb +3 -2
  104. data/lib/nokogiri/{html → html4}/sax/parser.rb +16 -16
  105. data/lib/nokogiri/html4/sax/parser_context.rb +20 -0
  106. data/lib/nokogiri/{html → html4}/sax/push_parser.rb +11 -11
  107. data/lib/nokogiri/html4.rb +46 -0
  108. data/lib/nokogiri/html5/document.rb +91 -0
  109. data/lib/nokogiri/html5/document_fragment.rb +83 -0
  110. data/lib/nokogiri/html5/node.rb +100 -0
  111. data/lib/nokogiri/html5.rb +478 -0
  112. data/lib/nokogiri/jruby/dependencies.rb +10 -9
  113. data/lib/nokogiri/syntax_error.rb +1 -0
  114. data/lib/nokogiri/version/constant.rb +2 -1
  115. data/lib/nokogiri/version/info.rb +31 -14
  116. data/lib/nokogiri/version.rb +1 -0
  117. data/lib/nokogiri/xml/attr.rb +5 -3
  118. data/lib/nokogiri/xml/attribute_decl.rb +2 -1
  119. data/lib/nokogiri/xml/builder.rb +71 -31
  120. data/lib/nokogiri/xml/cdata.rb +2 -1
  121. data/lib/nokogiri/xml/character_data.rb +1 -0
  122. data/lib/nokogiri/xml/document.rb +183 -96
  123. data/lib/nokogiri/xml/document_fragment.rb +41 -38
  124. data/lib/nokogiri/xml/dtd.rb +3 -2
  125. data/lib/nokogiri/xml/element_content.rb +1 -0
  126. data/lib/nokogiri/xml/element_decl.rb +2 -1
  127. data/lib/nokogiri/xml/entity_decl.rb +3 -2
  128. data/lib/nokogiri/xml/entity_reference.rb +1 -0
  129. data/lib/nokogiri/xml/namespace.rb +2 -0
  130. data/lib/nokogiri/xml/node/save_options.rb +9 -5
  131. data/lib/nokogiri/xml/node.rb +525 -354
  132. data/lib/nokogiri/xml/node_set.rb +50 -54
  133. data/lib/nokogiri/xml/notation.rb +12 -0
  134. data/lib/nokogiri/xml/parse_options.rb +13 -6
  135. data/lib/nokogiri/xml/pp/character_data.rb +8 -6
  136. data/lib/nokogiri/xml/pp/node.rb +24 -26
  137. data/lib/nokogiri/xml/pp.rb +3 -2
  138. data/lib/nokogiri/xml/processing_instruction.rb +2 -1
  139. data/lib/nokogiri/xml/reader.rb +20 -24
  140. data/lib/nokogiri/xml/relax_ng.rb +1 -0
  141. data/lib/nokogiri/xml/sax/document.rb +44 -49
  142. data/lib/nokogiri/xml/sax/parser.rb +37 -34
  143. data/lib/nokogiri/xml/sax/parser_context.rb +7 -3
  144. data/lib/nokogiri/xml/sax/push_parser.rb +5 -5
  145. data/lib/nokogiri/xml/sax.rb +5 -4
  146. data/lib/nokogiri/xml/schema.rb +7 -6
  147. data/lib/nokogiri/xml/searchable.rb +93 -62
  148. data/lib/nokogiri/xml/syntax_error.rb +5 -4
  149. data/lib/nokogiri/xml/text.rb +1 -0
  150. data/lib/nokogiri/xml/xpath/syntax_error.rb +2 -1
  151. data/lib/nokogiri/xml/xpath.rb +13 -1
  152. data/lib/nokogiri/xml/xpath_context.rb +2 -3
  153. data/lib/nokogiri/xml.rb +37 -37
  154. data/lib/nokogiri/xslt/stylesheet.rb +2 -1
  155. data/lib/nokogiri/xslt.rb +28 -20
  156. data/lib/nokogiri.rb +48 -43
  157. data/lib/xsd/xmlparser/nokogiri.rb +25 -24
  158. data/patches/libxml2/{0002-Remove-script-macro-support.patch → 0001-Remove-script-macro-support.patch} +0 -0
  159. data/patches/libxml2/{0003-Update-entities-to-remove-handling-of-ssi.patch → 0002-Update-entities-to-remove-handling-of-ssi.patch} +0 -0
  160. data/patches/libxml2/{0004-libxml2.la-is-in-top_builddir.patch → 0003-libxml2.la-is-in-top_builddir.patch} +1 -1
  161. data/patches/libxml2/{0008-use-glibc-strlen.patch → 0004-use-glibc-strlen.patch} +3 -3
  162. data/patches/libxml2/{0009-avoid-isnan-isinf.patch → 0005-avoid-isnan-isinf.patch} +4 -4
  163. data/patches/libxml2/0006-update-automake-files-for-arm64.patch +3040 -0
  164. data/patches/libxml2/0008-htmlParseComment-handle-abruptly-closed-comments.patch +61 -0
  165. data/patches/libxml2/0009-allow-wildcard-namespaces.patch +77 -0
  166. data/patches/libxslt/0001-update-automake-files-for-arm64.patch +2445 -1919
  167. data/ports/archives/libxml2-2.9.14.tar.xz +0 -0
  168. data/ports/archives/libxslt-1.1.35.tar.xz +0 -0
  169. metadata +204 -93
  170. data/lib/nokogiri/html/element_description_defaults.rb +0 -672
  171. data/lib/nokogiri/html/sax/parser_context.rb +0 -17
  172. data/patches/libxml2/0001-Revert-Do-not-URI-escape-in-server-side-includes.patch +0 -78
  173. data/patches/libxml2/0005-Fix-infinite-loop-in-xmlStringLenDecodeEntities.patch +0 -32
  174. data/patches/libxml2/0006-htmlParseComment-treat-as-if-it-closed-the-comment.patch +0 -73
  175. data/patches/libxml2/0007-use-new-htmlParseLookupCommentEnd-to-find-comment-en.patch +0 -103
  176. data/patches/libxml2/0010-parser.c-shrink-the-input-buffer-when-appropriate.patch +0 -70
  177. data/patches/libxml2/0011-update-automake-files-for-arm64.patch +0 -2511
  178. data/ports/archives/libxml2-2.9.10.tar.gz +0 -0
  179. data/ports/archives/libxslt-1.1.34.tar.gz +0 -0
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
- ENV['RC_ARCHS'] = '' if RUBY_PLATFORM =~ /darwin/
2
+
3
+ # rubocop:disable Style/GlobalVars
4
+
5
+ ENV["RC_ARCHS"] = "" if RUBY_PLATFORM.include?("darwin")
3
6
 
4
7
  require "mkmf"
5
8
  require "rbconfig"
@@ -8,20 +11,18 @@ require "shellwords"
8
11
  require "pathname"
9
12
 
10
13
  # helpful constants
11
- PACKAGE_ROOT_DIR = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
14
+ PACKAGE_ROOT_DIR = File.expand_path(File.join(File.dirname(__FILE__), "..", ".."))
12
15
  REQUIRED_LIBXML_VERSION = "2.6.21"
13
16
  RECOMMENDED_LIBXML_VERSION = "2.9.3"
14
17
 
15
- # The gem version constraint in the Rakefile is not respected at install time.
16
- # Keep this version in sync with the one in the Rakefile !
17
- REQUIRED_MINI_PORTILE_VERSION = "~> 2.5.0"
18
+ REQUIRED_MINI_PORTILE_VERSION = "~> 2.8.0" # keep this version in sync with the one in the gemspec
18
19
  REQUIRED_PKG_CONFIG_VERSION = "~> 1.1"
19
20
 
20
21
  # Keep track of what versions of what libraries we build against
21
22
  OTHER_LIBRARY_VERSIONS = {}
22
23
 
23
24
  NOKOGIRI_HELP_MESSAGE = <<~HELP
24
- USAGE: ruby #{$0} [options]
25
+ USAGE: ruby #{$PROGRAM_NAME} [options]
25
26
 
26
27
  Flags that are always valid:
27
28
 
@@ -91,6 +92,9 @@ NOKOGIRI_HELP_MESSAGE = <<~HELP
91
92
  --with-xml2-include=DIRECTORY
92
93
  Look for xml2 headers in DIRECTORY.
93
94
 
95
+ --with-xml2-source-dir=DIRECTORY
96
+ (dev only) Build libxml2 from the source code in DIRECTORY
97
+
94
98
 
95
99
  Related to libxslt:
96
100
 
@@ -103,6 +107,9 @@ NOKOGIRI_HELP_MESSAGE = <<~HELP
103
107
  --with-xslt-include=DIRECTORY
104
108
  Look for xslt headers in DIRECTORY.
105
109
 
110
+ --with-xslt-source-dir=DIRECTORY
111
+ (dev only) Build libxslt from the source code in DIRECTORY
112
+
106
113
 
107
114
  Related to libexslt:
108
115
 
@@ -150,7 +157,7 @@ HELP
150
157
  # utility functions
151
158
  #
152
159
  def config_clean?
153
- enable_config('clean', true)
160
+ enable_config("clean", true)
154
161
  end
155
162
 
156
163
  def config_static?
@@ -164,28 +171,28 @@ end
164
171
 
165
172
  def config_system_libraries?
166
173
  enable_config("system-libraries", ENV.key?("NOKOGIRI_USE_SYSTEM_LIBRARIES")) do |_, default|
167
- arg_config('--use-system-libraries', default)
174
+ arg_config("--use-system-libraries", default)
168
175
  end
169
176
  end
170
177
 
171
178
  def windows?
172
- RbConfig::CONFIG['target_os'] =~ /mingw32|mswin/
179
+ RbConfig::CONFIG["target_os"].match?(/mingw|mswin/)
173
180
  end
174
181
 
175
182
  def solaris?
176
- RbConfig::CONFIG['target_os'] =~ /solaris/
183
+ RbConfig::CONFIG["target_os"].include?("solaris")
177
184
  end
178
185
 
179
186
  def darwin?
180
- RbConfig::CONFIG['target_os'] =~ /darwin/
187
+ RbConfig::CONFIG["target_os"].include?("darwin")
181
188
  end
182
189
 
183
190
  def openbsd?
184
- RbConfig::CONFIG['target_os'] =~ /openbsd/
191
+ RbConfig::CONFIG["target_os"].include?("openbsd")
185
192
  end
186
193
 
187
194
  def aix?
188
- RbConfig::CONFIG["target_os"] =~ /aix/
195
+ RbConfig::CONFIG["target_os"].include?("aix")
189
196
  end
190
197
 
191
198
  def nix?
@@ -193,7 +200,7 @@ def nix?
193
200
  end
194
201
 
195
202
  def truffle?
196
- ::RUBY_ENGINE == 'truffleruby'
203
+ ::RUBY_ENGINE == "truffleruby"
197
204
  end
198
205
 
199
206
  def concat_flags(*args)
@@ -204,6 +211,18 @@ def local_have_library(lib, func = nil, headers = nil)
204
211
  have_library(lib, func, headers) || have_library("lib#{lib}", func, headers)
205
212
  end
206
213
 
214
+ def gnome_source
215
+ # As of 2022-02-20, some mirrors have expired SSL certificates. I'm able to retrieve from my home,
216
+ # but whatever host is resolved on the github actions workers see an expired cert.
217
+ #
218
+ # See https://github.com/sparklemotion/nokogiri/runs/5266206403?check_suite_focus=true
219
+ if ENV["NOKOGIRI_USE_CANONICAL_GNOME_SOURCE"]
220
+ "https://download.gnome.org"
221
+ else
222
+ "https://mirror.csclub.uwaterloo.ca/gnome" # old reliable
223
+ end
224
+ end
225
+
207
226
  LOCAL_PACKAGE_RESPONSE = Object.new
208
227
  def LOCAL_PACKAGE_RESPONSE.%(package)
209
228
  package ? "yes: #{package}" : "no"
@@ -222,9 +241,9 @@ def try_package_configuration(pc)
222
241
  # let's fall back to the pkg-config gem, which knows how to parse .pc files, and wrap it with the
223
242
  # same logic as MakeMakefile#pkg_config
224
243
  begin
225
- require 'rubygems'
226
- gem('pkg-config', REQUIRED_PKG_CONFIG_VERSION)
227
- require 'pkg-config'
244
+ require "rubygems"
245
+ gem("pkg-config", REQUIRED_PKG_CONFIG_VERSION)
246
+ require "pkg-config"
228
247
 
229
248
  checking_for("#{pc} using pkg-config gem version #{PKGConfig::VERSION}", LOCAL_PACKAGE_RESPONSE) do
230
249
  if PKGConfig.have_package(pc)
@@ -278,17 +297,16 @@ ensure
278
297
  end
279
298
 
280
299
  def abort_could_not_find_library(lib)
281
- abort("-----\n#{caller[0]}\n#{lib} is missing. Please locate mkmf.log to investigate how it is failing.\n-----")
300
+ callers = caller(1..2).join("\n")
301
+ abort("-----\n#{callers}\n#{lib} is missing. Please locate mkmf.log to investigate how it is failing.\n-----")
282
302
  end
283
303
 
284
- def chdir_for_build
304
+ def chdir_for_build(&block)
285
305
  # When using rake-compiler-dock on Windows, the underlying Virtualbox shared
286
306
  # folders don't support symlinks, but libiconv expects it for a build on
287
307
  # Linux. We work around this limitation by using the temp dir for cooking.
288
- build_dir = ENV['RCD_HOST_RUBY_PLATFORM'].to_s =~ /mingw|mswin|cygwin/ ? '/tmp' : '.'
289
- Dir.chdir(build_dir) do
290
- yield
291
- end
308
+ build_dir = /mingw|mswin|cygwin/.match?(ENV["RCD_HOST_RUBY_PLATFORM"].to_s) ? "/tmp" : "."
309
+ Dir.chdir(build_dir, &block)
292
310
  end
293
311
 
294
312
  def sh_export_path(path)
@@ -339,8 +357,8 @@ def have_libxml_headers?(version = nil)
339
357
  end
340
358
 
341
359
  def try_link_iconv(using = nil)
342
- checking_for(using ? "iconv using #{using}" : 'iconv') do
343
- ['', '-liconv'].any? do |opt|
360
+ checking_for(using ? "iconv using #{using}" : "iconv") do
361
+ ["", "-liconv"].any? do |opt|
344
362
  preserving_globals do
345
363
  yield if block_given?
346
364
 
@@ -364,6 +382,7 @@ def iconv_configure_flags
364
382
  ["iconv", "opt"].each do |target|
365
383
  config = preserving_globals { dir_config(target) }
366
384
  next unless config.any? && try_link_iconv("--with-#{target}-* flags") { dir_config(target) }
385
+
367
386
  idirs, ldirs = config.map do |dirs|
368
387
  Array(dirs).flat_map do |dir|
369
388
  dir.split(File::PATH_SEPARATOR)
@@ -371,22 +390,22 @@ def iconv_configure_flags
371
390
  end
372
391
 
373
392
  return [
374
- '--with-iconv=yes',
375
- *("CPPFLAGS=#{idirs.map { |dir| '-I' + dir }.join(' ')}" if idirs),
376
- *("LDFLAGS=#{ldirs.map { |dir| '-L' + dir }.join(' ')}" if ldirs),
393
+ "--with-iconv=yes",
394
+ *("CPPFLAGS=#{idirs.map { |dir| "-I" + dir }.join(" ")}" if idirs),
395
+ *("LDFLAGS=#{ldirs.map { |dir| "-L" + dir }.join(" ")}" if ldirs),
377
396
  ]
378
397
  end
379
398
 
380
399
  if try_link_iconv
381
- return ['--with-iconv=yes']
400
+ return ["--with-iconv=yes"]
382
401
  end
383
402
 
384
- config = preserving_globals { have_package_configuration('libiconv') }
385
- if config && try_link_iconv('pkg-config libiconv') { have_package_configuration('libiconv') }
403
+ config = preserving_globals { have_package_configuration("libiconv") }
404
+ if config && try_link_iconv("pkg-config libiconv") { have_package_configuration("libiconv") }
386
405
  cflags, ldflags, libs = config
387
406
 
388
407
  return [
389
- '--with-iconv=yes',
408
+ "--with-iconv=yes",
390
409
  "CPPFLAGS=#{cflags}",
391
410
  "LDFLAGS=#{ldflags}",
392
411
  "LIBS=#{libs}",
@@ -396,23 +415,26 @@ def iconv_configure_flags
396
415
  abort_could_not_find_library("libiconv")
397
416
  end
398
417
 
399
- def process_recipe(name, version, static_p, cross_p)
400
- require 'rubygems'
401
- gem('mini_portile2', REQUIRED_MINI_PORTILE_VERSION)
402
- require 'mini_portile2'
418
+ def process_recipe(name, version, static_p, cross_p, cacheable_p = true)
419
+ require "rubygems"
420
+ gem("mini_portile2", REQUIRED_MINI_PORTILE_VERSION) # gemspec is not respected at install time
421
+ require "mini_portile2"
403
422
  message("Using mini_portile version #{MiniPortile::VERSION}\n")
404
423
 
405
- if name != "libxml2" && name != "libxslt"
424
+ unless ["libxml2", "libxslt"].include?(name)
406
425
  OTHER_LIBRARY_VERSIONS[name] = version
407
426
  end
408
427
 
409
428
  MiniPortile.new(name, version).tap do |recipe|
410
- recipe.target = File.join(PACKAGE_ROOT_DIR, "ports")
411
- # Prefer host_alias over host in order to use i586-mingw32msvc as
412
- # correct compiler prefix for cross build, but use host if not set.
429
+ def recipe.port_path
430
+ "#{@target}/#{RUBY_PLATFORM}/#{@name}/#{@version}"
431
+ end
432
+
433
+ recipe.target = File.join(PACKAGE_ROOT_DIR, "ports") if cacheable_p
434
+ # Prefer host_alias over host in order to use the correct compiler prefix for cross build, but
435
+ # use host if not set.
413
436
  recipe.host = RbConfig::CONFIG["host_alias"].empty? ? RbConfig::CONFIG["host"] : RbConfig::CONFIG["host_alias"]
414
- recipe.patch_files = Dir[File.join(PACKAGE_ROOT_DIR, "patches", name, "*.patch")].sort
415
- recipe.configure_options << "--libdir=#{File.join(recipe.path, 'lib')}"
437
+ recipe.configure_options << "--libdir=#{File.join(recipe.path, "lib")}"
416
438
 
417
439
  yield recipe
418
440
 
@@ -456,10 +478,10 @@ def process_recipe(name, version, static_p, cross_p)
456
478
  ]
457
479
  end
458
480
 
459
- if RbConfig::CONFIG['target_cpu'] == 'universal'
460
- %w[CFLAGS LDFLAGS].each do |key|
461
- unless env[key].include?('-arch')
462
- env[key] = concat_flags(env[key], RbConfig::CONFIG['ARCH_FLAG'])
481
+ if RbConfig::CONFIG["target_cpu"] == "universal"
482
+ ["CFLAGS", "LDFLAGS"].each do |key|
483
+ unless env[key].include?("-arch")
484
+ env[key] = concat_flags(env[key], RbConfig::CONFIG["ARCH_FLAG"])
463
485
  end
464
486
  end
465
487
  end
@@ -468,8 +490,8 @@ def process_recipe(name, version, static_p, cross_p)
468
490
  "#{key}=#{value.strip}"
469
491
  end
470
492
 
471
- checkpoint = "#{recipe.target}/#{recipe.name}-#{recipe.version}-#{recipe.host}.installed"
472
- if File.exist?(checkpoint)
493
+ checkpoint = "#{recipe.target}/#{recipe.name}-#{recipe.version}-#{RUBY_PLATFORM}.installed"
494
+ if File.exist?(checkpoint) && !recipe.source_directory
473
495
  message("Building Nokogiri with a packaged version of #{name}-#{version}.\n")
474
496
  else
475
497
  message(<<~EOM)
@@ -482,11 +504,11 @@ def process_recipe(name, version, static_p, cross_p)
482
504
  message("The following patches are being applied:\n")
483
505
 
484
506
  recipe.patch_files.each do |patch|
485
- message(" - %s\n" % File.basename(patch))
507
+ message(format(" - %s\n", File.basename(patch)))
486
508
  end
487
509
  end
488
510
 
489
- message(<<~EOM)
511
+ message(<<~EOM) if name != "libgumbo"
490
512
 
491
513
  The Nokogiri maintainers intend to provide timely security updates, but if
492
514
  this is a concern for you and want to use your OS/distro system library
@@ -497,15 +519,14 @@ def process_recipe(name, version, static_p, cross_p)
497
519
 
498
520
  EOM
499
521
 
500
- message(<<~EOM) if name == 'libxml2'
501
- Note, however, that nokogiri cannot guarantee compatiblity with every
522
+ message(<<~EOM) if name == "libxml2"
523
+ Note, however, that nokogiri cannot guarantee compatibility with every
502
524
  version of libxml2 that may be provided by OS/package vendors.
503
525
 
504
526
  EOM
505
527
 
506
- chdir_for_build do
507
- recipe.cook
508
- end
528
+ pp(recipe.files)
529
+ chdir_for_build { recipe.cook }
509
530
  FileUtils.touch(checkpoint)
510
531
  end
511
532
  recipe.activate
@@ -516,7 +537,7 @@ def copy_packaged_libraries_headers(to_path:, from_recipes:)
516
537
  FileUtils.rm_rf(to_path, secure: true)
517
538
  FileUtils.mkdir(to_path)
518
539
  from_recipes.each do |recipe|
519
- FileUtils.cp_r(Dir[File.join(recipe.path, 'include/*')], to_path)
540
+ FileUtils.cp_r(Dir[File.join(recipe.path, "include/*")], to_path)
520
541
  end
521
542
  end
522
543
 
@@ -530,22 +551,22 @@ def do_clean
530
551
  pwd = Pathname(Dir.pwd)
531
552
 
532
553
  # Skip if this is a development work tree
533
- unless (root + '.git').exist?
554
+ unless (root + ".git").exist?
534
555
  message("Cleaning files only used during build.\n")
535
556
 
536
557
  # (root + 'tmp') cannot be removed at this stage because
537
558
  # nokogiri.so is yet to be copied to lib.
538
559
 
539
560
  # clean the ports build directory
540
- Pathname.glob(pwd.join('tmp', '*', 'ports')) do |dir|
561
+ Pathname.glob(pwd.join("tmp", "*", "ports")) do |dir|
541
562
  FileUtils.rm_rf(dir, verbose: true)
542
563
  end
543
564
 
544
565
  if config_static?
545
566
  # ports installation can be safely removed if statically linked.
546
- FileUtils.rm_rf(root + 'ports', verbose: true)
567
+ FileUtils.rm_rf(root + "ports", verbose: true)
547
568
  else
548
- FileUtils.rm_rf(root + 'ports' + 'archives', verbose: true)
569
+ FileUtils.rm_rf(root + "ports" + "archives", verbose: true)
549
570
  end
550
571
  end
551
572
 
@@ -555,25 +576,25 @@ end
555
576
  #
556
577
  # main
557
578
  #
558
- do_help if arg_config('--help')
559
- do_clean if arg_config('--clean')
579
+ do_help if arg_config("--help")
580
+ do_clean if arg_config("--clean")
560
581
 
561
582
  if openbsd? && !config_system_libraries?
562
- if %x(#{ENV['CC'] || '/usr/bin/cc'} -v 2>&1) !~ /clang/
563
- (ENV['CC'] ||= find_executable('egcc')) ||
583
+ if %x(#{ENV["CC"] || "/usr/bin/cc"} -v 2>&1) !~ /clang/
584
+ (ENV["CC"] ||= find_executable("egcc")) ||
564
585
  abort("Please install gcc 4.9+ from ports using `pkg_add -v gcc`")
565
586
  end
566
587
  append_cppflags "-I/usr/local/include"
567
588
  end
568
589
 
569
- if ENV['CC']
570
- RbConfig::CONFIG['CC'] = RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC']
590
+ if ENV["CC"]
591
+ RbConfig::CONFIG["CC"] = RbConfig::MAKEFILE_CONFIG["CC"] = ENV["CC"]
571
592
  end
572
593
 
573
594
  # use same c compiler for libxml and libxslt
574
- ENV['CC'] = RbConfig::CONFIG['CC']
595
+ ENV["CC"] = RbConfig::CONFIG["CC"]
575
596
 
576
- if arg_config('--prevent-strip')
597
+ if arg_config("--prevent-strip")
577
598
  old_cflags = $CFLAGS.split.join(" ")
578
599
  old_ldflags = $LDFLAGS.split.join(" ")
579
600
  old_dldflags = $DLDFLAGS.split.join(" ")
@@ -591,6 +612,10 @@ append_cppflags(ENV["CPPFLAGS"].split) unless ENV["CPPFLAGS"].nil?
591
612
  append_ldflags(ENV["LDFLAGS"].split) unless ENV["LDFLAGS"].nil?
592
613
  $LIBS = concat_flags($LIBS, ENV["LIBS"])
593
614
 
615
+ # nokogumbo code uses C90/C99 features, let's make sure older compilers won't give
616
+ # errors/warnings. see #2302
617
+ append_cflags(["-std=c99", "-Wno-declaration-after-statement"])
618
+
594
619
  # always include debugging information
595
620
  append_cflags("-g")
596
621
 
@@ -619,13 +644,13 @@ append_cppflags(' "-Idummypath"') if windows?
619
644
  if config_system_libraries?
620
645
  message "Building nokogiri using system libraries.\n"
621
646
  ensure_package_configuration(opt: "zlib", pc: "zlib", lib: "z",
622
- headers: "zlib.h", func: "gzdopen")
647
+ headers: "zlib.h", func: "gzdopen")
623
648
  ensure_package_configuration(opt: "xml2", pc: "libxml-2.0", lib: "xml2",
624
- headers: "libxml/parser.h", func: "xmlParseDoc")
649
+ headers: "libxml/parser.h", func: "xmlParseDoc")
625
650
  ensure_package_configuration(opt: "xslt", pc: "libxslt", lib: "xslt",
626
- headers: "libxslt/xslt.h", func: "xsltParseStylesheetDoc")
651
+ headers: "libxslt/xslt.h", func: "xsltParseStylesheetDoc")
627
652
  ensure_package_configuration(opt: "exslt", pc: "libexslt", lib: "exslt",
628
- headers: "libexslt/exslt.h", func: "exsltFuncRegister")
653
+ headers: "libexslt/exslt.h", func: "exsltFuncRegister")
629
654
 
630
655
  have_libxml_headers?(REQUIRED_LIBXML_VERSION) ||
631
656
  abort("ERROR: libxml2 version #{REQUIRED_LIBXML_VERSION} or later is required!")
@@ -636,20 +661,20 @@ else
636
661
  message "Building nokogiri using packaged libraries.\n"
637
662
 
638
663
  static_p = config_static?
639
- message "Static linking is #{static_p ? 'enabled' : 'disabled'}.\n"
664
+ message "Static linking is #{static_p ? "enabled" : "disabled"}.\n"
640
665
 
641
666
  cross_build_p = config_cross_build?
642
- message "Cross build is #{cross_build_p ? 'enabled' : 'disabled'}.\n"
667
+ message "Cross build is #{cross_build_p ? "enabled" : "disabled"}.\n"
643
668
 
644
- require 'yaml'
669
+ require "yaml"
645
670
  dependencies = YAML.load_file(File.join(PACKAGE_ROOT_DIR, "dependencies.yml"))
646
671
 
647
- dir_config('zlib')
672
+ dir_config("zlib")
648
673
 
649
674
  if cross_build_p || windows?
650
675
  zlib_recipe = process_recipe("zlib", dependencies["zlib"]["version"], static_p, cross_build_p) do |recipe|
651
676
  recipe.files = [{
652
- url: "http://zlib.net/fossils/#{recipe.name}-#{recipe.version}.tar.gz",
677
+ url: "https://zlib.net/fossils/#{recipe.name}-#{recipe.version}.tar.gz",
653
678
  sha256: dependencies["zlib"]["sha256"],
654
679
  }]
655
680
  if windows?
@@ -658,8 +683,8 @@ else
658
683
 
659
684
  def configure
660
685
  Dir.chdir(work_path) do
661
- mk = File.read('win32/Makefile.gcc')
662
- File.open('win32/Makefile.gcc', 'wb') do |f|
686
+ mk = File.read("win32/Makefile.gcc")
687
+ File.open("win32/Makefile.gcc", "wb") do |f|
663
688
  f.puts "BINARY_PATH = #{path}/bin"
664
689
  f.puts "LIBRARY_PATH = #{path}/lib"
665
690
  f.puts "INCLUDE_PATH = #{path}/include"
@@ -671,7 +696,7 @@ else
671
696
 
672
697
  def configured?
673
698
  Dir.chdir(work_path) do
674
- !!(File.read('win32/Makefile.gcc') =~ /^BINARY_PATH/)
699
+ !!(File.read("win32/Makefile.gcc") =~ /^BINARY_PATH/)
675
700
  end
676
701
  end
677
702
 
@@ -689,15 +714,7 @@ else
689
714
  def configure
690
715
  cflags = concat_flags(ENV["CFLAGS"], "-fPIC", "-g")
691
716
  execute("configure",
692
- ["env", "CHOST=#{host}", "CFLAGS=#{cflags}", "./configure", "--static", configure_prefix])
693
- end
694
-
695
- def compile
696
- if host =~ /darwin/
697
- execute("compile", "make AR=#{host}-libtool")
698
- else
699
- super
700
- end
717
+ ["env", "CHOST=#{host}", "CFLAGS=#{cflags}", "./configure", "--static", configure_prefix])
701
718
  end
702
719
  end
703
720
  end
@@ -705,15 +722,19 @@ else
705
722
 
706
723
  unless nix?
707
724
  libiconv_recipe = process_recipe("libiconv", dependencies["libiconv"]["version"], static_p,
708
- cross_build_p) do |recipe|
725
+ cross_build_p) do |recipe|
709
726
  recipe.files = [{
710
- url: "http://ftp.gnu.org/pub/gnu/libiconv/#{recipe.name}-#{recipe.version}.tar.gz",
727
+ url: "https://ftp.gnu.org/pub/gnu/libiconv/#{recipe.name}-#{recipe.version}.tar.gz",
711
728
  sha256: dependencies["libiconv"]["sha256"],
712
729
  }]
713
730
 
731
+ # The libiconv configure script doesn't accept "arm64" host string but "aarch64"
732
+ recipe.host = recipe.host.gsub("arm64-apple-darwin", "aarch64-apple-darwin")
733
+
714
734
  cflags = concat_flags(ENV["CFLAGS"], "-O2", "-U_FORTIFY_SOURCE", "-g")
715
735
 
716
736
  recipe.configure_options += [
737
+ "--disable-dependency-tracking",
717
738
  "CPPFLAGS=-Wall",
718
739
  "CFLAGS=#{cflags}",
719
740
  "CXXFLAGS=#{cflags}",
@@ -721,7 +742,7 @@ cross_build_p) do |recipe|
721
742
  ]
722
743
  end
723
744
  end
724
- elsif darwin? && !have_header('iconv.h')
745
+ elsif darwin? && !have_header("iconv.h")
725
746
  abort(<<~EOM.chomp)
726
747
  -----
727
748
  The file "iconv.h" is missing in your build environment,
@@ -733,25 +754,40 @@ cross_build_p) do |recipe|
733
754
  Tools" to open the developer site, download the installer for your OS
734
755
  version and run it.
735
756
  -----
736
- EOM
757
+ EOM
758
+ end
759
+
760
+ if zlib_recipe
761
+ append_cppflags("-I#{zlib_recipe.path}/include")
762
+ $LIBPATH = ["#{zlib_recipe.path}/lib"] | $LIBPATH
763
+ ensure_package_configuration(opt: "zlib", pc: "zlib", lib: "z",
764
+ headers: "zlib.h", func: "gzdopen")
737
765
  end
738
766
 
739
- unless windows?
740
- preserving_globals { local_have_library('z', 'gzdopen', 'zlib.h') } ||
741
- abort('zlib is missing; necessary for building libxml2')
767
+ if libiconv_recipe
768
+ append_cppflags("-I#{libiconv_recipe.path}/include")
769
+ $LIBPATH = ["#{libiconv_recipe.path}/lib"] | $LIBPATH
770
+ ensure_package_configuration(opt: "iconv", pc: "iconv", lib: "iconv",
771
+ headers: "iconv.h", func: "iconv_open")
742
772
  end
743
773
 
744
774
  libxml2_recipe = process_recipe("libxml2", dependencies["libxml2"]["version"], static_p, cross_build_p) do |recipe|
745
- recipe.files = [{
746
- url: "http://xmlsoft.org/sources/#{recipe.name}-#{recipe.version}.tar.gz",
747
- sha256: dependencies["libxml2"]["sha256"],
748
- }]
775
+ source_dir = arg_config("--with-xml2-source-dir")
776
+ if source_dir
777
+ recipe.source_directory = source_dir
778
+ else
779
+ minor_version = Gem::Version.new(recipe.version).segments.take(2).join(".")
780
+ recipe.files = [{
781
+ url: "#{gnome_source}/sources/libxml2/#{minor_version}/#{recipe.name}-#{recipe.version}.tar.xz",
782
+ sha256: dependencies["libxml2"]["sha256"],
783
+ }]
784
+ recipe.patch_files = Dir[File.join(PACKAGE_ROOT_DIR, "patches", "libxml2", "*.patch")].sort
785
+ end
749
786
 
750
787
  cflags = concat_flags(ENV["CFLAGS"], "-O2", "-U_FORTIFY_SOURCE", "-g")
751
788
 
752
789
  if zlib_recipe
753
790
  recipe.configure_options << "--with-zlib=#{zlib_recipe.path}"
754
- cflags = concat_flags(cflags, "-I#{zlib_recipe.path}/include")
755
791
  end
756
792
 
757
793
  if libiconv_recipe
@@ -768,6 +804,12 @@ cross_build_p) do |recipe|
768
804
  cflags = concat_flags(cflags, "-ULIBXML_STATIC", "-DIN_LIBXML")
769
805
  end
770
806
 
807
+ recipe.configure_options << if source_dir
808
+ "--config-cache"
809
+ else
810
+ "--disable-dependency-tracking"
811
+ end
812
+
771
813
  recipe.configure_options += [
772
814
  "--without-python",
773
815
  "--without-readline",
@@ -779,10 +821,17 @@ cross_build_p) do |recipe|
779
821
  end
780
822
 
781
823
  libxslt_recipe = process_recipe("libxslt", dependencies["libxslt"]["version"], static_p, cross_build_p) do |recipe|
782
- recipe.files = [{
783
- url: "http://xmlsoft.org/sources/#{recipe.name}-#{recipe.version}.tar.gz",
784
- sha256: dependencies["libxslt"]["sha256"],
785
- }]
824
+ source_dir = arg_config("--with-xslt-source-dir")
825
+ if source_dir
826
+ recipe.source_directory = source_dir
827
+ else
828
+ minor_version = Gem::Version.new(recipe.version).segments.take(2).join(".")
829
+ recipe.files = [{
830
+ url: "#{gnome_source}/sources/libxslt/#{minor_version}/#{recipe.name}-#{recipe.version}.tar.xz",
831
+ sha256: dependencies["libxslt"]["sha256"],
832
+ }]
833
+ recipe.patch_files = Dir[File.join(PACKAGE_ROOT_DIR, "patches", "libxslt", "*.patch")].sort
834
+ end
786
835
 
787
836
  cflags = concat_flags(ENV["CFLAGS"], "-O2", "-U_FORTIFY_SOURCE", "-g")
788
837
 
@@ -790,6 +839,12 @@ cross_build_p) do |recipe|
790
839
  recipe.configure_options += ["RANLIB=/usr/bin/ranlib", "AR=/usr/bin/ar"]
791
840
  end
792
841
 
842
+ recipe.configure_options << if source_dir
843
+ "--config-cache"
844
+ else
845
+ "--disable-dependency-tracking"
846
+ end
847
+
793
848
  recipe.configure_options += [
794
849
  "--without-python",
795
850
  "--without-crypto",
@@ -802,20 +857,17 @@ cross_build_p) do |recipe|
802
857
  append_cppflags("-DNOKOGIRI_PACKAGED_LIBRARIES")
803
858
  append_cppflags("-DNOKOGIRI_PRECOMPILED_LIBRARIES") if cross_build_p
804
859
 
805
- $LIBPATH = ["#{zlib_recipe.path}/lib"] | $LIBPATH if zlib_recipe
806
- $LIBPATH = ["#{libiconv_recipe.path}/lib"] | $LIBPATH if libiconv_recipe
807
-
808
860
  $libs = $libs.shellsplit.tap do |libs|
809
861
  [libxml2_recipe, libxslt_recipe].each do |recipe|
810
862
  libname = recipe.name[/\Alib(.+)\z/, 1]
811
863
  File.join(recipe.path, "bin", "#{libname}-config").tap do |config|
812
864
  # call config scripts explicit with 'sh' for compat with Windows
813
- $CPPFLAGS = %x(sh #{config} --cflags).strip << ' ' << $CPPFLAGS
865
+ $CPPFLAGS = %x(sh #{config} --cflags).strip << " " << $CPPFLAGS
814
866
  %x(sh #{config} --libs).strip.shellsplit.each do |arg|
815
867
  case arg
816
868
  when /\A-L(.+)\z/
817
869
  # Prioritize ports' directories
818
- $LIBPATH = if Regexp.last_match(1).start_with?(PACKAGE_ROOT_DIR + '/')
870
+ $LIBPATH = if Regexp.last_match(1).start_with?(PACKAGE_ROOT_DIR + "/")
819
871
  [Regexp.last_match(1)] | $LIBPATH
820
872
  else
821
873
  $LIBPATH | [Regexp.last_match(1)]
@@ -823,26 +875,26 @@ cross_build_p) do |recipe|
823
875
  when /\A-l./
824
876
  libs.unshift(arg)
825
877
  else
826
- $LDFLAGS << ' ' << arg.shellescape
878
+ $LDFLAGS << " " << arg.shellescape
827
879
  end
828
880
  end
829
881
  end
830
882
 
831
- patches_string = recipe.patch_files.map { |path| File.basename(path) }.join(' ')
883
+ patches_string = recipe.patch_files.map { |path| File.basename(path) }.join(" ")
832
884
  append_cppflags(%[-DNOKOGIRI_#{recipe.name.upcase}_PATCHES="\\\"#{patches_string}\\\""])
833
885
 
834
886
  case libname
835
- when 'xml2'
887
+ when "xml2"
836
888
  # xslt-config --libs or pkg-config libxslt --libs does not include
837
889
  # -llzma, so we need to add it manually when linking statically.
838
- if static_p && preserving_globals { local_have_library('lzma') }
890
+ if static_p && preserving_globals { local_have_library("lzma") }
839
891
  # Add it at the end; GH #988
840
- libs << '-llzma'
892
+ libs << "-llzma"
841
893
  end
842
- when 'xslt'
894
+ when "xslt"
843
895
  # xslt-config does not have a flag to emit options including
844
896
  # -lexslt, so add it manually.
845
- libs.unshift('-lexslt')
897
+ libs.unshift("-lexslt")
846
898
  end
847
899
  end
848
900
  end.shelljoin
@@ -850,10 +902,10 @@ cross_build_p) do |recipe|
850
902
  if static_p
851
903
  $libs = $libs.shellsplit.map do |arg|
852
904
  case arg
853
- when '-lxml2'
854
- File.join(libxml2_recipe.path, 'lib', libflag_to_filename(arg))
855
- when '-lxslt', '-lexslt'
856
- File.join(libxslt_recipe.path, 'lib', libflag_to_filename(arg))
905
+ when "-lxml2"
906
+ File.join(libxml2_recipe.path, "lib", libflag_to_filename(arg))
907
+ when "-lxslt", "-lexslt"
908
+ File.join(libxslt_recipe.path, "lib", libflag_to_filename(arg))
857
909
  else
858
910
  arg
859
911
  end
@@ -865,14 +917,66 @@ cross_build_p) do |recipe|
865
917
  ensure_func("exsltFuncRegister", "libexslt/exslt.h")
866
918
  end
867
919
 
868
- have_func('xmlHasFeature') || abort("xmlHasFeature() is missing.") # introduced in libxml 2.6.21
869
- have_func('xmlFirstElementChild') # introduced in libxml 2.7.3
870
- have_func('xmlRelaxNGSetParserStructuredErrors') # introduced in libxml 2.6.24
871
- have_func('xmlRelaxNGSetValidStructuredErrors') # introduced in libxml 2.6.21
872
- have_func('xmlSchemaSetValidStructuredErrors') # introduced in libxml 2.6.23
873
- have_func('xmlSchemaSetParserStructuredErrors') # introduced in libxml 2.6.23
920
+ libgumbo_recipe = process_recipe("libgumbo", "1.0.0-nokogiri", static_p, cross_build_p, false) do |recipe|
921
+ recipe.configure_options = []
922
+
923
+ class << recipe
924
+ def downloaded?
925
+ true
926
+ end
927
+
928
+ def extract
929
+ target = File.join(tmp_path, "gumbo-parser")
930
+ output("Copying gumbo-parser files into #{target}...")
931
+ FileUtils.mkdir_p(target)
932
+ FileUtils.cp(Dir.glob(File.join(PACKAGE_ROOT_DIR, "gumbo-parser/src/*")), target)
933
+ end
934
+
935
+ def configured?
936
+ true
937
+ end
938
+
939
+ def install
940
+ lib_dir = File.join(port_path, "lib")
941
+ inc_dir = File.join(port_path, "include")
942
+ FileUtils.mkdir_p([lib_dir, inc_dir])
943
+ FileUtils.cp(File.join(work_path, "libgumbo.a"), lib_dir)
944
+ FileUtils.cp(Dir.glob(File.join(work_path, "*.h")), inc_dir)
945
+ end
946
+
947
+ def compile
948
+ cflags = concat_flags(ENV["CFLAGS"], "-fPIC", "-g")
949
+
950
+ env = { "CC" => gcc_cmd, "CFLAGS" => cflags }
951
+ if config_cross_build?
952
+ if /darwin/.match?(host)
953
+ env["AR"] = "#{host}-libtool"
954
+ env["ARFLAGS"] = "-o"
955
+ else
956
+ env["AR"] = "#{host}-ar"
957
+ end
958
+ env["RANLIB"] = "#{host}-ranlib"
959
+ end
960
+
961
+ execute("compile", make_cmd, { env: env })
962
+ end
963
+ end
964
+ end
965
+ append_cppflags("-I#{File.join(libgumbo_recipe.path, "include")}")
966
+ $libs = $libs + " " + File.join(libgumbo_recipe.path, "lib", "libgumbo.a")
967
+ $LIBPATH = $LIBPATH | [File.join(libgumbo_recipe.path, "lib")]
968
+ ensure_func("gumbo_parse_with_options", "gumbo.h")
969
+
970
+ have_func("xmlHasFeature") || abort("xmlHasFeature() is missing.") # introduced in libxml 2.6.21
971
+ have_func("xmlFirstElementChild") # introduced in libxml 2.7.3
972
+ have_func("xmlRelaxNGSetParserStructuredErrors") # introduced in libxml 2.6.24
973
+ have_func("xmlRelaxNGSetValidStructuredErrors") # introduced in libxml 2.6.21
974
+ have_func("xmlSchemaSetValidStructuredErrors") # introduced in libxml 2.6.23
975
+ have_func("xmlSchemaSetParserStructuredErrors") # introduced in libxml 2.6.23
976
+ have_func("rb_gc_location") # introduced in Ruby 2.7
977
+ have_func("rb_category_warning") # introduced in Ruby 3.0
874
978
 
875
- have_func('vasprintf')
979
+ have_func("vasprintf")
876
980
 
877
981
  other_library_versions_string = OTHER_LIBRARY_VERSIONS.map { |k, v| [k, v].join(":") }.join(",")
878
982
  append_cppflags(%[-DNOKOGIRI_OTHER_LIBRARY_VERSIONS="\\\"#{other_library_versions_string}\\\""])
@@ -882,25 +986,25 @@ unless config_system_libraries?
882
986
  # When precompiling native gems, copy packaged libraries' headers to ext/nokogiri/include
883
987
  # These are packaged up by the cross-compiling callback in the ExtensionTask
884
988
  copy_packaged_libraries_headers(to_path: File.join(PACKAGE_ROOT_DIR, "ext/nokogiri/include"),
885
- from_recipes: [libxml2_recipe, libxslt_recipe])
989
+ from_recipes: [libxml2_recipe, libxslt_recipe])
886
990
  else
887
991
  # When compiling during installation, install packaged libraries' header files into ext/nokogiri/include
888
992
  copy_packaged_libraries_headers(to_path: "include",
889
- from_recipes: [libxml2_recipe, libxslt_recipe])
993
+ from_recipes: [libxml2_recipe, libxslt_recipe])
890
994
  $INSTALLFILES << ["include/**/*.h", "$(rubylibdir)"]
891
995
  end
892
996
  end
893
997
 
894
- create_makefile('nokogiri/nokogiri')
998
+ create_makefile("nokogiri/nokogiri")
895
999
 
896
1000
  if config_clean?
897
1001
  # Do not clean if run in a development work tree.
898
- File.open('Makefile', 'at') do |mk|
1002
+ File.open("Makefile", "at") do |mk|
899
1003
  mk.print(<<~EOF)
900
1004
 
901
1005
  all: clean-ports
902
1006
  clean-ports: $(DLLIB)
903
- \t-$(Q)$(RUBY) $(srcdir)/extconf.rb --clean --#{static_p ? 'enable' : 'disable'}-static
1007
+ \t-$(Q)$(RUBY) $(srcdir)/extconf.rb --clean --#{static_p ? "enable" : "disable"}-static
904
1008
  EOF
905
1009
  end
906
1010
  end