nokogiri 1.16.8 → 1.18.1

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 (95) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +14 -22
  3. data/LICENSE-DEPENDENCIES.md +6 -6
  4. data/README.md +8 -5
  5. data/dependencies.yml +6 -6
  6. data/ext/nokogiri/extconf.rb +188 -142
  7. data/ext/nokogiri/gumbo.c +69 -53
  8. data/ext/nokogiri/html4_document.c +10 -4
  9. data/ext/nokogiri/html4_element_description.c +18 -18
  10. data/ext/nokogiri/html4_sax_parser.c +40 -0
  11. data/ext/nokogiri/html4_sax_parser_context.c +48 -58
  12. data/ext/nokogiri/html4_sax_push_parser.c +25 -24
  13. data/ext/nokogiri/libxml2_polyfill.c +114 -0
  14. data/ext/nokogiri/nokogiri.c +9 -2
  15. data/ext/nokogiri/nokogiri.h +18 -33
  16. data/ext/nokogiri/xml_attr.c +1 -1
  17. data/ext/nokogiri/xml_cdata.c +2 -10
  18. data/ext/nokogiri/xml_comment.c +3 -8
  19. data/ext/nokogiri/xml_document.c +163 -156
  20. data/ext/nokogiri/xml_document_fragment.c +10 -25
  21. data/ext/nokogiri/xml_dtd.c +1 -1
  22. data/ext/nokogiri/xml_element_content.c +9 -9
  23. data/ext/nokogiri/xml_encoding_handler.c +4 -4
  24. data/ext/nokogiri/xml_namespace.c +6 -6
  25. data/ext/nokogiri/xml_node.c +134 -103
  26. data/ext/nokogiri/xml_node_set.c +46 -44
  27. data/ext/nokogiri/xml_reader.c +54 -58
  28. data/ext/nokogiri/xml_relax_ng.c +35 -56
  29. data/ext/nokogiri/xml_sax_parser.c +156 -88
  30. data/ext/nokogiri/xml_sax_parser_context.c +219 -131
  31. data/ext/nokogiri/xml_sax_push_parser.c +68 -49
  32. data/ext/nokogiri/xml_schema.c +50 -85
  33. data/ext/nokogiri/xml_syntax_error.c +19 -11
  34. data/ext/nokogiri/xml_text.c +2 -4
  35. data/ext/nokogiri/xml_xpath_context.c +103 -100
  36. data/ext/nokogiri/xslt_stylesheet.c +8 -8
  37. data/gumbo-parser/src/ascii.c +2 -2
  38. data/gumbo-parser/src/error.c +76 -48
  39. data/gumbo-parser/src/error.h +5 -1
  40. data/gumbo-parser/src/nokogiri_gumbo.h +11 -2
  41. data/gumbo-parser/src/parser.c +63 -25
  42. data/gumbo-parser/src/tokenizer.c +6 -6
  43. data/lib/nokogiri/class_resolver.rb +1 -1
  44. data/lib/nokogiri/css/node.rb +6 -2
  45. data/lib/nokogiri/css/parser.rb +6 -4
  46. data/lib/nokogiri/css/parser.y +2 -2
  47. data/lib/nokogiri/css/parser_extras.rb +6 -66
  48. data/lib/nokogiri/css/selector_cache.rb +38 -0
  49. data/lib/nokogiri/css/tokenizer.rb +4 -4
  50. data/lib/nokogiri/css/tokenizer.rex +9 -8
  51. data/lib/nokogiri/css/xpath_visitor.rb +42 -6
  52. data/lib/nokogiri/css.rb +86 -20
  53. data/lib/nokogiri/decorators/slop.rb +3 -5
  54. data/lib/nokogiri/encoding_handler.rb +2 -2
  55. data/lib/nokogiri/html4/document.rb +44 -23
  56. data/lib/nokogiri/html4/document_fragment.rb +124 -12
  57. data/lib/nokogiri/html4/encoding_reader.rb +1 -1
  58. data/lib/nokogiri/html4/sax/parser.rb +23 -38
  59. data/lib/nokogiri/html4/sax/parser_context.rb +4 -9
  60. data/lib/nokogiri/html4.rb +9 -14
  61. data/lib/nokogiri/html5/builder.rb +40 -0
  62. data/lib/nokogiri/html5/document.rb +61 -30
  63. data/lib/nokogiri/html5/document_fragment.rb +130 -20
  64. data/lib/nokogiri/html5/node.rb +4 -4
  65. data/lib/nokogiri/html5.rb +114 -72
  66. data/lib/nokogiri/version/constant.rb +1 -1
  67. data/lib/nokogiri/xml/builder.rb +8 -1
  68. data/lib/nokogiri/xml/document.rb +70 -26
  69. data/lib/nokogiri/xml/document_fragment.rb +84 -13
  70. data/lib/nokogiri/xml/node.rb +82 -11
  71. data/lib/nokogiri/xml/node_set.rb +9 -7
  72. data/lib/nokogiri/xml/parse_options.rb +1 -1
  73. data/lib/nokogiri/xml/pp/node.rb +6 -1
  74. data/lib/nokogiri/xml/reader.rb +46 -13
  75. data/lib/nokogiri/xml/relax_ng.rb +57 -20
  76. data/lib/nokogiri/xml/sax/document.rb +174 -83
  77. data/lib/nokogiri/xml/sax/parser.rb +115 -41
  78. data/lib/nokogiri/xml/sax/parser_context.rb +116 -8
  79. data/lib/nokogiri/xml/sax/push_parser.rb +3 -0
  80. data/lib/nokogiri/xml/sax.rb +48 -0
  81. data/lib/nokogiri/xml/schema.rb +112 -45
  82. data/lib/nokogiri/xml/searchable.rb +38 -42
  83. data/lib/nokogiri/xml/syntax_error.rb +22 -0
  84. data/lib/nokogiri/xml/xpath_context.rb +14 -3
  85. data/lib/nokogiri/xml.rb +13 -24
  86. data/lib/nokogiri/xslt.rb +3 -9
  87. data/lib/xsd/xmlparser/nokogiri.rb +3 -4
  88. data/patches/libxml2/0019-xpath-Use-separate-static-hash-table-for-standard-fu.patch +244 -0
  89. data/ports/archives/libxml2-2.13.5.tar.xz +0 -0
  90. data/ports/archives/libxslt-1.1.42.tar.xz +0 -0
  91. metadata +13 -12
  92. data/ext/nokogiri/libxml2_backwards_compat.c +0 -121
  93. data/patches/libxml2/0003-libxml2.la-is-in-top_builddir.patch +0 -25
  94. data/ports/archives/libxml2-2.12.9.tar.xz +0 -0
  95. data/ports/archives/libxslt-1.1.39.tar.xz +0 -0
