nokogiri 1.11.0.rc3-java → 1.11.0.rc4-java
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 +1015 -947
- data/README.md +1 -1
- data/ext/java/nokogiri/HtmlSaxParserContext.java +1 -1
- data/ext/java/nokogiri/HtmlSaxPushParser.java +1 -1
- data/ext/java/nokogiri/XmlNode.java +4 -6
- data/ext/java/nokogiri/XmlReader.java +2 -2
- data/ext/java/nokogiri/XmlRelaxng.java +10 -3
- data/ext/java/nokogiri/XmlSaxParserContext.java +8 -3
- data/ext/java/nokogiri/XmlSchema.java +84 -24
- data/ext/java/nokogiri/XmlSyntaxError.java +2 -6
- data/ext/java/nokogiri/XmlXpathContext.java +48 -18
- data/ext/java/nokogiri/internals/HtmlDomParserContext.java +51 -39
- data/ext/java/nokogiri/internals/NokogiriHandler.java +1 -1
- data/ext/java/nokogiri/internals/NokogiriNamespaceContext.java +9 -2
- data/ext/java/nokogiri/internals/NokogiriXPathFunction.java +62 -6
- data/ext/java/nokogiri/internals/NokogiriXPathFunctionResolver.java +4 -2
- data/ext/java/nokogiri/internals/XmlDomParserContext.java +2 -2
- data/ext/nokogiri/depend +476 -357
- data/ext/nokogiri/extconf.rb +441 -321
- data/ext/nokogiri/html_document.c +79 -78
- data/ext/nokogiri/html_sax_parser_context.c +2 -2
- data/ext/nokogiri/nokogiri.c +34 -46
- data/ext/nokogiri/xml_document.c +2 -2
- data/ext/nokogiri/xml_node.c +1 -1
- data/ext/nokogiri/xml_node_set.c +1 -1
- data/ext/nokogiri/xml_relax_ng.c +29 -11
- data/ext/nokogiri/xml_sax_parser.c +2 -7
- data/ext/nokogiri/xml_sax_parser_context.c +2 -2
- data/ext/nokogiri/xml_schema.c +55 -13
- data/ext/nokogiri/xml_xpath_context.c +80 -4
- data/ext/nokogiri/xslt_stylesheet.c +1 -4
- data/lib/nokogiri.rb +1 -1
- data/lib/nokogiri/css/parser.rb +3 -3
- data/lib/nokogiri/css/parser.y +2 -2
- data/lib/nokogiri/css/xpath_visitor.rb +70 -42
- data/lib/nokogiri/html/document.rb +12 -26
- data/lib/nokogiri/nokogiri.jar +0 -0
- data/lib/nokogiri/version.rb +2 -149
- data/lib/nokogiri/version/constant.rb +5 -0
- data/lib/nokogiri/version/info.rb +182 -0
- data/lib/nokogiri/xml/document.rb +17 -7
- data/lib/nokogiri/xml/document_fragment.rb +4 -6
- data/lib/nokogiri/xml/node.rb +50 -27
- data/lib/nokogiri/xml/parse_options.rb +6 -0
- data/lib/nokogiri/xml/relax_ng.rb +6 -2
- data/lib/nokogiri/xml/schema.rb +12 -4
- data/lib/nokogiri/xml/searchable.rb +3 -1
- metadata +47 -73
- 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/nokogiri.h +0 -134
- 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.h +0 -11
- 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,12 +1,110 @@
|
|
1
1
|
# :stopdoc:
|
2
2
|
ENV['RC_ARCHS'] = '' if RUBY_PLATFORM =~ /darwin/
|
3
3
|
|
4
|
-
require
|
4
|
+
require "mkmf"
|
5
|
+
require "rbconfig"
|
6
|
+
require "fileutils"
|
7
|
+
require "shellwords"
|
8
|
+
require "pathname"
|
5
9
|
|
6
|
-
|
10
|
+
#
|
11
|
+
# helpful constants
|
12
|
+
#
|
13
|
+
PACKAGE_ROOT_DIR = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
14
|
+
REQUIRED_LIBXML_VERSION = "2.6.21"
|
15
|
+
RECOMMENDED_LIBXML_VERSION = "2.9.3"
|
16
|
+
|
17
|
+
# The gem version constraint in the Rakefile is not respected at install time.
|
18
|
+
# Keep this version in sync with the one in the Rakefile !
|
19
|
+
REQUIRED_MINI_PORTILE_VERSION = "~> 2.5.0"
|
20
|
+
REQUIRED_PKG_CONFIG_VERSION = "~> 1.1"
|
21
|
+
|
22
|
+
# Keep track of what versions of what libraries we build against
|
23
|
+
OTHER_LIBRARY_VERSIONS = {}
|
24
|
+
|
25
|
+
NOKOGIRI_HELP_MESSAGE = <<~HELP
|
26
|
+
USAGE: ruby #{$0} [options]
|
27
|
+
|
28
|
+
Flags that are always valid:
|
29
|
+
|
30
|
+
--use-system-libraries
|
31
|
+
Use system libraries instead of building and using the packaged libraries
|
32
|
+
|
33
|
+
--disable-clean
|
34
|
+
Do not clean out intermediate files after successful build
|
35
|
+
|
36
|
+
|
37
|
+
Flags only used when using system libraries:
|
38
|
+
|
39
|
+
--with-opt-dir=DIRECTORY
|
40
|
+
Look for headers and libraries in DIRECTORY
|
41
|
+
|
42
|
+
--with-zlib-dir=DIR
|
43
|
+
Look for zlib header and library in DIRECTORY
|
44
|
+
|
45
|
+
--with-iconv-dir=DIRECTORY
|
46
|
+
Look for iconv header and library in DIRECTORY
|
47
|
+
|
48
|
+
--with-xml2-dir=DIRECTORY
|
49
|
+
Look for xml2 headers and library in DIRECTORY
|
50
|
+
|
51
|
+
--with-xml2-lib=DIRECTORY
|
52
|
+
Look for xml2 library in DIRECTORY
|
53
|
+
|
54
|
+
--with-xslt-include=DIRECTORY
|
55
|
+
Look for xslt headers in DIRECTORY
|
56
|
+
|
57
|
+
--with-xslt-dir=DIRECTORY
|
58
|
+
Look for xslt headers and library in DIRECTORY
|
59
|
+
|
60
|
+
--with-xslt-lib=DIRECTORY
|
61
|
+
Look for xslt library in DIRECTORY
|
62
|
+
|
63
|
+
--with-xslt-include=DIRECTORY
|
64
|
+
Look for xslt headers in DIRECTORY
|
65
|
+
|
66
|
+
--with-exslt-dir=DIRECTORY
|
67
|
+
Look for exslt headers and library in DIRECTORY
|
68
|
+
|
69
|
+
--with-exslt-lib=DIRECTORY
|
70
|
+
Look for exslt library in DIRECTORY
|
71
|
+
|
72
|
+
--with-exslt-include=DIRECTORY
|
73
|
+
Look for exslt headers in DIRECTORY
|
74
|
+
|
75
|
+
|
76
|
+
Flags only used when building and using the packaged libraries:
|
77
|
+
|
78
|
+
--disable-static
|
79
|
+
Do not statically link packaged libraries, instead use shared libraries
|
80
|
+
|
81
|
+
--enable-cross-build
|
82
|
+
Enable cross-build mode. (You probably do not want to set this manually.)
|
83
|
+
|
84
|
+
Environment variables used:
|
85
|
+
|
86
|
+
NOKOGIRI_USE_SYSTEM_LIBRARIES
|
87
|
+
When set, even if nil or blank, use system libraries instead of building and using the
|
88
|
+
packaged libraries. Equivalent to `--use-system-libraries`.
|
89
|
+
|
90
|
+
CC
|
91
|
+
Use this path to invoke the compiler instead of `RbConfig::CONFIG['CC']`
|
92
|
+
|
93
|
+
CPPFLAGS
|
94
|
+
If this string is accepted by the C preprocessor, add it to the flags passed to the C preprocessor
|
95
|
+
|
96
|
+
CFLAGS
|
97
|
+
If this string is accepted by the compiler, add it to the flags passed to the compiler
|
98
|
+
|
99
|
+
LDFLAGS
|
100
|
+
If this string is accepted by the linker, add it to the flags passed to the linker
|
101
|
+
|
102
|
+
LIBS
|
103
|
+
Add this string to the flags passed to the linker
|
104
|
+
HELP
|
7
105
|
|
8
106
|
#
|
9
|
-
# functions
|
107
|
+
# utility functions
|
10
108
|
#
|
11
109
|
def windows?
|
12
110
|
RbConfig::CONFIG['target_os'] =~ /mingw32|mswin/
|
@@ -32,181 +130,168 @@ def nix?
|
|
32
130
|
! (windows? || solaris? || darwin?)
|
33
131
|
end
|
34
132
|
|
35
|
-
def
|
36
|
-
|
37
|
-
# as a $PATH separator, we need to convert windows paths from
|
38
|
-
#
|
39
|
-
# C:/path/to/foo
|
40
|
-
#
|
41
|
-
# to
|
42
|
-
#
|
43
|
-
# /C/path/to/foo
|
44
|
-
#
|
45
|
-
# which is sh-compatible, in order to find things properly during
|
46
|
-
# configuration
|
47
|
-
if windows?
|
48
|
-
match = Regexp.new("^([A-Z]):(/.*)").match(path)
|
49
|
-
if match && match.length == 3
|
50
|
-
return File.join("/", match[1], match[2])
|
51
|
-
end
|
52
|
-
end
|
53
|
-
path
|
133
|
+
def concat_flags *args
|
134
|
+
args.compact.join(" ")
|
54
135
|
end
|
55
136
|
|
56
|
-
def
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
--disable-clean
|
61
|
-
Do not clean out intermediate files after successful build.
|
137
|
+
def local_have_library(lib, func=nil, headers=nil)
|
138
|
+
have_library(lib, func, headers) or have_library("lib#{lib}", func, headers)
|
139
|
+
end
|
62
140
|
|
63
|
-
|
64
|
-
|
141
|
+
LOCAL_PACKAGE_RESPONSE = Object.new
|
142
|
+
def LOCAL_PACKAGE_RESPONSE.%(package)
|
143
|
+
package ? "yes: #{package}" : "no"
|
144
|
+
end
|
65
145
|
|
66
|
-
|
67
|
-
|
146
|
+
# wrapper around MakeMakefil#pkg_config and the PKGConfig gem
|
147
|
+
def try_package_configuration(pc)
|
148
|
+
if !ENV.key?("NOKOGIRI_TEST_PKG_CONFIG_GEM")
|
149
|
+
# try MakeMakefile#pkg_config, which uses the system utility `pkg-config`.
|
150
|
+
return if checking_for("#{pc} using `pkg_config`", LOCAL_PACKAGE_RESPONSE) do
|
151
|
+
pkg_config(pc)
|
152
|
+
end
|
153
|
+
end
|
68
154
|
|
69
|
-
|
70
|
-
|
155
|
+
# `pkg-config` probably isn't installed, which appears to be the case for lots of freebsd systems.
|
156
|
+
# let's fall back to the pkg-config gem, which knows how to parse .pc files, and wrap it with the
|
157
|
+
# same logic as MakeMakefile#pkg_config
|
158
|
+
begin
|
159
|
+
require 'rubygems'
|
160
|
+
gem 'pkg-config', REQUIRED_PKG_CONFIG_VERSION
|
161
|
+
require 'pkg-config'
|
71
162
|
|
72
|
-
|
73
|
-
|
74
|
-
|
163
|
+
checking_for("#{pc} using pkg-config gem version #{PKGConfig::VERSION}", LOCAL_PACKAGE_RESPONSE) do
|
164
|
+
if PKGConfig.have_package(pc)
|
165
|
+
cflags = PKGConfig.cflags(pc)
|
166
|
+
ldflags = PKGConfig.libs_only_L(pc)
|
167
|
+
libs = PKGConfig.libs_only_l(pc)
|
75
168
|
|
76
|
-
|
77
|
-
|
78
|
-
--with-exslt-dir=DIR / --with-exslt-config=CONFIG
|
79
|
-
Use libxml2/libxslt/libexslt as specified.
|
169
|
+
Logging::message "pkg-config gem found package configuration for %s\n", pc
|
170
|
+
Logging::message "cflags: %s\nldflags: %s\nlibs: %s\n\n", cflags, ldflags, libs
|
80
171
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
172
|
+
[cflags, ldflags, libs]
|
173
|
+
end
|
174
|
+
end
|
175
|
+
rescue LoadError
|
176
|
+
message "Please install either the `pkg-config` utility or the `pkg-config` rubygem.\n"
|
177
|
+
end
|
85
178
|
end
|
86
179
|
|
87
|
-
|
88
|
-
|
89
|
-
|
180
|
+
# set up mkmf to link against the library if we can find it
|
181
|
+
def have_package_configuration(opt: nil, pc: nil, lib:, func:, headers:)
|
182
|
+
if opt
|
183
|
+
dir_config(opt)
|
184
|
+
dir_config("opt")
|
185
|
+
end
|
90
186
|
|
91
|
-
|
92
|
-
|
187
|
+
# see if we have enough path info to do this without trying any harder
|
188
|
+
if !ENV.key?("NOKOGIRI_TEST_PKG_CONFIG")
|
189
|
+
return true if local_have_library(lib, func, headers)
|
190
|
+
end
|
93
191
|
|
94
|
-
|
95
|
-
unless (root + '.git').exist?
|
96
|
-
message "Cleaning files only used during build.\n"
|
192
|
+
try_package_configuration(pc) if pc
|
97
193
|
|
98
|
-
|
99
|
-
|
194
|
+
# verify that we can compile and link against the library
|
195
|
+
local_have_library(lib, func, headers)
|
196
|
+
end
|
100
197
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
198
|
+
def ensure_package_configuration(opt: nil, pc: nil, lib:, func:, headers:)
|
199
|
+
have_package_configuration(opt: opt, pc: pc, lib: lib, func: func, headers: headers) or
|
200
|
+
abort_could_not_find_library(lib)
|
201
|
+
end
|
105
202
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
else
|
110
|
-
FileUtils.rm_rf(root + 'ports' + 'archives', verbose: true)
|
111
|
-
end
|
112
|
-
end
|
203
|
+
def ensure_func(func, headers=nil)
|
204
|
+
have_func(func, headers) or abort_could_not_find_library(lib)
|
205
|
+
end
|
113
206
|
|
114
|
-
|
207
|
+
def preserving_globals
|
208
|
+
values = [$arg_config, $INCFLAGS, $CFLAGS, $CPPFLAGS, $LDFLAGS, $DLDFLAGS, $LIBPATH, $libs].map(&:dup)
|
209
|
+
yield
|
210
|
+
ensure
|
211
|
+
$arg_config, $INCFLAGS, $CFLAGS, $CPPFLAGS, $LDFLAGS, $DLDFLAGS, $LIBPATH, $libs = values
|
115
212
|
end
|
116
213
|
|
117
|
-
def
|
118
|
-
|
119
|
-
|
214
|
+
def abort_could_not_find_library(lib)
|
215
|
+
abort "-----\n#{caller[0]}\n#{lib} is missing. Please locate mkmf.log to investigate how it is failing.\n-----"
|
216
|
+
end
|
120
217
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
218
|
+
def chdir_for_build
|
219
|
+
# When using rake-compiler-dock on Windows, the underlying Virtualbox shared
|
220
|
+
# folders don't support symlinks, but libiconv expects it for a build on
|
221
|
+
# Linux. We work around this limitation by using the temp dir for cooking.
|
222
|
+
build_dir = ENV['RCD_HOST_RUBY_PLATFORM'].to_s =~ /mingw|mswin|cygwin/ ? '/tmp' : '.'
|
223
|
+
Dir.chdir(build_dir) do
|
224
|
+
yield
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
def sh_export_path path
|
229
|
+
# because libxslt 1.1.29 configure.in uses AC_PATH_TOOL which treats ":"
|
230
|
+
# as a $PATH separator, we need to convert windows paths from
|
231
|
+
#
|
232
|
+
# C:/path/to/foo
|
233
|
+
#
|
234
|
+
# to
|
235
|
+
#
|
236
|
+
# /C/path/to/foo
|
237
|
+
#
|
238
|
+
# which is sh-compatible, in order to find things properly during
|
239
|
+
# configuration
|
240
|
+
return path if !windows?
|
129
241
|
|
130
|
-
|
131
|
-
|
132
|
-
|
242
|
+
match = Regexp.new("^([A-Z]):(/.*)").match(path)
|
243
|
+
if match && match.length == 3
|
244
|
+
return File.join("/", match[1], match[2])
|
245
|
+
end
|
133
246
|
|
134
|
-
|
135
|
-
|
247
|
+
path
|
248
|
+
end
|
136
249
|
|
137
|
-
|
250
|
+
def libflag_to_filename(ldflag)
|
251
|
+
case ldflag
|
252
|
+
when /\A-l(.+)/
|
253
|
+
"lib#{$1}.#{$LIBEXT}"
|
138
254
|
end
|
139
255
|
end
|
140
256
|
|
141
|
-
def
|
142
|
-
|
257
|
+
def using_system_libraries?
|
258
|
+
# NOTE: TruffleRuby uses this env var as it does not support using static libraries yet.
|
259
|
+
arg_config('--use-system-libraries', ENV.key?("NOKOGIRI_USE_SYSTEM_LIBRARIES"))
|
143
260
|
end
|
144
261
|
|
145
|
-
def
|
262
|
+
def have_libxml_headers?(version=nil)
|
146
263
|
source = if version.nil?
|
147
|
-
|
148
|
-
#include <libxml/xmlversion.h>
|
264
|
+
<<~SRC
|
265
|
+
#include <libxml/xmlversion.h>
|
149
266
|
SRC
|
150
267
|
else
|
151
268
|
version_int = sprintf "%d%2.2d%2.2d", *(version.split("."))
|
152
|
-
|
153
|
-
#include <libxml/xmlversion.h>
|
154
|
-
#if LIBXML_VERSION < #{version_int}
|
155
|
-
#error libxml2 is older than #{version}
|
156
|
-
#endif
|
269
|
+
<<~SRC
|
270
|
+
#include <libxml/xmlversion.h>
|
271
|
+
#if LIBXML_VERSION < #{version_int}
|
272
|
+
# error libxml2 is older than #{version}
|
273
|
+
#endif
|
157
274
|
SRC
|
158
275
|
end
|
159
276
|
|
160
277
|
try_cpp source
|
161
278
|
end
|
162
279
|
|
163
|
-
def
|
164
|
-
print "checking if the C compiler accepts #{flags}... "
|
165
|
-
with_cflags("#{$CFLAGS} #{flags}") do
|
166
|
-
if nokogiri_try_compile
|
167
|
-
puts 'yes'
|
168
|
-
true
|
169
|
-
else
|
170
|
-
puts 'no'
|
171
|
-
false
|
172
|
-
end
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
def preserving_globals
|
177
|
-
values = [
|
178
|
-
$arg_config,
|
179
|
-
$CFLAGS, $CPPFLAGS,
|
180
|
-
$LDFLAGS, $LIBPATH, $libs
|
181
|
-
].map(&:dup)
|
182
|
-
yield
|
183
|
-
ensure
|
184
|
-
$arg_config,
|
185
|
-
$CFLAGS, $CPPFLAGS,
|
186
|
-
$LDFLAGS, $LIBPATH, $libs =
|
187
|
-
values
|
188
|
-
end
|
189
|
-
|
190
|
-
def asplode(lib)
|
191
|
-
abort "-----\n#{lib} is missing. Please locate mkmf.log to investigate how it is failing.\n-----"
|
192
|
-
end
|
193
|
-
|
194
|
-
def have_iconv?(using = nil)
|
280
|
+
def try_link_iconv(using = nil)
|
195
281
|
checking_for(using ? "iconv using #{using}" : 'iconv') do
|
196
282
|
['', '-liconv'].any? do |opt|
|
197
283
|
preserving_globals do
|
198
284
|
yield if block_given?
|
199
285
|
|
200
|
-
try_link(
|
201
|
-
#include <stdlib.h>
|
202
|
-
#include <iconv.h>
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
}
|
286
|
+
try_link(<<~'SRC', opt)
|
287
|
+
#include <stdlib.h>
|
288
|
+
#include <iconv.h>
|
289
|
+
int main(void)
|
290
|
+
{
|
291
|
+
iconv_t cd = iconv_open("", "");
|
292
|
+
iconv(cd, NULL, NULL, NULL, NULL);
|
293
|
+
return EXIT_SUCCESS;
|
294
|
+
}
|
210
295
|
SRC
|
211
296
|
end
|
212
297
|
end
|
@@ -214,11 +299,10 @@ int main(void)
|
|
214
299
|
end
|
215
300
|
|
216
301
|
def iconv_configure_flags
|
217
|
-
#
|
218
|
-
|
219
|
-
|
220
|
-
if
|
221
|
-
have_iconv?("--with-#{name}-* flags") { dir_config(name) }
|
302
|
+
# give --with-iconv-dir and --with-opt-dir first priority
|
303
|
+
["iconv", "opt"].each do |target|
|
304
|
+
config = preserving_globals { dir_config(target) }
|
305
|
+
if config.any? && try_link_iconv("--with-#{target}-* flags") { dir_config(target) }
|
222
306
|
idirs, ldirs = config.map do |dirs|
|
223
307
|
Array(dirs).flat_map do |dir|
|
224
308
|
dir.split(File::PATH_SEPARATOR)
|
@@ -233,12 +317,12 @@ def iconv_configure_flags
|
|
233
317
|
end
|
234
318
|
end
|
235
319
|
|
236
|
-
if
|
320
|
+
if try_link_iconv
|
237
321
|
return ['--with-iconv=yes']
|
238
322
|
end
|
239
323
|
|
240
|
-
|
241
|
-
|
324
|
+
config = preserving_globals { have_package_configuration('libiconv') }
|
325
|
+
if config && try_link_iconv('pkg-config libiconv') { have_package_configuration('libiconv') }
|
242
326
|
cflags, ldflags, libs = config
|
243
327
|
|
244
328
|
return [
|
@@ -249,26 +333,25 @@ def iconv_configure_flags
|
|
249
333
|
]
|
250
334
|
end
|
251
335
|
|
252
|
-
|
336
|
+
abort_could_not_find_library "libiconv"
|
253
337
|
end
|
254
338
|
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
339
|
+
def process_recipe(name, version, static_p, cross_p)
|
340
|
+
require 'rubygems'
|
341
|
+
gem 'mini_portile2', REQUIRED_MINI_PORTILE_VERSION
|
342
|
+
require 'mini_portile2'
|
343
|
+
message "Using mini_portile version #{MiniPortile::VERSION}\n"
|
344
|
+
|
345
|
+
if name != "libxml2" && name != "libxslt"
|
346
|
+
OTHER_LIBRARY_VERSIONS[name] = version
|
262
347
|
end
|
263
|
-
end
|
264
348
|
|
265
|
-
def process_recipe(name, version, static_p, cross_p)
|
266
349
|
MiniPortile.new(name, version).tap do |recipe|
|
267
|
-
recipe.target = File.join(
|
350
|
+
recipe.target = File.join(PACKAGE_ROOT_DIR, "ports")
|
268
351
|
# Prefer host_alias over host in order to use i586-mingw32msvc as
|
269
352
|
# correct compiler prefix for cross build, but use host if not set.
|
270
353
|
recipe.host = RbConfig::CONFIG["host_alias"].empty? ? RbConfig::CONFIG["host"] : RbConfig::CONFIG["host_alias"]
|
271
|
-
recipe.patch_files = Dir[File.join(
|
354
|
+
recipe.patch_files = Dir[File.join(PACKAGE_ROOT_DIR, "patches", name, "*.patch")].sort
|
272
355
|
recipe.configure_options << "--libdir=#{File.join(recipe.path, "lib")}"
|
273
356
|
|
274
357
|
yield recipe
|
@@ -282,7 +365,11 @@ def process_recipe(name, version, static_p, cross_p)
|
|
282
365
|
recipe.configure_options.delete_if do |option|
|
283
366
|
case option
|
284
367
|
when /\A(\w+)=(.*)\z/
|
285
|
-
env
|
368
|
+
if env.key?($1)
|
369
|
+
env[$1] = concat_flags(env[$1], $2)
|
370
|
+
else
|
371
|
+
env[$1] = $2
|
372
|
+
end
|
286
373
|
true
|
287
374
|
else
|
288
375
|
false
|
@@ -294,7 +381,7 @@ def process_recipe(name, version, static_p, cross_p)
|
|
294
381
|
"--disable-shared",
|
295
382
|
"--enable-static",
|
296
383
|
]
|
297
|
-
env[
|
384
|
+
env["CFLAGS"] = concat_flags(env["CFLAGS"], "-fPIC")
|
298
385
|
else
|
299
386
|
recipe.configure_options += [
|
300
387
|
"--enable-shared",
|
@@ -312,59 +399,50 @@ def process_recipe(name, version, static_p, cross_p)
|
|
312
399
|
if RbConfig::CONFIG['target_cpu'] == 'universal'
|
313
400
|
%w[CFLAGS LDFLAGS].each do |key|
|
314
401
|
unless env[key].include?('-arch')
|
315
|
-
env[key]
|
402
|
+
env[key] = concat_flags(env[key], RbConfig::CONFIG['ARCH_FLAG'])
|
316
403
|
end
|
317
404
|
end
|
318
405
|
end
|
319
406
|
|
320
407
|
recipe.configure_options += env.map do |key, value|
|
321
|
-
"#{key}=#{value}"
|
408
|
+
"#{key}=#{value.strip}"
|
322
409
|
end
|
323
410
|
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
411
|
+
checkpoint = "#{recipe.target}/#{recipe.name}-#{recipe.version}-#{recipe.host}.installed"
|
412
|
+
if File.exist?(checkpoint)
|
413
|
+
message "Building Nokogiri with a packaged version of #{name}-#{version}.\n"
|
414
|
+
else
|
415
|
+
message <<~EOM
|
416
|
+
---------- IMPORTANT NOTICE ----------
|
417
|
+
Building Nokogiri with a packaged version of #{name}-#{version}.
|
418
|
+
Configuration options: #{recipe.configure_options.shelljoin}
|
419
|
+
EOM
|
330
420
|
|
331
|
-
|
332
|
-
|
421
|
+
unless recipe.patch_files.empty?
|
422
|
+
message "The following patches are being applied:\n"
|
333
423
|
|
334
|
-
|
335
|
-
|
424
|
+
recipe.patch_files.each do |patch|
|
425
|
+
message " - %s\n" % File.basename(patch)
|
426
|
+
end
|
336
427
|
end
|
337
|
-
end
|
338
|
-
|
339
|
-
message <<-"EOS"
|
340
428
|
|
341
|
-
|
342
|
-
updates in a timely manner, but if this is a concern for you and want
|
343
|
-
to use the system library instead; abort this installation process and
|
344
|
-
reinstall nokogiri as follows:
|
429
|
+
message <<~EOM
|
345
430
|
|
346
|
-
|
347
|
-
|
348
|
-
|
431
|
+
The Nokogiri maintainers intend to provide timely security updates, but if
|
432
|
+
this is a concern for you and want to use your OS/distro system library
|
433
|
+
instead, then abort this installation process and install nokogiri as
|
434
|
+
instructed at:
|
349
435
|
|
350
|
-
|
436
|
+
https://nokogiri.org/tutorials/installing_nokogiri.html#install-with-system-libraries
|
351
437
|
|
352
|
-
|
353
|
-
bundle install
|
354
|
-
EOS
|
438
|
+
EOM
|
355
439
|
|
356
|
-
|
440
|
+
message <<~EOM if name == 'libxml2'
|
441
|
+
Note, however, that nokogiri cannot guarantee compatiblity with every
|
442
|
+
version of libxml2 that may be provided by OS/package vendors.
|
357
443
|
|
358
|
-
|
359
|
-
versions of libxml2 provided by OS/package vendors.
|
360
|
-
EOS
|
444
|
+
EOM
|
361
445
|
|
362
|
-
message <<-"EOS"
|
363
|
-
************************************************************************
|
364
|
-
EOS
|
365
|
-
|
366
|
-
checkpoint = "#{recipe.target}/#{recipe.name}-#{recipe.version}-#{recipe.host}.installed"
|
367
|
-
unless File.exist?(checkpoint)
|
368
446
|
chdir_for_build do
|
369
447
|
recipe.cook
|
370
448
|
end
|
@@ -374,116 +452,115 @@ versions of libxml2 provided by OS/package vendors.
|
|
374
452
|
end
|
375
453
|
end
|
376
454
|
|
377
|
-
def
|
378
|
-
|
379
|
-
|
380
|
-
|
455
|
+
def copy_packaged_libraries_headers(to_path:, from_recipes:)
|
456
|
+
FileUtils.rm_rf(to_path, secure: true)
|
457
|
+
FileUtils.mkdir(to_path)
|
458
|
+
from_recipes.each do |recipe|
|
459
|
+
FileUtils.cp_r(Dir[File.join(recipe.path, 'include/*')], to_path)
|
381
460
|
end
|
382
461
|
end
|
383
462
|
|
384
|
-
def
|
385
|
-
|
463
|
+
def do_help
|
464
|
+
print NOKOGIRI_HELP_MESSAGE
|
465
|
+
exit! 0
|
386
466
|
end
|
387
467
|
|
388
|
-
|
389
|
-
|
390
|
-
|
468
|
+
def do_clean
|
469
|
+
root = Pathname(PACKAGE_ROOT_DIR)
|
470
|
+
pwd = Pathname(Dir.pwd)
|
391
471
|
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
472
|
+
# Skip if this is a development work tree
|
473
|
+
unless (root + '.git').exist?
|
474
|
+
message "Cleaning files only used during build.\n"
|
475
|
+
|
476
|
+
# (root + 'tmp') cannot be removed at this stage because
|
477
|
+
# nokogiri.so is yet to be copied to lib.
|
398
478
|
|
399
|
-
|
400
|
-
|
479
|
+
# clean the ports build directory
|
480
|
+
Pathname.glob(pwd.join('tmp', '*', 'ports')) do |dir|
|
481
|
+
FileUtils.rm_rf(dir, verbose: true)
|
482
|
+
end
|
483
|
+
|
484
|
+
if enable_config('static')
|
485
|
+
# ports installation can be safely removed if statically linked.
|
486
|
+
FileUtils.rm_rf(root + 'ports', verbose: true)
|
487
|
+
else
|
488
|
+
FileUtils.rm_rf(root + 'ports' + 'archives', verbose: true)
|
489
|
+
end
|
490
|
+
end
|
491
|
+
|
492
|
+
exit! 0
|
401
493
|
end
|
402
494
|
|
495
|
+
#
|
496
|
+
# main
|
497
|
+
#
|
498
|
+
do_help if arg_config('--help')
|
499
|
+
do_clean if arg_config('--clean')
|
500
|
+
|
403
501
|
if openbsd? && !using_system_libraries?
|
404
502
|
if `#{ENV['CC'] || '/usr/bin/cc'} -v 2>&1` !~ /clang/
|
405
503
|
ENV['CC'] ||= find_executable('egcc') or
|
406
504
|
abort "Please install gcc 4.9+ from ports using `pkg_add -v gcc`"
|
407
505
|
end
|
408
|
-
|
506
|
+
append_cppflags "-I/usr/local/include"
|
409
507
|
end
|
410
508
|
|
411
509
|
if ENV['CC']
|
412
510
|
RbConfig::CONFIG['CC'] = RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC']
|
413
511
|
end
|
512
|
+
|
414
513
|
# use same c compiler for libxml and libxslt
|
415
514
|
ENV['CC'] = RbConfig::CONFIG['CC']
|
416
515
|
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
if windows?
|
423
|
-
$CFLAGS << " -DXP_WIN -DXP_WIN32 -DUSE_INCLUDED_VASPRINTF"
|
424
|
-
end
|
425
|
-
|
426
|
-
if solaris? || aix?
|
427
|
-
$CFLAGS << " -DUSE_INCLUDED_VASPRINTF"
|
428
|
-
end
|
429
|
-
|
430
|
-
if darwin?
|
431
|
-
# Let Apple LLVM/clang 5.1 ignore unknown compiler flags
|
432
|
-
add_cflags("-Wno-error=unused-command-line-argument-hard-error-in-future")
|
433
|
-
end
|
516
|
+
# adopt environment config
|
517
|
+
append_cflags(ENV["CFLAGS"].split(/\s+/)) if !ENV["CFLAGS"].nil?
|
518
|
+
append_cppflags(ENV["CPPFLAGS"].split(/\s+/)) if !ENV["CPPFLAGS"].nil?
|
519
|
+
append_ldflags(ENV["LDFLAGS"].split(/\s+/)) if !ENV["LDFLAGS"].nil?
|
520
|
+
$LIBS = concat_flags($LIBS, ENV["LIBS"])
|
434
521
|
|
435
|
-
|
436
|
-
|
437
|
-
|
522
|
+
append_cflags("-g") # always include debugging information
|
523
|
+
append_cflags("-Winline") # we use at least one inline function in the C extension
|
524
|
+
append_cflags("-Wmissing-noreturn") # good to have no matter what Ruby was compiled with
|
525
|
+
append_cflags("-Wno-error=unused-command-line-argument-hard-error-in-future") if darwin?
|
526
|
+
# append_cflags(["-Wcast-qual", "-Wwrite-strings"]) # these tend to be noisy, but on occasion useful during development
|
438
527
|
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
528
|
+
# Add SDK-specific include path for macOS and brew versions before v2.2.12 (2020-04-08) [#1851, #1801]
|
529
|
+
macos_mojave_sdk_include_path = "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/libxml2"
|
530
|
+
if using_system_libraries? && darwin? && Dir.exist?(macos_mojave_sdk_include_path)
|
531
|
+
append_cppflags("-I#{macos_mojave_sdk_include_path}")
|
443
532
|
end
|
444
533
|
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
end
|
534
|
+
# Work around a character escaping bug in MSYS by passing an arbitrary double-quoted parameter to gcc.
|
535
|
+
# See https://sourceforge.net/p/mingw/bugs/2142
|
536
|
+
append_cppflags(' "-Idummypath"') if windows?
|
449
537
|
|
450
|
-
|
451
|
-
when using_system_libraries?
|
538
|
+
if using_system_libraries?
|
452
539
|
message "Building nokogiri using system libraries.\n"
|
540
|
+
ensure_package_configuration(opt: "zlib", pc: "zlib", lib: "z", headers: "zlib.h", func: "gzdopen")
|
541
|
+
ensure_package_configuration(opt: "xml2", pc: "libxml-2.0", lib: "xml2", headers: "libxml/parser.h", func: "xmlParseDoc")
|
542
|
+
ensure_package_configuration(opt: "xslt", pc: "libxslt", lib: "xslt", headers: "libxslt/xslt.h", func: "xsltParseStylesheetDoc")
|
543
|
+
ensure_package_configuration(opt: "exslt", pc: "libexslt", lib: "exslt", headers: "libexslt/exslt.h", func: "exsltFuncRegister")
|
453
544
|
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
dir_config('xml2').any? or package_config('libxml-2.0')
|
460
|
-
dir_config('xslt').any? or package_config('libxslt')
|
461
|
-
dir_config('exslt').any? or package_config('libexslt')
|
462
|
-
|
463
|
-
check_libxml_version or abort "ERROR: cannot discover where libxml2 is located on your system. please make sure `pkg-config` is installed."
|
464
|
-
check_libxml_version("2.6.21") or abort "ERROR: libxml2 version 2.6.21 or later is required!"
|
465
|
-
check_libxml_version("2.9.3") or warn "WARNING: libxml2 version 2.9.3 or later is highly recommended, but proceeding anyway."
|
545
|
+
have_libxml_headers?(REQUIRED_LIBXML_VERSION) or
|
546
|
+
abort "ERROR: libxml2 version #{REQUIRED_LIBXML_VERSION} or later is required!"
|
547
|
+
have_libxml_headers?(RECOMMENDED_LIBXML_VERSION) or
|
548
|
+
warn "WARNING: libxml2 version #{RECOMMENDED_LIBXML_VERSION} or later is highly recommended, but proceeding anyway."
|
466
549
|
|
467
550
|
else
|
468
551
|
message "Building nokogiri using packaged libraries.\n"
|
469
552
|
|
470
|
-
|
471
|
-
|
472
|
-
require 'rubygems'
|
473
|
-
gem 'mini_portile2', '~> 2.5.0'
|
474
|
-
require 'mini_portile2'
|
475
|
-
message "Using mini_portile version #{MiniPortile::VERSION}\n"
|
553
|
+
static_p = enable_config("static", true)
|
554
|
+
message "Static linking is #{static_p ? "enabled" : "disabled"}.\n"
|
476
555
|
|
477
|
-
|
556
|
+
cross_build_p = enable_config("cross-build")
|
557
|
+
message "Cross build is #{cross_build_p ? "enabled" : "disabled"}.\n"
|
478
558
|
|
479
|
-
|
480
|
-
|
559
|
+
require 'yaml'
|
560
|
+
dependencies = YAML.load_file(File.join(PACKAGE_ROOT_DIR, "dependencies.yml"))
|
481
561
|
|
482
562
|
dir_config('zlib')
|
483
563
|
|
484
|
-
dependencies = YAML.load_file(File.join(ROOT, "dependencies.yml"))
|
485
|
-
|
486
|
-
cross_build_p = enable_config("cross-build")
|
487
564
|
if cross_build_p || windows?
|
488
565
|
zlib_recipe = process_recipe("zlib", dependencies["zlib"]["version"], static_p, cross_build_p) do |recipe|
|
489
566
|
recipe.files = [{
|
@@ -525,7 +602,16 @@ else
|
|
525
602
|
else
|
526
603
|
class << recipe
|
527
604
|
def configure
|
528
|
-
|
605
|
+
cflags = concat_flags(ENV["CFLAGS"], "-fPIC", "-g")
|
606
|
+
execute "configure", ["env", "CHOST=#{host}", "CFLAGS=#{cflags}", "./configure", "--static", configure_prefix]
|
607
|
+
end
|
608
|
+
|
609
|
+
def compile
|
610
|
+
if host=~/darwin/
|
611
|
+
execute "compile", "make AR=#{host}-libtool"
|
612
|
+
else
|
613
|
+
super
|
614
|
+
end
|
529
615
|
end
|
530
616
|
end
|
531
617
|
end
|
@@ -537,35 +623,37 @@ else
|
|
537
623
|
url: "http://ftp.gnu.org/pub/gnu/libiconv/#{recipe.name}-#{recipe.version}.tar.gz",
|
538
624
|
sha256: dependencies["libiconv"]["sha256"]
|
539
625
|
}]
|
626
|
+
|
627
|
+
cflags = concat_flags(ENV["CFLAGS"], "-O2", "-U_FORTIFY_SOURCE", "-g")
|
628
|
+
|
540
629
|
recipe.configure_options += [
|
541
630
|
"CPPFLAGS=-Wall",
|
542
|
-
"CFLAGS
|
543
|
-
"CXXFLAGS
|
631
|
+
"CFLAGS=#{cflags}",
|
632
|
+
"CXXFLAGS=#{cflags}",
|
544
633
|
"LDFLAGS="
|
545
634
|
]
|
546
635
|
end
|
547
636
|
end
|
548
637
|
else
|
549
638
|
if darwin? && !have_header('iconv.h')
|
550
|
-
abort
|
551
|
-
-----
|
552
|
-
The file "iconv.h" is missing in your build environment,
|
553
|
-
which means you haven't installed Xcode Command Line Tools properly.
|
554
|
-
|
555
|
-
To install Command Line Tools, try running `xcode-select --install` on
|
556
|
-
terminal and follow the instructions. If it fails, open Xcode.app,
|
557
|
-
select from the menu "Xcode" - "Open Developer Tool" - "More Developer
|
558
|
-
Tools" to open the developer site, download the installer for your OS
|
559
|
-
version and run it.
|
560
|
-
-----
|
561
|
-
EOM
|
639
|
+
abort <<~EOM.chomp
|
640
|
+
-----
|
641
|
+
The file "iconv.h" is missing in your build environment,
|
642
|
+
which means you haven't installed Xcode Command Line Tools properly.
|
643
|
+
|
644
|
+
To install Command Line Tools, try running `xcode-select --install` on
|
645
|
+
terminal and follow the instructions. If it fails, open Xcode.app,
|
646
|
+
select from the menu "Xcode" - "Open Developer Tool" - "More Developer
|
647
|
+
Tools" to open the developer site, download the installer for your OS
|
648
|
+
version and run it.
|
649
|
+
-----
|
650
|
+
EOM
|
562
651
|
end
|
563
652
|
end
|
564
653
|
|
565
654
|
unless windows?
|
566
|
-
preserving_globals {
|
567
|
-
|
568
|
-
} or abort 'zlib is missing; necessary for building libxml2'
|
655
|
+
preserving_globals { local_have_library('z', 'gzdopen', 'zlib.h') } or
|
656
|
+
abort 'zlib is missing; necessary for building libxml2'
|
569
657
|
end
|
570
658
|
|
571
659
|
libxml2_recipe = process_recipe("libxml2", dependencies["libxml2"]["version"], static_p, cross_build_p) do |recipe|
|
@@ -573,15 +661,31 @@ EOM
|
|
573
661
|
url: "http://xmlsoft.org/sources/#{recipe.name}-#{recipe.version}.tar.gz",
|
574
662
|
sha256: dependencies["libxml2"]["sha256"]
|
575
663
|
}]
|
664
|
+
|
665
|
+
cflags = concat_flags(ENV["CFLAGS"], "-O2", "-U_FORTIFY_SOURCE", "-g")
|
666
|
+
|
667
|
+
if zlib_recipe
|
668
|
+
recipe.configure_options << "--with-zlib=#{zlib_recipe.path}"
|
669
|
+
cflags = concat_flags(cflags, "-I#{zlib_recipe.path}/include")
|
670
|
+
end
|
671
|
+
|
672
|
+
if libiconv_recipe
|
673
|
+
recipe.configure_options << "--with-iconv=#{libiconv_recipe.path}"
|
674
|
+
else
|
675
|
+
recipe.configure_options += iconv_configure_flags
|
676
|
+
end
|
677
|
+
|
678
|
+
if darwin? && !cross_build_p
|
679
|
+
recipe.configure_options += ["RANLIB=/usr/bin/ranlib", "AR=/usr/bin/ar"]
|
680
|
+
end
|
681
|
+
|
576
682
|
recipe.configure_options += [
|
577
683
|
"--without-python",
|
578
684
|
"--without-readline",
|
579
|
-
*(zlib_recipe ? ["--with-zlib=#{zlib_recipe.path}", "CFLAGS=-I#{zlib_recipe.path}/include"] : []),
|
580
|
-
*(libiconv_recipe ? "--with-iconv=#{libiconv_recipe.path}" : iconv_configure_flags),
|
581
685
|
"--with-c14n",
|
582
686
|
"--with-debug",
|
583
687
|
"--with-threads",
|
584
|
-
|
688
|
+
"CFLAGS=#{cflags}",
|
585
689
|
]
|
586
690
|
end
|
587
691
|
|
@@ -590,23 +694,28 @@ EOM
|
|
590
694
|
url: "http://xmlsoft.org/sources/#{recipe.name}-#{recipe.version}.tar.gz",
|
591
695
|
sha256: dependencies["libxslt"]["sha256"]
|
592
696
|
}]
|
697
|
+
|
698
|
+
cflags = concat_flags(ENV["CFLAGS"], "-O2", "-U_FORTIFY_SOURCE", "-g")
|
699
|
+
|
700
|
+
if darwin? && !cross_build_p
|
701
|
+
recipe.configure_options += ["RANLIB=/usr/bin/ranlib", "AR=/usr/bin/ar"]
|
702
|
+
end
|
703
|
+
|
593
704
|
recipe.configure_options += [
|
594
705
|
"--without-python",
|
595
706
|
"--without-crypto",
|
596
707
|
"--with-debug",
|
597
708
|
"--with-libxml-prefix=#{sh_export_path(libxml2_recipe.path)}",
|
598
|
-
|
709
|
+
"CFLAGS=#{cflags}",
|
599
710
|
]
|
600
711
|
end
|
601
712
|
|
602
|
-
|
713
|
+
append_cppflags("-DNOKOGIRI_PACKAGED_LIBRARIES")
|
714
|
+
append_cppflags("-DNOKOGIRI_PRECOMPILED_LIBRARIES") if cross_build_p
|
715
|
+
|
603
716
|
$LIBPATH = ["#{zlib_recipe.path}/lib"] | $LIBPATH if zlib_recipe
|
604
717
|
$LIBPATH = ["#{libiconv_recipe.path}/lib"] | $LIBPATH if libiconv_recipe
|
605
718
|
|
606
|
-
have_lzma = preserving_globals {
|
607
|
-
have_library('lzma')
|
608
|
-
}
|
609
|
-
|
610
719
|
$libs = $libs.shellsplit.tap do |libs|
|
611
720
|
[libxml2_recipe, libxslt_recipe].each do |recipe|
|
612
721
|
libname = recipe.name[/\Alib(.+)\z/, 1]
|
@@ -617,7 +726,7 @@ EOM
|
|
617
726
|
case arg
|
618
727
|
when /\A-L(.+)\z/
|
619
728
|
# Prioritize ports' directories
|
620
|
-
if $1.start_with?(
|
729
|
+
if $1.start_with?(PACKAGE_ROOT_DIR + '/')
|
621
730
|
$LIBPATH = [$1] | $LIBPATH
|
622
731
|
else
|
623
732
|
$LIBPATH = $LIBPATH | [$1]
|
@@ -630,14 +739,14 @@ EOM
|
|
630
739
|
end
|
631
740
|
end
|
632
741
|
|
633
|
-
|
634
|
-
|
742
|
+
patches_string = recipe.patch_files.map { |path| File.basename(path) }.join(' ')
|
743
|
+
append_cppflags(%Q[-DNOKOGIRI_#{recipe.name.upcase}_PATCHES="\\\"#{patches_string}\\\""])
|
635
744
|
|
636
745
|
case libname
|
637
746
|
when 'xml2'
|
638
747
|
# xslt-config --libs or pkg-config libxslt --libs does not include
|
639
748
|
# -llzma, so we need to add it manually when linking statically.
|
640
|
-
if static_p &&
|
749
|
+
if static_p && preserving_globals { local_have_library('lzma') }
|
641
750
|
# Add it at the end; GH #988
|
642
751
|
libs << '-llzma'
|
643
752
|
end
|
@@ -653,46 +762,57 @@ EOM
|
|
653
762
|
$libs = $libs.shellsplit.map do |arg|
|
654
763
|
case arg
|
655
764
|
when '-lxml2'
|
656
|
-
File.join(libxml2_recipe.path, 'lib',
|
765
|
+
File.join(libxml2_recipe.path, 'lib', libflag_to_filename(arg))
|
657
766
|
when '-lxslt', '-lexslt'
|
658
|
-
File.join(libxslt_recipe.path, 'lib',
|
767
|
+
File.join(libxslt_recipe.path, 'lib', libflag_to_filename(arg))
|
659
768
|
else
|
660
769
|
arg
|
661
770
|
end
|
662
771
|
end.shelljoin
|
663
772
|
end
|
664
|
-
end
|
665
773
|
|
666
|
-
|
667
|
-
"
|
668
|
-
"
|
669
|
-
"exslt" => ['exsltFuncRegister', 'libexslt/exslt.h'],
|
670
|
-
}.each do |lib, (func, header)|
|
671
|
-
have_func(func, header) ||
|
672
|
-
have_library(lib, func, header) ||
|
673
|
-
have_library("lib#{lib}", func, header) or
|
674
|
-
asplode("lib#{lib}")
|
774
|
+
ensure_func("xmlParseDoc", "libxml/parser.h")
|
775
|
+
ensure_func("xsltParseStylesheetDoc", "libxslt/xslt.h")
|
776
|
+
ensure_func("exsltFuncRegister", "libexslt/exslt.h")
|
675
777
|
end
|
676
778
|
|
677
|
-
have_func('xmlHasFeature') or abort
|
678
|
-
have_func('xmlFirstElementChild')
|
679
|
-
have_func('xmlRelaxNGSetParserStructuredErrors')
|
680
|
-
have_func('
|
681
|
-
have_func('
|
682
|
-
have_func('
|
683
|
-
|
779
|
+
have_func('xmlHasFeature') or abort("xmlHasFeature() is missing.") # introduced in libxml 2.6.21
|
780
|
+
have_func('xmlFirstElementChild') # introduced in libxml 2.7.3
|
781
|
+
have_func('xmlRelaxNGSetParserStructuredErrors') # introduced in libxml 2.6.24
|
782
|
+
have_func('xmlRelaxNGSetValidStructuredErrors') # introduced in libxml 2.6.21
|
783
|
+
have_func('xmlSchemaSetValidStructuredErrors') # introduced in libxml 2.6.23
|
784
|
+
have_func('xmlSchemaSetParserStructuredErrors') # introduced in libxml 2.6.23
|
785
|
+
|
786
|
+
have_func('vasprintf')
|
787
|
+
|
788
|
+
other_library_versions_string = OTHER_LIBRARY_VERSIONS.map { |k,v| [k,v].join(":") }.join(",")
|
789
|
+
append_cppflags(%Q[-DNOKOGIRI_OTHER_LIBRARY_VERSIONS="\\\"#{other_library_versions_string}\\\""])
|
790
|
+
|
791
|
+
unless using_system_libraries?
|
792
|
+
if cross_build_p
|
793
|
+
# When precompiling native gems, copy packaged libraries' headers to ext/nokogiri/include
|
794
|
+
# These are packaged up by the cross-compiling callback in the ExtensionTask
|
795
|
+
copy_packaged_libraries_headers(to_path: File.join(PACKAGE_ROOT_DIR, "ext/nokogiri/include"),
|
796
|
+
from_recipes: [libxml2_recipe, libxslt_recipe])
|
797
|
+
else
|
798
|
+
# When compiling during installation, install packaged libraries' header files into ext/nokogiri/include
|
799
|
+
copy_packaged_libraries_headers(to_path: "include",
|
800
|
+
from_recipes: [libxml2_recipe, libxslt_recipe])
|
801
|
+
$INSTALLFILES << ["include/**/*.h", "$(rubylibdir)"]
|
802
|
+
end
|
803
|
+
end
|
684
804
|
|
685
805
|
create_makefile('nokogiri/nokogiri')
|
686
806
|
|
687
807
|
if enable_config('clean', true)
|
688
808
|
# Do not clean if run in a development work tree.
|
689
809
|
File.open('Makefile', 'at') do |mk|
|
690
|
-
mk.print
|
691
|
-
all: clean-ports
|
810
|
+
mk.print <<~EOF
|
692
811
|
|
693
|
-
clean-ports
|
694
|
-
|
695
|
-
|
812
|
+
all: clean-ports
|
813
|
+
clean-ports: $(DLLIB)
|
814
|
+
\t-$(Q)$(RUBY) $(srcdir)/extconf.rb --clean --#{static_p ? 'enable' : 'disable'}-static
|
815
|
+
EOF
|
696
816
|
end
|
697
817
|
end
|
698
818
|
|