nokogiri 1.11.1 → 1.12.0.rc1
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.
- checksums.yaml +4 -4
- data/LICENSE-DEPENDENCIES.md +232 -11
- data/LICENSE.md +1 -1
- data/README.md +27 -21
- data/dependencies.yml +12 -12
- data/ext/nokogiri/depend +35 -474
- data/ext/nokogiri/extconf.rb +391 -243
- data/ext/nokogiri/gumbo.c +611 -0
- data/ext/nokogiri/{html_document.c → html4_document.c} +18 -23
- data/ext/nokogiri/html4_element_description.c +294 -0
- data/ext/nokogiri/html4_entity_lookup.c +37 -0
- data/ext/nokogiri/html4_sax_parser_context.c +119 -0
- data/ext/nokogiri/{html_sax_push_parser.c → html4_sax_push_parser.c} +29 -27
- data/ext/nokogiri/libxml2_backwards_compat.c +121 -0
- data/ext/nokogiri/nokogiri.c +206 -66
- data/ext/nokogiri/nokogiri.h +166 -76
- data/ext/nokogiri/test_global_handlers.c +3 -4
- data/ext/nokogiri/xml_attr.c +15 -15
- data/ext/nokogiri/xml_attribute_decl.c +18 -18
- data/ext/nokogiri/xml_cdata.c +13 -18
- data/ext/nokogiri/xml_comment.c +19 -26
- data/ext/nokogiri/xml_document.c +258 -200
- data/ext/nokogiri/xml_document_fragment.c +13 -15
- data/ext/nokogiri/xml_dtd.c +54 -48
- data/ext/nokogiri/xml_element_content.c +31 -26
- data/ext/nokogiri/xml_element_decl.c +22 -22
- data/ext/nokogiri/xml_encoding_handler.c +28 -17
- data/ext/nokogiri/xml_entity_decl.c +32 -30
- data/ext/nokogiri/xml_entity_reference.c +16 -18
- data/ext/nokogiri/xml_namespace.c +58 -49
- data/ext/nokogiri/xml_node.c +473 -414
- data/ext/nokogiri/xml_node_set.c +174 -162
- data/ext/nokogiri/xml_processing_instruction.c +17 -19
- data/ext/nokogiri/xml_reader.c +193 -157
- data/ext/nokogiri/xml_relax_ng.c +29 -23
- data/ext/nokogiri/xml_sax_parser.c +111 -106
- data/ext/nokogiri/xml_sax_parser_context.c +102 -85
- data/ext/nokogiri/xml_sax_push_parser.c +34 -27
- data/ext/nokogiri/xml_schema.c +49 -41
- data/ext/nokogiri/xml_syntax_error.c +21 -23
- data/ext/nokogiri/xml_text.c +13 -17
- data/ext/nokogiri/xml_xpath_context.c +86 -77
- data/ext/nokogiri/xslt_stylesheet.c +157 -156
- data/gumbo-parser/CHANGES.md +63 -0
- data/gumbo-parser/Makefile +101 -0
- data/gumbo-parser/THANKS +27 -0
- data/gumbo-parser/src/Makefile +17 -0
- data/gumbo-parser/src/README.md +41 -0
- data/gumbo-parser/src/ascii.c +75 -0
- data/gumbo-parser/src/ascii.h +115 -0
- data/gumbo-parser/src/attribute.c +42 -0
- data/gumbo-parser/src/attribute.h +17 -0
- data/gumbo-parser/src/char_ref.c +22225 -0
- data/gumbo-parser/src/char_ref.h +29 -0
- data/gumbo-parser/src/char_ref.rl +2154 -0
- data/gumbo-parser/src/error.c +626 -0
- data/gumbo-parser/src/error.h +148 -0
- data/gumbo-parser/src/foreign_attrs.c +104 -0
- data/gumbo-parser/src/foreign_attrs.gperf +27 -0
- data/gumbo-parser/src/gumbo.h +943 -0
- data/gumbo-parser/src/insertion_mode.h +33 -0
- data/gumbo-parser/src/macros.h +91 -0
- data/gumbo-parser/src/parser.c +4886 -0
- data/gumbo-parser/src/parser.h +41 -0
- data/gumbo-parser/src/replacement.h +33 -0
- data/gumbo-parser/src/string_buffer.c +103 -0
- data/gumbo-parser/src/string_buffer.h +68 -0
- data/gumbo-parser/src/string_piece.c +48 -0
- data/gumbo-parser/src/svg_attrs.c +174 -0
- data/gumbo-parser/src/svg_attrs.gperf +77 -0
- data/gumbo-parser/src/svg_tags.c +137 -0
- data/gumbo-parser/src/svg_tags.gperf +55 -0
- data/gumbo-parser/src/tag.c +222 -0
- data/gumbo-parser/src/tag_lookup.c +382 -0
- data/gumbo-parser/src/tag_lookup.gperf +169 -0
- data/gumbo-parser/src/tag_lookup.h +13 -0
- data/gumbo-parser/src/token_buffer.c +79 -0
- data/gumbo-parser/src/token_buffer.h +71 -0
- data/gumbo-parser/src/token_type.h +17 -0
- data/gumbo-parser/src/tokenizer.c +3463 -0
- data/gumbo-parser/src/tokenizer.h +112 -0
- data/gumbo-parser/src/tokenizer_states.h +339 -0
- data/gumbo-parser/src/utf8.c +245 -0
- data/gumbo-parser/src/utf8.h +164 -0
- data/gumbo-parser/src/util.c +68 -0
- data/gumbo-parser/src/util.h +30 -0
- data/gumbo-parser/src/vector.c +111 -0
- data/gumbo-parser/src/vector.h +45 -0
- data/lib/nokogiri.rb +31 -50
- data/lib/nokogiri/css.rb +14 -14
- data/lib/nokogiri/css/parser.rb +2 -2
- data/lib/nokogiri/css/parser.y +1 -1
- data/lib/nokogiri/css/syntax_error.rb +1 -1
- data/lib/nokogiri/extension.rb +26 -0
- data/lib/nokogiri/gumbo.rb +14 -0
- data/lib/nokogiri/html.rb +31 -27
- data/lib/nokogiri/html4.rb +40 -0
- data/lib/nokogiri/{html → html4}/builder.rb +2 -2
- data/lib/nokogiri/{html → html4}/document.rb +4 -4
- data/lib/nokogiri/{html → html4}/document_fragment.rb +17 -17
- data/lib/nokogiri/{html → html4}/element_description.rb +1 -1
- data/lib/nokogiri/{html → html4}/element_description_defaults.rb +1 -1
- data/lib/nokogiri/{html → html4}/entity_lookup.rb +1 -1
- data/lib/nokogiri/{html → html4}/sax/parser.rb +11 -14
- data/lib/nokogiri/html4/sax/parser_context.rb +19 -0
- data/lib/nokogiri/{html → html4}/sax/push_parser.rb +5 -5
- data/lib/nokogiri/html5.rb +473 -0
- data/lib/nokogiri/html5/document.rb +74 -0
- data/lib/nokogiri/html5/document_fragment.rb +80 -0
- data/lib/nokogiri/html5/node.rb +93 -0
- data/lib/nokogiri/version/constant.rb +1 -1
- data/lib/nokogiri/version/info.rb +42 -9
- data/lib/nokogiri/xml.rb +35 -36
- data/lib/nokogiri/xml/document.rb +74 -28
- data/lib/nokogiri/xml/node.rb +45 -47
- data/lib/nokogiri/xml/parse_options.rb +2 -0
- data/lib/nokogiri/xml/pp.rb +2 -2
- data/lib/nokogiri/xml/reader.rb +2 -9
- data/lib/nokogiri/xml/sax.rb +4 -4
- data/lib/nokogiri/xml/sax/document.rb +24 -30
- data/lib/nokogiri/xml/xpath.rb +3 -5
- data/lib/nokogiri/xml/xpath/syntax_error.rb +1 -1
- data/lib/nokogiri/xslt.rb +16 -16
- data/lib/nokogiri/xslt/stylesheet.rb +1 -1
- data/patches/libxml2/{0002-Remove-script-macro-support.patch → 0001-Remove-script-macro-support.patch} +0 -0
- data/patches/libxml2/{0003-Update-entities-to-remove-handling-of-ssi.patch → 0002-Update-entities-to-remove-handling-of-ssi.patch} +0 -0
- data/patches/libxml2/{0004-libxml2.la-is-in-top_builddir.patch → 0003-libxml2.la-is-in-top_builddir.patch} +1 -1
- data/patches/libxml2/{0008-use-glibc-strlen.patch → 0004-use-glibc-strlen.patch} +0 -0
- data/patches/libxml2/{0009-avoid-isnan-isinf.patch → 0005-avoid-isnan-isinf.patch} +4 -4
- data/patches/libxml2/0006-update-automake-files-for-arm64.patch +2511 -0
- data/patches/libxml2/0007-Fix-XPath-recursion-limit.patch +31 -0
- data/patches/libxslt/0001-update-automake-files-for-arm64.patch +2511 -0
- data/patches/libxslt/0002-Fix-xml2-config-check-in-configure-script.patch +19 -0
- data/ports/archives/libxml2-2.9.12.tar.gz +0 -0
- metadata +117 -109
- data/ext/nokogiri/html_document.h +0 -10
- data/ext/nokogiri/html_element_description.c +0 -279
- data/ext/nokogiri/html_element_description.h +0 -10
- data/ext/nokogiri/html_entity_lookup.c +0 -32
- data/ext/nokogiri/html_entity_lookup.h +0 -8
- data/ext/nokogiri/html_sax_parser_context.c +0 -118
- data/ext/nokogiri/html_sax_parser_context.h +0 -11
- data/ext/nokogiri/html_sax_push_parser.h +0 -9
- data/ext/nokogiri/xml_attr.h +0 -9
- data/ext/nokogiri/xml_attribute_decl.h +0 -9
- data/ext/nokogiri/xml_cdata.h +0 -9
- data/ext/nokogiri/xml_comment.h +0 -9
- data/ext/nokogiri/xml_document.h +0 -23
- data/ext/nokogiri/xml_document_fragment.h +0 -10
- data/ext/nokogiri/xml_dtd.h +0 -10
- data/ext/nokogiri/xml_element_content.h +0 -10
- data/ext/nokogiri/xml_element_decl.h +0 -9
- data/ext/nokogiri/xml_encoding_handler.h +0 -8
- data/ext/nokogiri/xml_entity_decl.h +0 -10
- data/ext/nokogiri/xml_entity_reference.h +0 -9
- data/ext/nokogiri/xml_io.c +0 -63
- data/ext/nokogiri/xml_io.h +0 -11
- data/ext/nokogiri/xml_libxml2_hacks.c +0 -112
- data/ext/nokogiri/xml_libxml2_hacks.h +0 -12
- data/ext/nokogiri/xml_namespace.h +0 -14
- data/ext/nokogiri/xml_node.h +0 -13
- data/ext/nokogiri/xml_node_set.h +0 -12
- data/ext/nokogiri/xml_processing_instruction.h +0 -9
- data/ext/nokogiri/xml_reader.h +0 -10
- data/ext/nokogiri/xml_relax_ng.h +0 -9
- data/ext/nokogiri/xml_sax_parser.h +0 -39
- data/ext/nokogiri/xml_sax_parser_context.h +0 -10
- data/ext/nokogiri/xml_sax_push_parser.h +0 -9
- data/ext/nokogiri/xml_schema.h +0 -9
- data/ext/nokogiri/xml_syntax_error.h +0 -25
- data/ext/nokogiri/xml_text.h +0 -9
- data/ext/nokogiri/xml_xpath_context.h +0 -10
- data/ext/nokogiri/xslt_stylesheet.h +0 -14
- data/lib/nokogiri/html/sax/parser_context.rb +0 -17
- data/patches/libxml2/0001-Revert-Do-not-URI-escape-in-server-side-includes.patch +0 -78
- data/patches/libxml2/0005-Fix-infinite-loop-in-xmlStringLenDecodeEntities.patch +0 -32
- data/patches/libxml2/0006-htmlParseComment-treat-as-if-it-closed-the-comment.patch +0 -73
- data/patches/libxml2/0007-use-new-htmlParseLookupCommentEnd-to-find-comment-en.patch +0 -103
- data/ports/archives/libxml2-2.9.10.tar.gz +0 -0
data/ext/nokogiri/extconf.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
# :
|
2
|
-
ENV[
|
1
|
+
# frozen_string_literal: true
|
2
|
+
ENV["RC_ARCHS"] = "" if RUBY_PLATFORM =~ /darwin/
|
3
3
|
|
4
4
|
require "mkmf"
|
5
5
|
require "rbconfig"
|
@@ -7,16 +7,14 @@ require "fileutils"
|
|
7
7
|
require "shellwords"
|
8
8
|
require "pathname"
|
9
9
|
|
10
|
-
#
|
11
|
-
|
12
|
-
#
|
13
|
-
PACKAGE_ROOT_DIR = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
10
|
+
# helpful constants
|
11
|
+
PACKAGE_ROOT_DIR = File.expand_path(File.join(File.dirname(__FILE__), "..", ".."))
|
14
12
|
REQUIRED_LIBXML_VERSION = "2.6.21"
|
15
13
|
RECOMMENDED_LIBXML_VERSION = "2.9.3"
|
16
14
|
|
17
15
|
# The gem version constraint in the Rakefile is not respected at install time.
|
18
16
|
# Keep this version in sync with the one in the Rakefile !
|
19
|
-
REQUIRED_MINI_PORTILE_VERSION = "~> 2.
|
17
|
+
REQUIRED_MINI_PORTILE_VERSION = "~> 2.6.1"
|
20
18
|
REQUIRED_PKG_CONFIG_VERSION = "~> 1.1"
|
21
19
|
|
22
20
|
# Keep track of what versions of what libraries we build against
|
@@ -28,10 +26,16 @@ NOKOGIRI_HELP_MESSAGE = <<~HELP
|
|
28
26
|
Flags that are always valid:
|
29
27
|
|
30
28
|
--use-system-libraries
|
31
|
-
|
29
|
+
--enable-system-libraries
|
30
|
+
Use system libraries instead of building and using the packaged libraries.
|
31
|
+
|
32
|
+
--disable-system-libraries
|
33
|
+
Use the packaged libraries, and ignore the system libraries. This is the default on most
|
34
|
+
platforms, and overrides `--use-system-libraries` and the environment variable
|
35
|
+
`NOKOGIRI_USE_SYSTEM_LIBRARIES`.
|
32
36
|
|
33
37
|
--disable-clean
|
34
|
-
Do not clean out intermediate files after successful build
|
38
|
+
Do not clean out intermediate files after successful build.
|
35
39
|
|
36
40
|
--prevent-strip
|
37
41
|
Take steps to prevent stripping the symbol table and debugging info from the shared
|
@@ -40,47 +44,88 @@ NOKOGIRI_HELP_MESSAGE = <<~HELP
|
|
40
44
|
|
41
45
|
Flags only used when using system libraries:
|
42
46
|
|
43
|
-
|
44
|
-
|
47
|
+
General:
|
48
|
+
|
49
|
+
--with-opt-dir=DIRECTORY
|
50
|
+
Look for headers and libraries in DIRECTORY.
|
51
|
+
|
52
|
+
--with-opt-lib=DIRECTORY
|
53
|
+
Look for libraries in DIRECTORY.
|
54
|
+
|
55
|
+
--with-opt-include=DIRECTORY
|
56
|
+
Look for headers in DIRECTORY.
|
57
|
+
|
58
|
+
|
59
|
+
Related to zlib:
|
60
|
+
|
61
|
+
--with-zlib-dir=DIRECTORY
|
62
|
+
Look for zlib headers and library in DIRECTORY.
|
63
|
+
|
64
|
+
--with-zlib-lib=DIRECTORY
|
65
|
+
Look for zlib library in DIRECTORY.
|
66
|
+
|
67
|
+
--with-zlib-include=DIRECTORY
|
68
|
+
Look for zlib headers in DIRECTORY.
|
69
|
+
|
70
|
+
|
71
|
+
Related to iconv:
|
72
|
+
|
73
|
+
--with-iconv-dir=DIRECTORY
|
74
|
+
Look for iconv headers and library in DIRECTORY.
|
75
|
+
|
76
|
+
--with-iconv-lib=DIRECTORY
|
77
|
+
Look for iconv library in DIRECTORY.
|
78
|
+
|
79
|
+
--with-iconv-include=DIRECTORY
|
80
|
+
Look for iconv headers in DIRECTORY.
|
81
|
+
|
82
|
+
|
83
|
+
Related to libxml2:
|
84
|
+
|
85
|
+
--with-xml2-dir=DIRECTORY
|
86
|
+
Look for xml2 headers and library in DIRECTORY.
|
87
|
+
|
88
|
+
--with-xml2-lib=DIRECTORY
|
89
|
+
Look for xml2 library in DIRECTORY.
|
90
|
+
|
91
|
+
--with-xml2-include=DIRECTORY
|
92
|
+
Look for xml2 headers in DIRECTORY.
|
93
|
+
|
94
|
+
--with-xml2-source-dir=DIRECTORY
|
95
|
+
(dev only) Build libxml2 from the source code in DIRECTORY
|
45
96
|
|
46
|
-
--with-zlib-dir=DIR
|
47
|
-
Look for zlib header and library in DIRECTORY
|
48
97
|
|
49
|
-
|
50
|
-
Look for iconv header and library in DIRECTORY
|
98
|
+
Related to libxslt:
|
51
99
|
|
52
|
-
|
53
|
-
|
100
|
+
--with-xslt-dir=DIRECTORY
|
101
|
+
Look for xslt headers and library in DIRECTORY.
|
54
102
|
|
55
|
-
|
56
|
-
|
103
|
+
--with-xslt-lib=DIRECTORY
|
104
|
+
Look for xslt library in DIRECTORY.
|
57
105
|
|
58
|
-
|
59
|
-
|
106
|
+
--with-xslt-include=DIRECTORY
|
107
|
+
Look for xslt headers in DIRECTORY.
|
60
108
|
|
61
|
-
|
62
|
-
|
109
|
+
--with-xslt-source-dir=DIRECTORY
|
110
|
+
(dev only) Build libxslt from the source code in DIRECTORY
|
63
111
|
|
64
|
-
--with-xslt-lib=DIRECTORY
|
65
|
-
Look for xslt library in DIRECTORY
|
66
112
|
|
67
|
-
|
68
|
-
Look for xslt headers in DIRECTORY
|
113
|
+
Related to libexslt:
|
69
114
|
|
70
|
-
|
71
|
-
|
115
|
+
--with-exslt-dir=DIRECTORY
|
116
|
+
Look for exslt headers and library in DIRECTORY.
|
72
117
|
|
73
|
-
|
74
|
-
|
118
|
+
--with-exslt-lib=DIRECTORY
|
119
|
+
Look for exslt library in DIRECTORY.
|
75
120
|
|
76
|
-
|
77
|
-
|
121
|
+
--with-exslt-include=DIRECTORY
|
122
|
+
Look for exslt headers in DIRECTORY.
|
78
123
|
|
79
124
|
|
80
125
|
Flags only used when building and using the packaged libraries:
|
81
126
|
|
82
127
|
--disable-static
|
83
|
-
Do not statically link packaged libraries, instead use shared libraries
|
128
|
+
Do not statically link packaged libraries, instead use shared libraries.
|
84
129
|
|
85
130
|
--enable-cross-build
|
86
131
|
Enable cross-build mode. (You probably do not want to set this manually.)
|
@@ -89,8 +134,7 @@ NOKOGIRI_HELP_MESSAGE = <<~HELP
|
|
89
134
|
Environment variables used:
|
90
135
|
|
91
136
|
NOKOGIRI_USE_SYSTEM_LIBRARIES
|
92
|
-
|
93
|
-
packaged libraries. Equivalent to `--use-system-libraries`.
|
137
|
+
Equivalent to `--enable-system-libraries` when set, even if nil or blank.
|
94
138
|
|
95
139
|
CC
|
96
140
|
Use this path to invoke the compiler instead of `RbConfig::CONFIG['CC']`
|
@@ -111,20 +155,39 @@ HELP
|
|
111
155
|
#
|
112
156
|
# utility functions
|
113
157
|
#
|
158
|
+
def config_clean?
|
159
|
+
enable_config("clean", true)
|
160
|
+
end
|
161
|
+
|
162
|
+
def config_static?
|
163
|
+
default_static = !truffle?
|
164
|
+
enable_config("static", default_static)
|
165
|
+
end
|
166
|
+
|
167
|
+
def config_cross_build?
|
168
|
+
enable_config("cross-build")
|
169
|
+
end
|
170
|
+
|
171
|
+
def config_system_libraries?
|
172
|
+
enable_config("system-libraries", ENV.key?("NOKOGIRI_USE_SYSTEM_LIBRARIES")) do |_, default|
|
173
|
+
arg_config("--use-system-libraries", default)
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
114
177
|
def windows?
|
115
|
-
RbConfig::CONFIG[
|
178
|
+
RbConfig::CONFIG["target_os"] =~ /mingw32|mswin/
|
116
179
|
end
|
117
180
|
|
118
181
|
def solaris?
|
119
|
-
RbConfig::CONFIG[
|
182
|
+
RbConfig::CONFIG["target_os"] =~ /solaris/
|
120
183
|
end
|
121
184
|
|
122
185
|
def darwin?
|
123
|
-
RbConfig::CONFIG[
|
186
|
+
RbConfig::CONFIG["target_os"] =~ /darwin/
|
124
187
|
end
|
125
188
|
|
126
189
|
def openbsd?
|
127
|
-
RbConfig::CONFIG[
|
190
|
+
RbConfig::CONFIG["target_os"] =~ /openbsd/
|
128
191
|
end
|
129
192
|
|
130
193
|
def aix?
|
@@ -132,15 +195,19 @@ def aix?
|
|
132
195
|
end
|
133
196
|
|
134
197
|
def nix?
|
135
|
-
!
|
198
|
+
!(windows? || solaris? || darwin?)
|
199
|
+
end
|
200
|
+
|
201
|
+
def truffle?
|
202
|
+
::RUBY_ENGINE == "truffleruby"
|
136
203
|
end
|
137
204
|
|
138
|
-
def concat_flags
|
205
|
+
def concat_flags(*args)
|
139
206
|
args.compact.join(" ")
|
140
207
|
end
|
141
208
|
|
142
|
-
def local_have_library(lib, func=nil, headers=nil)
|
143
|
-
have_library(lib, func, headers)
|
209
|
+
def local_have_library(lib, func = nil, headers = nil)
|
210
|
+
have_library(lib, func, headers) || have_library("lib#{lib}", func, headers)
|
144
211
|
end
|
145
212
|
|
146
213
|
LOCAL_PACKAGE_RESPONSE = Object.new
|
@@ -150,7 +217,7 @@ end
|
|
150
217
|
|
151
218
|
# wrapper around MakeMakefil#pkg_config and the PKGConfig gem
|
152
219
|
def try_package_configuration(pc)
|
153
|
-
|
220
|
+
unless ENV.key?("NOKOGIRI_TEST_PKG_CONFIG_GEM")
|
154
221
|
# try MakeMakefile#pkg_config, which uses the system utility `pkg-config`.
|
155
222
|
return if checking_for("#{pc} using `pkg_config`", LOCAL_PACKAGE_RESPONSE) do
|
156
223
|
pkg_config(pc)
|
@@ -161,9 +228,9 @@ def try_package_configuration(pc)
|
|
161
228
|
# let's fall back to the pkg-config gem, which knows how to parse .pc files, and wrap it with the
|
162
229
|
# same logic as MakeMakefile#pkg_config
|
163
230
|
begin
|
164
|
-
require
|
165
|
-
gem
|
166
|
-
require
|
231
|
+
require "rubygems"
|
232
|
+
gem("pkg-config", REQUIRED_PKG_CONFIG_VERSION)
|
233
|
+
require "pkg-config"
|
167
234
|
|
168
235
|
checking_for("#{pc} using pkg-config gem version #{PKGConfig::VERSION}", LOCAL_PACKAGE_RESPONSE) do
|
169
236
|
if PKGConfig.have_package(pc)
|
@@ -171,14 +238,14 @@ def try_package_configuration(pc)
|
|
171
238
|
ldflags = PKGConfig.libs_only_L(pc)
|
172
239
|
libs = PKGConfig.libs_only_l(pc)
|
173
240
|
|
174
|
-
Logging
|
175
|
-
Logging
|
241
|
+
Logging.message("pkg-config gem found package configuration for %s\n", pc)
|
242
|
+
Logging.message("cflags: %s\nldflags: %s\nlibs: %s\n\n", cflags, ldflags, libs)
|
176
243
|
|
177
244
|
[cflags, ldflags, libs]
|
178
245
|
end
|
179
246
|
end
|
180
247
|
rescue LoadError
|
181
|
-
message
|
248
|
+
message("Please install either the `pkg-config` utility or the `pkg-config` rubygem.\n")
|
182
249
|
end
|
183
250
|
end
|
184
251
|
|
@@ -190,7 +257,7 @@ def have_package_configuration(opt: nil, pc: nil, lib:, func:, headers:)
|
|
190
257
|
end
|
191
258
|
|
192
259
|
# see if we have enough path info to do this without trying any harder
|
193
|
-
|
260
|
+
unless ENV.key?("NOKOGIRI_TEST_PKG_CONFIG")
|
194
261
|
return true if local_have_library(lib, func, headers)
|
195
262
|
end
|
196
263
|
|
@@ -201,12 +268,12 @@ def have_package_configuration(opt: nil, pc: nil, lib:, func:, headers:)
|
|
201
268
|
end
|
202
269
|
|
203
270
|
def ensure_package_configuration(opt: nil, pc: nil, lib:, func:, headers:)
|
204
|
-
have_package_configuration(opt: opt, pc: pc, lib: lib, func: func, headers: headers)
|
271
|
+
have_package_configuration(opt: opt, pc: pc, lib: lib, func: func, headers: headers) ||
|
205
272
|
abort_could_not_find_library(lib)
|
206
273
|
end
|
207
274
|
|
208
|
-
def ensure_func(func, headers=nil)
|
209
|
-
have_func(func, headers)
|
275
|
+
def ensure_func(func, headers = nil)
|
276
|
+
have_func(func, headers) || abort_could_not_find_library(func)
|
210
277
|
end
|
211
278
|
|
212
279
|
def preserving_globals
|
@@ -217,20 +284,20 @@ ensure
|
|
217
284
|
end
|
218
285
|
|
219
286
|
def abort_could_not_find_library(lib)
|
220
|
-
abort
|
287
|
+
abort("-----\n#{caller[0]}\n#{lib} is missing. Please locate mkmf.log to investigate how it is failing.\n-----")
|
221
288
|
end
|
222
289
|
|
223
290
|
def chdir_for_build
|
224
291
|
# When using rake-compiler-dock on Windows, the underlying Virtualbox shared
|
225
292
|
# folders don't support symlinks, but libiconv expects it for a build on
|
226
293
|
# Linux. We work around this limitation by using the temp dir for cooking.
|
227
|
-
build_dir = ENV[
|
294
|
+
build_dir = ENV["RCD_HOST_RUBY_PLATFORM"].to_s =~ /mingw|mswin|cygwin/ ? "/tmp" : "."
|
228
295
|
Dir.chdir(build_dir) do
|
229
296
|
yield
|
230
297
|
end
|
231
298
|
end
|
232
299
|
|
233
|
-
def sh_export_path
|
300
|
+
def sh_export_path(path)
|
234
301
|
# because libxslt 1.1.29 configure.in uses AC_PATH_TOOL which treats ":"
|
235
302
|
# as a $PATH separator, we need to convert windows paths from
|
236
303
|
#
|
@@ -242,7 +309,7 @@ def sh_export_path path
|
|
242
309
|
#
|
243
310
|
# which is sh-compatible, in order to find things properly during
|
244
311
|
# configuration
|
245
|
-
return path
|
312
|
+
return path unless windows?
|
246
313
|
|
247
314
|
match = Regexp.new("^([A-Z]):(/.*)").match(path)
|
248
315
|
if match && match.length == 3
|
@@ -255,36 +322,31 @@ end
|
|
255
322
|
def libflag_to_filename(ldflag)
|
256
323
|
case ldflag
|
257
324
|
when /\A-l(.+)/
|
258
|
-
"lib#{
|
325
|
+
"lib#{Regexp.last_match(1)}.#{$LIBEXT}"
|
259
326
|
end
|
260
327
|
end
|
261
328
|
|
262
|
-
def
|
263
|
-
# NOTE: TruffleRuby uses this env var as it does not support using static libraries yet.
|
264
|
-
arg_config('--use-system-libraries', ENV.key?("NOKOGIRI_USE_SYSTEM_LIBRARIES"))
|
265
|
-
end
|
266
|
-
|
267
|
-
def have_libxml_headers?(version=nil)
|
329
|
+
def have_libxml_headers?(version = nil)
|
268
330
|
source = if version.nil?
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
try_cpp
|
331
|
+
<<~SRC
|
332
|
+
#include <libxml/xmlversion.h>
|
333
|
+
SRC
|
334
|
+
else
|
335
|
+
version_int = format("%d%2.2d%2.2d", *version.split("."))
|
336
|
+
<<~SRC
|
337
|
+
#include <libxml/xmlversion.h>
|
338
|
+
#if LIBXML_VERSION < #{version_int}
|
339
|
+
# error libxml2 is older than #{version}
|
340
|
+
#endif
|
341
|
+
SRC
|
342
|
+
end
|
343
|
+
|
344
|
+
try_cpp(source)
|
283
345
|
end
|
284
346
|
|
285
347
|
def try_link_iconv(using = nil)
|
286
|
-
checking_for(using ? "iconv using #{using}" :
|
287
|
-
[
|
348
|
+
checking_for(using ? "iconv using #{using}" : "iconv") do
|
349
|
+
["", "-liconv"].any? do |opt|
|
288
350
|
preserving_globals do
|
289
351
|
yield if block_given?
|
290
352
|
|
@@ -307,62 +369,60 @@ def iconv_configure_flags
|
|
307
369
|
# give --with-iconv-dir and --with-opt-dir first priority
|
308
370
|
["iconv", "opt"].each do |target|
|
309
371
|
config = preserving_globals { dir_config(target) }
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
end
|
316
|
-
|
317
|
-
return [
|
318
|
-
'--with-iconv=yes',
|
319
|
-
*("CPPFLAGS=#{idirs.map { |dir| '-I' + dir }.join(' ')}" if idirs),
|
320
|
-
*("LDFLAGS=#{ldirs.map { |dir| '-L' + dir }.join(' ')}" if ldirs),
|
321
|
-
]
|
372
|
+
next unless config.any? && try_link_iconv("--with-#{target}-* flags") { dir_config(target) }
|
373
|
+
idirs, ldirs = config.map do |dirs|
|
374
|
+
Array(dirs).flat_map do |dir|
|
375
|
+
dir.split(File::PATH_SEPARATOR)
|
376
|
+
end if dirs
|
322
377
|
end
|
378
|
+
|
379
|
+
return [
|
380
|
+
"--with-iconv=yes",
|
381
|
+
*("CPPFLAGS=#{idirs.map { |dir| "-I" + dir }.join(" ")}" if idirs),
|
382
|
+
*("LDFLAGS=#{ldirs.map { |dir| "-L" + dir }.join(" ")}" if ldirs),
|
383
|
+
]
|
323
384
|
end
|
324
385
|
|
325
386
|
if try_link_iconv
|
326
|
-
return [
|
387
|
+
return ["--with-iconv=yes"]
|
327
388
|
end
|
328
389
|
|
329
|
-
config = preserving_globals { have_package_configuration(
|
330
|
-
if config && try_link_iconv(
|
390
|
+
config = preserving_globals { have_package_configuration("libiconv") }
|
391
|
+
if config && try_link_iconv("pkg-config libiconv") { have_package_configuration("libiconv") }
|
331
392
|
cflags, ldflags, libs = config
|
332
393
|
|
333
394
|
return [
|
334
|
-
|
395
|
+
"--with-iconv=yes",
|
335
396
|
"CPPFLAGS=#{cflags}",
|
336
397
|
"LDFLAGS=#{ldflags}",
|
337
398
|
"LIBS=#{libs}",
|
338
399
|
]
|
339
400
|
end
|
340
401
|
|
341
|
-
abort_could_not_find_library
|
402
|
+
abort_could_not_find_library("libiconv")
|
342
403
|
end
|
343
404
|
|
344
|
-
def process_recipe(name, version, static_p, cross_p)
|
345
|
-
require
|
346
|
-
gem
|
347
|
-
require
|
348
|
-
message
|
405
|
+
def process_recipe(name, version, static_p, cross_p, cacheable_p=true)
|
406
|
+
require "rubygems"
|
407
|
+
gem("mini_portile2", REQUIRED_MINI_PORTILE_VERSION)
|
408
|
+
require "mini_portile2"
|
409
|
+
message("Using mini_portile version #{MiniPortile::VERSION}\n")
|
349
410
|
|
350
|
-
|
411
|
+
unless ["libxml2", "libxslt"].include?(name)
|
351
412
|
OTHER_LIBRARY_VERSIONS[name] = version
|
352
413
|
end
|
353
414
|
|
354
415
|
MiniPortile.new(name, version).tap do |recipe|
|
355
|
-
recipe.target = File.join(PACKAGE_ROOT_DIR, "ports")
|
416
|
+
recipe.target = File.join(PACKAGE_ROOT_DIR, "ports") if cacheable_p
|
356
417
|
# Prefer host_alias over host in order to use i586-mingw32msvc as
|
357
418
|
# correct compiler prefix for cross build, but use host if not set.
|
358
419
|
recipe.host = RbConfig::CONFIG["host_alias"].empty? ? RbConfig::CONFIG["host"] : RbConfig::CONFIG["host_alias"]
|
359
|
-
recipe.patch_files = Dir[File.join(PACKAGE_ROOT_DIR, "patches", name, "*.patch")].sort
|
360
420
|
recipe.configure_options << "--libdir=#{File.join(recipe.path, "lib")}"
|
361
421
|
|
362
422
|
yield recipe
|
363
423
|
|
364
424
|
env = Hash.new do |hash, key|
|
365
|
-
hash[key] =
|
425
|
+
hash[key] = (ENV[key]).to_s
|
366
426
|
end
|
367
427
|
|
368
428
|
recipe.configure_options.flatten!
|
@@ -370,10 +430,10 @@ def process_recipe(name, version, static_p, cross_p)
|
|
370
430
|
recipe.configure_options.delete_if do |option|
|
371
431
|
case option
|
372
432
|
when /\A(\w+)=(.*)\z/
|
373
|
-
if env.key?(
|
374
|
-
|
433
|
+
env[Regexp.last_match(1)] = if env.key?(Regexp.last_match(1))
|
434
|
+
concat_flags(env[Regexp.last_match(1)], Regexp.last_match(2))
|
375
435
|
else
|
376
|
-
|
436
|
+
Regexp.last_match(2)
|
377
437
|
end
|
378
438
|
true
|
379
439
|
else
|
@@ -401,10 +461,10 @@ def process_recipe(name, version, static_p, cross_p)
|
|
401
461
|
]
|
402
462
|
end
|
403
463
|
|
404
|
-
if RbConfig::CONFIG[
|
464
|
+
if RbConfig::CONFIG["target_cpu"] == "universal"
|
405
465
|
%w[CFLAGS LDFLAGS].each do |key|
|
406
|
-
unless env[key].include?(
|
407
|
-
env[key] = concat_flags(env[key], RbConfig::CONFIG[
|
466
|
+
unless env[key].include?("-arch")
|
467
|
+
env[key] = concat_flags(env[key], RbConfig::CONFIG["ARCH_FLAG"])
|
408
468
|
end
|
409
469
|
end
|
410
470
|
end
|
@@ -414,44 +474,42 @@ def process_recipe(name, version, static_p, cross_p)
|
|
414
474
|
end
|
415
475
|
|
416
476
|
checkpoint = "#{recipe.target}/#{recipe.name}-#{recipe.version}-#{recipe.host}.installed"
|
417
|
-
if File.exist?(checkpoint)
|
418
|
-
message
|
477
|
+
if File.exist?(checkpoint) && !recipe.source_directory
|
478
|
+
message("Building Nokogiri with a packaged version of #{name}-#{version}.\n")
|
419
479
|
else
|
420
|
-
message
|
480
|
+
message(<<~EOM)
|
421
481
|
---------- IMPORTANT NOTICE ----------
|
422
482
|
Building Nokogiri with a packaged version of #{name}-#{version}.
|
423
483
|
Configuration options: #{recipe.configure_options.shelljoin}
|
424
484
|
EOM
|
425
485
|
|
426
486
|
unless recipe.patch_files.empty?
|
427
|
-
message
|
487
|
+
message("The following patches are being applied:\n")
|
428
488
|
|
429
489
|
recipe.patch_files.each do |patch|
|
430
|
-
message
|
490
|
+
message(" - %s\n" % File.basename(patch))
|
431
491
|
end
|
432
492
|
end
|
433
493
|
|
434
|
-
message
|
494
|
+
message(<<~EOM) if name != "libgumbo"
|
435
495
|
|
436
496
|
The Nokogiri maintainers intend to provide timely security updates, but if
|
437
497
|
this is a concern for you and want to use your OS/distro system library
|
438
498
|
instead, then abort this installation process and install nokogiri as
|
439
499
|
instructed at:
|
440
500
|
|
441
|
-
https://nokogiri.org/tutorials/installing_nokogiri.html#
|
501
|
+
https://nokogiri.org/tutorials/installing_nokogiri.html#installing-using-standard-system-libraries
|
442
502
|
|
443
503
|
EOM
|
444
504
|
|
445
|
-
message
|
446
|
-
Note, however, that nokogiri cannot guarantee
|
505
|
+
message(<<~EOM) if name == "libxml2"
|
506
|
+
Note, however, that nokogiri cannot guarantee compatibility with every
|
447
507
|
version of libxml2 that may be provided by OS/package vendors.
|
448
508
|
|
449
509
|
EOM
|
450
510
|
|
451
|
-
chdir_for_build
|
452
|
-
|
453
|
-
end
|
454
|
-
FileUtils.touch checkpoint
|
511
|
+
chdir_for_build { recipe.cook }
|
512
|
+
FileUtils.touch(checkpoint)
|
455
513
|
end
|
456
514
|
recipe.activate
|
457
515
|
end
|
@@ -461,13 +519,13 @@ def copy_packaged_libraries_headers(to_path:, from_recipes:)
|
|
461
519
|
FileUtils.rm_rf(to_path, secure: true)
|
462
520
|
FileUtils.mkdir(to_path)
|
463
521
|
from_recipes.each do |recipe|
|
464
|
-
FileUtils.cp_r(Dir[File.join(recipe.path,
|
522
|
+
FileUtils.cp_r(Dir[File.join(recipe.path, "include/*")], to_path)
|
465
523
|
end
|
466
524
|
end
|
467
525
|
|
468
526
|
def do_help
|
469
|
-
print
|
470
|
-
exit!
|
527
|
+
print(NOKOGIRI_HELP_MESSAGE)
|
528
|
+
exit!(0)
|
471
529
|
end
|
472
530
|
|
473
531
|
def do_clean
|
@@ -475,50 +533,50 @@ def do_clean
|
|
475
533
|
pwd = Pathname(Dir.pwd)
|
476
534
|
|
477
535
|
# Skip if this is a development work tree
|
478
|
-
unless (root +
|
479
|
-
message
|
536
|
+
unless (root + ".git").exist?
|
537
|
+
message("Cleaning files only used during build.\n")
|
480
538
|
|
481
539
|
# (root + 'tmp') cannot be removed at this stage because
|
482
540
|
# nokogiri.so is yet to be copied to lib.
|
483
541
|
|
484
542
|
# clean the ports build directory
|
485
|
-
Pathname.glob(pwd.join(
|
543
|
+
Pathname.glob(pwd.join("tmp", "*", "ports")) do |dir|
|
486
544
|
FileUtils.rm_rf(dir, verbose: true)
|
487
545
|
end
|
488
546
|
|
489
|
-
if
|
547
|
+
if config_static?
|
490
548
|
# ports installation can be safely removed if statically linked.
|
491
|
-
FileUtils.rm_rf(root +
|
549
|
+
FileUtils.rm_rf(root + "ports", verbose: true)
|
492
550
|
else
|
493
|
-
FileUtils.rm_rf(root +
|
551
|
+
FileUtils.rm_rf(root + "ports" + "archives", verbose: true)
|
494
552
|
end
|
495
553
|
end
|
496
554
|
|
497
|
-
exit!
|
555
|
+
exit!(0)
|
498
556
|
end
|
499
557
|
|
500
558
|
#
|
501
559
|
# main
|
502
560
|
#
|
503
|
-
do_help if arg_config(
|
504
|
-
do_clean if arg_config(
|
561
|
+
do_help if arg_config("--help")
|
562
|
+
do_clean if arg_config("--clean")
|
505
563
|
|
506
|
-
if openbsd? && !
|
507
|
-
if
|
508
|
-
ENV[
|
509
|
-
abort
|
564
|
+
if openbsd? && !config_system_libraries?
|
565
|
+
if %x(#{ENV["CC"] || "/usr/bin/cc"} -v 2>&1) !~ /clang/
|
566
|
+
(ENV["CC"] ||= find_executable("egcc")) ||
|
567
|
+
abort("Please install gcc 4.9+ from ports using `pkg_add -v gcc`")
|
510
568
|
end
|
511
569
|
append_cppflags "-I/usr/local/include"
|
512
570
|
end
|
513
571
|
|
514
|
-
if ENV[
|
515
|
-
RbConfig::CONFIG[
|
572
|
+
if ENV["CC"]
|
573
|
+
RbConfig::CONFIG["CC"] = RbConfig::MAKEFILE_CONFIG["CC"] = ENV["CC"]
|
516
574
|
end
|
517
575
|
|
518
576
|
# use same c compiler for libxml and libxslt
|
519
|
-
ENV[
|
577
|
+
ENV["CC"] = RbConfig::CONFIG["CC"]
|
520
578
|
|
521
|
-
if arg_config(
|
579
|
+
if arg_config("--prevent-strip")
|
522
580
|
old_cflags = $CFLAGS.split.join(" ")
|
523
581
|
old_ldflags = $LDFLAGS.split.join(" ")
|
524
582
|
old_dldflags = $DLDFLAGS.split.join(" ")
|
@@ -531,20 +589,29 @@ if arg_config('--prevent-strip')
|
|
531
589
|
end
|
532
590
|
|
533
591
|
# adopt environment config
|
534
|
-
append_cflags(ENV["CFLAGS"].split)
|
535
|
-
append_cppflags(ENV["CPPFLAGS"].split)
|
536
|
-
append_ldflags(ENV["LDFLAGS"].split)
|
592
|
+
append_cflags(ENV["CFLAGS"].split) unless ENV["CFLAGS"].nil?
|
593
|
+
append_cppflags(ENV["CPPFLAGS"].split) unless ENV["CPPFLAGS"].nil?
|
594
|
+
append_ldflags(ENV["LDFLAGS"].split) unless ENV["LDFLAGS"].nil?
|
537
595
|
$LIBS = concat_flags($LIBS, ENV["LIBS"])
|
538
596
|
|
539
|
-
|
540
|
-
append_cflags("-
|
541
|
-
|
597
|
+
# always include debugging information
|
598
|
+
append_cflags("-g")
|
599
|
+
|
600
|
+
# we use at least one inline function in the C extension
|
601
|
+
append_cflags("-Winline")
|
602
|
+
|
603
|
+
# good to have no matter what Ruby was compiled with
|
604
|
+
append_cflags("-Wmissing-noreturn")
|
605
|
+
|
606
|
+
# handle clang variations, see #1101
|
542
607
|
append_cflags("-Wno-error=unused-command-line-argument-hard-error-in-future") if darwin?
|
543
|
-
|
608
|
+
|
609
|
+
# these tend to be noisy, but on occasion useful during development
|
610
|
+
# append_cflags(["-Wcast-qual", "-Wwrite-strings"])
|
544
611
|
|
545
612
|
# Add SDK-specific include path for macOS and brew versions before v2.2.12 (2020-04-08) [#1851, #1801]
|
546
613
|
macos_mojave_sdk_include_path = "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/libxml2"
|
547
|
-
if
|
614
|
+
if config_system_libraries? && darwin? && Dir.exist?(macos_mojave_sdk_include_path)
|
548
615
|
append_cppflags("-I#{macos_mojave_sdk_include_path}")
|
549
616
|
end
|
550
617
|
|
@@ -552,46 +619,50 @@ end
|
|
552
619
|
# See https://sourceforge.net/p/mingw/bugs/2142
|
553
620
|
append_cppflags(' "-Idummypath"') if windows?
|
554
621
|
|
555
|
-
if
|
622
|
+
if config_system_libraries?
|
556
623
|
message "Building nokogiri using system libraries.\n"
|
557
|
-
ensure_package_configuration(opt: "zlib", pc: "zlib", lib: "z",
|
558
|
-
|
559
|
-
ensure_package_configuration(opt: "
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
624
|
+
ensure_package_configuration(opt: "zlib", pc: "zlib", lib: "z",
|
625
|
+
headers: "zlib.h", func: "gzdopen")
|
626
|
+
ensure_package_configuration(opt: "xml2", pc: "libxml-2.0", lib: "xml2",
|
627
|
+
headers: "libxml/parser.h", func: "xmlParseDoc")
|
628
|
+
ensure_package_configuration(opt: "xslt", pc: "libxslt", lib: "xslt",
|
629
|
+
headers: "libxslt/xslt.h", func: "xsltParseStylesheetDoc")
|
630
|
+
ensure_package_configuration(opt: "exslt", pc: "libexslt", lib: "exslt",
|
631
|
+
headers: "libexslt/exslt.h", func: "exsltFuncRegister")
|
632
|
+
|
633
|
+
have_libxml_headers?(REQUIRED_LIBXML_VERSION) ||
|
634
|
+
abort("ERROR: libxml2 version #{REQUIRED_LIBXML_VERSION} or later is required!")
|
635
|
+
have_libxml_headers?(RECOMMENDED_LIBXML_VERSION) ||
|
636
|
+
warn("WARNING: libxml2 version #{RECOMMENDED_LIBXML_VERSION} or later is highly recommended, but proceeding anyway.")
|
566
637
|
|
567
638
|
else
|
568
639
|
message "Building nokogiri using packaged libraries.\n"
|
569
640
|
|
570
|
-
static_p =
|
641
|
+
static_p = config_static?
|
571
642
|
message "Static linking is #{static_p ? "enabled" : "disabled"}.\n"
|
572
643
|
|
573
|
-
cross_build_p =
|
644
|
+
cross_build_p = config_cross_build?
|
574
645
|
message "Cross build is #{cross_build_p ? "enabled" : "disabled"}.\n"
|
575
646
|
|
576
|
-
require
|
647
|
+
require "yaml"
|
577
648
|
dependencies = YAML.load_file(File.join(PACKAGE_ROOT_DIR, "dependencies.yml"))
|
578
649
|
|
579
|
-
dir_config(
|
650
|
+
dir_config("zlib")
|
580
651
|
|
581
652
|
if cross_build_p || windows?
|
582
653
|
zlib_recipe = process_recipe("zlib", dependencies["zlib"]["version"], static_p, cross_build_p) do |recipe|
|
583
654
|
recipe.files = [{
|
584
|
-
|
585
|
-
|
586
|
-
|
655
|
+
url: "http://zlib.net/fossils/#{recipe.name}-#{recipe.version}.tar.gz",
|
656
|
+
sha256: dependencies["zlib"]["sha256"],
|
657
|
+
}]
|
587
658
|
if windows?
|
588
659
|
class << recipe
|
589
660
|
attr_accessor :cross_build_p
|
590
661
|
|
591
662
|
def configure
|
592
|
-
Dir.chdir
|
593
|
-
mk = File.read
|
594
|
-
File.open
|
663
|
+
Dir.chdir(work_path) do
|
664
|
+
mk = File.read("win32/Makefile.gcc")
|
665
|
+
File.open("win32/Makefile.gcc", "wb") do |f|
|
595
666
|
f.puts "BINARY_PATH = #{path}/bin"
|
596
667
|
f.puts "LIBRARY_PATH = #{path}/lib"
|
597
668
|
f.puts "INCLUDE_PATH = #{path}/include"
|
@@ -602,17 +673,17 @@ else
|
|
602
673
|
end
|
603
674
|
|
604
675
|
def configured?
|
605
|
-
Dir.chdir
|
606
|
-
!!
|
676
|
+
Dir.chdir(work_path) do
|
677
|
+
!!(File.read("win32/Makefile.gcc") =~ /^BINARY_PATH/)
|
607
678
|
end
|
608
679
|
end
|
609
680
|
|
610
681
|
def compile
|
611
|
-
execute
|
682
|
+
execute("compile", "make -f win32/Makefile.gcc")
|
612
683
|
end
|
613
684
|
|
614
685
|
def install
|
615
|
-
execute
|
686
|
+
execute("install", "make -f win32/Makefile.gcc install")
|
616
687
|
end
|
617
688
|
end
|
618
689
|
recipe.cross_build_p = cross_build_p
|
@@ -620,12 +691,13 @@ else
|
|
620
691
|
class << recipe
|
621
692
|
def configure
|
622
693
|
cflags = concat_flags(ENV["CFLAGS"], "-fPIC", "-g")
|
623
|
-
execute
|
694
|
+
execute("configure",
|
695
|
+
["env", "CHOST=#{host}", "CFLAGS=#{cflags}", "./configure", "--static", configure_prefix])
|
624
696
|
end
|
625
697
|
|
626
698
|
def compile
|
627
|
-
if host
|
628
|
-
execute
|
699
|
+
if host =~ /darwin/
|
700
|
+
execute("compile", "make AR=#{host}-libtool")
|
629
701
|
else
|
630
702
|
super
|
631
703
|
end
|
@@ -635,49 +707,55 @@ else
|
|
635
707
|
end
|
636
708
|
|
637
709
|
unless nix?
|
638
|
-
libiconv_recipe = process_recipe("libiconv", dependencies["libiconv"]["version"], static_p,
|
710
|
+
libiconv_recipe = process_recipe("libiconv", dependencies["libiconv"]["version"], static_p,
|
711
|
+
cross_build_p) do |recipe|
|
639
712
|
recipe.files = [{
|
640
|
-
|
641
|
-
|
642
|
-
|
713
|
+
url: "http://ftp.gnu.org/pub/gnu/libiconv/#{recipe.name}-#{recipe.version}.tar.gz",
|
714
|
+
sha256: dependencies["libiconv"]["sha256"],
|
715
|
+
}]
|
643
716
|
|
644
717
|
cflags = concat_flags(ENV["CFLAGS"], "-O2", "-U_FORTIFY_SOURCE", "-g")
|
645
718
|
|
646
719
|
recipe.configure_options += [
|
720
|
+
"--disable-dependency-tracking",
|
647
721
|
"CPPFLAGS=-Wall",
|
648
722
|
"CFLAGS=#{cflags}",
|
649
723
|
"CXXFLAGS=#{cflags}",
|
650
|
-
"LDFLAGS="
|
724
|
+
"LDFLAGS=",
|
651
725
|
]
|
652
726
|
end
|
653
727
|
end
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
-----
|
728
|
+
elsif darwin? && !have_header("iconv.h")
|
729
|
+
abort(<<~EOM.chomp)
|
730
|
+
-----
|
731
|
+
The file "iconv.h" is missing in your build environment,
|
732
|
+
which means you haven't installed Xcode Command Line Tools properly.
|
733
|
+
|
734
|
+
To install Command Line Tools, try running `xcode-select --install` on
|
735
|
+
terminal and follow the instructions. If it fails, open Xcode.app,
|
736
|
+
select from the menu "Xcode" - "Open Developer Tool" - "More Developer
|
737
|
+
Tools" to open the developer site, download the installer for your OS
|
738
|
+
version and run it.
|
739
|
+
-----
|
667
740
|
EOM
|
668
|
-
end
|
669
741
|
end
|
670
742
|
|
671
743
|
unless windows?
|
672
|
-
preserving_globals { local_have_library(
|
673
|
-
abort
|
744
|
+
preserving_globals { local_have_library("z", "gzdopen", "zlib.h") } ||
|
745
|
+
abort("zlib is missing; necessary for building libxml2")
|
674
746
|
end
|
675
747
|
|
676
748
|
libxml2_recipe = process_recipe("libxml2", dependencies["libxml2"]["version"], static_p, cross_build_p) do |recipe|
|
677
|
-
|
749
|
+
source_dir = arg_config("--with-xml2-source-dir")
|
750
|
+
if source_dir
|
751
|
+
recipe.source_directory = source_dir
|
752
|
+
else
|
753
|
+
recipe.files = [{
|
678
754
|
url: "http://xmlsoft.org/sources/#{recipe.name}-#{recipe.version}.tar.gz",
|
679
|
-
sha256: dependencies["libxml2"]["sha256"]
|
755
|
+
sha256: dependencies["libxml2"]["sha256"],
|
680
756
|
}]
|
757
|
+
recipe.patch_files = Dir[File.join(PACKAGE_ROOT_DIR, "patches", "libxml2", "*.patch")].sort
|
758
|
+
end
|
681
759
|
|
682
760
|
cflags = concat_flags(ENV["CFLAGS"], "-O2", "-U_FORTIFY_SOURCE", "-g")
|
683
761
|
|
@@ -696,6 +774,16 @@ else
|
|
696
774
|
recipe.configure_options += ["RANLIB=/usr/bin/ranlib", "AR=/usr/bin/ar"]
|
697
775
|
end
|
698
776
|
|
777
|
+
if windows?
|
778
|
+
cflags = concat_flags(cflags, "-ULIBXML_STATIC", "-DIN_LIBXML")
|
779
|
+
end
|
780
|
+
|
781
|
+
recipe.configure_options << if source_dir
|
782
|
+
"--config-cache"
|
783
|
+
else
|
784
|
+
"--disable-dependency-tracking"
|
785
|
+
end
|
786
|
+
|
699
787
|
recipe.configure_options += [
|
700
788
|
"--without-python",
|
701
789
|
"--without-readline",
|
@@ -707,10 +795,16 @@ else
|
|
707
795
|
end
|
708
796
|
|
709
797
|
libxslt_recipe = process_recipe("libxslt", dependencies["libxslt"]["version"], static_p, cross_build_p) do |recipe|
|
710
|
-
|
798
|
+
source_dir = arg_config("--with-xslt-source-dir")
|
799
|
+
if source_dir
|
800
|
+
recipe.source_directory = source_dir
|
801
|
+
else
|
802
|
+
recipe.files = [{
|
711
803
|
url: "http://xmlsoft.org/sources/#{recipe.name}-#{recipe.version}.tar.gz",
|
712
|
-
sha256: dependencies["libxslt"]["sha256"]
|
804
|
+
sha256: dependencies["libxslt"]["sha256"],
|
713
805
|
}]
|
806
|
+
recipe.patch_files = Dir[File.join(PACKAGE_ROOT_DIR, "patches", "libxslt", "*.patch")].sort
|
807
|
+
end
|
714
808
|
|
715
809
|
cflags = concat_flags(ENV["CFLAGS"], "-O2", "-U_FORTIFY_SOURCE", "-g")
|
716
810
|
|
@@ -718,6 +812,12 @@ else
|
|
718
812
|
recipe.configure_options += ["RANLIB=/usr/bin/ranlib", "AR=/usr/bin/ar"]
|
719
813
|
end
|
720
814
|
|
815
|
+
recipe.configure_options << if source_dir
|
816
|
+
"--config-cache"
|
817
|
+
else
|
818
|
+
"--disable-dependency-tracking"
|
819
|
+
end
|
820
|
+
|
721
821
|
recipe.configure_options += [
|
722
822
|
"--without-python",
|
723
823
|
"--without-crypto",
|
@@ -738,39 +838,39 @@ else
|
|
738
838
|
libname = recipe.name[/\Alib(.+)\z/, 1]
|
739
839
|
File.join(recipe.path, "bin", "#{libname}-config").tap do |config|
|
740
840
|
# call config scripts explicit with 'sh' for compat with Windows
|
741
|
-
$CPPFLAGS =
|
742
|
-
|
841
|
+
$CPPFLAGS = %x(sh #{config} --cflags).strip << " " << $CPPFLAGS
|
842
|
+
%x(sh #{config} --libs).strip.shellsplit.each do |arg|
|
743
843
|
case arg
|
744
844
|
when /\A-L(.+)\z/
|
745
845
|
# Prioritize ports' directories
|
746
|
-
if
|
747
|
-
|
846
|
+
$LIBPATH = if Regexp.last_match(1).start_with?(PACKAGE_ROOT_DIR + "/")
|
847
|
+
[Regexp.last_match(1)] | $LIBPATH
|
748
848
|
else
|
749
|
-
$LIBPATH
|
849
|
+
$LIBPATH | [Regexp.last_match(1)]
|
750
850
|
end
|
751
851
|
when /\A-l./
|
752
852
|
libs.unshift(arg)
|
753
853
|
else
|
754
|
-
$LDFLAGS <<
|
854
|
+
$LDFLAGS << " " << arg.shellescape
|
755
855
|
end
|
756
856
|
end
|
757
857
|
end
|
758
858
|
|
759
|
-
patches_string = recipe.patch_files.map { |path| File.basename(path) }.join(
|
760
|
-
append_cppflags(%
|
859
|
+
patches_string = recipe.patch_files.map { |path| File.basename(path) }.join(" ")
|
860
|
+
append_cppflags(%[-DNOKOGIRI_#{recipe.name.upcase}_PATCHES="\\\"#{patches_string}\\\""])
|
761
861
|
|
762
862
|
case libname
|
763
|
-
when
|
863
|
+
when "xml2"
|
764
864
|
# xslt-config --libs or pkg-config libxslt --libs does not include
|
765
865
|
# -llzma, so we need to add it manually when linking statically.
|
766
|
-
if static_p && preserving_globals { local_have_library(
|
866
|
+
if static_p && preserving_globals { local_have_library("lzma") }
|
767
867
|
# Add it at the end; GH #988
|
768
|
-
libs <<
|
868
|
+
libs << "-llzma"
|
769
869
|
end
|
770
|
-
when
|
870
|
+
when "xslt"
|
771
871
|
# xslt-config does not have a flag to emit options including
|
772
872
|
# -lexslt, so add it manually.
|
773
|
-
libs.unshift(
|
873
|
+
libs.unshift("-lexslt")
|
774
874
|
end
|
775
875
|
end
|
776
876
|
end.shelljoin
|
@@ -778,10 +878,10 @@ else
|
|
778
878
|
if static_p
|
779
879
|
$libs = $libs.shellsplit.map do |arg|
|
780
880
|
case arg
|
781
|
-
when
|
782
|
-
File.join(libxml2_recipe.path,
|
783
|
-
when
|
784
|
-
File.join(libxslt_recipe.path,
|
881
|
+
when "-lxml2"
|
882
|
+
File.join(libxml2_recipe.path, "lib", libflag_to_filename(arg))
|
883
|
+
when "-lxslt", "-lexslt"
|
884
|
+
File.join(libxslt_recipe.path, "lib", libflag_to_filename(arg))
|
785
885
|
else
|
786
886
|
arg
|
787
887
|
end
|
@@ -793,44 +893,92 @@ else
|
|
793
893
|
ensure_func("exsltFuncRegister", "libexslt/exslt.h")
|
794
894
|
end
|
795
895
|
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
896
|
+
libgumbo_recipe = process_recipe("libgumbo", "1.0.0-nokogiri", static_p, cross_build_p, false) do |recipe|
|
897
|
+
recipe.configure_options = []
|
898
|
+
|
899
|
+
class << recipe
|
900
|
+
def downloaded?
|
901
|
+
true
|
902
|
+
end
|
903
|
+
|
904
|
+
def extract
|
905
|
+
target = File.join(tmp_path, "gumbo-parser")
|
906
|
+
output("Copying gumbo-parser files into #{target}...")
|
907
|
+
FileUtils.mkdir_p(target)
|
908
|
+
FileUtils.cp(Dir.glob(File.join(PACKAGE_ROOT_DIR, "gumbo-parser/src/*")), target)
|
909
|
+
end
|
910
|
+
|
911
|
+
def configured?
|
912
|
+
true
|
913
|
+
end
|
914
|
+
|
915
|
+
def install
|
916
|
+
lib_dir = File.join(port_path, "lib")
|
917
|
+
inc_dir = File.join(port_path, "include")
|
918
|
+
FileUtils.mkdir_p([lib_dir, inc_dir])
|
919
|
+
FileUtils.cp(File.join(work_path, "libgumbo.a"), lib_dir)
|
920
|
+
FileUtils.cp(Dir.glob(File.join(work_path, "*.h")), inc_dir)
|
921
|
+
end
|
922
|
+
|
923
|
+
def compile
|
924
|
+
cflags = concat_flags(ENV["CFLAGS"], "-fPIC", "-g")
|
925
|
+
|
926
|
+
env = { "CC" => gcc_cmd, "CFLAGS" => cflags }
|
927
|
+
if config_cross_build?
|
928
|
+
if host =~ /darwin/
|
929
|
+
env["AR"] = "#{host}-libtool"
|
930
|
+
env["ARFLAGS"] = "-o"
|
931
|
+
else
|
932
|
+
env["AR"] = "#{host}-ar"
|
933
|
+
end
|
934
|
+
env["RANLIB"] = "#{host}-ranlib"
|
935
|
+
end
|
936
|
+
|
937
|
+
execute("compile", make_cmd, { env: env })
|
938
|
+
end
|
939
|
+
end
|
940
|
+
end
|
941
|
+
append_cppflags("-I#{File.join(libgumbo_recipe.path, "include")}")
|
942
|
+
$libs = $libs + " " + File.join(libgumbo_recipe.path, "lib", "libgumbo.a")
|
943
|
+
$LIBPATH = $LIBPATH | [File.join(libgumbo_recipe.path, "lib")]
|
944
|
+
ensure_func("gumbo_parse_with_options", "gumbo.h")
|
945
|
+
|
946
|
+
have_func("xmlHasFeature") || abort("xmlHasFeature() is missing.") # introduced in libxml 2.6.21
|
947
|
+
have_func("xmlFirstElementChild") # introduced in libxml 2.7.3
|
948
|
+
have_func("xmlRelaxNGSetParserStructuredErrors") # introduced in libxml 2.6.24
|
949
|
+
have_func("xmlRelaxNGSetValidStructuredErrors") # introduced in libxml 2.6.21
|
950
|
+
have_func("xmlSchemaSetValidStructuredErrors") # introduced in libxml 2.6.23
|
951
|
+
have_func("xmlSchemaSetParserStructuredErrors") # introduced in libxml 2.6.23
|
802
952
|
|
803
|
-
have_func(
|
953
|
+
have_func("vasprintf")
|
804
954
|
|
805
|
-
other_library_versions_string = OTHER_LIBRARY_VERSIONS.map { |k,v| [k,v].join(":") }.join(",")
|
806
|
-
append_cppflags(%
|
955
|
+
other_library_versions_string = OTHER_LIBRARY_VERSIONS.map { |k, v| [k, v].join(":") }.join(",")
|
956
|
+
append_cppflags(%[-DNOKOGIRI_OTHER_LIBRARY_VERSIONS="\\\"#{other_library_versions_string}\\\""])
|
807
957
|
|
808
|
-
unless
|
958
|
+
unless config_system_libraries?
|
809
959
|
if cross_build_p
|
810
960
|
# When precompiling native gems, copy packaged libraries' headers to ext/nokogiri/include
|
811
961
|
# These are packaged up by the cross-compiling callback in the ExtensionTask
|
812
962
|
copy_packaged_libraries_headers(to_path: File.join(PACKAGE_ROOT_DIR, "ext/nokogiri/include"),
|
813
|
-
|
963
|
+
from_recipes: [libxml2_recipe, libxslt_recipe])
|
814
964
|
else
|
815
965
|
# When compiling during installation, install packaged libraries' header files into ext/nokogiri/include
|
816
966
|
copy_packaged_libraries_headers(to_path: "include",
|
817
|
-
|
967
|
+
from_recipes: [libxml2_recipe, libxslt_recipe])
|
818
968
|
$INSTALLFILES << ["include/**/*.h", "$(rubylibdir)"]
|
819
969
|
end
|
820
970
|
end
|
821
971
|
|
822
|
-
create_makefile(
|
972
|
+
create_makefile("nokogiri/nokogiri")
|
823
973
|
|
824
|
-
if
|
974
|
+
if config_clean?
|
825
975
|
# Do not clean if run in a development work tree.
|
826
|
-
File.open(
|
827
|
-
mk.print
|
976
|
+
File.open("Makefile", "at") do |mk|
|
977
|
+
mk.print(<<~EOF)
|
828
978
|
|
829
979
|
all: clean-ports
|
830
980
|
clean-ports: $(DLLIB)
|
831
|
-
\t-$(Q)$(RUBY) $(srcdir)/extconf.rb --clean --#{static_p ?
|
981
|
+
\t-$(Q)$(RUBY) $(srcdir)/extconf.rb --clean --#{static_p ? "enable" : "disable"}-static
|
832
982
|
EOF
|
833
983
|
end
|
834
984
|
end
|
835
|
-
|
836
|
-
# :startdoc:
|