@@ -12,8 +12,8 @@ require "pathname"
12
12
 
13
13
  # helpful constants
14
14
  PACKAGE_ROOT_DIR = File.expand_path(File.join(File.dirname(__FILE__), "..", ".."))
15
- REQUIRED_LIBXML_VERSION = "2.6.21"
16
- RECOMMENDED_LIBXML_VERSION = "2.9.3"
15
+ REQUIRED_LIBXML_VERSION = "2.9.2"
16
+ RECOMMENDED_LIBXML_VERSION = "2.12.0"
17
17
 
18
18
  REQUIRED_MINI_PORTILE_VERSION = "~> 2.8.2" # keep this version in sync with the one in the gemspec
19
19
  REQUIRED_PKG_CONFIG_VERSION = "~> 1.1"
@@ -57,30 +57,6 @@ NOKOGIRI_HELP_MESSAGE = <<~HELP
57
57
  Look for headers in DIRECTORY.
58
58
 
59
59
 
60
- Related to zlib:
61
-
62
- --with-zlib-dir=DIRECTORY
63
- Look for zlib headers and library in DIRECTORY.
64
-
65
- --with-zlib-lib=DIRECTORY
66
- Look for zlib library in DIRECTORY.
67
-
68
- --with-zlib-include=DIRECTORY
69
- Look for zlib headers in DIRECTORY.
70
-
71
-
72
- Related to iconv:
73
-
74
- --with-iconv-dir=DIRECTORY
75
- Look for iconv headers and library in DIRECTORY.
76
-
77
- --with-iconv-lib=DIRECTORY
78
- Look for iconv library in DIRECTORY.
79
-
80
- --with-iconv-include=DIRECTORY
81
- Look for iconv headers in DIRECTORY.
82
-
83
-
84
60
  Related to libxml2:
