nokogiri 1.11.0.rc1-x86-linux
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 +7 -0
- data/LICENSE-DEPENDENCIES.md +1614 -0
- data/LICENSE.md +9 -0
- data/README.md +200 -0
- data/bin/nokogiri +118 -0
- data/dependencies.yml +74 -0
- data/ext/nokogiri/depend +358 -0
- data/ext/nokogiri/extconf.rb +695 -0
- data/ext/nokogiri/html_document.c +170 -0
- data/ext/nokogiri/html_document.h +10 -0
- data/ext/nokogiri/html_element_description.c +279 -0
- data/ext/nokogiri/html_element_description.h +10 -0
- data/ext/nokogiri/html_entity_lookup.c +32 -0
- data/ext/nokogiri/html_entity_lookup.h +8 -0
- data/ext/nokogiri/html_sax_parser_context.c +116 -0
- data/ext/nokogiri/html_sax_parser_context.h +11 -0
- data/ext/nokogiri/html_sax_push_parser.c +87 -0
- data/ext/nokogiri/html_sax_push_parser.h +9 -0
- data/ext/nokogiri/nokogiri.c +147 -0
- data/ext/nokogiri/nokogiri.h +122 -0
- data/ext/nokogiri/xml_attr.c +103 -0
- data/ext/nokogiri/xml_attr.h +9 -0
- data/ext/nokogiri/xml_attribute_decl.c +70 -0
- data/ext/nokogiri/xml_attribute_decl.h +9 -0
- data/ext/nokogiri/xml_cdata.c +62 -0
- data/ext/nokogiri/xml_cdata.h +9 -0
- data/ext/nokogiri/xml_comment.c +69 -0
- data/ext/nokogiri/xml_comment.h +9 -0
- data/ext/nokogiri/xml_document.c +617 -0
- data/ext/nokogiri/xml_document.h +23 -0
- data/ext/nokogiri/xml_document_fragment.c +48 -0
- data/ext/nokogiri/xml_document_fragment.h +10 -0
- data/ext/nokogiri/xml_dtd.c +202 -0
- data/ext/nokogiri/xml_dtd.h +10 -0
- data/ext/nokogiri/xml_element_content.c +123 -0
- data/ext/nokogiri/xml_element_content.h +10 -0
- data/ext/nokogiri/xml_element_decl.c +69 -0
- data/ext/nokogiri/xml_element_decl.h +9 -0
- data/ext/nokogiri/xml_encoding_handler.c +79 -0
- data/ext/nokogiri/xml_encoding_handler.h +8 -0
- data/ext/nokogiri/xml_entity_decl.c +110 -0
- data/ext/nokogiri/xml_entity_decl.h +10 -0
- data/ext/nokogiri/xml_entity_reference.c +52 -0
- data/ext/nokogiri/xml_entity_reference.h +9 -0
- data/ext/nokogiri/xml_io.c +61 -0
- data/ext/nokogiri/xml_io.h +11 -0
- data/ext/nokogiri/xml_libxml2_hacks.c +112 -0
- data/ext/nokogiri/xml_libxml2_hacks.h +12 -0
- data/ext/nokogiri/xml_namespace.c +111 -0
- data/ext/nokogiri/xml_namespace.h +14 -0
- data/ext/nokogiri/xml_node.c +1773 -0
- data/ext/nokogiri/xml_node.h +13 -0
- data/ext/nokogiri/xml_node_set.c +486 -0
- data/ext/nokogiri/xml_node_set.h +12 -0
- data/ext/nokogiri/xml_processing_instruction.c +56 -0
- data/ext/nokogiri/xml_processing_instruction.h +9 -0
- data/ext/nokogiri/xml_reader.c +668 -0
- data/ext/nokogiri/xml_reader.h +10 -0
- data/ext/nokogiri/xml_relax_ng.c +161 -0
- data/ext/nokogiri/xml_relax_ng.h +9 -0
- data/ext/nokogiri/xml_sax_parser.c +310 -0
- data/ext/nokogiri/xml_sax_parser.h +39 -0
- data/ext/nokogiri/xml_sax_parser_context.c +262 -0
- data/ext/nokogiri/xml_sax_parser_context.h +10 -0
- data/ext/nokogiri/xml_sax_push_parser.c +159 -0
- data/ext/nokogiri/xml_sax_push_parser.h +9 -0
- data/ext/nokogiri/xml_schema.c +205 -0
- data/ext/nokogiri/xml_schema.h +9 -0
- data/ext/nokogiri/xml_syntax_error.c +64 -0
- data/ext/nokogiri/xml_syntax_error.h +13 -0
- data/ext/nokogiri/xml_text.c +52 -0
- data/ext/nokogiri/xml_text.h +9 -0
- data/ext/nokogiri/xml_xpath_context.c +298 -0
- data/ext/nokogiri/xml_xpath_context.h +10 -0
- data/ext/nokogiri/xslt_stylesheet.c +266 -0
- data/ext/nokogiri/xslt_stylesheet.h +14 -0
- data/lib/nokogiri.rb +127 -0
- data/lib/nokogiri/2.4/nokogiri.so +0 -0
- data/lib/nokogiri/2.5/nokogiri.so +0 -0
- data/lib/nokogiri/2.6/nokogiri.so +0 -0
- data/lib/nokogiri/2.7/nokogiri.so +0 -0
- data/lib/nokogiri/css.rb +28 -0
- data/lib/nokogiri/css/node.rb +53 -0
- data/lib/nokogiri/css/parser.rb +751 -0
- data/lib/nokogiri/css/parser.y +272 -0
- data/lib/nokogiri/css/parser_extras.rb +92 -0
- data/lib/nokogiri/css/syntax_error.rb +8 -0
- data/lib/nokogiri/css/tokenizer.rb +154 -0
- data/lib/nokogiri/css/tokenizer.rex +55 -0
- data/lib/nokogiri/css/xpath_visitor.rb +232 -0
- data/lib/nokogiri/decorators/slop.rb +43 -0
- data/lib/nokogiri/html.rb +38 -0
- data/lib/nokogiri/html/builder.rb +36 -0
- data/lib/nokogiri/html/document.rb +336 -0
- data/lib/nokogiri/html/document_fragment.rb +50 -0
- data/lib/nokogiri/html/element_description.rb +24 -0
- data/lib/nokogiri/html/element_description_defaults.rb +672 -0
- data/lib/nokogiri/html/entity_lookup.rb +14 -0
- data/lib/nokogiri/html/sax/parser.rb +63 -0
- data/lib/nokogiri/html/sax/parser_context.rb +17 -0
- data/lib/nokogiri/html/sax/push_parser.rb +37 -0
- data/lib/nokogiri/jruby/dependencies.rb +20 -0
- data/lib/nokogiri/syntax_error.rb +5 -0
- data/lib/nokogiri/version.rb +149 -0
- data/lib/nokogiri/xml.rb +76 -0
- data/lib/nokogiri/xml/attr.rb +15 -0
- data/lib/nokogiri/xml/attribute_decl.rb +19 -0
- data/lib/nokogiri/xml/builder.rb +447 -0
- data/lib/nokogiri/xml/cdata.rb +12 -0
- data/lib/nokogiri/xml/character_data.rb +8 -0
- data/lib/nokogiri/xml/document.rb +280 -0
- data/lib/nokogiri/xml/document_fragment.rb +161 -0
- data/lib/nokogiri/xml/dtd.rb +33 -0
- data/lib/nokogiri/xml/element_content.rb +37 -0
- data/lib/nokogiri/xml/element_decl.rb +14 -0
- data/lib/nokogiri/xml/entity_decl.rb +20 -0
- data/lib/nokogiri/xml/entity_reference.rb +19 -0
- data/lib/nokogiri/xml/namespace.rb +14 -0
- data/lib/nokogiri/xml/node.rb +916 -0
- data/lib/nokogiri/xml/node/save_options.rb +62 -0
- data/lib/nokogiri/xml/node_set.rb +372 -0
- data/lib/nokogiri/xml/notation.rb +7 -0
- data/lib/nokogiri/xml/parse_options.rb +121 -0
- data/lib/nokogiri/xml/pp.rb +3 -0
- data/lib/nokogiri/xml/pp/character_data.rb +19 -0
- data/lib/nokogiri/xml/pp/node.rb +57 -0
- data/lib/nokogiri/xml/processing_instruction.rb +9 -0
- data/lib/nokogiri/xml/reader.rb +116 -0
- data/lib/nokogiri/xml/relax_ng.rb +33 -0
- data/lib/nokogiri/xml/sax.rb +5 -0
- data/lib/nokogiri/xml/sax/document.rb +172 -0
- data/lib/nokogiri/xml/sax/parser.rb +123 -0
- data/lib/nokogiri/xml/sax/parser_context.rb +17 -0
- data/lib/nokogiri/xml/sax/push_parser.rb +61 -0
- data/lib/nokogiri/xml/schema.rb +64 -0
- data/lib/nokogiri/xml/searchable.rb +231 -0
- data/lib/nokogiri/xml/syntax_error.rb +71 -0
- data/lib/nokogiri/xml/text.rb +10 -0
- data/lib/nokogiri/xml/xpath.rb +11 -0
- data/lib/nokogiri/xml/xpath/syntax_error.rb +12 -0
- data/lib/nokogiri/xml/xpath_context.rb +17 -0
- data/lib/nokogiri/xslt.rb +57 -0
- data/lib/nokogiri/xslt/stylesheet.rb +26 -0
- data/lib/xsd/xmlparser/nokogiri.rb +103 -0
- metadata +482 -0
@@ -0,0 +1,695 @@
|
|
1
|
+
# :stopdoc:
|
2
|
+
ENV['RC_ARCHS'] = '' if RUBY_PLATFORM =~ /darwin/
|
3
|
+
|
4
|
+
require 'mkmf'
|
5
|
+
|
6
|
+
ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
7
|
+
|
8
|
+
#
|
9
|
+
# functions
|
10
|
+
#
|
11
|
+
def windows?
|
12
|
+
RbConfig::CONFIG['target_os'] =~ /mingw32|mswin/
|
13
|
+
end
|
14
|
+
|
15
|
+
def solaris?
|
16
|
+
RbConfig::CONFIG['target_os'] =~ /solaris/
|
17
|
+
end
|
18
|
+
|
19
|
+
def darwin?
|
20
|
+
RbConfig::CONFIG['target_os'] =~ /darwin/
|
21
|
+
end
|
22
|
+
|
23
|
+
def openbsd?
|
24
|
+
RbConfig::CONFIG['target_os'] =~ /openbsd/
|
25
|
+
end
|
26
|
+
|
27
|
+
def nix?
|
28
|
+
! (windows? || solaris? || darwin?)
|
29
|
+
end
|
30
|
+
|
31
|
+
def sh_export_path path
|
32
|
+
# because libxslt 1.1.29 configure.in uses AC_PATH_TOOL which treats ":"
|
33
|
+
# as a $PATH separator, we need to convert windows paths from
|
34
|
+
#
|
35
|
+
# C:/path/to/foo
|
36
|
+
#
|
37
|
+
# to
|
38
|
+
#
|
39
|
+
# /C/path/to/foo
|
40
|
+
#
|
41
|
+
# which is sh-compatible, in order to find things properly during
|
42
|
+
# configuration
|
43
|
+
if windows?
|
44
|
+
match = Regexp.new("^([A-Z]):(/.*)").match(path)
|
45
|
+
if match && match.length == 3
|
46
|
+
return File.join("/", match[1], match[2])
|
47
|
+
end
|
48
|
+
end
|
49
|
+
path
|
50
|
+
end
|
51
|
+
|
52
|
+
def do_help
|
53
|
+
print <<HELP
|
54
|
+
usage: ruby #{$0} [options]
|
55
|
+
|
56
|
+
--disable-clean
|
57
|
+
Do not clean out intermediate files after successful build.
|
58
|
+
|
59
|
+
--disable-static
|
60
|
+
Do not statically link bundled libraries.
|
61
|
+
|
62
|
+
--with-iconv-dir=DIR
|
63
|
+
Use the iconv library placed under DIR.
|
64
|
+
|
65
|
+
--with-zlib-dir=DIR
|
66
|
+
Use the zlib library placed under DIR.
|
67
|
+
|
68
|
+
--use-system-libraries
|
69
|
+
Use system libraries instead of building and using the bundled
|
70
|
+
libraries.
|
71
|
+
|
72
|
+
--with-xml2-dir=DIR / --with-xml2-config=CONFIG
|
73
|
+
--with-xslt-dir=DIR / --with-xslt-config=CONFIG
|
74
|
+
--with-exslt-dir=DIR / --with-exslt-config=CONFIG
|
75
|
+
Use libxml2/libxslt/libexslt as specified.
|
76
|
+
|
77
|
+
--enable-cross-build
|
78
|
+
Do cross-build.
|
79
|
+
HELP
|
80
|
+
exit! 0
|
81
|
+
end
|
82
|
+
|
83
|
+
def do_clean
|
84
|
+
require 'pathname'
|
85
|
+
require 'fileutils'
|
86
|
+
|
87
|
+
root = Pathname(ROOT)
|
88
|
+
pwd = Pathname(Dir.pwd)
|
89
|
+
|
90
|
+
# Skip if this is a development work tree
|
91
|
+
unless (root + '.git').exist?
|
92
|
+
message "Cleaning files only used during build.\n"
|
93
|
+
|
94
|
+
# (root + 'tmp') cannot be removed at this stage because
|
95
|
+
# nokogiri.so is yet to be copied to lib.
|
96
|
+
|
97
|
+
# clean the ports build directory
|
98
|
+
Pathname.glob(pwd.join('tmp', '*', 'ports')) do |dir|
|
99
|
+
FileUtils.rm_rf(dir, verbose: true)
|
100
|
+
end
|
101
|
+
|
102
|
+
if enable_config('static')
|
103
|
+
# ports installation can be safely removed if statically linked.
|
104
|
+
FileUtils.rm_rf(root + 'ports', verbose: true)
|
105
|
+
else
|
106
|
+
FileUtils.rm_rf(root + 'ports' + 'archives', verbose: true)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
exit! 0
|
111
|
+
end
|
112
|
+
|
113
|
+
def package_config pkg, options={}
|
114
|
+
package = pkg_config(pkg)
|
115
|
+
return package if package
|
116
|
+
|
117
|
+
begin
|
118
|
+
require 'rubygems'
|
119
|
+
gem 'pkg-config', (gem_ver='~> 1.1')
|
120
|
+
require 'pkg-config' and message("Using pkg-config gem version #{PKGConfig::VERSION}\n")
|
121
|
+
rescue LoadError
|
122
|
+
message "pkg-config could not be used to find #{pkg}\nPlease install either `pkg-config` or the pkg-config gem per\n\n gem install pkg-config -v #{gem_ver.inspect}\n\n"
|
123
|
+
else
|
124
|
+
return nil unless PKGConfig.have_package(pkg)
|
125
|
+
|
126
|
+
cflags = PKGConfig.cflags(pkg)
|
127
|
+
ldflags = PKGConfig.libs_only_L(pkg)
|
128
|
+
libs = PKGConfig.libs_only_l(pkg)
|
129
|
+
|
130
|
+
Logging::message "PKGConfig package configuration for %s\n", pkg
|
131
|
+
Logging::message "cflags: %s\nldflags: %s\nlibs: %s\n\n", cflags, ldflags, libs
|
132
|
+
|
133
|
+
[cflags, ldflags, libs]
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
def nokogiri_try_compile
|
138
|
+
try_compile "int main() {return 0;}", "", {werror: true}
|
139
|
+
end
|
140
|
+
|
141
|
+
def check_libxml_version version=nil
|
142
|
+
source = if version.nil?
|
143
|
+
<<-SRC
|
144
|
+
#include <libxml/xmlversion.h>
|
145
|
+
SRC
|
146
|
+
else
|
147
|
+
version_int = sprintf "%d%2.2d%2.2d", *(version.split("."))
|
148
|
+
<<-SRC
|
149
|
+
#include <libxml/xmlversion.h>
|
150
|
+
#if LIBXML_VERSION < #{version_int}
|
151
|
+
#error libxml2 is older than #{version}
|
152
|
+
#endif
|
153
|
+
SRC
|
154
|
+
end
|
155
|
+
|
156
|
+
try_cpp source
|
157
|
+
end
|
158
|
+
|
159
|
+
def add_cflags(flags)
|
160
|
+
print "checking if the C compiler accepts #{flags}... "
|
161
|
+
with_cflags("#{$CFLAGS} #{flags}") do
|
162
|
+
if nokogiri_try_compile
|
163
|
+
puts 'yes'
|
164
|
+
true
|
165
|
+
else
|
166
|
+
puts 'no'
|
167
|
+
false
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
def preserving_globals
|
173
|
+
values = [
|
174
|
+
$arg_config,
|
175
|
+
$CFLAGS, $CPPFLAGS,
|
176
|
+
$LDFLAGS, $LIBPATH, $libs
|
177
|
+
].map(&:dup)
|
178
|
+
yield
|
179
|
+
ensure
|
180
|
+
$arg_config,
|
181
|
+
$CFLAGS, $CPPFLAGS,
|
182
|
+
$LDFLAGS, $LIBPATH, $libs =
|
183
|
+
values
|
184
|
+
end
|
185
|
+
|
186
|
+
def asplode(lib)
|
187
|
+
abort "-----\n#{lib} is missing. Please locate mkmf.log to investigate how it is failing.\n-----"
|
188
|
+
end
|
189
|
+
|
190
|
+
def have_iconv?(using = nil)
|
191
|
+
checking_for(using ? "iconv using #{using}" : 'iconv') do
|
192
|
+
['', '-liconv'].any? do |opt|
|
193
|
+
preserving_globals do
|
194
|
+
yield if block_given?
|
195
|
+
|
196
|
+
try_link(<<-'SRC', opt)
|
197
|
+
#include <stdlib.h>
|
198
|
+
#include <iconv.h>
|
199
|
+
|
200
|
+
int main(void)
|
201
|
+
{
|
202
|
+
iconv_t cd = iconv_open("", "");
|
203
|
+
iconv(cd, NULL, NULL, NULL, NULL);
|
204
|
+
return EXIT_SUCCESS;
|
205
|
+
}
|
206
|
+
SRC
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
def iconv_configure_flags
|
213
|
+
# If --with-iconv-dir or --with-opt-dir is given, it should be
|
214
|
+
# the first priority
|
215
|
+
%w[iconv opt].each do |name|
|
216
|
+
if (config = preserving_globals { dir_config(name) }).any? &&
|
217
|
+
have_iconv?("--with-#{name}-* flags") { dir_config(name) }
|
218
|
+
idirs, ldirs = config.map do |dirs|
|
219
|
+
Array(dirs).flat_map do |dir|
|
220
|
+
dir.split(File::PATH_SEPARATOR)
|
221
|
+
end if dirs
|
222
|
+
end
|
223
|
+
|
224
|
+
return [
|
225
|
+
'--with-iconv=yes',
|
226
|
+
*("CPPFLAGS=#{idirs.map { |dir| '-I' + dir }.join(' ')}" if idirs),
|
227
|
+
*("LDFLAGS=#{ldirs.map { |dir| '-L' + dir }.join(' ')}" if ldirs),
|
228
|
+
]
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
if have_iconv?
|
233
|
+
return ['--with-iconv=yes']
|
234
|
+
end
|
235
|
+
|
236
|
+
if (config = preserving_globals { package_config('libiconv') }) &&
|
237
|
+
have_iconv?('pkg-config libiconv') { package_config('libiconv') }
|
238
|
+
cflags, ldflags, libs = config
|
239
|
+
|
240
|
+
return [
|
241
|
+
'--with-iconv=yes',
|
242
|
+
"CPPFLAGS=#{cflags}",
|
243
|
+
"LDFLAGS=#{ldflags}",
|
244
|
+
"LIBS=#{libs}",
|
245
|
+
]
|
246
|
+
end
|
247
|
+
|
248
|
+
asplode "libiconv"
|
249
|
+
end
|
250
|
+
|
251
|
+
# When using rake-compiler-dock on Windows, the underlying Virtualbox shared
|
252
|
+
# folders don't support symlinks, but libiconv expects it for a build on
|
253
|
+
# Linux. We work around this limitation by using the temp dir for cooking.
|
254
|
+
def chdir_for_build
|
255
|
+
build_dir = ENV['RCD_HOST_RUBY_PLATFORM'].to_s =~ /mingw|mswin|cygwin/ ? '/tmp' : '.'
|
256
|
+
Dir.chdir(build_dir) do
|
257
|
+
yield
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
def process_recipe(name, version, static_p, cross_p)
|
262
|
+
MiniPortile.new(name, version).tap do |recipe|
|
263
|
+
recipe.target = File.join(ROOT, "ports")
|
264
|
+
# Prefer host_alias over host in order to use i586-mingw32msvc as
|
265
|
+
# correct compiler prefix for cross build, but use host if not set.
|
266
|
+
recipe.host = RbConfig::CONFIG["host_alias"].empty? ? RbConfig::CONFIG["host"] : RbConfig::CONFIG["host_alias"]
|
267
|
+
recipe.patch_files = Dir[File.join(ROOT, "patches", name, "*.patch")].sort
|
268
|
+
recipe.configure_options << "--libdir=#{File.join(recipe.path, "lib")}"
|
269
|
+
|
270
|
+
yield recipe
|
271
|
+
|
272
|
+
env = Hash.new do |hash, key|
|
273
|
+
hash[key] = "#{ENV[key]}" # (ENV[key].dup rescue '')
|
274
|
+
end
|
275
|
+
|
276
|
+
recipe.configure_options.flatten!
|
277
|
+
|
278
|
+
recipe.configure_options.delete_if do |option|
|
279
|
+
case option
|
280
|
+
when /\A(\w+)=(.*)\z/
|
281
|
+
env[$1] = $2
|
282
|
+
true
|
283
|
+
else
|
284
|
+
false
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
if static_p
|
289
|
+
recipe.configure_options += [
|
290
|
+
"--disable-shared",
|
291
|
+
"--enable-static",
|
292
|
+
]
|
293
|
+
env['CFLAGS'] = "-fPIC #{env['CFLAGS']}"
|
294
|
+
else
|
295
|
+
recipe.configure_options += [
|
296
|
+
"--enable-shared",
|
297
|
+
"--disable-static",
|
298
|
+
]
|
299
|
+
end
|
300
|
+
|
301
|
+
if cross_p
|
302
|
+
recipe.configure_options += [
|
303
|
+
"--target=#{recipe.host}",
|
304
|
+
"--host=#{recipe.host}",
|
305
|
+
]
|
306
|
+
end
|
307
|
+
|
308
|
+
if RbConfig::CONFIG['target_cpu'] == 'universal'
|
309
|
+
%w[CFLAGS LDFLAGS].each do |key|
|
310
|
+
unless env[key].include?('-arch')
|
311
|
+
env[key] += ' ' + RbConfig::CONFIG['ARCH_FLAG']
|
312
|
+
end
|
313
|
+
end
|
314
|
+
end
|
315
|
+
|
316
|
+
recipe.configure_options += env.map do |key, value|
|
317
|
+
"#{key}=#{value}"
|
318
|
+
end
|
319
|
+
|
320
|
+
message <<-"EOS"
|
321
|
+
************************************************************************
|
322
|
+
IMPORTANT NOTICE:
|
323
|
+
|
324
|
+
Building Nokogiri with a packaged version of #{name}-#{version}#{'.' if recipe.patch_files.empty?}
|
325
|
+
EOS
|
326
|
+
|
327
|
+
unless recipe.patch_files.empty?
|
328
|
+
message "with the following patches applied:\n"
|
329
|
+
|
330
|
+
recipe.patch_files.each do |patch|
|
331
|
+
message "\t- %s\n" % File.basename(patch)
|
332
|
+
end
|
333
|
+
end
|
334
|
+
|
335
|
+
message <<-"EOS"
|
336
|
+
|
337
|
+
Team Nokogiri will keep on doing their best to provide security
|
338
|
+
updates in a timely manner, but if this is a concern for you and want
|
339
|
+
to use the system library instead; abort this installation process and
|
340
|
+
reinstall nokogiri as follows:
|
341
|
+
|
342
|
+
gem install nokogiri -- --use-system-libraries
|
343
|
+
[--with-xml2-config=/path/to/xml2-config]
|
344
|
+
[--with-xslt-config=/path/to/xslt-config]
|
345
|
+
|
346
|
+
If you are using Bundler, tell it to use the option:
|
347
|
+
|
348
|
+
bundle config build.nokogiri --use-system-libraries
|
349
|
+
bundle install
|
350
|
+
EOS
|
351
|
+
|
352
|
+
message <<-"EOS" if name == 'libxml2'
|
353
|
+
|
354
|
+
Note, however, that nokogiri is not fully compatible with arbitrary
|
355
|
+
versions of libxml2 provided by OS/package vendors.
|
356
|
+
EOS
|
357
|
+
|
358
|
+
message <<-"EOS"
|
359
|
+
************************************************************************
|
360
|
+
EOS
|
361
|
+
|
362
|
+
checkpoint = "#{recipe.target}/#{recipe.name}-#{recipe.version}-#{recipe.host}.installed"
|
363
|
+
unless File.exist?(checkpoint)
|
364
|
+
chdir_for_build do
|
365
|
+
recipe.cook
|
366
|
+
end
|
367
|
+
FileUtils.touch checkpoint
|
368
|
+
end
|
369
|
+
recipe.activate
|
370
|
+
end
|
371
|
+
end
|
372
|
+
|
373
|
+
def lib_a(ldflag)
|
374
|
+
case ldflag
|
375
|
+
when /\A-l(.+)/
|
376
|
+
"lib#{$1}.#{$LIBEXT}"
|
377
|
+
end
|
378
|
+
end
|
379
|
+
|
380
|
+
def using_system_libraries?
|
381
|
+
arg_config('--use-system-libraries', !!ENV['NOKOGIRI_USE_SYSTEM_LIBRARIES'])
|
382
|
+
end
|
383
|
+
|
384
|
+
#
|
385
|
+
# main
|
386
|
+
#
|
387
|
+
|
388
|
+
case
|
389
|
+
when arg_config('--help')
|
390
|
+
do_help
|
391
|
+
when arg_config('--clean')
|
392
|
+
do_clean
|
393
|
+
end
|
394
|
+
|
395
|
+
if darwin?
|
396
|
+
ENV['CFLAGS'] = "#{ENV['CFLAGS']} -I /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/libxml2"
|
397
|
+
end
|
398
|
+
|
399
|
+
if openbsd? && !using_system_libraries?
|
400
|
+
if `#{ENV['CC'] || '/usr/bin/cc'} -v 2>&1` !~ /clang/
|
401
|
+
ENV['CC'] ||= find_executable('egcc') or
|
402
|
+
abort "Please install gcc 4.9+ from ports using `pkg_add -v gcc`"
|
403
|
+
end
|
404
|
+
ENV['CFLAGS'] = "#{ENV['CFLAGS']} -I /usr/local/include"
|
405
|
+
end
|
406
|
+
|
407
|
+
if ENV['CC']
|
408
|
+
RbConfig::CONFIG['CC'] = RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC']
|
409
|
+
end
|
410
|
+
# use same c compiler for libxml and libxslt
|
411
|
+
ENV['CC'] = RbConfig::CONFIG['CC']
|
412
|
+
|
413
|
+
$LIBS << " #{ENV["LIBS"]}"
|
414
|
+
|
415
|
+
# Read CFLAGS from ENV and make sure compiling works.
|
416
|
+
add_cflags(ENV["CFLAGS"])
|
417
|
+
|
418
|
+
if windows?
|
419
|
+
$CFLAGS << " -DXP_WIN -DXP_WIN32 -DUSE_INCLUDED_VASPRINTF"
|
420
|
+
end
|
421
|
+
|
422
|
+
if solaris?
|
423
|
+
$CFLAGS << " -DUSE_INCLUDED_VASPRINTF"
|
424
|
+
end
|
425
|
+
|
426
|
+
if darwin?
|
427
|
+
# Let Apple LLVM/clang 5.1 ignore unknown compiler flags
|
428
|
+
add_cflags("-Wno-error=unused-command-line-argument-hard-error-in-future")
|
429
|
+
end
|
430
|
+
|
431
|
+
if nix?
|
432
|
+
$CFLAGS << " -g -DXP_UNIX"
|
433
|
+
end
|
434
|
+
|
435
|
+
if RUBY_PLATFORM =~ /mingw/i
|
436
|
+
# Work around a character escaping bug in MSYS by passing an arbitrary
|
437
|
+
# double quoted parameter to gcc. See https://sourceforge.net/p/mingw/bugs/2142
|
438
|
+
$CPPFLAGS << ' "-Idummypath"'
|
439
|
+
end
|
440
|
+
|
441
|
+
if RbConfig::CONFIG['CC'] =~ /gcc/
|
442
|
+
$CFLAGS << " -O3" unless $CFLAGS[/-O\d/]
|
443
|
+
$CFLAGS << " -Wall -Wcast-qual -Wwrite-strings -Wmissing-noreturn -Winline"
|
444
|
+
end
|
445
|
+
|
446
|
+
case
|
447
|
+
when using_system_libraries?
|
448
|
+
message "Building nokogiri using system libraries.\n"
|
449
|
+
|
450
|
+
dir_config('zlib')
|
451
|
+
|
452
|
+
# Using system libraries means we rely on the system libxml2 with
|
453
|
+
# regard to the iconv support.
|
454
|
+
|
455
|
+
dir_config('xml2').any? or package_config('libxml-2.0')
|
456
|
+
dir_config('xslt').any? or package_config('libxslt')
|
457
|
+
dir_config('exslt').any? or package_config('libexslt')
|
458
|
+
|
459
|
+
check_libxml_version or abort "ERROR: cannot discover where libxml2 is located on your system. please make sure `pkg-config` is installed."
|
460
|
+
check_libxml_version("2.6.21") or abort "ERROR: libxml2 version 2.6.21 or later is required!"
|
461
|
+
check_libxml_version("2.9.3") or warn "WARNING: libxml2 version 2.9.3 or later is highly recommended, but proceeding anyway."
|
462
|
+
|
463
|
+
else
|
464
|
+
message "Building nokogiri using packaged libraries.\n"
|
465
|
+
|
466
|
+
# The gem version constraint in the Rakefile is not respected at install time.
|
467
|
+
# Keep this version in sync with the one in the Rakefile !
|
468
|
+
require 'rubygems'
|
469
|
+
gem 'mini_portile2', '~> 2.4.0'
|
470
|
+
require 'mini_portile2'
|
471
|
+
message "Using mini_portile version #{MiniPortile::VERSION}\n"
|
472
|
+
|
473
|
+
require 'yaml'
|
474
|
+
|
475
|
+
static_p = enable_config('static', true) or
|
476
|
+
message "Static linking is disabled.\n"
|
477
|
+
|
478
|
+
dir_config('zlib')
|
479
|
+
|
480
|
+
dependencies = YAML.load_file(File.join(ROOT, "dependencies.yml"))
|
481
|
+
|
482
|
+
cross_build_p = enable_config("cross-build")
|
483
|
+
if cross_build_p || windows?
|
484
|
+
zlib_recipe = process_recipe("zlib", dependencies["zlib"]["version"], static_p, cross_build_p) do |recipe|
|
485
|
+
recipe.files = [{
|
486
|
+
url: "http://zlib.net/fossils/#{recipe.name}-#{recipe.version}.tar.gz",
|
487
|
+
sha256: dependencies["zlib"]["sha256"]
|
488
|
+
}]
|
489
|
+
if windows?
|
490
|
+
class << recipe
|
491
|
+
attr_accessor :cross_build_p
|
492
|
+
|
493
|
+
def configure
|
494
|
+
Dir.chdir work_path do
|
495
|
+
mk = File.read 'win32/Makefile.gcc'
|
496
|
+
File.open 'win32/Makefile.gcc', 'wb' do |f|
|
497
|
+
f.puts "BINARY_PATH = #{path}/bin"
|
498
|
+
f.puts "LIBRARY_PATH = #{path}/lib"
|
499
|
+
f.puts "INCLUDE_PATH = #{path}/include"
|
500
|
+
mk.sub!(/^PREFIX\s*=\s*$/, "PREFIX = #{host}-") if cross_build_p
|
501
|
+
f.puts mk
|
502
|
+
end
|
503
|
+
end
|
504
|
+
end
|
505
|
+
|
506
|
+
def configured?
|
507
|
+
Dir.chdir work_path do
|
508
|
+
!! (File.read('win32/Makefile.gcc') =~ /^BINARY_PATH/)
|
509
|
+
end
|
510
|
+
end
|
511
|
+
|
512
|
+
def compile
|
513
|
+
execute "compile", "make -f win32/Makefile.gcc"
|
514
|
+
end
|
515
|
+
|
516
|
+
def install
|
517
|
+
execute "install", "make -f win32/Makefile.gcc install"
|
518
|
+
end
|
519
|
+
end
|
520
|
+
recipe.cross_build_p = cross_build_p
|
521
|
+
else
|
522
|
+
class << recipe
|
523
|
+
def configure
|
524
|
+
execute "configure", ["env", "CHOST=#{host}", "CFLAGS=-fPIC #{ENV['CFLAGS']}", "./configure", "--static", configure_prefix]
|
525
|
+
end
|
526
|
+
end
|
527
|
+
end
|
528
|
+
end
|
529
|
+
|
530
|
+
unless nix?
|
531
|
+
libiconv_recipe = process_recipe("libiconv", dependencies["libiconv"]["version"], static_p, cross_build_p) do |recipe|
|
532
|
+
recipe.files = [{
|
533
|
+
url: "http://ftp.gnu.org/pub/gnu/libiconv/#{recipe.name}-#{recipe.version}.tar.gz",
|
534
|
+
sha256: dependencies["libiconv"]["sha256"]
|
535
|
+
}]
|
536
|
+
recipe.configure_options += [
|
537
|
+
"CPPFLAGS=-Wall",
|
538
|
+
"CFLAGS=-O2 -g",
|
539
|
+
"CXXFLAGS=-O2 -g",
|
540
|
+
"LDFLAGS="
|
541
|
+
]
|
542
|
+
end
|
543
|
+
end
|
544
|
+
else
|
545
|
+
if darwin? && !have_header('iconv.h')
|
546
|
+
abort <<'EOM'.chomp
|
547
|
+
-----
|
548
|
+
The file "iconv.h" is missing in your build environment,
|
549
|
+
which means you haven't installed Xcode Command Line Tools properly.
|
550
|
+
|
551
|
+
To install Command Line Tools, try running `xcode-select --install` on
|
552
|
+
terminal and follow the instructions. If it fails, open Xcode.app,
|
553
|
+
select from the menu "Xcode" - "Open Developer Tool" - "More Developer
|
554
|
+
Tools" to open the developer site, download the installer for your OS
|
555
|
+
version and run it.
|
556
|
+
-----
|
557
|
+
EOM
|
558
|
+
end
|
559
|
+
end
|
560
|
+
|
561
|
+
unless windows?
|
562
|
+
preserving_globals {
|
563
|
+
have_library('z', 'gzdopen', 'zlib.h')
|
564
|
+
} or abort 'zlib is missing; necessary for building libxml2'
|
565
|
+
end
|
566
|
+
|
567
|
+
libxml2_recipe = process_recipe("libxml2", dependencies["libxml2"]["version"], static_p, cross_build_p) do |recipe|
|
568
|
+
recipe.files = [{
|
569
|
+
url: "http://xmlsoft.org/sources/#{recipe.name}-#{recipe.version}.tar.gz",
|
570
|
+
sha256: dependencies["libxml2"]["sha256"]
|
571
|
+
}]
|
572
|
+
recipe.configure_options += [
|
573
|
+
"--without-python",
|
574
|
+
"--without-readline",
|
575
|
+
*(zlib_recipe ? ["--with-zlib=#{zlib_recipe.path}", "CFLAGS=-I#{zlib_recipe.path}/include"] : []),
|
576
|
+
*(libiconv_recipe ? "--with-iconv=#{libiconv_recipe.path}" : iconv_configure_flags),
|
577
|
+
"--with-c14n",
|
578
|
+
"--with-debug",
|
579
|
+
"--with-threads",
|
580
|
+
*(darwin? ? ["RANLIB=/usr/bin/ranlib", "AR=/usr/bin/ar"] : "")
|
581
|
+
]
|
582
|
+
end
|
583
|
+
|
584
|
+
libxslt_recipe = process_recipe("libxslt", dependencies["libxslt"]["version"], static_p, cross_build_p) do |recipe|
|
585
|
+
recipe.files = [{
|
586
|
+
url: "http://xmlsoft.org/sources/#{recipe.name}-#{recipe.version}.tar.gz",
|
587
|
+
sha256: dependencies["libxslt"]["sha256"]
|
588
|
+
}]
|
589
|
+
recipe.configure_options += [
|
590
|
+
"--without-python",
|
591
|
+
"--without-crypto",
|
592
|
+
"--with-debug",
|
593
|
+
"--with-libxml-prefix=#{sh_export_path(libxml2_recipe.path)}",
|
594
|
+
*(darwin? ? ["RANLIB=/usr/bin/ranlib", "AR=/usr/bin/ar"] : "")
|
595
|
+
]
|
596
|
+
end
|
597
|
+
|
598
|
+
$CFLAGS << ' ' << '-DNOKOGIRI_USE_PACKAGED_LIBRARIES'
|
599
|
+
$LIBPATH = ["#{zlib_recipe.path}/lib"] | $LIBPATH if zlib_recipe
|
600
|
+
$LIBPATH = ["#{libiconv_recipe.path}/lib"] | $LIBPATH if libiconv_recipe
|
601
|
+
|
602
|
+
have_lzma = preserving_globals {
|
603
|
+
have_library('lzma')
|
604
|
+
}
|
605
|
+
|
606
|
+
$libs = $libs.shellsplit.tap do |libs|
|
607
|
+
[libxml2_recipe, libxslt_recipe].each do |recipe|
|
608
|
+
libname = recipe.name[/\Alib(.+)\z/, 1]
|
609
|
+
File.join(recipe.path, "bin", "#{libname}-config").tap do |config|
|
610
|
+
# call config scripts explicit with 'sh' for compat with Windows
|
611
|
+
$CPPFLAGS = `sh #{config} --cflags`.strip << ' ' << $CPPFLAGS
|
612
|
+
`sh #{config} --libs`.strip.shellsplit.each do |arg|
|
613
|
+
case arg
|
614
|
+
when /\A-L(.+)\z/
|
615
|
+
# Prioritize ports' directories
|
616
|
+
if $1.start_with?(ROOT + '/')
|
617
|
+
$LIBPATH = [$1] | $LIBPATH
|
618
|
+
else
|
619
|
+
$LIBPATH = $LIBPATH | [$1]
|
620
|
+
end
|
621
|
+
when /\A-l./
|
622
|
+
libs.unshift(arg)
|
623
|
+
else
|
624
|
+
$LDFLAGS << ' ' << arg.shellescape
|
625
|
+
end
|
626
|
+
end
|
627
|
+
end
|
628
|
+
|
629
|
+
# Defining a macro that expands to a C string; double quotes are significant.
|
630
|
+
$CPPFLAGS << ' ' << "-DNOKOGIRI_#{recipe.name.upcase}_PATCHES=\"#{recipe.patch_files.map { |path| File.basename(path) }.join(' ')}\"".inspect
|
631
|
+
|
632
|
+
case libname
|
633
|
+
when 'xml2'
|
634
|
+
# xslt-config --libs or pkg-config libxslt --libs does not include
|
635
|
+
# -llzma, so we need to add it manually when linking statically.
|
636
|
+
if static_p && have_lzma
|
637
|
+
# Add it at the end; GH #988
|
638
|
+
libs << '-llzma'
|
639
|
+
end
|
640
|
+
when 'xslt'
|
641
|
+
# xslt-config does not have a flag to emit options including
|
642
|
+
# -lexslt, so add it manually.
|
643
|
+
libs.unshift('-lexslt')
|
644
|
+
end
|
645
|
+
end
|
646
|
+
end.shelljoin
|
647
|
+
|
648
|
+
if static_p
|
649
|
+
$libs = $libs.shellsplit.map do |arg|
|
650
|
+
case arg
|
651
|
+
when '-lxml2'
|
652
|
+
File.join(libxml2_recipe.path, 'lib', lib_a(arg))
|
653
|
+
when '-lxslt', '-lexslt'
|
654
|
+
File.join(libxslt_recipe.path, 'lib', lib_a(arg))
|
655
|
+
else
|
656
|
+
arg
|
657
|
+
end
|
658
|
+
end.shelljoin
|
659
|
+
end
|
660
|
+
end
|
661
|
+
|
662
|
+
{
|
663
|
+
"xml2" => ['xmlParseDoc', 'libxml/parser.h'],
|
664
|
+
"xslt" => ['xsltParseStylesheetDoc', 'libxslt/xslt.h'],
|
665
|
+
"exslt" => ['exsltFuncRegister', 'libexslt/exslt.h'],
|
666
|
+
}.each do |lib, (func, header)|
|
667
|
+
have_func(func, header) ||
|
668
|
+
have_library(lib, func, header) ||
|
669
|
+
have_library("lib#{lib}", func, header) or
|
670
|
+
asplode("lib#{lib}")
|
671
|
+
end
|
672
|
+
|
673
|
+
have_func('xmlHasFeature') or abort "xmlHasFeature() is missing."
|
674
|
+
have_func('xmlFirstElementChild')
|
675
|
+
have_func('xmlRelaxNGSetParserStructuredErrors')
|
676
|
+
have_func('xmlRelaxNGSetParserStructuredErrors')
|
677
|
+
have_func('xmlRelaxNGSetValidStructuredErrors')
|
678
|
+
have_func('xmlSchemaSetValidStructuredErrors')
|
679
|
+
have_func('xmlSchemaSetParserStructuredErrors')
|
680
|
+
|
681
|
+
create_makefile('nokogiri/nokogiri')
|
682
|
+
|
683
|
+
if enable_config('clean', true)
|
684
|
+
# Do not clean if run in a development work tree.
|
685
|
+
File.open('Makefile', 'at') do |mk|
|
686
|
+
mk.print <<EOF
|
687
|
+
all: clean-ports
|
688
|
+
|
689
|
+
clean-ports: $(DLLIB)
|
690
|
+
-$(Q)$(RUBY) $(srcdir)/extconf.rb --clean --#{static_p ? 'enable' : 'disable'}-static
|
691
|
+
EOF
|
692
|
+
end
|
693
|
+
end
|
694
|
+
|
695
|
+
# :startdoc:
|