nokogiri 1.11.0-arm64-darwin → 1.11.4-arm64-darwin
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 +12 -12
- data/LICENSE.md +1 -1
- data/README.md +21 -16
- data/dependencies.yml +12 -12
- data/ext/nokogiri/depend +34 -474
- data/ext/nokogiri/extconf.rb +253 -183
- data/ext/nokogiri/html_document.c +10 -15
- data/ext/nokogiri/html_element_description.c +84 -71
- data/ext/nokogiri/html_entity_lookup.c +21 -16
- data/ext/nokogiri/html_sax_parser_context.c +67 -64
- data/ext/nokogiri/html_sax_push_parser.c +42 -34
- data/ext/nokogiri/include/libxml2/libxml/c14n.h +6 -4
- data/ext/nokogiri/include/libxml2/libxml/parser.h +9 -7
- data/ext/nokogiri/include/libxml2/libxml/tree.h +3 -3
- data/ext/nokogiri/include/libxml2/libxml/xmlIO.h +2 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlexports.h +39 -115
- data/ext/nokogiri/include/libxml2/libxml/xmlschemas.h +1 -1
- data/ext/nokogiri/include/libxml2/libxml/xmlversion.h +6 -6
- data/ext/nokogiri/include/libxml2/libxml/xpath.h +1 -3
- data/ext/nokogiri/libxml2_backwards_compat.c +121 -0
- data/ext/nokogiri/nokogiri.c +171 -60
- data/ext/nokogiri/nokogiri.h +158 -75
- data/ext/nokogiri/test_global_handlers.c +40 -0
- 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 +246 -188
- data/ext/nokogiri/xml_document_fragment.c +13 -15
- data/ext/nokogiri/xml_dtd.c +54 -48
- data/ext/nokogiri/xml_element_content.c +30 -27
- data/ext/nokogiri/xml_element_decl.c +22 -22
- data/ext/nokogiri/xml_encoding_handler.c +17 -11
- data/ext/nokogiri/xml_entity_decl.c +32 -30
- data/ext/nokogiri/xml_entity_reference.c +16 -18
- data/ext/nokogiri/xml_namespace.c +56 -49
- data/ext/nokogiri/xml_node.c +371 -320
- data/ext/nokogiri/xml_node_set.c +168 -156
- data/ext/nokogiri/xml_processing_instruction.c +17 -19
- data/ext/nokogiri/xml_reader.c +191 -157
- data/ext/nokogiri/xml_relax_ng.c +29 -23
- data/ext/nokogiri/xml_sax_parser.c +117 -112
- data/ext/nokogiri/xml_sax_parser_context.c +101 -84
- data/ext/nokogiri/xml_sax_push_parser.c +36 -27
- data/ext/nokogiri/xml_schema.c +48 -42
- data/ext/nokogiri/xml_syntax_error.c +42 -21
- data/ext/nokogiri/xml_text.c +13 -17
- data/ext/nokogiri/xml_xpath_context.c +134 -127
- data/ext/nokogiri/xslt_stylesheet.c +157 -157
- data/lib/nokogiri.rb +1 -22
- data/lib/nokogiri/2.5/nokogiri.bundle +0 -0
- data/lib/nokogiri/2.6/nokogiri.bundle +0 -0
- data/lib/nokogiri/2.7/nokogiri.bundle +0 -0
- data/lib/nokogiri/3.0/nokogiri.bundle +0 -0
- data/lib/nokogiri/css/parser.rb +1 -1
- data/lib/nokogiri/extension.rb +26 -0
- data/lib/nokogiri/html/document_fragment.rb +15 -15
- data/lib/nokogiri/version/constant.rb +1 -1
- data/lib/nokogiri/version/info.rb +31 -8
- data/lib/nokogiri/xml/document.rb +74 -28
- data/lib/nokogiri/xml/node.rb +39 -42
- data/lib/nokogiri/xml/reader.rb +2 -9
- data/lib/nokogiri/xml/xpath.rb +1 -3
- data/lib/nokogiri/xml/xpath/syntax_error.rb +1 -1
- metadata +11 -43
- data/ext/nokogiri/html_document.h +0 -10
- data/ext/nokogiri/html_element_description.h +0 -10
- data/ext/nokogiri/html_entity_lookup.h +0 -8
- 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 -13
- 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/ext/nokogiri/extconf.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# :
|
1
|
+
# frozen_string_literal: true
|
2
2
|
ENV['RC_ARCHS'] = '' if RUBY_PLATFORM =~ /darwin/
|
3
3
|
|
4
4
|
require "mkmf"
|
@@ -7,9 +7,7 @@ require "fileutils"
|
|
7
7
|
require "shellwords"
|
8
8
|
require "pathname"
|
9
9
|
|
10
|
-
#
|
11
|
-
# helpful constants
|
12
|
-
#
|
10
|
+
# helpful constants
|
13
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"
|
@@ -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,82 @@ 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.
|
45
78
|
|
46
|
-
|
47
|
-
|
79
|
+
--with-iconv-include=DIRECTORY
|
80
|
+
Look for iconv headers in DIRECTORY.
|
48
81
|
|
49
|
-
--with-iconv-dir=DIRECTORY
|
50
|
-
Look for iconv header and library in DIRECTORY
|
51
82
|
|
52
|
-
|
53
|
-
Look for xml2 headers and library in DIRECTORY
|
83
|
+
Related to libxml2:
|
54
84
|
|
55
|
-
|
56
|
-
|
85
|
+
--with-xml2-dir=DIRECTORY
|
86
|
+
Look for xml2 headers and library in DIRECTORY.
|
57
87
|
|
58
|
-
|
59
|
-
|
88
|
+
--with-xml2-lib=DIRECTORY
|
89
|
+
Look for xml2 library in DIRECTORY.
|
60
90
|
|
61
|
-
|
62
|
-
|
91
|
+
--with-xml2-include=DIRECTORY
|
92
|
+
Look for xml2 headers in DIRECTORY.
|
63
93
|
|
64
|
-
--with-xslt-lib=DIRECTORY
|
65
|
-
Look for xslt library in DIRECTORY
|
66
94
|
|
67
|
-
|
68
|
-
Look for xslt headers in DIRECTORY
|
95
|
+
Related to libxslt:
|
69
96
|
|
70
|
-
|
71
|
-
|
97
|
+
--with-xslt-dir=DIRECTORY
|
98
|
+
Look for xslt headers and library in DIRECTORY.
|
72
99
|
|
73
|
-
|
74
|
-
|
100
|
+
--with-xslt-lib=DIRECTORY
|
101
|
+
Look for xslt library in DIRECTORY.
|
75
102
|
|
76
|
-
|
77
|
-
|
103
|
+
--with-xslt-include=DIRECTORY
|
104
|
+
Look for xslt headers in DIRECTORY.
|
105
|
+
|
106
|
+
|
107
|
+
Related to libexslt:
|
108
|
+
|
109
|
+
--with-exslt-dir=DIRECTORY
|
110
|
+
Look for exslt headers and library in DIRECTORY.
|
111
|
+
|
112
|
+
--with-exslt-lib=DIRECTORY
|
113
|
+
Look for exslt library in DIRECTORY.
|
114
|
+
|
115
|
+
--with-exslt-include=DIRECTORY
|
116
|
+
Look for exslt headers in DIRECTORY.
|
78
117
|
|
79
118
|
|
80
119
|
Flags only used when building and using the packaged libraries:
|
81
120
|
|
82
121
|
--disable-static
|
83
|
-
Do not statically link packaged libraries, instead use shared libraries
|
122
|
+
Do not statically link packaged libraries, instead use shared libraries.
|
84
123
|
|
85
124
|
--enable-cross-build
|
86
125
|
Enable cross-build mode. (You probably do not want to set this manually.)
|
@@ -89,8 +128,7 @@ NOKOGIRI_HELP_MESSAGE = <<~HELP
|
|
89
128
|
Environment variables used:
|
90
129
|
|
91
130
|
NOKOGIRI_USE_SYSTEM_LIBRARIES
|
92
|
-
|
93
|
-
packaged libraries. Equivalent to `--use-system-libraries`.
|
131
|
+
Equivalent to `--enable-system-libraries` when set, even if nil or blank.
|
94
132
|
|
95
133
|
CC
|
96
134
|
Use this path to invoke the compiler instead of `RbConfig::CONFIG['CC']`
|
@@ -111,6 +149,25 @@ HELP
|
|
111
149
|
#
|
112
150
|
# utility functions
|
113
151
|
#
|
152
|
+
def config_clean?
|
153
|
+
enable_config('clean', true)
|
154
|
+
end
|
155
|
+
|
156
|
+
def config_static?
|
157
|
+
default_static = !truffle?
|
158
|
+
enable_config("static", default_static)
|
159
|
+
end
|
160
|
+
|
161
|
+
def config_cross_build?
|
162
|
+
enable_config("cross-build")
|
163
|
+
end
|
164
|
+
|
165
|
+
def config_system_libraries?
|
166
|
+
enable_config("system-libraries", ENV.key?("NOKOGIRI_USE_SYSTEM_LIBRARIES")) do |_, default|
|
167
|
+
arg_config('--use-system-libraries', default)
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
114
171
|
def windows?
|
115
172
|
RbConfig::CONFIG['target_os'] =~ /mingw32|mswin/
|
116
173
|
end
|
@@ -132,15 +189,19 @@ def aix?
|
|
132
189
|
end
|
133
190
|
|
134
191
|
def nix?
|
135
|
-
!
|
192
|
+
!(windows? || solaris? || darwin?)
|
136
193
|
end
|
137
194
|
|
138
|
-
def
|
195
|
+
def truffle?
|
196
|
+
::RUBY_ENGINE == 'truffleruby'
|
197
|
+
end
|
198
|
+
|
199
|
+
def concat_flags(*args)
|
139
200
|
args.compact.join(" ")
|
140
201
|
end
|
141
202
|
|
142
|
-
def local_have_library(lib, func=nil, headers=nil)
|
143
|
-
have_library(lib, func, headers)
|
203
|
+
def local_have_library(lib, func = nil, headers = nil)
|
204
|
+
have_library(lib, func, headers) || have_library("lib#{lib}", func, headers)
|
144
205
|
end
|
145
206
|
|
146
207
|
LOCAL_PACKAGE_RESPONSE = Object.new
|
@@ -150,7 +211,7 @@ end
|
|
150
211
|
|
151
212
|
# wrapper around MakeMakefil#pkg_config and the PKGConfig gem
|
152
213
|
def try_package_configuration(pc)
|
153
|
-
|
214
|
+
unless ENV.key?("NOKOGIRI_TEST_PKG_CONFIG_GEM")
|
154
215
|
# try MakeMakefile#pkg_config, which uses the system utility `pkg-config`.
|
155
216
|
return if checking_for("#{pc} using `pkg_config`", LOCAL_PACKAGE_RESPONSE) do
|
156
217
|
pkg_config(pc)
|
@@ -162,7 +223,7 @@ def try_package_configuration(pc)
|
|
162
223
|
# same logic as MakeMakefile#pkg_config
|
163
224
|
begin
|
164
225
|
require 'rubygems'
|
165
|
-
gem
|
226
|
+
gem('pkg-config', REQUIRED_PKG_CONFIG_VERSION)
|
166
227
|
require 'pkg-config'
|
167
228
|
|
168
229
|
checking_for("#{pc} using pkg-config gem version #{PKGConfig::VERSION}", LOCAL_PACKAGE_RESPONSE) do
|
@@ -171,14 +232,14 @@ def try_package_configuration(pc)
|
|
171
232
|
ldflags = PKGConfig.libs_only_L(pc)
|
172
233
|
libs = PKGConfig.libs_only_l(pc)
|
173
234
|
|
174
|
-
Logging
|
175
|
-
Logging
|
235
|
+
Logging.message("pkg-config gem found package configuration for %s\n", pc)
|
236
|
+
Logging.message("cflags: %s\nldflags: %s\nlibs: %s\n\n", cflags, ldflags, libs)
|
176
237
|
|
177
238
|
[cflags, ldflags, libs]
|
178
239
|
end
|
179
240
|
end
|
180
241
|
rescue LoadError
|
181
|
-
message
|
242
|
+
message("Please install either the `pkg-config` utility or the `pkg-config` rubygem.\n")
|
182
243
|
end
|
183
244
|
end
|
184
245
|
|
@@ -190,7 +251,7 @@ def have_package_configuration(opt: nil, pc: nil, lib:, func:, headers:)
|
|
190
251
|
end
|
191
252
|
|
192
253
|
# see if we have enough path info to do this without trying any harder
|
193
|
-
|
254
|
+
unless ENV.key?("NOKOGIRI_TEST_PKG_CONFIG")
|
194
255
|
return true if local_have_library(lib, func, headers)
|
195
256
|
end
|
196
257
|
|
@@ -201,12 +262,12 @@ def have_package_configuration(opt: nil, pc: nil, lib:, func:, headers:)
|
|
201
262
|
end
|
202
263
|
|
203
264
|
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)
|
265
|
+
have_package_configuration(opt: opt, pc: pc, lib: lib, func: func, headers: headers) ||
|
205
266
|
abort_could_not_find_library(lib)
|
206
267
|
end
|
207
268
|
|
208
|
-
def ensure_func(func, headers=nil)
|
209
|
-
have_func(func, headers)
|
269
|
+
def ensure_func(func, headers = nil)
|
270
|
+
have_func(func, headers) || abort_could_not_find_library(func)
|
210
271
|
end
|
211
272
|
|
212
273
|
def preserving_globals
|
@@ -217,7 +278,7 @@ ensure
|
|
217
278
|
end
|
218
279
|
|
219
280
|
def abort_could_not_find_library(lib)
|
220
|
-
abort
|
281
|
+
abort("-----\n#{caller[0]}\n#{lib} is missing. Please locate mkmf.log to investigate how it is failing.\n-----")
|
221
282
|
end
|
222
283
|
|
223
284
|
def chdir_for_build
|
@@ -230,7 +291,7 @@ def chdir_for_build
|
|
230
291
|
end
|
231
292
|
end
|
232
293
|
|
233
|
-
def sh_export_path
|
294
|
+
def sh_export_path(path)
|
234
295
|
# because libxslt 1.1.29 configure.in uses AC_PATH_TOOL which treats ":"
|
235
296
|
# as a $PATH separator, we need to convert windows paths from
|
236
297
|
#
|
@@ -242,7 +303,7 @@ def sh_export_path path
|
|
242
303
|
#
|
243
304
|
# which is sh-compatible, in order to find things properly during
|
244
305
|
# configuration
|
245
|
-
return path
|
306
|
+
return path unless windows?
|
246
307
|
|
247
308
|
match = Regexp.new("^([A-Z]):(/.*)").match(path)
|
248
309
|
if match && match.length == 3
|
@@ -255,31 +316,26 @@ end
|
|
255
316
|
def libflag_to_filename(ldflag)
|
256
317
|
case ldflag
|
257
318
|
when /\A-l(.+)/
|
258
|
-
"lib#{
|
319
|
+
"lib#{Regexp.last_match(1)}.#{$LIBEXT}"
|
259
320
|
end
|
260
321
|
end
|
261
322
|
|
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)
|
323
|
+
def have_libxml_headers?(version = nil)
|
268
324
|
source = if version.nil?
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
try_cpp
|
325
|
+
<<~SRC
|
326
|
+
#include <libxml/xmlversion.h>
|
327
|
+
SRC
|
328
|
+
else
|
329
|
+
version_int = format("%d%2.2d%2.2d", *version.split("."))
|
330
|
+
<<~SRC
|
331
|
+
#include <libxml/xmlversion.h>
|
332
|
+
#if LIBXML_VERSION < #{version_int}
|
333
|
+
# error libxml2 is older than #{version}
|
334
|
+
#endif
|
335
|
+
SRC
|
336
|
+
end
|
337
|
+
|
338
|
+
try_cpp(source)
|
283
339
|
end
|
284
340
|
|
285
341
|
def try_link_iconv(using = nil)
|
@@ -307,19 +363,18 @@ def iconv_configure_flags
|
|
307
363
|
# give --with-iconv-dir and --with-opt-dir first priority
|
308
364
|
["iconv", "opt"].each do |target|
|
309
365
|
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
|
-
]
|
366
|
+
next unless config.any? && try_link_iconv("--with-#{target}-* flags") { dir_config(target) }
|
367
|
+
idirs, ldirs = config.map do |dirs|
|
368
|
+
Array(dirs).flat_map do |dir|
|
369
|
+
dir.split(File::PATH_SEPARATOR)
|
370
|
+
end if dirs
|
322
371
|
end
|
372
|
+
|
373
|
+
return [
|
374
|
+
'--with-iconv=yes',
|
375
|
+
*("CPPFLAGS=#{idirs.map { |dir| '-I' + dir }.join(' ')}" if idirs),
|
376
|
+
*("LDFLAGS=#{ldirs.map { |dir| '-L' + dir }.join(' ')}" if ldirs),
|
377
|
+
]
|
323
378
|
end
|
324
379
|
|
325
380
|
if try_link_iconv
|
@@ -338,14 +393,14 @@ def iconv_configure_flags
|
|
338
393
|
]
|
339
394
|
end
|
340
395
|
|
341
|
-
abort_could_not_find_library
|
396
|
+
abort_could_not_find_library("libiconv")
|
342
397
|
end
|
343
398
|
|
344
399
|
def process_recipe(name, version, static_p, cross_p)
|
345
400
|
require 'rubygems'
|
346
|
-
gem
|
401
|
+
gem('mini_portile2', REQUIRED_MINI_PORTILE_VERSION)
|
347
402
|
require 'mini_portile2'
|
348
|
-
message
|
403
|
+
message("Using mini_portile version #{MiniPortile::VERSION}\n")
|
349
404
|
|
350
405
|
if name != "libxml2" && name != "libxslt"
|
351
406
|
OTHER_LIBRARY_VERSIONS[name] = version
|
@@ -357,12 +412,12 @@ def process_recipe(name, version, static_p, cross_p)
|
|
357
412
|
# correct compiler prefix for cross build, but use host if not set.
|
358
413
|
recipe.host = RbConfig::CONFIG["host_alias"].empty? ? RbConfig::CONFIG["host"] : RbConfig::CONFIG["host_alias"]
|
359
414
|
recipe.patch_files = Dir[File.join(PACKAGE_ROOT_DIR, "patches", name, "*.patch")].sort
|
360
|
-
recipe.configure_options << "--libdir=#{File.join(recipe.path,
|
415
|
+
recipe.configure_options << "--libdir=#{File.join(recipe.path, 'lib')}"
|
361
416
|
|
362
417
|
yield recipe
|
363
418
|
|
364
419
|
env = Hash.new do |hash, key|
|
365
|
-
hash[key] =
|
420
|
+
hash[key] = (ENV[key]).to_s
|
366
421
|
end
|
367
422
|
|
368
423
|
recipe.configure_options.flatten!
|
@@ -370,10 +425,10 @@ def process_recipe(name, version, static_p, cross_p)
|
|
370
425
|
recipe.configure_options.delete_if do |option|
|
371
426
|
case option
|
372
427
|
when /\A(\w+)=(.*)\z/
|
373
|
-
if env.key?(
|
374
|
-
|
428
|
+
env[Regexp.last_match(1)] = if env.key?(Regexp.last_match(1))
|
429
|
+
concat_flags(env[Regexp.last_match(1)], Regexp.last_match(2))
|
375
430
|
else
|
376
|
-
|
431
|
+
Regexp.last_match(2)
|
377
432
|
end
|
378
433
|
true
|
379
434
|
else
|
@@ -415,34 +470,34 @@ def process_recipe(name, version, static_p, cross_p)
|
|
415
470
|
|
416
471
|
checkpoint = "#{recipe.target}/#{recipe.name}-#{recipe.version}-#{recipe.host}.installed"
|
417
472
|
if File.exist?(checkpoint)
|
418
|
-
message
|
473
|
+
message("Building Nokogiri with a packaged version of #{name}-#{version}.\n")
|
419
474
|
else
|
420
|
-
message
|
475
|
+
message(<<~EOM)
|
421
476
|
---------- IMPORTANT NOTICE ----------
|
422
477
|
Building Nokogiri with a packaged version of #{name}-#{version}.
|
423
478
|
Configuration options: #{recipe.configure_options.shelljoin}
|
424
479
|
EOM
|
425
480
|
|
426
481
|
unless recipe.patch_files.empty?
|
427
|
-
message
|
482
|
+
message("The following patches are being applied:\n")
|
428
483
|
|
429
484
|
recipe.patch_files.each do |patch|
|
430
|
-
message
|
485
|
+
message(" - %s\n" % File.basename(patch))
|
431
486
|
end
|
432
487
|
end
|
433
488
|
|
434
|
-
message
|
489
|
+
message(<<~EOM)
|
435
490
|
|
436
491
|
The Nokogiri maintainers intend to provide timely security updates, but if
|
437
492
|
this is a concern for you and want to use your OS/distro system library
|
438
493
|
instead, then abort this installation process and install nokogiri as
|
439
494
|
instructed at:
|
440
495
|
|
441
|
-
https://nokogiri.org/tutorials/installing_nokogiri.html#
|
496
|
+
https://nokogiri.org/tutorials/installing_nokogiri.html#installing-using-standard-system-libraries
|
442
497
|
|
443
498
|
EOM
|
444
499
|
|
445
|
-
message
|
500
|
+
message(<<~EOM) if name == 'libxml2'
|
446
501
|
Note, however, that nokogiri cannot guarantee compatiblity with every
|
447
502
|
version of libxml2 that may be provided by OS/package vendors.
|
448
503
|
|
@@ -451,7 +506,7 @@ def process_recipe(name, version, static_p, cross_p)
|
|
451
506
|
chdir_for_build do
|
452
507
|
recipe.cook
|
453
508
|
end
|
454
|
-
FileUtils.touch
|
509
|
+
FileUtils.touch(checkpoint)
|
455
510
|
end
|
456
511
|
recipe.activate
|
457
512
|
end
|
@@ -466,8 +521,8 @@ def copy_packaged_libraries_headers(to_path:, from_recipes:)
|
|
466
521
|
end
|
467
522
|
|
468
523
|
def do_help
|
469
|
-
print
|
470
|
-
exit!
|
524
|
+
print(NOKOGIRI_HELP_MESSAGE)
|
525
|
+
exit!(0)
|
471
526
|
end
|
472
527
|
|
473
528
|
def do_clean
|
@@ -476,7 +531,7 @@ def do_clean
|
|
476
531
|
|
477
532
|
# Skip if this is a development work tree
|
478
533
|
unless (root + '.git').exist?
|
479
|
-
message
|
534
|
+
message("Cleaning files only used during build.\n")
|
480
535
|
|
481
536
|
# (root + 'tmp') cannot be removed at this stage because
|
482
537
|
# nokogiri.so is yet to be copied to lib.
|
@@ -486,7 +541,7 @@ def do_clean
|
|
486
541
|
FileUtils.rm_rf(dir, verbose: true)
|
487
542
|
end
|
488
543
|
|
489
|
-
if
|
544
|
+
if config_static?
|
490
545
|
# ports installation can be safely removed if statically linked.
|
491
546
|
FileUtils.rm_rf(root + 'ports', verbose: true)
|
492
547
|
else
|
@@ -494,7 +549,7 @@ def do_clean
|
|
494
549
|
end
|
495
550
|
end
|
496
551
|
|
497
|
-
exit!
|
552
|
+
exit!(0)
|
498
553
|
end
|
499
554
|
|
500
555
|
#
|
@@ -503,10 +558,10 @@ end
|
|
503
558
|
do_help if arg_config('--help')
|
504
559
|
do_clean if arg_config('--clean')
|
505
560
|
|
506
|
-
if openbsd? && !
|
507
|
-
if
|
508
|
-
ENV['CC'] ||= find_executable('egcc')
|
509
|
-
abort
|
561
|
+
if openbsd? && !config_system_libraries?
|
562
|
+
if %x(#{ENV['CC'] || '/usr/bin/cc'} -v 2>&1) !~ /clang/
|
563
|
+
(ENV['CC'] ||= find_executable('egcc')) ||
|
564
|
+
abort("Please install gcc 4.9+ from ports using `pkg_add -v gcc`")
|
510
565
|
end
|
511
566
|
append_cppflags "-I/usr/local/include"
|
512
567
|
end
|
@@ -531,20 +586,29 @@ if arg_config('--prevent-strip')
|
|
531
586
|
end
|
532
587
|
|
533
588
|
# adopt environment config
|
534
|
-
append_cflags(ENV["CFLAGS"].split)
|
535
|
-
append_cppflags(ENV["CPPFLAGS"].split)
|
536
|
-
append_ldflags(ENV["LDFLAGS"].split)
|
589
|
+
append_cflags(ENV["CFLAGS"].split) unless ENV["CFLAGS"].nil?
|
590
|
+
append_cppflags(ENV["CPPFLAGS"].split) unless ENV["CPPFLAGS"].nil?
|
591
|
+
append_ldflags(ENV["LDFLAGS"].split) unless ENV["LDFLAGS"].nil?
|
537
592
|
$LIBS = concat_flags($LIBS, ENV["LIBS"])
|
538
593
|
|
539
|
-
|
540
|
-
append_cflags("-
|
541
|
-
|
594
|
+
# always include debugging information
|
595
|
+
append_cflags("-g")
|
596
|
+
|
597
|
+
# we use at least one inline function in the C extension
|
598
|
+
append_cflags("-Winline")
|
599
|
+
|
600
|
+
# good to have no matter what Ruby was compiled with
|
601
|
+
append_cflags("-Wmissing-noreturn")
|
602
|
+
|
603
|
+
# handle clang variations, see #1101
|
542
604
|
append_cflags("-Wno-error=unused-command-line-argument-hard-error-in-future") if darwin?
|
543
|
-
|
605
|
+
|
606
|
+
# these tend to be noisy, but on occasion useful during development
|
607
|
+
# append_cflags(["-Wcast-qual", "-Wwrite-strings"])
|
544
608
|
|
545
609
|
# Add SDK-specific include path for macOS and brew versions before v2.2.12 (2020-04-08) [#1851, #1801]
|
546
610
|
macos_mojave_sdk_include_path = "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/libxml2"
|
547
|
-
if
|
611
|
+
if config_system_libraries? && darwin? && Dir.exist?(macos_mojave_sdk_include_path)
|
548
612
|
append_cppflags("-I#{macos_mojave_sdk_include_path}")
|
549
613
|
end
|
550
614
|
|
@@ -552,26 +616,30 @@ end
|
|
552
616
|
# See https://sourceforge.net/p/mingw/bugs/2142
|
553
617
|
append_cppflags(' "-Idummypath"') if windows?
|
554
618
|
|
555
|
-
if
|
619
|
+
if config_system_libraries?
|
556
620
|
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
|
-
|
621
|
+
ensure_package_configuration(opt: "zlib", pc: "zlib", lib: "z",
|
622
|
+
headers: "zlib.h", func: "gzdopen")
|
623
|
+
ensure_package_configuration(opt: "xml2", pc: "libxml-2.0", lib: "xml2",
|
624
|
+
headers: "libxml/parser.h", func: "xmlParseDoc")
|
625
|
+
ensure_package_configuration(opt: "xslt", pc: "libxslt", lib: "xslt",
|
626
|
+
headers: "libxslt/xslt.h", func: "xsltParseStylesheetDoc")
|
627
|
+
ensure_package_configuration(opt: "exslt", pc: "libexslt", lib: "exslt",
|
628
|
+
headers: "libexslt/exslt.h", func: "exsltFuncRegister")
|
629
|
+
|
630
|
+
have_libxml_headers?(REQUIRED_LIBXML_VERSION) ||
|
631
|
+
abort("ERROR: libxml2 version #{REQUIRED_LIBXML_VERSION} or later is required!")
|
632
|
+
have_libxml_headers?(RECOMMENDED_LIBXML_VERSION) ||
|
633
|
+
warn("WARNING: libxml2 version #{RECOMMENDED_LIBXML_VERSION} or later is highly recommended, but proceeding anyway.")
|
566
634
|
|
567
635
|
else
|
568
636
|
message "Building nokogiri using packaged libraries.\n"
|
569
637
|
|
570
|
-
static_p =
|
571
|
-
message "Static linking is #{static_p ?
|
638
|
+
static_p = config_static?
|
639
|
+
message "Static linking is #{static_p ? 'enabled' : 'disabled'}.\n"
|
572
640
|
|
573
|
-
cross_build_p =
|
574
|
-
message "Cross build is #{cross_build_p ?
|
641
|
+
cross_build_p = config_cross_build?
|
642
|
+
message "Cross build is #{cross_build_p ? 'enabled' : 'disabled'}.\n"
|
575
643
|
|
576
644
|
require 'yaml'
|
577
645
|
dependencies = YAML.load_file(File.join(PACKAGE_ROOT_DIR, "dependencies.yml"))
|
@@ -581,17 +649,17 @@ else
|
|
581
649
|
if cross_build_p || windows?
|
582
650
|
zlib_recipe = process_recipe("zlib", dependencies["zlib"]["version"], static_p, cross_build_p) do |recipe|
|
583
651
|
recipe.files = [{
|
584
|
-
|
585
|
-
|
586
|
-
|
652
|
+
url: "http://zlib.net/fossils/#{recipe.name}-#{recipe.version}.tar.gz",
|
653
|
+
sha256: dependencies["zlib"]["sha256"],
|
654
|
+
}]
|
587
655
|
if windows?
|
588
656
|
class << recipe
|
589
657
|
attr_accessor :cross_build_p
|
590
658
|
|
591
659
|
def configure
|
592
|
-
Dir.chdir
|
593
|
-
mk = File.read
|
594
|
-
File.open
|
660
|
+
Dir.chdir(work_path) do
|
661
|
+
mk = File.read('win32/Makefile.gcc')
|
662
|
+
File.open('win32/Makefile.gcc', 'wb') do |f|
|
595
663
|
f.puts "BINARY_PATH = #{path}/bin"
|
596
664
|
f.puts "LIBRARY_PATH = #{path}/lib"
|
597
665
|
f.puts "INCLUDE_PATH = #{path}/include"
|
@@ -602,17 +670,17 @@ else
|
|
602
670
|
end
|
603
671
|
|
604
672
|
def configured?
|
605
|
-
Dir.chdir
|
606
|
-
!!
|
673
|
+
Dir.chdir(work_path) do
|
674
|
+
!!(File.read('win32/Makefile.gcc') =~ /^BINARY_PATH/)
|
607
675
|
end
|
608
676
|
end
|
609
677
|
|
610
678
|
def compile
|
611
|
-
execute
|
679
|
+
execute("compile", "make -f win32/Makefile.gcc")
|
612
680
|
end
|
613
681
|
|
614
682
|
def install
|
615
|
-
execute
|
683
|
+
execute("install", "make -f win32/Makefile.gcc install")
|
616
684
|
end
|
617
685
|
end
|
618
686
|
recipe.cross_build_p = cross_build_p
|
@@ -620,12 +688,13 @@ else
|
|
620
688
|
class << recipe
|
621
689
|
def configure
|
622
690
|
cflags = concat_flags(ENV["CFLAGS"], "-fPIC", "-g")
|
623
|
-
execute
|
691
|
+
execute("configure",
|
692
|
+
["env", "CHOST=#{host}", "CFLAGS=#{cflags}", "./configure", "--static", configure_prefix])
|
624
693
|
end
|
625
694
|
|
626
695
|
def compile
|
627
|
-
if host
|
628
|
-
execute
|
696
|
+
if host =~ /darwin/
|
697
|
+
execute("compile", "make AR=#{host}-libtool")
|
629
698
|
else
|
630
699
|
super
|
631
700
|
end
|
@@ -635,11 +704,12 @@ else
|
|
635
704
|
end
|
636
705
|
|
637
706
|
unless nix?
|
638
|
-
libiconv_recipe = process_recipe("libiconv", dependencies["libiconv"]["version"], static_p,
|
707
|
+
libiconv_recipe = process_recipe("libiconv", dependencies["libiconv"]["version"], static_p,
|
708
|
+
cross_build_p) do |recipe|
|
639
709
|
recipe.files = [{
|
640
|
-
|
641
|
-
|
642
|
-
|
710
|
+
url: "http://ftp.gnu.org/pub/gnu/libiconv/#{recipe.name}-#{recipe.version}.tar.gz",
|
711
|
+
sha256: dependencies["libiconv"]["sha256"],
|
712
|
+
}]
|
643
713
|
|
644
714
|
cflags = concat_flags(ENV["CFLAGS"], "-O2", "-U_FORTIFY_SOURCE", "-g")
|
645
715
|
|
@@ -647,37 +717,35 @@ else
|
|
647
717
|
"CPPFLAGS=-Wall",
|
648
718
|
"CFLAGS=#{cflags}",
|
649
719
|
"CXXFLAGS=#{cflags}",
|
650
|
-
"LDFLAGS="
|
720
|
+
"LDFLAGS=",
|
651
721
|
]
|
652
722
|
end
|
653
723
|
end
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
-----
|
724
|
+
elsif darwin? && !have_header('iconv.h')
|
725
|
+
abort(<<~EOM.chomp)
|
726
|
+
-----
|
727
|
+
The file "iconv.h" is missing in your build environment,
|
728
|
+
which means you haven't installed Xcode Command Line Tools properly.
|
729
|
+
|
730
|
+
To install Command Line Tools, try running `xcode-select --install` on
|
731
|
+
terminal and follow the instructions. If it fails, open Xcode.app,
|
732
|
+
select from the menu "Xcode" - "Open Developer Tool" - "More Developer
|
733
|
+
Tools" to open the developer site, download the installer for your OS
|
734
|
+
version and run it.
|
735
|
+
-----
|
667
736
|
EOM
|
668
|
-
end
|
669
737
|
end
|
670
738
|
|
671
739
|
unless windows?
|
672
|
-
preserving_globals { local_have_library('z', 'gzdopen', 'zlib.h') }
|
673
|
-
abort
|
740
|
+
preserving_globals { local_have_library('z', 'gzdopen', 'zlib.h') } ||
|
741
|
+
abort('zlib is missing; necessary for building libxml2')
|
674
742
|
end
|
675
743
|
|
676
744
|
libxml2_recipe = process_recipe("libxml2", dependencies["libxml2"]["version"], static_p, cross_build_p) do |recipe|
|
677
745
|
recipe.files = [{
|
678
|
-
|
679
|
-
|
680
|
-
|
746
|
+
url: "http://xmlsoft.org/sources/#{recipe.name}-#{recipe.version}.tar.gz",
|
747
|
+
sha256: dependencies["libxml2"]["sha256"],
|
748
|
+
}]
|
681
749
|
|
682
750
|
cflags = concat_flags(ENV["CFLAGS"], "-O2", "-U_FORTIFY_SOURCE", "-g")
|
683
751
|
|
@@ -696,6 +764,10 @@ else
|
|
696
764
|
recipe.configure_options += ["RANLIB=/usr/bin/ranlib", "AR=/usr/bin/ar"]
|
697
765
|
end
|
698
766
|
|
767
|
+
if windows?
|
768
|
+
cflags = concat_flags(cflags, "-ULIBXML_STATIC", "-DIN_LIBXML")
|
769
|
+
end
|
770
|
+
|
699
771
|
recipe.configure_options += [
|
700
772
|
"--without-python",
|
701
773
|
"--without-readline",
|
@@ -708,9 +780,9 @@ else
|
|
708
780
|
|
709
781
|
libxslt_recipe = process_recipe("libxslt", dependencies["libxslt"]["version"], static_p, cross_build_p) do |recipe|
|
710
782
|
recipe.files = [{
|
711
|
-
|
712
|
-
|
713
|
-
|
783
|
+
url: "http://xmlsoft.org/sources/#{recipe.name}-#{recipe.version}.tar.gz",
|
784
|
+
sha256: dependencies["libxslt"]["sha256"],
|
785
|
+
}]
|
714
786
|
|
715
787
|
cflags = concat_flags(ENV["CFLAGS"], "-O2", "-U_FORTIFY_SOURCE", "-g")
|
716
788
|
|
@@ -738,15 +810,15 @@ else
|
|
738
810
|
libname = recipe.name[/\Alib(.+)\z/, 1]
|
739
811
|
File.join(recipe.path, "bin", "#{libname}-config").tap do |config|
|
740
812
|
# call config scripts explicit with 'sh' for compat with Windows
|
741
|
-
$CPPFLAGS =
|
742
|
-
|
813
|
+
$CPPFLAGS = %x(sh #{config} --cflags).strip << ' ' << $CPPFLAGS
|
814
|
+
%x(sh #{config} --libs).strip.shellsplit.each do |arg|
|
743
815
|
case arg
|
744
816
|
when /\A-L(.+)\z/
|
745
817
|
# Prioritize ports' directories
|
746
|
-
if
|
747
|
-
|
818
|
+
$LIBPATH = if Regexp.last_match(1).start_with?(PACKAGE_ROOT_DIR + '/')
|
819
|
+
[Regexp.last_match(1)] | $LIBPATH
|
748
820
|
else
|
749
|
-
$LIBPATH
|
821
|
+
$LIBPATH | [Regexp.last_match(1)]
|
750
822
|
end
|
751
823
|
when /\A-l./
|
752
824
|
libs.unshift(arg)
|
@@ -757,7 +829,7 @@ else
|
|
757
829
|
end
|
758
830
|
|
759
831
|
patches_string = recipe.patch_files.map { |path| File.basename(path) }.join(' ')
|
760
|
-
append_cppflags(%
|
832
|
+
append_cppflags(%[-DNOKOGIRI_#{recipe.name.upcase}_PATCHES="\\\"#{patches_string}\\\""])
|
761
833
|
|
762
834
|
case libname
|
763
835
|
when 'xml2'
|
@@ -793,7 +865,7 @@ else
|
|
793
865
|
ensure_func("exsltFuncRegister", "libexslt/exslt.h")
|
794
866
|
end
|
795
867
|
|
796
|
-
have_func('xmlHasFeature')
|
868
|
+
have_func('xmlHasFeature') || abort("xmlHasFeature() is missing.") # introduced in libxml 2.6.21
|
797
869
|
have_func('xmlFirstElementChild') # introduced in libxml 2.7.3
|
798
870
|
have_func('xmlRelaxNGSetParserStructuredErrors') # introduced in libxml 2.6.24
|
799
871
|
have_func('xmlRelaxNGSetValidStructuredErrors') # introduced in libxml 2.6.21
|
@@ -802,10 +874,10 @@ have_func('xmlSchemaSetParserStructuredErrors') # introduced in libxml 2.6.23
|
|
802
874
|
|
803
875
|
have_func('vasprintf')
|
804
876
|
|
805
|
-
other_library_versions_string = OTHER_LIBRARY_VERSIONS.map { |k,v| [k,v].join(":") }.join(",")
|
806
|
-
append_cppflags(%
|
877
|
+
other_library_versions_string = OTHER_LIBRARY_VERSIONS.map { |k, v| [k, v].join(":") }.join(",")
|
878
|
+
append_cppflags(%[-DNOKOGIRI_OTHER_LIBRARY_VERSIONS="\\\"#{other_library_versions_string}\\\""])
|
807
879
|
|
808
|
-
unless
|
880
|
+
unless config_system_libraries?
|
809
881
|
if cross_build_p
|
810
882
|
# When precompiling native gems, copy packaged libraries' headers to ext/nokogiri/include
|
811
883
|
# These are packaged up by the cross-compiling callback in the ExtensionTask
|
@@ -821,10 +893,10 @@ end
|
|
821
893
|
|
822
894
|
create_makefile('nokogiri/nokogiri')
|
823
895
|
|
824
|
-
if
|
896
|
+
if config_clean?
|
825
897
|
# Do not clean if run in a development work tree.
|
826
898
|
File.open('Makefile', 'at') do |mk|
|
827
|
-
mk.print
|
899
|
+
mk.print(<<~EOF)
|
828
900
|
|
829
901
|
all: clean-ports
|
830
902
|
clean-ports: $(DLLIB)
|
@@ -832,5 +904,3 @@ if enable_config('clean', true)
|
|
832
904
|
EOF
|
833
905
|
end
|
834
906
|
end
|
835
|
-
|
836
|
-
# :startdoc:
|