85
61
 
86
62
  --with-xml2-dir=DIRECTORY
@@ -95,6 +71,10 @@ NOKOGIRI_HELP_MESSAGE = <<~HELP
95
71
  --with-xml2-source-dir=DIRECTORY
96
72
  (dev only) Build libxml2 from the source code in DIRECTORY
97
73
 
74
+ --disable-xml2-legacy
75
+ Do not build libxml2 with zlib, liblzma, or HTTP support. This will become the default
76
+ in a future version of Nokogiri.
77
+
98
78
 
99
79
  Related to libxslt:
100
80
 
@@ -123,6 +103,30 @@ NOKOGIRI_HELP_MESSAGE = <<~HELP
123
103
  Look for exslt headers in DIRECTORY.
124
104
 
125
105
 
106
+ Related to iconv:
107
+
108
+ --with-iconv-dir=DIRECTORY
109
+ Look for iconv headers and library in DIRECTORY.
110
+
111
+ --with-iconv-lib=DIRECTORY
112
+ Look for iconv library in DIRECTORY.
113
+
114
+ --with-iconv-include=DIRECTORY
115
+ Look for iconv headers in DIRECTORY.
116
+
117
+
118
+ Related to zlib (ignored if `--disable-xml2-legacy` is used):
119
+
120
+ --with-zlib-dir=DIRECTORY
121
+ Look for zlib headers and library in DIRECTORY.
122
+
123
+ --with-zlib-lib=DIRECTORY
124
+ Look for zlib library in DIRECTORY.
125
+
126
+ --with-zlib-include=DIRECTORY
127
+ Look for zlib headers in DIRECTORY.
128
+
129
+
126
130
  Flags only used when building and using the packaged libraries:
127
131
 
128
132
  --disable-static
@@ -137,6 +141,9 @@ NOKOGIRI_HELP_MESSAGE = <<~HELP
137
141
  NOKOGIRI_USE_SYSTEM_LIBRARIES
138
142
  Equivalent to `--enable-system-libraries` when set, even if nil or blank.
139
143
 
144
+ AR
145
+ Use this path to invoke the library archiver instead of `RbConfig::CONFIG['AR']`
146
+
140
147
  CC
141
148
  Use this path to invoke the compiler instead of `RbConfig::CONFIG['CC']`
142
149
 
@@ -146,6 +153,9 @@ NOKOGIRI_HELP_MESSAGE = <<~HELP
146
153
  CFLAGS
147
154
  If this string is accepted by the compiler, add it to the flags passed to the compiler
148
155
 
156
+ LD
157
+ Use this path to invoke the linker instead of `RbConfig::CONFIG['LD']`
158
+
149
159
  LDFLAGS
150
160
  If this string is accepted by the linker, add it to the flags passed to the linker
151
161
 
@@ -175,6 +185,10 @@ def config_system_libraries?
175
185
  end
176
186
  end
177
187
 
188
+ def config_with_xml2_legacy?
189
+ enable_config("xml2-legacy", true)
190
+ end
191
+
178
192
  def windows?
179
193
  RbConfig::CONFIG["target_os"].match?(/mingw|mswin/)
180
194
  end
@@ -195,10 +209,14 @@ def aix?
195
209
  RbConfig::CONFIG["target_os"].include?("aix")
196
210
  end
197
211
 
198
- def nix?
212
+ def unix?
199
213
  !(windows? || solaris? || darwin?)
200
214
  end
201
215
 
