nokogiri 1.16.8 → 1.18.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +11 -21
- data/LICENSE-DEPENDENCIES.md +6 -6
- data/README.md +8 -5
- data/dependencies.yml +6 -6
- data/ext/nokogiri/extconf.rb +189 -151
- data/ext/nokogiri/gumbo.c +69 -53
- data/ext/nokogiri/html4_document.c +10 -4
- data/ext/nokogiri/html4_element_description.c +18 -18
- data/ext/nokogiri/html4_sax_parser.c +40 -0
- data/ext/nokogiri/html4_sax_parser_context.c +48 -58
- data/ext/nokogiri/html4_sax_push_parser.c +25 -24
- data/ext/nokogiri/libxml2_polyfill.c +114 -0
- data/ext/nokogiri/nokogiri.c +9 -2
- data/ext/nokogiri/nokogiri.h +18 -33
- data/ext/nokogiri/xml_attr.c +1 -1
- data/ext/nokogiri/xml_cdata.c +2 -10
- data/ext/nokogiri/xml_comment.c +3 -8
- data/ext/nokogiri/xml_document.c +163 -156
- data/ext/nokogiri/xml_document_fragment.c +10 -25
- data/ext/nokogiri/xml_dtd.c +1 -1
- data/ext/nokogiri/xml_element_content.c +9 -9
- data/ext/nokogiri/xml_encoding_handler.c +4 -4
- data/ext/nokogiri/xml_namespace.c +6 -6
- data/ext/nokogiri/xml_node.c +134 -103
- data/ext/nokogiri/xml_node_set.c +46 -44
- data/ext/nokogiri/xml_reader.c +54 -58
- data/ext/nokogiri/xml_relax_ng.c +35 -56
- data/ext/nokogiri/xml_sax_parser.c +156 -88
- data/ext/nokogiri/xml_sax_parser_context.c +219 -131
- data/ext/nokogiri/xml_sax_push_parser.c +68 -49
- data/ext/nokogiri/xml_schema.c +50 -85
- data/ext/nokogiri/xml_syntax_error.c +19 -11
- data/ext/nokogiri/xml_text.c +2 -4
- data/ext/nokogiri/xml_xpath_context.c +103 -100
- data/ext/nokogiri/xslt_stylesheet.c +8 -8
- data/gumbo-parser/src/ascii.c +2 -2
- data/gumbo-parser/src/error.c +76 -48
- data/gumbo-parser/src/error.h +5 -1
- data/gumbo-parser/src/nokogiri_gumbo.h +11 -2
- data/gumbo-parser/src/parser.c +63 -25
- data/gumbo-parser/src/tokenizer.c +6 -6
- data/lib/nokogiri/class_resolver.rb +1 -1
- data/lib/nokogiri/css/node.rb +6 -2
- data/lib/nokogiri/css/parser.rb +6 -4
- data/lib/nokogiri/css/parser.y +2 -2
- data/lib/nokogiri/css/parser_extras.rb +6 -66
- data/lib/nokogiri/css/selector_cache.rb +38 -0
- data/lib/nokogiri/css/tokenizer.rb +4 -4
- data/lib/nokogiri/css/tokenizer.rex +9 -8
- data/lib/nokogiri/css/xpath_visitor.rb +43 -6
- data/lib/nokogiri/css.rb +86 -20
- data/lib/nokogiri/decorators/slop.rb +3 -5
- data/lib/nokogiri/encoding_handler.rb +2 -2
- data/lib/nokogiri/html4/document.rb +44 -23
- data/lib/nokogiri/html4/document_fragment.rb +124 -12
- data/lib/nokogiri/html4/encoding_reader.rb +1 -1
- data/lib/nokogiri/html4/sax/parser.rb +23 -38
- data/lib/nokogiri/html4/sax/parser_context.rb +4 -9
- data/lib/nokogiri/html4.rb +9 -14
- data/lib/nokogiri/html5/builder.rb +40 -0
- data/lib/nokogiri/html5/document.rb +61 -30
- data/lib/nokogiri/html5/document_fragment.rb +130 -20
- data/lib/nokogiri/html5/node.rb +4 -4
- data/lib/nokogiri/html5.rb +114 -72
- data/lib/nokogiri/version/constant.rb +1 -1
- data/lib/nokogiri/xml/builder.rb +8 -1
- data/lib/nokogiri/xml/document.rb +70 -26
- data/lib/nokogiri/xml/document_fragment.rb +84 -13
- data/lib/nokogiri/xml/node.rb +82 -11
- data/lib/nokogiri/xml/node_set.rb +9 -7
- data/lib/nokogiri/xml/parse_options.rb +1 -1
- data/lib/nokogiri/xml/pp/node.rb +6 -1
- data/lib/nokogiri/xml/reader.rb +46 -13
- data/lib/nokogiri/xml/relax_ng.rb +57 -20
- data/lib/nokogiri/xml/sax/document.rb +174 -83
- data/lib/nokogiri/xml/sax/parser.rb +115 -41
- data/lib/nokogiri/xml/sax/parser_context.rb +116 -8
- data/lib/nokogiri/xml/sax/push_parser.rb +3 -0
- data/lib/nokogiri/xml/sax.rb +48 -0
- data/lib/nokogiri/xml/schema.rb +112 -45
- data/lib/nokogiri/xml/searchable.rb +38 -42
- data/lib/nokogiri/xml/syntax_error.rb +22 -0
- data/lib/nokogiri/xml/xpath_context.rb +14 -3
- data/lib/nokogiri/xml.rb +13 -24
- data/lib/nokogiri/xslt.rb +3 -9
- data/lib/xsd/xmlparser/nokogiri.rb +3 -4
- data/patches/libxml2/0019-xpath-Use-separate-static-hash-table-for-standard-fu.patch +244 -0
- data/ports/archives/libxml2-2.13.6.tar.xz +0 -0
- data/ports/archives/libxslt-1.1.43.tar.xz +0 -0
- metadata +13 -12
- data/ext/nokogiri/libxml2_backwards_compat.c +0 -121
- data/patches/libxml2/0003-libxml2.la-is-in-top_builddir.patch +0 -25
- data/ports/archives/libxml2-2.12.9.tar.xz +0 -0
- data/ports/archives/libxslt-1.1.39.tar.xz +0 -0
data/ext/nokogiri/extconf.rb
CHANGED
@@ -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.
|
16
|
-
RECOMMENDED_LIBXML_VERSION = "2.
|
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
|
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
|
@@ -222,15 +240,7 @@ def zlib_source(version_string)
|
|
222
240
|
end
|
223
241
|
|
224
242
|
def gnome_source
|
225
|
-
|
226
|
-
# but whatever host is resolved on the github actions workers see an expired cert.
|
227
|
-
#
|
228
|
-
# See https://github.com/sparklemotion/nokogiri/runs/5266206403?check_suite_focus=true
|
229
|
-
if ENV["NOKOGIRI_USE_CANONICAL_GNOME_SOURCE"]
|
230
|
-
"https://download.gnome.org"
|
231
|
-
else
|
232
|
-
"https://muug.ca/mirror/gnome" # old reliable
|
233
|
-
end
|
243
|
+
"https://download.gnome.org"
|
234
244
|
end
|
235
245
|
|
236
246
|
LOCAL_PACKAGE_RESPONSE = Object.new
|
@@ -626,12 +636,22 @@ if openbsd? && !config_system_libraries?
|
|
626
636
|
append_cppflags "-I/usr/local/include"
|
627
637
|
end
|
628
638
|
|
639
|
+
if ENV["AR"]
|
640
|
+
RbConfig::CONFIG["AR"] = RbConfig::MAKEFILE_CONFIG["AR"] = ENV["AR"]
|
641
|
+
end
|
642
|
+
|
629
643
|
if ENV["CC"]
|
630
644
|
RbConfig::CONFIG["CC"] = RbConfig::MAKEFILE_CONFIG["CC"] = ENV["CC"]
|
631
645
|
end
|
632
646
|
|
633
|
-
|
647
|
+
if ENV["LD"]
|
648
|
+
RbConfig::CONFIG["LD"] = RbConfig::MAKEFILE_CONFIG["LD"] = ENV["LD"]
|
649
|
+
end
|
650
|
+
|
651
|
+
# use same toolchain for libxml and libxslt
|
652
|
+
ENV["AR"] = RbConfig::CONFIG["AR"]
|
634
653
|
ENV["CC"] = RbConfig::CONFIG["CC"]
|
654
|
+
ENV["LD"] = RbConfig::CONFIG["LD"]
|
635
655
|
|
636
656
|
if arg_config("--prevent-strip")
|
637
657
|
old_cflags = $CFLAGS.split.join(" ")
|
@@ -646,9 +666,9 @@ if arg_config("--prevent-strip")
|
|
646
666
|
end
|
647
667
|
|
648
668
|
# adopt environment config
|
649
|
-
append_cflags(ENV["CFLAGS"]
|
650
|
-
append_cppflags(ENV["CPPFLAGS"]
|
651
|
-
append_ldflags(ENV["LDFLAGS"]
|
669
|
+
append_cflags(ENV["CFLAGS"]) unless ENV["CFLAGS"].nil?
|
670
|
+
append_cppflags(ENV["CPPFLAGS"]) unless ENV["CPPFLAGS"].nil?
|
671
|
+
append_ldflags(ENV["LDFLAGS"]) unless ENV["LDFLAGS"].nil?
|
652
672
|
$LIBS = concat_flags($LIBS, ENV["LIBS"])
|
653
673
|
|
654
674
|
# libgumbo uses C90/C99 features, see #2302
|
@@ -666,12 +686,9 @@ append_cflags("-Winline")
|
|
666
686
|
# good to have no matter what Ruby was compiled with
|
667
687
|
append_cflags("-Wmissing-noreturn")
|
668
688
|
|
669
|
-
# check integer loss of precision
|
670
|
-
|
671
|
-
|
672
|
-
else
|
673
|
-
append_cflags("-Wconversion -Wno-sign-conversion")
|
674
|
-
end
|
689
|
+
# check integer loss of precision. this flag won't generally work until Ruby 3.4.
|
690
|
+
# see https://bugs.ruby-lang.org/issues/20507
|
691
|
+
append_cflags("-Wconversion")
|
675
692
|
|
676
693
|
# handle clang variations, see #1101
|
677
694
|
if darwin?
|
@@ -684,7 +701,7 @@ end
|
|
684
701
|
|
685
702
|
# Add SDK-specific include path for macOS and brew versions before v2.2.12 (2020-04-08) [#1851, #1801]
|
686
703
|
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)
|
704
|
+
if config_system_libraries? && darwin? && Dir.exist?(macos_mojave_sdk_include_path) && !nix?
|
688
705
|
append_cppflags("-I#{macos_mojave_sdk_include_path}")
|
689
706
|
end
|
690
707
|
|
@@ -694,13 +711,15 @@ append_cppflags(' "-Idummypath"') if windows?
|
|
694
711
|
|
695
712
|
if config_system_libraries?
|
696
713
|
message "Building nokogiri using system libraries.\n"
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
714
|
+
if config_with_xml2_legacy?
|
715
|
+
ensure_package_configuration(
|
716
|
+
opt: "zlib",
|
717
|
+
pc: "zlib",
|
718
|
+
lib: "z",
|
719
|
+
headers: "zlib.h",
|
720
|
+
func: "gzdopen",
|
721
|
+
)
|
722
|
+
end
|
704
723
|
ensure_package_configuration(
|
705
724
|
opt: "xml2",
|
706
725
|
pc: "libxml-2.0",
|
@@ -744,58 +763,60 @@ else
|
|
744
763
|
require "yaml"
|
745
764
|
dependencies = YAML.load_file(File.join(PACKAGE_ROOT_DIR, "dependencies.yml"))
|
746
765
|
|
747
|
-
dir_config("zlib")
|
766
|
+
dir_config("zlib") if config_with_xml2_legacy?
|
748
767
|
|
749
768
|
if cross_build_p || windows?
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
769
|
+
if config_with_xml2_legacy?
|
770
|
+
zlib_recipe = process_recipe("zlib", dependencies["zlib"]["version"], static_p, cross_build_p) do |recipe|
|
771
|
+
recipe.files = [{
|
772
|
+
url: zlib_source(recipe.version),
|
773
|
+
sha256: dependencies["zlib"]["sha256"],
|
774
|
+
}]
|
775
|
+
if windows?
|
776
|
+
class << recipe
|
777
|
+
attr_accessor :cross_build_p
|
778
|
+
|
779
|
+
def configure
|
780
|
+
Dir.chdir(work_path) do
|
781
|
+
mk = File.read("win32/Makefile.gcc")
|
782
|
+
File.open("win32/Makefile.gcc", "wb") do |f|
|
783
|
+
f.puts "BINARY_PATH = #{path}/bin"
|
784
|
+
f.puts "LIBRARY_PATH = #{path}/lib"
|
785
|
+
f.puts "INCLUDE_PATH = #{path}/include"
|
786
|
+
mk.sub!(/^PREFIX\s*=\s*$/, "PREFIX = #{host}-") if cross_build_p
|
787
|
+
f.puts mk
|
788
|
+
end
|
768
789
|
end
|
769
790
|
end
|
770
|
-
end
|
771
791
|
|
772
|
-
|
773
|
-
|
774
|
-
|
792
|
+
def configured?
|
793
|
+
Dir.chdir(work_path) do
|
794
|
+
!!(File.read("win32/Makefile.gcc") =~ /^BINARY_PATH/)
|
795
|
+
end
|
775
796
|
end
|
776
|
-
end
|
777
797
|
|
778
|
-
|
779
|
-
|
780
|
-
|
798
|
+
def compile
|
799
|
+
execute("compile", "make -f win32/Makefile.gcc")
|
800
|
+
end
|
781
801
|
|
782
|
-
|
783
|
-
|
802
|
+
def install
|
803
|
+
execute("install", "make -f win32/Makefile.gcc install")
|
804
|
+
end
|
784
805
|
end
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
806
|
+
recipe.cross_build_p = cross_build_p
|
807
|
+
else
|
808
|
+
class << recipe
|
809
|
+
def configure
|
810
|
+
env = {}
|
811
|
+
env["CFLAGS"] = concat_flags(ENV["CFLAGS"], "-fPIC", "-g")
|
812
|
+
env["CHOST"] = host
|
813
|
+
execute("configure", ["./configure", "--static", configure_prefix], { env: env })
|
814
|
+
if darwin?
|
815
|
+
# needed as of zlib 1.2.13
|
816
|
+
Dir.chdir(work_path) do
|
817
|
+
makefile = File.read("Makefile").gsub(/^AR=.*$/, "AR=#{host}-libtool")
|
818
|
+
File.open("Makefile", "w") { |m| m.write(makefile) }
|
819
|
+
end
|
799
820
|
end
|
800
821
|
end
|
801
822
|
end
|
@@ -803,7 +824,7 @@ else
|
|
803
824
|
end
|
804
825
|
end
|
805
826
|
|
806
|
-
unless
|
827
|
+
unless unix?
|
807
828
|
libiconv_recipe = process_recipe(
|
808
829
|
"libiconv",
|
809
830
|
dependencies["libiconv"]["version"],
|
@@ -818,7 +839,7 @@ else
|
|
818
839
|
# The libiconv configure script doesn't accept "arm64" host string but "aarch64"
|
819
840
|
recipe.host = recipe.host.gsub("arm64-apple-darwin", "aarch64-apple-darwin")
|
820
841
|
|
821
|
-
cflags = concat_flags(ENV["CFLAGS"], "-O2", "-
|
842
|
+
cflags = concat_flags(ENV["CFLAGS"], "-O2", "-g")
|
822
843
|
|
823
844
|
recipe.configure_options += [
|
824
845
|
"--disable-dependency-tracking",
|
@@ -882,12 +903,16 @@ else
|
|
882
903
|
end
|
883
904
|
|
884
905
|
cppflags = concat_flags(ENV["CPPFLAGS"])
|
885
|
-
cflags = concat_flags(ENV["CFLAGS"], "-O2", "-
|
906
|
+
cflags = concat_flags(ENV["CFLAGS"], "-O2", "-g")
|
886
907
|
|
887
908
|
if cross_build_p
|
888
909
|
cppflags = concat_flags(cppflags, "-DNOKOGIRI_PRECOMPILED_LIBRARIES")
|
889
910
|
end
|
890
911
|
|
912
|
+
if config_with_xml2_legacy?
|
913
|
+
recipe.configure_options << "--with-legacy"
|
914
|
+
end
|
915
|
+
|
891
916
|
if zlib_recipe
|
892
917
|
recipe.configure_options << "--with-zlib=#{zlib_recipe.path}"
|
893
918
|
end
|
@@ -899,7 +924,8 @@ else
|
|
899
924
|
end
|
900
925
|
|
901
926
|
if darwin? && !cross_build_p
|
902
|
-
recipe.configure_options
|
927
|
+
recipe.configure_options << "RANLIB=/usr/bin/ranlib" unless ENV.key?("RANLIB")
|
928
|
+
recipe.configure_options << "AR=/usr/bin/ar" unless ENV.key?("AR")
|
903
929
|
end
|
904
930
|
|
905
931
|
if windows?
|
@@ -918,7 +944,6 @@ else
|
|
918
944
|
"--with-c14n",
|
919
945
|
"--with-debug",
|
920
946
|
"--with-threads",
|
921
|
-
"--without-tls", # see https://github.com/sparklemotion/nokogiri/issues/3031
|
922
947
|
"CPPFLAGS=#{cppflags}",
|
923
948
|
"CFLAGS=#{cflags}",
|
924
949
|
]
|
@@ -937,10 +962,11 @@ else
|
|
937
962
|
recipe.patch_files = Dir[File.join(PACKAGE_ROOT_DIR, "patches", "libxslt", "*.patch")].sort
|
938
963
|
end
|
939
964
|
|
940
|
-
cflags = concat_flags(ENV["CFLAGS"], "-O2", "-
|
965
|
+
cflags = concat_flags(ENV["CFLAGS"], "-O2", "-g")
|
941
966
|
|
942
967
|
if darwin? && !cross_build_p
|
943
|
-
recipe.configure_options
|
968
|
+
recipe.configure_options << "RANLIB=/usr/bin/ranlib" unless ENV.key?("RANLIB")
|
969
|
+
recipe.configure_options << "AR=/usr/bin/ar" unless ENV.key?("AR")
|
944
970
|
end
|
945
971
|
|
946
972
|
if windows?
|
@@ -1031,63 +1057,75 @@ else
|
|
1031
1057
|
ensure_func("exsltFuncRegister", "libexslt/exslt.h")
|
1032
1058
|
end
|
1033
1059
|
|
1034
|
-
|
1035
|
-
|
1060
|
+
if arg_config("--gumbo-dev")
|
1061
|
+
message("DEV MODE ENABLED: build libgumbo as packaged source")
|
1062
|
+
ext_dir = File.dirname(__FILE__)
|
1063
|
+
Dir.chdir(ext_dir) do
|
1064
|
+
$srcs = Dir["*.c", "../../gumbo-parser/src/*.c"]
|
1065
|
+
$hdrs = Dir["*.h", "../../gumbo-parser/src/*.h"]
|
1066
|
+
end
|
1067
|
+
$INCFLAGS << " -I$(srcdir)/../../gumbo-parser/src"
|
1068
|
+
$VPATH << "$(srcdir)/../../gumbo-parser/src"
|
1069
|
+
find_header("nokogiri_gumbo.h") || abort("nokogiri_gumbo.h not found")
|
1070
|
+
else
|
1071
|
+
libgumbo_recipe = process_recipe("libgumbo", "1.0.0-nokogiri", static_p, cross_build_p, false) do |recipe|
|
1072
|
+
recipe.configure_options = []
|
1036
1073
|
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1074
|
+
class << recipe
|
1075
|
+
def downloaded?
|
1076
|
+
true
|
1077
|
+
end
|
1041
1078
|
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1079
|
+
def extract
|
1080
|
+
target = File.join(tmp_path, "gumbo-parser")
|
1081
|
+
output("Copying gumbo-parser files into #{target}...")
|
1082
|
+
FileUtils.mkdir_p(target)
|
1083
|
+
FileUtils.cp(Dir.glob(File.join(PACKAGE_ROOT_DIR, "gumbo-parser/src/*")), target)
|
1084
|
+
end
|
1048
1085
|
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1086
|
+
def configured?
|
1087
|
+
true
|
1088
|
+
end
|
1052
1089
|
|
1053
|
-
|
1054
|
-
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1090
|
+
def install
|
1091
|
+
lib_dir = File.join(port_path, "lib")
|
1092
|
+
inc_dir = File.join(port_path, "include")
|
1093
|
+
FileUtils.mkdir_p([lib_dir, inc_dir])
|
1094
|
+
FileUtils.cp(File.join(work_path, "libgumbo.a"), lib_dir)
|
1095
|
+
FileUtils.cp(Dir.glob(File.join(work_path, "*.h")), inc_dir)
|
1096
|
+
end
|
1060
1097
|
|
1061
|
-
|
1062
|
-
|
1098
|
+
def compile
|
1099
|
+
cflags = concat_flags(ENV["CFLAGS"], "-fPIC", "-O2", "-g")
|
1063
1100
|
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1101
|
+
env = { "CC" => gcc_cmd, "CFLAGS" => cflags }
|
1102
|
+
if config_cross_build?
|
1103
|
+
if host.include?("darwin")
|
1104
|
+
env["AR"] = "#{host}-libtool"
|
1105
|
+
env["ARFLAGS"] = "-o"
|
1106
|
+
else
|
1107
|
+
env["AR"] = "#{host}-ar"
|
1108
|
+
end
|
1109
|
+
env["RANLIB"] = "#{host}-ranlib"
|
1110
|
+
if windows?
|
1111
|
+
concat_flags(env["CFLAGS"], "-D_RUBY_UCRT")
|
1112
|
+
end
|
1071
1113
|
end
|
1072
|
-
env["RANLIB"] = "#{host}-ranlib"
|
1073
|
-
end
|
1074
1114
|
|
1075
|
-
|
1115
|
+
execute("compile", make_cmd, { env: env })
|
1116
|
+
end
|
1076
1117
|
end
|
1077
1118
|
end
|
1119
|
+
append_cppflags("-I#{File.join(libgumbo_recipe.path, "include")}")
|
1120
|
+
$libs = $libs + " " + File.join(libgumbo_recipe.path, "lib", "libgumbo.a")
|
1121
|
+
$LIBPATH = $LIBPATH | [File.join(libgumbo_recipe.path, "lib")]
|
1122
|
+
ensure_func("gumbo_parse_with_options", "nokogiri_gumbo.h")
|
1078
1123
|
end
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
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
|
1124
|
+
|
1125
|
+
have_func("xmlCtxtSetOptions") # introduced in libxml2 2.13.0
|
1126
|
+
have_func("xmlCtxtGetOptions") # introduced in libxml2 2.14.0
|
1127
|
+
have_func("xmlSwitchEncodingName") # introduced in libxml2 2.13.0
|
1128
|
+
have_func("rb_category_warning") # introduced in Ruby 3.0 but had trouble resolving this symbol in truffleruby
|
1091
1129
|
|
1092
1130
|
other_library_versions_string = OTHER_LIBRARY_VERSIONS.map { |k, v| [k, v].join(":") }.join(",")
|
1093
1131
|
append_cppflags(%[-DNOKOGIRI_OTHER_LIBRARY_VERSIONS="\\"#{other_library_versions_string}\\""])
|
@@ -1118,7 +1156,7 @@ if config_clean?
|
|
1118
1156
|
mk.print(<<~EOF)
|
1119
1157
|
|
1120
1158
|
all: clean-ports
|
1121
|
-
clean-ports: $(
|
1159
|
+
clean-ports: $(TARGET_SO)
|
1122
1160
|
\t-$(Q)$(RUBY) $(srcdir)/extconf.rb --clean --#{static_p ? "enable" : "disable"}-static
|
1123
1161
|
EOF
|
1124
1162
|
end
|