nokogiri 1.6.1-x86-mingw32 → 1.6.2.rc1-x86-mingw32
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 -7
- data/.editorconfig +17 -0
- data/.travis.yml +4 -6
- data/CHANGELOG.ja.rdoc +37 -8
- data/CHANGELOG.rdoc +48 -3
- data/Gemfile +3 -3
- data/Manifest.txt +57 -1
- data/README.ja.rdoc +22 -16
- data/README.rdoc +24 -19
- data/ROADMAP.md +1 -2
- data/Rakefile +161 -58
- data/build_all +56 -31
- data/dependencies.yml +3 -3
- data/ext/nokogiri/extconf.rb +379 -121
- data/ext/nokogiri/html_document.c +2 -2
- data/ext/nokogiri/nokogiri.c +6 -1
- data/ext/nokogiri/xml_document.c +5 -4
- data/ext/nokogiri/xml_node.c +11 -4
- data/ext/nokogiri/xml_reader.c +1 -1
- data/ext/nokogiri/xml_sax_parser_context.c +40 -0
- data/ext/nokogiri/xml_syntax_error.c +10 -5
- data/ext/nokogiri/xml_syntax_error.h +1 -1
- data/ext/nokogiri/xml_xpath_context.c +2 -14
- data/ext/nokogiri/xslt_stylesheet.c +1 -1
- data/lib/nokogiri.rb +31 -22
- data/lib/nokogiri/1.9/nokogiri.so +0 -0
- data/lib/nokogiri/2.0/nokogiri.so +0 -0
- data/lib/nokogiri/2.1/nokogiri.so +0 -0
- data/lib/nokogiri/css/node.rb +0 -50
- data/lib/nokogiri/css/parser.rb +213 -218
- data/lib/nokogiri/css/parser.y +21 -30
- data/lib/nokogiri/css/xpath_visitor.rb +62 -14
- data/lib/nokogiri/html/document.rb +97 -18
- data/lib/nokogiri/html/sax/parser.rb +2 -2
- data/lib/nokogiri/version.rb +1 -1
- data/lib/nokogiri/xml/builder.rb +1 -1
- data/lib/nokogiri/xml/document.rb +2 -2
- data/lib/nokogiri/xml/dtd.rb +10 -0
- data/lib/nokogiri/xml/node.rb +26 -1
- data/lib/nokogiri/xml/sax/parser.rb +1 -1
- data/suppressions/README.txt +1 -0
- data/suppressions/nokogiri_ree-1.8.7.358.supp +61 -0
- data/suppressions/nokogiri_ruby-1.8.7.370.supp +0 -0
- data/suppressions/nokogiri_ruby-1.9.2.320.supp +28 -0
- data/suppressions/nokogiri_ruby-1.9.3.327.supp +28 -0
- data/test/css/test_nthiness.rb +65 -2
- data/test/css/test_parser.rb +27 -10
- data/test/css/test_tokenizer.rb +1 -1
- data/test/css/test_xpath_visitor.rb +6 -1
- data/test/files/atom.xml +344 -0
- data/test/files/shift_jis_no_charset.html +9 -0
- data/test/helper.rb +10 -0
- data/test/html/test_document.rb +74 -7
- data/test/html/test_document_encoding.rb +10 -0
- data/test/html/test_document_fragment.rb +3 -3
- data/test/namespaces/test_namespaces_in_cloned_doc.rb +31 -0
- data/test/test_nokogiri.rb +6 -0
- data/test/test_reader.rb +7 -4
- data/test/test_xslt_transforms.rb +25 -0
- data/test/xml/sax/test_parser.rb +16 -0
- data/test/xml/sax/test_parser_context.rb +9 -0
- data/test/xml/test_builder.rb +9 -0
- data/test/xml/test_c14n.rb +12 -2
- data/test/xml/test_document.rb +66 -0
- data/test/xml/test_document_fragment.rb +5 -0
- data/test/xml/test_dtd.rb +84 -0
- data/test/xml/test_entity_reference.rb +3 -3
- data/test/xml/test_node.rb +21 -3
- data/test/xml/test_node_attributes.rb +17 -0
- data/test/xml/test_schema.rb +26 -0
- data/test/xml/test_xpath.rb +81 -0
- metadata +235 -176
- data/lib/nokogiri/nokogiri.rb +0 -1
- data/tasks/cross_compile.rb +0 -134
data/dependencies.yml
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
libxml2: "2.8.0"
|
2
|
-
libxslt: "1.1.
|
3
|
-
zlib: "1.2.
|
4
|
-
libiconv: "1.
|
2
|
+
libxslt: "1.1.28"
|
3
|
+
zlib: "1.2.8"
|
4
|
+
libiconv: "1.14"
|
data/ext/nokogiri/extconf.rb
CHANGED
@@ -1,15 +1,74 @@
|
|
1
1
|
ENV['RC_ARCHS'] = '' if RUBY_PLATFORM =~ /darwin/
|
2
2
|
|
3
|
+
# Available options:
|
4
|
+
#
|
5
|
+
# --enable-clean (default)
|
6
|
+
# --disable-clean
|
7
|
+
#
|
8
|
+
# --enable-static (default)
|
9
|
+
# --disable-static
|
10
|
+
#
|
11
|
+
# --with-iconv-dir=DIR
|
12
|
+
#
|
13
|
+
# --with-zlib-dir=DIR
|
14
|
+
#
|
15
|
+
# --use-system-libraries
|
16
|
+
# --with-xml2-dir=DIR / --with-xml2-config=CONFIG
|
17
|
+
# --with-xslt-dir=DIR / --with-xslt-config=CONFIG
|
18
|
+
# --with-exslt-dir=DIR / --with-exslt-config=CONFIG
|
19
|
+
#
|
20
|
+
# --enable-cross-build
|
21
|
+
|
3
22
|
# :stopdoc:
|
4
23
|
|
5
24
|
require 'mkmf'
|
6
25
|
|
26
|
+
def message!(important_message)
|
27
|
+
message important_message
|
28
|
+
if !$stdout.tty? && File.chardev?('/dev/tty')
|
29
|
+
File.open('/dev/tty', 'w') { |tty|
|
30
|
+
tty.print important_message
|
31
|
+
}
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
7
35
|
RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC']
|
8
36
|
|
9
37
|
ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
10
|
-
|
11
|
-
|
12
|
-
|
38
|
+
# Workaround for Ruby bug #8074, introduced in Ruby 2.0.0, fixed in Ruby 2.1.0
|
39
|
+
# https://bugs.ruby-lang.org/issues/8074
|
40
|
+
@libdir_basename = "lib"
|
41
|
+
|
42
|
+
if arg_config('--clean')
|
43
|
+
require 'pathname'
|
44
|
+
require 'fileutils'
|
45
|
+
|
46
|
+
root = Pathname(ROOT)
|
47
|
+
pwd = Pathname(Dir.pwd)
|
48
|
+
|
49
|
+
# Skip if this is a development work tree
|
50
|
+
unless (root + '.git').exist?
|
51
|
+
message "Cleaning files only used during build.\n"
|
52
|
+
|
53
|
+
# (root + 'tmp') cannot be removed at this stage because
|
54
|
+
# nokogiri.so is yet to be copied to lib.
|
55
|
+
|
56
|
+
# clean the ports build directory
|
57
|
+
Pathname.glob(pwd.join('tmp', '*', 'ports')) { |dir|
|
58
|
+
FileUtils.rm_rf(dir, verbose: true)
|
59
|
+
FileUtils.rmdir(dir.parent, parents: true, verbose: true)
|
60
|
+
}
|
61
|
+
|
62
|
+
if enable_config('static')
|
63
|
+
# ports installation can be safely removed if statically linked.
|
64
|
+
FileUtils.rm_rf(root + 'ports', verbose: true)
|
65
|
+
else
|
66
|
+
FileUtils.rm_rf(root + 'ports' + 'archives', verbose: true)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
exit
|
71
|
+
end
|
13
72
|
|
14
73
|
if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'macruby'
|
15
74
|
$LIBRUBYARG_STATIC.gsub!(/-static/, '')
|
@@ -18,158 +77,345 @@ end
|
|
18
77
|
$CFLAGS << " #{ENV["CFLAGS"]}"
|
19
78
|
$LIBS << " #{ENV["LIBS"]}"
|
20
79
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
80
|
+
def preserving_globals
|
81
|
+
values = [
|
82
|
+
$arg_config,
|
83
|
+
$CFLAGS, $CPPFLAGS,
|
84
|
+
$LDFLAGS, $LIBPATH, $libs
|
85
|
+
].map(&:dup)
|
86
|
+
yield
|
87
|
+
ensure
|
88
|
+
$arg_config,
|
89
|
+
$CFLAGS, $CPPFLAGS,
|
90
|
+
$LDFLAGS, $LIBPATH, $libs =
|
91
|
+
values
|
29
92
|
end
|
30
93
|
|
31
|
-
|
32
|
-
|
33
|
-
$LIBS << " -lz" # TODO why is this necessary?
|
94
|
+
def asplode(lib)
|
95
|
+
abort "-----\n#{lib} is missing. please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.\n-----"
|
34
96
|
end
|
35
97
|
|
36
|
-
|
37
|
-
|
38
|
-
|
98
|
+
def have_iconv?
|
99
|
+
have_header('iconv.h') or return false
|
100
|
+
%w{ iconv_open libiconv_open }.any? do |method|
|
101
|
+
have_func(method, 'iconv.h') or
|
102
|
+
have_library('iconv', method, 'iconv.h')
|
103
|
+
end
|
39
104
|
end
|
40
105
|
|
41
|
-
|
42
|
-
#
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
106
|
+
def each_iconv_idir
|
107
|
+
# If --with-iconv-dir or --with-opt-dir is given, it should be
|
108
|
+
# the first priority
|
109
|
+
%w[iconv opt].each { |config|
|
110
|
+
idir = preserving_globals {
|
111
|
+
dir_config(config)
|
112
|
+
}.first and yield idir
|
113
|
+
}
|
114
|
+
|
115
|
+
# Try the system default
|
116
|
+
yield "/usr/include"
|
117
|
+
|
118
|
+
cflags, = preserving_globals {
|
119
|
+
pkg_config('libiconv')
|
120
|
+
}
|
121
|
+
if cflags
|
122
|
+
cflags.shellsplit.each { |arg|
|
123
|
+
arg.sub!(/\A-I/, '') and
|
124
|
+
yield arg
|
125
|
+
}
|
126
|
+
end
|
52
127
|
|
53
|
-
|
54
|
-
|
128
|
+
nil
|
129
|
+
end
|
55
130
|
|
56
|
-
|
57
|
-
|
131
|
+
def iconv_prefix
|
132
|
+
# Make sure libxml2 is built with iconv
|
133
|
+
each_iconv_idir { |idir|
|
134
|
+
prefix = %r{\A(.+)?/include\z} === idir && $1 or next
|
135
|
+
File.exist?(File.join(idir, 'iconv.h')) or next
|
136
|
+
preserving_globals {
|
137
|
+
# Follow the way libxml2's configure uses a value given with
|
138
|
+
# --with-iconv[=DIR]
|
139
|
+
$CPPFLAGS = "-I#{idir} " << $CPPFLAGS
|
140
|
+
$LIBPATH.unshift(File.join(prefix, "lib"))
|
141
|
+
have_iconv?
|
142
|
+
} and break prefix
|
143
|
+
} or asplode "libiconv"
|
144
|
+
end
|
58
145
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
146
|
+
def process_recipe(name, version, static_p, cross_p)
|
147
|
+
MiniPortile.new(name, version).tap do |recipe|
|
148
|
+
recipe.target = portsdir = File.join(ROOT, "ports")
|
149
|
+
# Prefer host_alias over host in order to use i586-mingw32msvc as
|
150
|
+
# correct compiler prefix for cross build, but use host if not set.
|
151
|
+
recipe.host = RbConfig::CONFIG["host_alias"].empty? ? RbConfig::CONFIG["host"] : RbConfig::CONFIG["host_alias"]
|
152
|
+
recipe.patch_files = Dir[File.join(portsdir, "patches", name, "*.patch")].sort
|
63
153
|
|
64
|
-
|
65
|
-
|
66
|
-
|
154
|
+
if static_p
|
155
|
+
recipe.configure_options = [
|
156
|
+
"--disable-shared",
|
157
|
+
"--enable-static",
|
158
|
+
"CFLAGS='-fPIC #{ENV["CFLAGS"]}'",
|
159
|
+
]
|
160
|
+
else
|
161
|
+
recipe.configure_options = [
|
162
|
+
"--enable-shared",
|
163
|
+
"--disable-static",
|
164
|
+
]
|
165
|
+
end
|
67
166
|
|
68
|
-
|
69
|
-
|
167
|
+
if cross_p
|
168
|
+
recipe.configure_options += [
|
169
|
+
"--target=#{recipe.host}",
|
170
|
+
"--host=#{recipe.host}",
|
171
|
+
]
|
172
|
+
end
|
70
173
|
|
71
|
-
|
72
|
-
LIBDIR,
|
174
|
+
yield recipe
|
73
175
|
|
74
|
-
|
75
|
-
|
76
|
-
|
176
|
+
if recipe.patch_files.empty?
|
177
|
+
message! "Building #{name}-#{version} for nokogiri.\n"
|
178
|
+
else
|
179
|
+
message! "Building #{name}-#{version} for nokogiri with the following patches applied:\n"
|
77
180
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
File.join(INCLUDEDIR, "libxml2")
|
82
|
-
] + HEADER_DIRS
|
83
|
-
|
84
|
-
# If the user has homebrew installed, use the libxml2 inside homebrew
|
85
|
-
brew_prefix = `brew --prefix libxml2 2> /dev/null`.chomp
|
86
|
-
unless brew_prefix.empty?
|
87
|
-
LIB_DIRS.unshift File.join(brew_prefix, 'lib')
|
88
|
-
XML2_HEADER_DIRS.unshift File.join(brew_prefix, 'include/libxml2')
|
181
|
+
recipe.patch_files.each { |patch|
|
182
|
+
message! "\t- %s\n" % File.basename(patch)
|
183
|
+
}
|
89
184
|
end
|
90
185
|
|
91
|
-
|
92
|
-
|
93
|
-
|
186
|
+
message! <<-"EOS"
|
187
|
+
************************************************************************
|
188
|
+
IMPORTANT! Nokogiri builds and uses a packaged version of #{name}.
|
94
189
|
|
95
|
-
|
96
|
-
|
97
|
-
|
190
|
+
If this is a concern for you and you want to use the system library
|
191
|
+
instead, abort this installation process and reinstall nokogiri as
|
192
|
+
follows:
|
98
193
|
|
99
|
-
|
100
|
-
unless File.exist?(checkpoint)
|
101
|
-
recipe.cook
|
102
|
-
FileUtils.touch checkpoint
|
103
|
-
end
|
104
|
-
recipe.activate
|
105
|
-
end
|
194
|
+
gem install nokogiri -- --use-system-libraries
|
106
195
|
|
107
|
-
|
196
|
+
If you are using Bundler, tell it to use the option:
|
108
197
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
"--disable-static",
|
113
|
-
"--without-python",
|
114
|
-
"--without-readline",
|
115
|
-
"--with-c14n",
|
116
|
-
"--with-debug",
|
117
|
-
"--with-threads"
|
118
|
-
]
|
119
|
-
common_recipe.call recipe
|
120
|
-
end
|
198
|
+
bundle config build.nokogiri --use-system-libraries
|
199
|
+
bundle install
|
200
|
+
EOS
|
121
201
|
|
122
|
-
|
123
|
-
recipe.configure_options = [
|
124
|
-
"--enable-shared",
|
125
|
-
"--disable-static",
|
126
|
-
"--without-python",
|
127
|
-
"--without-crypto",
|
128
|
-
"--with-debug",
|
129
|
-
"--with-libxml-prefix=#{libxml2_recipe.path}"
|
130
|
-
]
|
131
|
-
common_recipe.call recipe
|
132
|
-
end
|
202
|
+
message! <<-"EOS" if name == 'libxml2'
|
133
203
|
|
134
|
-
|
135
|
-
|
204
|
+
However, note that nokogiri does not necessarily support all versions
|
205
|
+
of libxml2.
|
136
206
|
|
137
|
-
|
207
|
+
For example, libxml2-2.9.0 and higher are currently known to be broken
|
208
|
+
and thus unsupported by nokogiri, due to compatibility problems and
|
209
|
+
XPath optimization bugs.
|
210
|
+
EOS
|
138
211
|
|
139
|
-
|
140
|
-
|
141
|
-
|
212
|
+
message! <<-"EOS"
|
213
|
+
************************************************************************
|
214
|
+
EOS
|
215
|
+
|
216
|
+
checkpoint = "#{recipe.target}/#{recipe.name}-#{recipe.version}-#{recipe.host}.installed"
|
217
|
+
unless File.exist?(checkpoint)
|
218
|
+
recipe.cook
|
219
|
+
FileUtils.touch checkpoint
|
220
|
+
end
|
221
|
+
recipe.activate
|
142
222
|
end
|
143
223
|
end
|
144
224
|
|
145
|
-
|
146
|
-
dir_config('iconv', HEADER_DIRS, LIB_DIRS)
|
147
|
-
dir_config('xml2', XML2_HEADER_DIRS, LIB_DIRS)
|
148
|
-
dir_config('xslt', HEADER_DIRS, LIB_DIRS)
|
225
|
+
windows_p = RbConfig::CONFIG['target_os'] == 'mingw32' || RbConfig::CONFIG['target_os'] =~ /mswin/
|
149
226
|
|
150
|
-
|
151
|
-
|
227
|
+
if windows_p
|
228
|
+
$CFLAGS << " -DXP_WIN -DXP_WIN32 -DUSE_INCLUDED_VASPRINTF"
|
229
|
+
elsif RbConfig::CONFIG['target_os'] =~ /solaris/
|
230
|
+
$CFLAGS << " -DUSE_INCLUDED_VASPRINTF"
|
231
|
+
else
|
232
|
+
$CFLAGS << " -g -DXP_UNIX"
|
152
233
|
end
|
153
234
|
|
154
|
-
|
155
|
-
|
156
|
-
|
235
|
+
if RUBY_PLATFORM =~ /mingw/i
|
236
|
+
# Work around a character escaping bug in MSYS by passing an arbitrary
|
237
|
+
# double quoted parameter to gcc. See https://sourceforge.net/p/mingw/bugs/2142
|
238
|
+
$CPPFLAGS << ' "-Idummypath"'
|
239
|
+
end
|
157
240
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
241
|
+
if RbConfig::MAKEFILE_CONFIG['CC'] =~ /gcc/
|
242
|
+
$CFLAGS << " -O3" unless $CFLAGS[/-O\d/]
|
243
|
+
$CFLAGS << " -Wall -Wcast-qual -Wwrite-strings -Wconversion -Wmissing-noreturn -Winline"
|
244
|
+
end
|
245
|
+
|
246
|
+
case
|
247
|
+
when arg_config('--use-system-libraries', !!ENV['NOKOGIRI_USE_SYSTEM_LIBRARIES'])
|
248
|
+
message! "Building nokogiri using system libraries.\n"
|
249
|
+
|
250
|
+
dir_config('zlib')
|
251
|
+
|
252
|
+
# Using system libraries means we rely on the system libxml2 with
|
253
|
+
# regard to the iconv support.
|
254
|
+
|
255
|
+
dir_config('xml2').any? || pkg_config('libxml-2.0')
|
256
|
+
dir_config('xslt').any? || pkg_config('libxslt')
|
257
|
+
dir_config('exslt').any? || pkg_config('libexslt')
|
258
|
+
else
|
259
|
+
message! "Building nokogiri using packaged libraries.\n"
|
260
|
+
|
261
|
+
require 'mini_portile'
|
262
|
+
require 'yaml'
|
263
|
+
|
264
|
+
static_p = enable_config('static', true) or
|
265
|
+
message! "Static linking is disabled.\n"
|
266
|
+
|
267
|
+
dir_config('zlib')
|
268
|
+
|
269
|
+
dependencies = YAML.load_file(File.join(ROOT, "dependencies.yml"))
|
270
|
+
|
271
|
+
cross_build_p = enable_config("cross-build")
|
272
|
+
if cross_build_p || windows_p
|
273
|
+
zlib_recipe = process_recipe("zlib", dependencies["zlib"], static_p, cross_build_p) do |recipe|
|
274
|
+
recipe.files = ["http://zlib.net/#{recipe.name}-#{recipe.version}.tar.gz"]
|
275
|
+
class << recipe
|
276
|
+
attr_accessor :cross_build_p
|
277
|
+
|
278
|
+
def configure
|
279
|
+
Dir.chdir work_path do
|
280
|
+
mk = File.read 'win32/Makefile.gcc'
|
281
|
+
File.open 'win32/Makefile.gcc', 'wb' do |f|
|
282
|
+
f.puts "BINARY_PATH = #{path}/bin"
|
283
|
+
f.puts "LIBRARY_PATH = #{path}/lib"
|
284
|
+
f.puts "INCLUDE_PATH = #{path}/include"
|
285
|
+
mk.sub!(/^PREFIX\s*=\s*$/, "PREFIX = #{host}-") if cross_build_p
|
286
|
+
f.puts mk
|
287
|
+
end
|
288
|
+
end
|
289
|
+
end
|
290
|
+
|
291
|
+
def configured?
|
292
|
+
Dir.chdir work_path do
|
293
|
+
!! (File.read('win32/Makefile.gcc') =~ /^BINARY_PATH/)
|
294
|
+
end
|
295
|
+
end
|
296
|
+
|
297
|
+
def compile
|
298
|
+
execute "compile", "make -f win32/Makefile.gcc"
|
299
|
+
end
|
300
|
+
|
301
|
+
def install
|
302
|
+
execute "install", "make -f win32/Makefile.gcc install"
|
303
|
+
end
|
304
|
+
end
|
305
|
+
recipe.cross_build_p = cross_build_p
|
306
|
+
end
|
307
|
+
|
308
|
+
libiconv_recipe = process_recipe("libiconv", dependencies["libiconv"], static_p, cross_build_p) do |recipe|
|
309
|
+
recipe.files = ["http://ftp.gnu.org/pub/gnu/libiconv/#{recipe.name}-#{recipe.version}.tar.gz"]
|
310
|
+
recipe.configure_options += [
|
311
|
+
"CPPFLAGS='-Wall'",
|
312
|
+
"CFLAGS='-O2 -g'",
|
313
|
+
"CXXFLAGS='-O2 -g'",
|
314
|
+
"LDFLAGS="
|
315
|
+
]
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|
319
|
+
libxml2_recipe = process_recipe("libxml2", dependencies["libxml2"], static_p, cross_build_p) do |recipe|
|
320
|
+
recipe.files = ["ftp://ftp.xmlsoft.org/libxml2/#{recipe.name}-#{recipe.version}.tar.gz"]
|
321
|
+
recipe.configure_options += [
|
322
|
+
"--without-python",
|
323
|
+
"--without-readline",
|
324
|
+
"--with-iconv=#{libiconv_recipe ? libiconv_recipe.path : iconv_prefix}",
|
325
|
+
"--with-c14n",
|
326
|
+
"--with-debug",
|
327
|
+
"--with-threads"
|
328
|
+
]
|
329
|
+
end
|
330
|
+
|
331
|
+
libxslt_recipe = process_recipe("libxslt", dependencies["libxslt"], static_p, cross_build_p) do |recipe|
|
332
|
+
recipe.files = ["ftp://ftp.xmlsoft.org/libxml2/#{recipe.name}-#{recipe.version}.tar.gz"]
|
333
|
+
recipe.configure_options += [
|
334
|
+
"--without-python",
|
335
|
+
"--without-crypto",
|
336
|
+
"--with-debug",
|
337
|
+
"--with-libxml-prefix=#{libxml2_recipe.path}"
|
338
|
+
]
|
339
|
+
end
|
340
|
+
|
341
|
+
$CFLAGS << ' ' << '-DNOKOGIRI_USE_PACKAGED_LIBRARIES'
|
342
|
+
$LIBPATH = ["#{zlib_recipe.path}/lib"] | $LIBPATH if zlib_recipe
|
343
|
+
$LIBPATH = ["#{libiconv_recipe.path}/lib"] | $LIBPATH if libiconv_recipe
|
344
|
+
|
345
|
+
have_lzma = preserving_globals {
|
346
|
+
have_library('lzma')
|
347
|
+
}
|
348
|
+
|
349
|
+
$libs = $libs.shellsplit.tap { |libs|
|
350
|
+
[libxml2_recipe, libxslt_recipe].each { |recipe|
|
351
|
+
libname = recipe.name[/\Alib(.+)\z/, 1]
|
352
|
+
File.join(recipe.path, "bin", "#{libname}-config").tap { |config|
|
353
|
+
# call config scripts explicit with 'sh' for compat with Windows
|
354
|
+
$CPPFLAGS = `sh #{config} --cflags`.strip << ' ' << $CPPFLAGS
|
355
|
+
`sh #{config} --libs`.strip.shellsplit.each { |arg|
|
356
|
+
case arg
|
357
|
+
when /\A-L(.+)\z/
|
358
|
+
# Prioritize ports' directories
|
359
|
+
if $1.start_with?(ROOT + '/')
|
360
|
+
$LIBPATH = [$1] | $LIBPATH
|
361
|
+
else
|
362
|
+
$LIBPATH = $LIBPATH | [$1]
|
363
|
+
end
|
364
|
+
when /\A-l./
|
365
|
+
libs.unshift(arg)
|
366
|
+
else
|
367
|
+
$LDFLAGS << ' ' << arg.shellescape
|
368
|
+
end
|
369
|
+
}
|
370
|
+
}
|
371
|
+
|
372
|
+
$CPPFLAGS << ' ' << "-DNOKOGIRI_#{recipe.name.upcase}_PATH=\"#{recipe.path}\"".shellescape
|
373
|
+
|
374
|
+
case libname
|
375
|
+
when 'xml2'
|
376
|
+
# xslt-config --libs or pkg-config libxslt --libs does not include
|
377
|
+
# -llzma, so we need to add it manually when linking statically.
|
378
|
+
if static_p && have_lzma
|
379
|
+
# Add it at the end; GH #988
|
380
|
+
libs << '-llzma'
|
381
|
+
end
|
382
|
+
when 'xslt'
|
383
|
+
# xslt-config does not have a flag to emit options including
|
384
|
+
# -lexslt, so add it manually.
|
385
|
+
libs.unshift('-lexslt')
|
386
|
+
end
|
387
|
+
}
|
388
|
+
}.shelljoin
|
389
|
+
|
390
|
+
if static_p
|
391
|
+
message 'checking for linker flags for static linking... '
|
392
|
+
|
393
|
+
case
|
394
|
+
when try_link('int main(void) { return 0; }',
|
395
|
+
['-Wl,-Bstatic', '-lxml2', '-Wl,-Bdynamic'].shelljoin)
|
396
|
+
message "-Wl,-Bstatic\n"
|
397
|
+
|
398
|
+
$libs = $libs.shellsplit.flat_map { |arg|
|
399
|
+
case arg
|
400
|
+
when '-lxml2', '-lxslt', '-lexslt'
|
401
|
+
['-Wl,-Bstatic', arg, '-Wl,-Bdynamic']
|
402
|
+
else
|
403
|
+
arg
|
404
|
+
end
|
405
|
+
}.shelljoin
|
406
|
+
else
|
407
|
+
message "NONE\n"
|
408
|
+
end
|
163
409
|
end
|
164
410
|
end
|
165
411
|
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
412
|
+
{
|
413
|
+
"xml2" => ['xmlParseDoc', 'libxml/parser.h'],
|
414
|
+
"xslt" => ['xsltParseStylesheetDoc', 'libxslt/xslt.h'],
|
415
|
+
"exslt" => ['exsltFuncRegister', 'libexslt/exslt.h'],
|
416
|
+
}.each { |lib, (func, header)|
|
417
|
+
have_func(func, header) || have_library(lib, func, header) || have_library("lib#{lib}", func, header) or asplode("lib#{lib}")
|
418
|
+
}
|
173
419
|
|
174
420
|
unless have_func('xmlHasFeature')
|
175
421
|
abort "-----\nThe function 'xmlHasFeature' is missing from your installation of libxml2. Likely this means that your installed version of libxml2 is old enough that nokogiri will not work well. To get around this problem, please upgrade your installation of libxml2.
|
@@ -192,4 +438,16 @@ end
|
|
192
438
|
|
193
439
|
create_makefile('nokogiri/nokogiri')
|
194
440
|
|
441
|
+
if enable_config('clean', true)
|
442
|
+
# Do not clean if run in a development work tree.
|
443
|
+
File.open('Makefile', 'at') { |mk|
|
444
|
+
mk.print <<EOF
|
445
|
+
all: clean-ports
|
446
|
+
|
447
|
+
clean-ports: $(DLLIB)
|
448
|
+
-$(Q)$(RUBY) $(srcdir)/extconf.rb --clean --#{static_p ? 'enable' : 'disable'}-static
|
449
|
+
EOF
|
450
|
+
}
|
451
|
+
end
|
452
|
+
|
195
453
|
# :startdoc:
|