216
+ def nix?
217
+ ENV.key?("NIX_CC")
218
+ end
219
+
202
220
  def truffle?
203
221
  RUBY_ENGINE == "truffleruby"
204
222
  end
@@ -626,12 +644,22 @@ if openbsd? && !config_system_libraries?
626
644
  append_cppflags "-I/usr/local/include"
627
645
  end
628
646
 
647
+ if ENV["AR"]
648
+ RbConfig::CONFIG["AR"] = RbConfig::MAKEFILE_CONFIG["AR"] = ENV["AR"]
649
+ end
650
+
629
651
  if ENV["CC"]
630
652
  RbConfig::CONFIG["CC"] = RbConfig::MAKEFILE_CONFIG["CC"] = ENV["CC"]
631
653
  end
632
654
 
633
- # use same c compiler for libxml and libxslt
655
+ if ENV["LD"]
656
+ RbConfig::CONFIG["LD"] = RbConfig::MAKEFILE_CONFIG["LD"] = ENV["LD"]
657
+ end
658
+
659
+ # use same toolchain for libxml and libxslt
660
+ ENV["AR"] = RbConfig::CONFIG["AR"]
634
661
  ENV["CC"] = RbConfig::CONFIG["CC"]
662
+ ENV["LD"] = RbConfig::CONFIG["LD"]
635
663
 
636
664
  if arg_config("--prevent-strip")
637
665
  old_cflags = $CFLAGS.split.join(" ")
@@ -646,9 +674,9 @@ if arg_config("--prevent-strip")
646
674
  end
647
675
 
648
676
  # adopt environment config
649
- append_cflags(ENV["CFLAGS"].split) unless ENV["CFLAGS"].nil?
650
- append_cppflags(ENV["CPPFLAGS"].split) unless ENV["CPPFLAGS"].nil?
651
- append_ldflags(ENV["LDFLAGS"].split) unless ENV["LDFLAGS"].nil?
677
+ append_cflags(ENV["CFLAGS"]) unless ENV["CFLAGS"].nil?
678
+ append_cppflags(ENV["CPPFLAGS"]) unless ENV["CPPFLAGS"].nil?
679
+ append_ldflags(ENV["LDFLAGS"]) unless ENV["LDFLAGS"].nil?
652
680
  $LIBS = concat_flags($LIBS, ENV["LIBS"])
653
681
 
654
682
  # libgumbo uses C90/C99 features, see #2302
@@ -666,12 +694,9 @@ append_cflags("-Winline")
666
694
  # good to have no matter what Ruby was compiled with
667
695
  append_cflags("-Wmissing-noreturn")
668
696
 
669
- # check integer loss of precision
670
- if darwin?
671
- append_cflags("-Wshorten-64-to-32")
672
- else
673
- append_cflags("-Wconversion -Wno-sign-conversion")
674
- end
697
+ # check integer loss of precision. this flag won't generally work until Ruby 3.4.
698
+ # see https://bugs.ruby-lang.org/issues/20507
699
+ append_cflags("-Wconversion")
675
700
 
676
701
  # handle clang variations, see #1101
677
702
  if darwin?
@@ -684,7 +709,7 @@ end
684
709
 
685
710
  # Add SDK-specific include path for macOS and brew versions before v2.2.12 (2020-04-08) [#1851, #1801]
686
711
  macos_mojave_sdk_include_path = "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/libxml2"
687
- if config_system_libraries? && darwin? && Dir.exist?(macos_mojave_sdk_include_path)
712
+ if config_system_libraries? && darwin? && Dir.exist?(macos_mojave_sdk_include_path) && !nix?
688
713
  append_cppflags("-I#{macos_mojave_sdk_include_path}")
689
714
  end
690
715
 
@@ -694,13 +719,15 @@ append_cppflags(' "-Idummypath"') if windows?
694
719
 
695
720
  if config_system_libraries?
696
721
  message "Building nokogiri using system libraries.\n"
697
- ensure_package_configuration(
698
- opt: "zlib",
699
- pc: "zlib",
700
- lib: "z",
701
- headers: "zlib.h",
702
- func: "gzdopen",
703
- )
722
+ if config_with_xml2_legacy?
723
+ ensure_package_configuration(
724
+ opt: "zlib",
725
+ pc: "zlib",
726
+ lib: "z",
727
+ headers: "zlib.h",
728
+ func: "gzdopen",
729
+ )
730
+ end
704
731
  ensure_package_configuration(
705
732
  opt: "xml2",
706
733
  pc: "libxml-2.0",
@@ -744,58 +771,60 @@ else
744
771
  require "yaml"
745
772
  dependencies = YAML.load_file(File.join(PACKAGE_ROOT_DIR, "dependencies.yml"))
746
773
 
747
- dir_config("zlib")
774
+ dir_config("zlib") if config_with_xml2_legacy?
748
775
 
749
776
  if cross_build_p || windows?
750
- zlib_recipe = process_recipe("zlib", dependencies["zlib"]["version"], static_p, cross_build_p) do |recipe|
751
- recipe.files = [{
752
- url: zlib_source(recipe.version),
753
- sha256: dependencies["zlib"]["sha256"],
754
- }]
755
- if windows?
756
- class << recipe
757
- attr_accessor :cross_build_p
758
-
759
- def configure
760
- Dir.chdir(work_path) do
761
- mk = File.read("win32/Makefile.gcc")
762
- File.open("win32/Makefile.gcc", "wb") do |f|
763
- f.puts "BINARY_PATH = #{path}/bin"
764
- f.puts "LIBRARY_PATH = #{path}/lib"
765
- f.puts "INCLUDE_PATH = #{path}/include"
766
- mk.sub!(/^PREFIX\s*=\s*$/, "PREFIX = #{host}-") if cross_build_p
767
- f.puts mk
777
+ if config_with_xml2_legacy?
778
+ zlib_recipe = process_recipe("zlib", dependencies["zlib"]["version"], static_p, cross_build_p) do |recipe|
779
+ recipe.files = [{
780
+ url: zlib_source(recipe.version),
781
+ sha256: dependencies["zlib"]["sha256"],
782
+ }]
783
+ if windows?
784
+ class << recipe
785
+ attr_accessor :cross_build_p
786
+
787
+ def configure
788
+ Dir.chdir(work_path) do
789
+ mk = File.read("win32/Makefile.gcc")
790
+ File.open("win32/Makefile.gcc", "wb") do |f|
791
+ f.puts "BINARY_PATH = #{path}/bin"
792
+ f.puts "LIBRARY_PATH = #{path}/lib"
793
+ f.puts "INCLUDE_PATH = #{path}/include"
794
+ mk.sub!(/^PREFIX\s*=\s*$/, "PREFIX = #{host}-") if cross_build_p
795
+ f.puts mk
796
+ end
768
797
  end
769
798
  end
770
- end
771
799
 
772
- def configured?
773
- Dir.chdir(work_path) do
774
- !!(File.read("win32/Makefile.gcc") =~ /^BINARY_PATH/)
800
+ def configured?
801
+ Dir.chdir(work_path) do
802
+ !!(File.read("win32/Makefile.gcc") =~ /^BINARY_PATH/)
803
+ end
775
804
  end
776
- end
777
805
 
778
- def compile
779
- execute("compile", "make -f win32/Makefile.gcc")
780
- end
806
+ def compile
807
+ execute("compile", "make -f win32/Makefile.gcc")
808
+ end
781
809
 
782
- def install
783
- execute("install", "make -f win32/Makefile.gcc install")
810
+ def install
811
+ execute("install", "make -f win32/Makefile.gcc install")
812
+ end
784
813
  end
785
- end
786
- recipe.cross_build_p = cross_build_p
787
- else
788
- class << recipe
789
- def configure
790
- env = {}
791
- env["CFLAGS"] = concat_flags(ENV["CFLAGS"], "-fPIC", "-g")
792
- env["CHOST"] = host
793
- execute("configure", ["./configure", "--static", configure_prefix], { env: env })
794
- if darwin?
795
- # needed as of zlib 1.2.13
796
- Dir.chdir(work_path) do
797
- makefile = File.read("Makefile").gsub(/^AR=.*$/, "AR=#{host}-libtool")
798
- File.open("Makefile", "w") { |m| m.write(makefile) }
814
+ recipe.cross_build_p = cross_build_p
815
+ else
816
+ class << recipe
817
+ def configure
818
+ env = {}
819
+ env["CFLAGS"] = concat_flags(ENV["CFLAGS"], "-fPIC", "-g")
820
+ env["CHOST"] = host
821
+ execute("configure", ["./configure", "--static", configure_prefix], { env: env })
822
+ if darwin?
823
+ # needed as of zlib 1.2.13
824
+ Dir.chdir(work_path) do
825
+ makefile = File.read("Makefile").gsub(/^AR=.*$/, "AR=#{host}-libtool")
826
+ File.open("Makefile", "w") { |m| m.write(makefile) }
827
+ end
799
828
  end
800
829
  end
801
830
  end
@@ -803,7 +832,7 @@ else
803
832
  end
804
833
  end
805
834
 
806
- unless nix?
835
+ unless unix?
807
836
  libiconv_recipe = process_recipe(
808
837
  "libiconv",
809
838
  dependencies["libiconv"]["version"],
@@ -818,7 +847,7 @@ else
818
847
  # The libiconv configure script doesn't accept "arm64" host string but "aarch64"
819
848
  recipe.host = recipe.host.gsub("arm64-apple-darwin", "aarch64-apple-darwin")
820
849
 
821
- cflags = concat_flags(ENV["CFLAGS"], "-O2", "-U_FORTIFY_SOURCE", "-g")
850
+ cflags = concat_flags(ENV["CFLAGS"], "-O2", "-g")
822
851
 
823
852
  recipe.configure_options += [
824
853
  "--disable-dependency-tracking",
@@ -882,12 +911,16 @@ else
882
911
  end
883
912
 
884
913
  cppflags = concat_flags(ENV["CPPFLAGS"])
885
- cflags = concat_flags(ENV["CFLAGS"], "-O2", "-U_FORTIFY_SOURCE", "-g")
914
+ cflags = concat_flags(ENV["CFLAGS"], "-O2", "-g")
886
915
 
887
916
  if cross_build_p
888
917
  cppflags = concat_flags(cppflags, "-DNOKOGIRI_PRECOMPILED_LIBRARIES")
889
918
  end
890
919
 
920
+ if config_with_xml2_legacy?
921
+ recipe.configure_options << "--with-legacy"
922
+ end
923
+
891
924
  if zlib_recipe
892
925
  recipe.configure_options << "--with-zlib=#{zlib_recipe.path}"
893
926
  end
@@ -899,7 +932,8 @@ else
899
932
  end
900
933
 
901
934
  if darwin? && !cross_build_p
902
- recipe.configure_options += ["RANLIB=/usr/bin/ranlib", "AR=/usr/bin/ar"]
935
+ recipe.configure_options << "RANLIB=/usr/bin/ranlib" unless ENV.key?("RANLIB")
936
+ recipe.configure_options << "AR=/usr/bin/ar" unless ENV.key?("AR")
903
937
  end
904
938
 
905
939
  if windows?
@@ -918,7 +952,6 @@ else
918
952
  "--with-c14n",
919
953
  "--with-debug",
920
954
  "--with-threads",
921
- "--without-tls", # see https://github.com/sparklemotion/nokogiri/issues/3031
922
955
  "CPPFLAGS=#{cppflags}",
923
956
  "CFLAGS=#{cflags}",
924
957
  ]
@@ -937,10 +970,11 @@ else
937
970
  recipe.patch_files = Dir[File.join(PACKAGE_ROOT_DIR, "patches", "libxslt", "*.patch")].sort
938
971
  end
939
972
 
940
- cflags = concat_flags(ENV["CFLAGS"], "-O2", "-U_FORTIFY_SOURCE", "-g")
973
+ cflags = concat_flags(ENV["CFLAGS"], "-O2", "-g")
941
974
 
942
975
  if darwin? && !cross_build_p
943
- recipe.configure_options += ["RANLIB=/usr/bin/ranlib", "AR=/usr/bin/ar"]
976
+ recipe.configure_options << "RANLIB=/usr/bin/ranlib" unless ENV.key?("RANLIB")
977
+ recipe.configure_options << "AR=/usr/bin/ar" unless ENV.key?("AR")
944
978
  end
945
979
 
946
980
  if windows?
@@ -1031,63 +1065,75 @@ else
1031
1065
  ensure_func("exsltFuncRegister", "libexslt/exslt.h")
1032
1066
  end
1033
1067
 
1034
- libgumbo_recipe = process_recipe("libgumbo", "1.0.0-nokogiri", static_p, cross_build_p, false) do |recipe|
1035
- recipe.configure_options = []
1068
+ if arg_config("--gumbo-dev")
1069
+ message("DEV MODE ENABLED: build libgumbo as packaged source")
1070
+ ext_dir = File.dirname(__FILE__)
1071
+ Dir.chdir(ext_dir) do
1072
+ $srcs = Dir["*.c", "../../gumbo-parser/src/*.c"]
1073
+ $hdrs = Dir["*.h", "../../gumbo-parser/src/*.h"]
1074
+ end
1075
+ $INCFLAGS << " -I$(srcdir)/../../gumbo-parser/src"
1076
+ $VPATH << "$(srcdir)/../../gumbo-parser/src"
1077
+ find_header("nokogiri_gumbo.h") || abort("nokogiri_gumbo.h not found")
1078
+ else
1079
+ libgumbo_recipe = process_recipe("libgumbo", "1.0.0-nokogiri", static_p, cross_build_p, false) do |recipe|
1080
+ recipe.configure_options = []
1036
1081
 
1037
- class << recipe
1038
- def downloaded?
1039
- true
1040
- end
1082
+ class << recipe
1083
+ def downloaded?
1084
+ true
1085
+ end
1041
1086
 
1042
- def extract
1043
- target = File.join(tmp_path, "gumbo-parser")
1044
- output("Copying gumbo-parser files into #{target}...")
1045
- FileUtils.mkdir_p(target)
1046
- FileUtils.cp(Dir.glob(File.join(PACKAGE_ROOT_DIR, "gumbo-parser/src/*")), target)
1047
- end
1087
+ def extract
1088
+ target = File.join(tmp_path, "gumbo-parser")
1089
+ output("Copying gumbo-parser files into #{target}...")
1090
+ FileUtils.mkdir_p(target)
1091
+ FileUtils.cp(Dir.glob(File.join(PACKAGE_ROOT_DIR, "gumbo-parser/src/*")), target)
1092
+ end
1048
1093
 
1049
- def configured?
1050
- true
1051
- end
1094
+ def configured?
1095
+ true
1096
+ end
1052
1097
 
1053
- def install
1054
- lib_dir = File.join(port_path, "lib")
1055
- inc_dir = File.join(port_path, "include")
1056
- FileUtils.mkdir_p([lib_dir, inc_dir])
1057
- FileUtils.cp(File.join(work_path, "libgumbo.a"), lib_dir)
1058
- FileUtils.cp(Dir.glob(File.join(work_path, "*.h")), inc_dir)
1059
- end
1098
+ def install
1099
+ lib_dir = File.join(port_path, "lib")
1100
+ inc_dir = File.join(port_path, "include")
1101
+ FileUtils.mkdir_p([lib_dir, inc_dir])
1102
+ FileUtils.cp(File.join(work_path, "libgumbo.a"), lib_dir)
1103
+ FileUtils.cp(Dir.glob(File.join(work_path, "*.h")), inc_dir)
1104
+ end
1060
1105
 
1061
- def compile
1062
- cflags = concat_flags(ENV["CFLAGS"], "-fPIC", "-O2", "-g")
1106
+ def compile
1107
+ cflags = concat_flags(ENV["CFLAGS"], "-fPIC", "-O2", "-g")
1063
1108
 
1064
- env = { "CC" => gcc_cmd, "CFLAGS" => cflags }
1065
- if config_cross_build?
1066
- if host.include?("darwin")
1067
- env["AR"] = "#{host}-libtool"
1068
- env["ARFLAGS"] = "-o"
1069
- else
1070
- env["AR"] = "#{host}-ar"
1109
+ env = { "CC" => gcc_cmd, "CFLAGS" => cflags }
1110
+ if config_cross_build?
1111
+ if host.include?("darwin")
1112
+ env["AR"] = "#{host}-libtool"
1113
+ env["ARFLAGS"] = "-o"
1114
+ else
1115
+ env["AR"] = "#{host}-ar"
1116
+ end
1117
+ env["RANLIB"] = "#{host}-ranlib"
1118
+ if windows?
1119
+ concat_flags(env["CFLAGS"], "-D_RUBY_UCRT")
1120
+ end
1071
1121
  end
1072
- env["RANLIB"] = "#{host}-ranlib"
1073
- end
1074
1122
 
1075
- execute("compile", make_cmd, { env: env })
1123
+ execute("compile", make_cmd, { env: env })
1124
+ end
1076
1125
  end
1077
1126
  end
1127
+ append_cppflags("-I#{File.join(libgumbo_recipe.path, "include")}")
1128
+ $libs = $libs + " " + File.join(libgumbo_recipe.path, "lib", "libgumbo.a")
1129
+ $LIBPATH = $LIBPATH | [File.join(libgumbo_recipe.path, "lib")]
1130
+ ensure_func("gumbo_parse_with_options", "nokogiri_gumbo.h")
1078
1131
  end
1079
- append_cppflags("-I#{File.join(libgumbo_recipe.path, "include")}")
1080
- $libs = $libs + " " + File.join(libgumbo_recipe.path, "lib", "libgumbo.a")
1081
- $LIBPATH = $LIBPATH | [File.join(libgumbo_recipe.path, "lib")]
1082
- ensure_func("gumbo_parse_with_options", "nokogiri_gumbo.h")
1083
-
1084
- have_func("xmlHasFeature") || abort("xmlHasFeature() is missing.") # introduced in libxml 2.6.21
1085
- have_func("xmlFirstElementChild") # introduced in libxml 2.7.3
1086
- have_func("xmlRelaxNGSetParserStructuredErrors") # introduced in libxml 2.6.24
1087
- have_func("xmlRelaxNGSetValidStructuredErrors") # introduced in libxml 2.6.21
1088
- have_func("xmlSchemaSetValidStructuredErrors") # introduced in libxml 2.6.23
1089
- have_func("xmlSchemaSetParserStructuredErrors") # introduced in libxml 2.6.23
1090
- have_func("rb_category_warning") # introduced in Ruby 3.0
1132
+
1133
+ have_func("xmlCtxtSetOptions") # introduced in libxml2 2.13.0
1134
+ have_func("xmlCtxtGetOptions") # introduced in libxml2 2.14.0
1135
+ have_func("xmlSwitchEncodingName") # introduced in libxml2 2.13.0
1136
+ have_func("rb_category_warning") # introduced in Ruby 3.0 but had trouble resolving this symbol in truffleruby
1091
1137
 
1092
1138
  other_library_versions_string = OTHER_LIBRARY_VERSIONS.map { |k, v| [k, v].join(":") }.join(",")
1093
1139
  append_cppflags(%[-DNOKOGIRI_OTHER_LIBRARY_VERSIONS="\\"#{other_library_versions_string}\\""])
@@ -1118,7 +1164,7 @@ if config_clean?
1118
1164
  mk.print(<<~EOF)
1119
1165
 
1120
1166
  all: clean-ports
1121
- clean-ports: $(DLLIB)
1167
+ clean-ports: $(TARGET_SO)
1122
1168
  \t-$(Q)$(RUBY) $(srcdir)/extconf.rb --clean --#{static_p ? "enable" : "disable"}-static
1123
1169
  EOF
1124
1170
  end