nokogiri 1.6.1-java → 1.6.2-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/.editorconfig +17 -0
- data/.travis.yml +6 -6
- data/CHANGELOG.ja.rdoc +61 -8
- data/CHANGELOG.rdoc +58 -3
- data/Gemfile +3 -3
- data/Manifest.txt +57 -1
- data/README.ja.rdoc +22 -17
- data/README.rdoc +23 -18
- data/ROADMAP.md +1 -2
- data/Rakefile +162 -58
- data/build_all +56 -31
- data/dependencies.yml +3 -3
- data/ext/java/nokogiri/NokogiriService.java +9 -5
- data/ext/java/nokogiri/XmlDocument.java +95 -54
- data/ext/java/nokogiri/XmlNode.java +93 -42
- data/ext/java/nokogiri/XmlReader.java +1 -1
- data/ext/java/nokogiri/XmlSaxParserContext.java +33 -0
- data/ext/java/nokogiri/XmlSchema.java +4 -2
- data/ext/java/nokogiri/XmlXpathContext.java +118 -76
- data/ext/java/nokogiri/internals/IgnoreSchemaErrorsErrorHandler.java +20 -0
- data/ext/java/nokogiri/internals/NokogiriHandler.java +3 -10
- data/ext/java/nokogiri/internals/NokogiriHelpers.java +40 -23
- data/ext/java/nokogiri/internals/NokogiriNamespaceCache.java +59 -54
- data/ext/java/nokogiri/internals/NokogiriXPathFunctionResolver.java +1 -1
- data/ext/java/nokogiri/internals/ParserContext.java +1 -4
- data/ext/java/nokogiri/internals/SaveContextVisitor.java +6 -2
- data/ext/java/nokogiri/internals/c14n/AttrCompare.java +119 -0
- data/ext/java/nokogiri/internals/c14n/C14nHelper.java +159 -0
- data/ext/java/nokogiri/internals/c14n/CanonicalFilter.java +37 -0
- data/ext/java/nokogiri/internals/c14n/CanonicalizationException.java +93 -0
- data/ext/java/nokogiri/internals/c14n/Canonicalizer.java +252 -0
- data/ext/java/nokogiri/internals/c14n/Canonicalizer11.java +639 -0
- data/ext/java/nokogiri/internals/c14n/Canonicalizer11_OmitComments.java +38 -0
- data/ext/java/nokogiri/internals/c14n/Canonicalizer11_WithComments.java +38 -0
- data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315.java +368 -0
- data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315Excl.java +295 -0
- data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315ExclOmitComments.java +40 -0
- data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315ExclWithComments.java +44 -0
- data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315OmitComments.java +44 -0
- data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315WithComments.java +43 -0
- data/ext/java/nokogiri/internals/c14n/CanonicalizerBase.java +630 -0
- data/ext/java/nokogiri/internals/c14n/CanonicalizerPhysical.java +173 -0
- data/ext/java/nokogiri/internals/c14n/CanonicalizerSpi.java +76 -0
- data/ext/java/nokogiri/internals/c14n/Constants.java +42 -0
- data/ext/java/nokogiri/internals/c14n/ElementProxy.java +293 -0
- data/ext/java/nokogiri/internals/c14n/HelperNodeList.java +93 -0
- data/ext/java/nokogiri/internals/c14n/IgnoreAllErrorHandler.java +79 -0
- data/ext/java/nokogiri/internals/c14n/InclusiveNamespaces.java +165 -0
- data/ext/java/nokogiri/internals/c14n/InvalidCanonicalizerException.java +76 -0
- data/ext/java/nokogiri/internals/c14n/NameSpaceSymbTable.java +402 -0
- data/ext/java/nokogiri/internals/c14n/NodeFilter.java +51 -0
- data/ext/java/nokogiri/internals/c14n/UtfHelpper.java +179 -0
- data/ext/java/nokogiri/internals/c14n/XMLUtils.java +507 -0
- data/ext/nokogiri/extconf.rb +429 -128
- 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 +76 -7
- 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/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/nokogiri.jar +0 -0
- 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/ports/patches/libxml2/0001-Fix-parser-local-buffers-size-problems.patch +265 -0
- data/ports/patches/libxml2/0002-Fix-entities-local-buffers-size-problems.patch +102 -0
- data/ports/patches/libxml2/0003-Fix-an-error-in-previous-commit.patch +26 -0
- data/ports/patches/libxml2/0004-Fix-potential-out-of-bound-access.patch +26 -0
- data/ports/patches/libxml2/0005-Detect-excessive-entities-expansion-upon-replacement.patch +158 -0
- data/ports/patches/libxml2/0006-Do-not-fetch-external-parsed-entities.patch +78 -0
- data/ports/patches/libxml2/0007-Enforce-XML_PARSER_EOF-state-handling-through-the-pa.patch +480 -0
- data/ports/patches/libxml2/0008-Improve-handling-of-xmlStopParser.patch +315 -0
- data/ports/patches/libxml2/0009-Fix-a-couple-of-return-without-value.patch +37 -0
- data/ports/patches/libxslt/0001-Adding-doc-update-related-to-1.1.28.patch +222 -0
- data/ports/patches/libxslt/0002-Fix-a-couple-of-places-where-f-printf-parameters-wer.patch +53 -0
- data/ports/patches/libxslt/0003-Initialize-pseudo-random-number-generator-with-curre.patch +60 -0
- data/ports/patches/libxslt/0004-EXSLT-function-str-replace-is-broken-as-is.patch +42 -0
- data/ports/patches/libxslt/0006-Fix-str-padding-to-work-with-UTF-8-strings.patch +164 -0
- data/ports/patches/libxslt/0007-Separate-function-for-predicate-matching-in-patterns.patch +587 -0
- data/ports/patches/libxslt/0008-Fix-direct-pattern-matching.patch +80 -0
- data/ports/patches/libxslt/0009-Fix-certain-patterns-with-predicates.patch +185 -0
- data/ports/patches/libxslt/0010-Fix-handling-of-UTF-8-strings-in-EXSLT-crypto-module.patch +126 -0
- data/ports/patches/libxslt/0013-Memory-leak-in-xsltCompileIdKeyPattern-error-path.patch +25 -0
- data/ports/patches/libxslt/0014-Fix-for-bug-436589.patch +43 -0
- data/ports/patches/libxslt/0015-Fix-mkdir-for-mingw.patch +41 -0
- 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 +9 -3
- data/test/namespaces/test_namespaces_aliased_default.rb +24 -0
- data/test/namespaces/test_namespaces_in_cloned_doc.rb +31 -0
- data/test/namespaces/test_namespaces_preservation.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_text.rb +15 -0
- data/test/xml/test_xpath.rb +87 -0
- data/test_all +3 -3
- metadata +119 -68
- data/tasks/cross_compile.rb +0 -134
data/ext/nokogiri/extconf.rb
CHANGED
@@ -1,183 +1,472 @@
|
|
1
|
-
ENV['RC_ARCHS'] = '' if RUBY_PLATFORM =~ /darwin/
|
2
|
-
|
3
1
|
# :stopdoc:
|
2
|
+
ENV['RC_ARCHS'] = '' if RUBY_PLATFORM =~ /darwin/
|
4
3
|
|
5
4
|
require 'mkmf'
|
6
5
|
|
7
|
-
|
6
|
+
if arg_config('--help')
|
7
|
+
print <<HELP
|
8
|
+
usage: ruby #{$0} [options]
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
@libdir_basename = "lib" # shrug, ruby 2.0 won't work for me.
|
12
|
-
INCLUDEDIR = RbConfig::CONFIG['includedir']
|
10
|
+
--disable-clean
|
11
|
+
Do not clean out intermediate files after successful build.
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
end
|
13
|
+
--disable-static
|
14
|
+
Do not statically link bundled libraries.
|
17
15
|
|
18
|
-
|
19
|
-
|
16
|
+
--with-iconv-dir=DIR
|
17
|
+
Use the iconv library placed under DIR.
|
20
18
|
|
21
|
-
|
19
|
+
--with-zlib-dir=DIR
|
20
|
+
Use the zlib library placed under DIR.
|
22
21
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
22
|
+
--use-system-libraries
|
23
|
+
Use system libraries intead of building and using the bundled
|
24
|
+
libraries.
|
25
|
+
|
26
|
+
--with-xml2-dir=DIR / --with-xml2-config=CONFIG
|
27
|
+
--with-xslt-dir=DIR / --with-xslt-config=CONFIG
|
28
|
+
--with-exslt-dir=DIR / --with-exslt-config=CONFIG
|
29
|
+
Use libxml2/libxslt/libexslt as specified.
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
--enable-cross-build
|
32
|
+
Do cross-build.
|
33
|
+
HELP
|
34
|
+
exit! 0
|
34
35
|
end
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
|
37
|
+
def message!(important_message)
|
38
|
+
message important_message
|
39
|
+
if !$stdout.tty? && File.chardev?('/dev/tty')
|
40
|
+
File.open('/dev/tty', 'w') { |tty|
|
41
|
+
tty.print important_message
|
42
|
+
}
|
43
|
+
end
|
44
|
+
rescue Errno::ENXIO
|
39
45
|
end
|
40
46
|
|
41
|
-
if
|
42
|
-
# I'm cross compiling!
|
43
|
-
HEADER_DIRS = [INCLUDEDIR]
|
44
|
-
LIB_DIRS = [LIBDIR]
|
45
|
-
XML2_HEADER_DIRS = [File.join(INCLUDEDIR, "libxml2"), INCLUDEDIR]
|
47
|
+
RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC']
|
46
48
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
49
|
+
ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
50
|
+
# Workaround for Ruby bug #8074, introduced in Ruby 2.0.0, fixed in Ruby 2.1.0
|
51
|
+
# https://bugs.ruby-lang.org/issues/8074
|
52
|
+
@libdir_basename = "lib" if RUBY_VERSION < '2.1.0'
|
53
|
+
|
54
|
+
# Workaround for Ruby bug #9760, will be fixed in Ruby 2.2
|
55
|
+
class Array
|
56
|
+
alias orig_or |
|
57
|
+
|
58
|
+
def | other
|
59
|
+
if self.equal?($DEFLIBPATH) && other.equal?($LIBPATH)
|
60
|
+
# Make sure library directories we set take precedence over $(libdir)
|
61
|
+
other.orig_or(self)
|
62
|
+
else
|
63
|
+
self.orig_or(other)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end if RUBY_VERSION < '2.2.0'
|
52
67
|
|
53
|
-
|
54
|
-
|
68
|
+
if arg_config('--clean')
|
69
|
+
require 'pathname'
|
70
|
+
require 'fileutils'
|
55
71
|
|
56
|
-
|
57
|
-
|
72
|
+
root = Pathname(ROOT)
|
73
|
+
pwd = Pathname(Dir.pwd)
|
58
74
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
]
|
75
|
+
# Skip if this is a development work tree
|
76
|
+
unless (root + '.git').exist?
|
77
|
+
message "Cleaning files only used during build.\n"
|
63
78
|
|
64
|
-
|
65
|
-
|
66
|
-
'/opt/local/lib',
|
79
|
+
# (root + 'tmp') cannot be removed at this stage because
|
80
|
+
# nokogiri.so is yet to be copied to lib.
|
67
81
|
|
68
|
-
|
69
|
-
|
82
|
+
# clean the ports build directory
|
83
|
+
Pathname.glob(pwd.join('tmp', '*', 'ports')) { |dir|
|
84
|
+
FileUtils.rm_rf(dir, verbose: true)
|
85
|
+
FileUtils.rmdir(dir.parent, parents: true, verbose: true)
|
86
|
+
}
|
70
87
|
|
71
|
-
|
72
|
-
|
88
|
+
if enable_config('static')
|
89
|
+
# ports installation can be safely removed if statically linked.
|
90
|
+
FileUtils.rm_rf(root + 'ports', verbose: true)
|
91
|
+
else
|
92
|
+
FileUtils.rm_rf(root + 'ports' + 'archives', verbose: true)
|
93
|
+
end
|
94
|
+
end
|
73
95
|
|
74
|
-
|
75
|
-
|
76
|
-
]
|
96
|
+
exit
|
97
|
+
end
|
77
98
|
|
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')
|
89
|
-
end
|
99
|
+
if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'macruby'
|
100
|
+
$LIBRUBYARG_STATIC.gsub!(/-static/, '')
|
101
|
+
end
|
90
102
|
|
91
|
-
|
92
|
-
|
93
|
-
require 'yaml'
|
103
|
+
$CFLAGS << " #{ENV["CFLAGS"]}"
|
104
|
+
$LIBS << " #{ENV["LIBS"]}"
|
94
105
|
|
95
|
-
|
96
|
-
|
97
|
-
|
106
|
+
def preserving_globals
|
107
|
+
values = [
|
108
|
+
$arg_config,
|
109
|
+
$CFLAGS, $CPPFLAGS,
|
110
|
+
$LDFLAGS, $LIBPATH, $libs
|
111
|
+
].map(&:dup)
|
112
|
+
yield
|
113
|
+
ensure
|
114
|
+
$arg_config,
|
115
|
+
$CFLAGS, $CPPFLAGS,
|
116
|
+
$LDFLAGS, $LIBPATH, $libs =
|
117
|
+
values
|
118
|
+
end
|
98
119
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
FileUtils.touch checkpoint
|
103
|
-
end
|
104
|
-
recipe.activate
|
105
|
-
end
|
120
|
+
def asplode(lib)
|
121
|
+
abort "-----\n#{lib} is missing. please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.\n-----"
|
122
|
+
end
|
106
123
|
|
107
|
-
|
124
|
+
def have_iconv?
|
125
|
+
have_header('iconv.h') or return false
|
126
|
+
%w{ iconv_open libiconv_open }.any? do |method|
|
127
|
+
have_func(method, 'iconv.h') or
|
128
|
+
have_library('iconv', method, 'iconv.h')
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def each_iconv_idir
|
133
|
+
# If --with-iconv-dir or --with-opt-dir is given, it should be
|
134
|
+
# the first priority
|
135
|
+
%w[iconv opt].each { |config|
|
136
|
+
idir = preserving_globals {
|
137
|
+
dir_config(config)
|
138
|
+
}.first and yield idir
|
139
|
+
}
|
140
|
+
|
141
|
+
# Try the system default
|
142
|
+
yield "/usr/include"
|
143
|
+
|
144
|
+
cflags, = preserving_globals {
|
145
|
+
pkg_config('libiconv')
|
146
|
+
}
|
147
|
+
if cflags
|
148
|
+
cflags.shellsplit.each { |arg|
|
149
|
+
arg.sub!(/\A-I/, '') and
|
150
|
+
yield arg
|
151
|
+
}
|
152
|
+
end
|
108
153
|
|
109
|
-
|
154
|
+
nil
|
155
|
+
end
|
156
|
+
|
157
|
+
def iconv_prefix
|
158
|
+
# Make sure libxml2 is built with iconv
|
159
|
+
each_iconv_idir { |idir|
|
160
|
+
next unless File.file?(File.join(idir, 'iconv.h'))
|
161
|
+
|
162
|
+
prefix, dir = File.split(idir)
|
163
|
+
next unless dir == 'include'
|
164
|
+
|
165
|
+
preserving_globals {
|
166
|
+
# Follow the way libxml2's configure uses a value given with
|
167
|
+
# --with-iconv[=DIR]
|
168
|
+
$CPPFLAGS = "-I#{idir}".quote << ' ' << $CPPFLAGS
|
169
|
+
$LIBPATH.unshift(File.join(prefix, "lib"))
|
170
|
+
have_iconv?
|
171
|
+
} and break prefix
|
172
|
+
} or asplode "libiconv"
|
173
|
+
end
|
174
|
+
|
175
|
+
def process_recipe(name, version, static_p, cross_p)
|
176
|
+
MiniPortile.new(name, version).tap do |recipe|
|
177
|
+
recipe.target = portsdir = File.join(ROOT, "ports")
|
178
|
+
# Prefer host_alias over host in order to use i586-mingw32msvc as
|
179
|
+
# correct compiler prefix for cross build, but use host if not set.
|
180
|
+
recipe.host = RbConfig::CONFIG["host_alias"].empty? ? RbConfig::CONFIG["host"] : RbConfig::CONFIG["host_alias"]
|
181
|
+
recipe.patch_files = Dir[File.join(portsdir, "patches", name, "*.patch")].sort
|
182
|
+
|
183
|
+
if static_p
|
184
|
+
recipe.configure_options = [
|
185
|
+
"--disable-shared",
|
186
|
+
"--enable-static",
|
187
|
+
"CFLAGS='-fPIC #{ENV["CFLAGS"]}'",
|
188
|
+
]
|
189
|
+
else
|
110
190
|
recipe.configure_options = [
|
111
191
|
"--enable-shared",
|
112
192
|
"--disable-static",
|
113
|
-
"--without-python",
|
114
|
-
"--without-readline",
|
115
|
-
"--with-c14n",
|
116
|
-
"--with-debug",
|
117
|
-
"--with-threads"
|
118
193
|
]
|
119
|
-
common_recipe.call recipe
|
120
194
|
end
|
121
195
|
|
122
|
-
|
123
|
-
recipe.configure_options
|
124
|
-
"--
|
125
|
-
"--
|
126
|
-
"--without-python",
|
127
|
-
"--without-crypto",
|
128
|
-
"--with-debug",
|
129
|
-
"--with-libxml-prefix=#{libxml2_recipe.path}"
|
196
|
+
if cross_p
|
197
|
+
recipe.configure_options += [
|
198
|
+
"--target=#{recipe.host}",
|
199
|
+
"--host=#{recipe.host}",
|
130
200
|
]
|
131
|
-
common_recipe.call recipe
|
132
201
|
end
|
133
202
|
|
134
|
-
|
135
|
-
|
203
|
+
yield recipe
|
204
|
+
|
205
|
+
if recipe.patch_files.empty?
|
206
|
+
message! "Building #{name}-#{version} for nokogiri.\n"
|
207
|
+
else
|
208
|
+
message! "Building #{name}-#{version} for nokogiri with the following patches applied:\n"
|
209
|
+
|
210
|
+
recipe.patch_files.each { |patch|
|
211
|
+
message! "\t- %s\n" % File.basename(patch)
|
212
|
+
}
|
213
|
+
end
|
214
|
+
|
215
|
+
message! <<-"EOS"
|
216
|
+
************************************************************************
|
217
|
+
IMPORTANT! Nokogiri builds and uses a packaged version of #{name}.
|
218
|
+
|
219
|
+
If this is a concern for you and you want to use the system library
|
220
|
+
instead, abort this installation process and reinstall nokogiri as
|
221
|
+
follows:
|
222
|
+
|
223
|
+
gem install nokogiri -- --use-system-libraries
|
224
|
+
|
225
|
+
If you are using Bundler, tell it to use the option:
|
226
|
+
|
227
|
+
bundle config build.nokogiri --use-system-libraries
|
228
|
+
bundle install
|
229
|
+
EOS
|
230
|
+
|
231
|
+
message! <<-"EOS" if name == 'libxml2'
|
232
|
+
|
233
|
+
However, note that nokogiri does not necessarily support all versions
|
234
|
+
of libxml2.
|
136
235
|
|
137
|
-
|
236
|
+
For example, libxml2-2.9.0 and higher are currently known to be broken
|
237
|
+
and thus unsupported by nokogiri, due to compatibility problems and
|
238
|
+
XPath optimization bugs.
|
239
|
+
EOS
|
138
240
|
|
139
|
-
|
140
|
-
|
141
|
-
|
241
|
+
message! <<-"EOS"
|
242
|
+
************************************************************************
|
243
|
+
EOS
|
244
|
+
|
245
|
+
checkpoint = "#{recipe.target}/#{recipe.name}-#{recipe.version}-#{recipe.host}.installed"
|
246
|
+
unless File.exist?(checkpoint)
|
247
|
+
recipe.cook
|
248
|
+
FileUtils.touch checkpoint
|
249
|
+
end
|
250
|
+
recipe.activate
|
142
251
|
end
|
143
252
|
end
|
144
253
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
254
|
+
case RbConfig::CONFIG['target_os']
|
255
|
+
when 'mingw32', /mswin/
|
256
|
+
windows_p = true
|
257
|
+
$CFLAGS << " -DXP_WIN -DXP_WIN32 -DUSE_INCLUDED_VASPRINTF"
|
258
|
+
when /solaris/
|
259
|
+
$CFLAGS << " -DUSE_INCLUDED_VASPRINTF"
|
260
|
+
else
|
261
|
+
$CFLAGS << " -g -DXP_UNIX"
|
262
|
+
end
|
149
263
|
|
150
|
-
|
151
|
-
|
264
|
+
if RUBY_PLATFORM =~ /mingw/i
|
265
|
+
# Work around a character escaping bug in MSYS by passing an arbitrary
|
266
|
+
# double quoted parameter to gcc. See https://sourceforge.net/p/mingw/bugs/2142
|
267
|
+
$CPPFLAGS << ' "-Idummypath"'
|
268
|
+
end
|
269
|
+
|
270
|
+
if RbConfig::MAKEFILE_CONFIG['CC'] =~ /gcc/
|
271
|
+
$CFLAGS << " -O3" unless $CFLAGS[/-O\d/]
|
272
|
+
$CFLAGS << " -Wall -Wcast-qual -Wwrite-strings -Wconversion -Wmissing-noreturn -Winline"
|
152
273
|
end
|
153
274
|
|
154
|
-
|
155
|
-
|
156
|
-
|
275
|
+
case
|
276
|
+
when arg_config('--use-system-libraries', !!ENV['NOKOGIRI_USE_SYSTEM_LIBRARIES'])
|
277
|
+
message! "Building nokogiri using system libraries.\n"
|
157
278
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
279
|
+
dir_config('zlib')
|
280
|
+
|
281
|
+
# Using system libraries means we rely on the system libxml2 with
|
282
|
+
# regard to the iconv support.
|
283
|
+
|
284
|
+
dir_config('xml2').any? or pkg_config('libxml-2.0')
|
285
|
+
dir_config('xslt').any? or pkg_config('libxslt')
|
286
|
+
dir_config('exslt').any? or pkg_config('libexslt')
|
287
|
+
|
288
|
+
try_cpp(<<-SRC) or abort "libxml2 version 2.6.21 or later is required!"
|
289
|
+
#include <libxml/xmlversion.h>
|
290
|
+
|
291
|
+
#if LIBXML_VERSION < 20621
|
292
|
+
#error libxml2 is too old
|
293
|
+
#endif
|
294
|
+
SRC
|
295
|
+
|
296
|
+
try_cpp(<<-SRC) or warn "libxml2 version 2.9.0 and later is not yet supported, but proceeding anyway."
|
297
|
+
#include <libxml/xmlversion.h>
|
298
|
+
|
299
|
+
#if LIBXML_VERSION >= 20900
|
300
|
+
#error libxml2 is too new
|
301
|
+
#endif
|
302
|
+
SRC
|
303
|
+
else
|
304
|
+
message! "Building nokogiri using packaged libraries.\n"
|
305
|
+
|
306
|
+
require 'mini_portile'
|
307
|
+
require 'yaml'
|
308
|
+
|
309
|
+
static_p = enable_config('static', true) or
|
310
|
+
message! "Static linking is disabled.\n"
|
311
|
+
|
312
|
+
dir_config('zlib')
|
313
|
+
|
314
|
+
dependencies = YAML.load_file(File.join(ROOT, "dependencies.yml"))
|
315
|
+
|
316
|
+
cross_build_p = enable_config("cross-build")
|
317
|
+
if cross_build_p || windows_p
|
318
|
+
zlib_recipe = process_recipe("zlib", dependencies["zlib"], static_p, cross_build_p) do |recipe|
|
319
|
+
recipe.files = ["http://zlib.net/#{recipe.name}-#{recipe.version}.tar.gz"]
|
320
|
+
class << recipe
|
321
|
+
attr_accessor :cross_build_p
|
322
|
+
|
323
|
+
def configure
|
324
|
+
Dir.chdir work_path do
|
325
|
+
mk = File.read 'win32/Makefile.gcc'
|
326
|
+
File.open 'win32/Makefile.gcc', 'wb' do |f|
|
327
|
+
f.puts "BINARY_PATH = #{path}/bin"
|
328
|
+
f.puts "LIBRARY_PATH = #{path}/lib"
|
329
|
+
f.puts "INCLUDE_PATH = #{path}/include"
|
330
|
+
mk.sub!(/^PREFIX\s*=\s*$/, "PREFIX = #{host}-") if cross_build_p
|
331
|
+
f.puts mk
|
332
|
+
end
|
333
|
+
end
|
334
|
+
end
|
335
|
+
|
336
|
+
def configured?
|
337
|
+
Dir.chdir work_path do
|
338
|
+
!! (File.read('win32/Makefile.gcc') =~ /^BINARY_PATH/)
|
339
|
+
end
|
340
|
+
end
|
341
|
+
|
342
|
+
def compile
|
343
|
+
execute "compile", "make -f win32/Makefile.gcc"
|
344
|
+
end
|
345
|
+
|
346
|
+
def install
|
347
|
+
execute "install", "make -f win32/Makefile.gcc install"
|
348
|
+
end
|
349
|
+
end
|
350
|
+
recipe.cross_build_p = cross_build_p
|
351
|
+
end
|
352
|
+
|
353
|
+
libiconv_recipe = process_recipe("libiconv", dependencies["libiconv"], static_p, cross_build_p) do |recipe|
|
354
|
+
recipe.files = ["http://ftp.gnu.org/pub/gnu/libiconv/#{recipe.name}-#{recipe.version}.tar.gz"]
|
355
|
+
recipe.configure_options += [
|
356
|
+
"CPPFLAGS='-Wall'",
|
357
|
+
"CFLAGS='-O2 -g'",
|
358
|
+
"CXXFLAGS='-O2 -g'",
|
359
|
+
"LDFLAGS="
|
360
|
+
]
|
361
|
+
end
|
163
362
|
end
|
164
|
-
end
|
165
363
|
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
364
|
+
libxml2_recipe = process_recipe("libxml2", dependencies["libxml2"], static_p, cross_build_p) do |recipe|
|
365
|
+
recipe.files = ["ftp://ftp.xmlsoft.org/libxml2/#{recipe.name}-#{recipe.version}.tar.gz"]
|
366
|
+
recipe.configure_options += [
|
367
|
+
"--without-python",
|
368
|
+
"--without-readline",
|
369
|
+
"--with-iconv=#{libiconv_recipe ? libiconv_recipe.path : iconv_prefix}",
|
370
|
+
"--with-c14n",
|
371
|
+
"--with-debug",
|
372
|
+
"--with-threads"
|
373
|
+
]
|
374
|
+
end
|
173
375
|
|
174
|
-
|
175
|
-
|
376
|
+
libxslt_recipe = process_recipe("libxslt", dependencies["libxslt"], static_p, cross_build_p) do |recipe|
|
377
|
+
recipe.files = ["ftp://ftp.xmlsoft.org/libxml2/#{recipe.name}-#{recipe.version}.tar.gz"]
|
378
|
+
recipe.configure_options += [
|
379
|
+
"--without-python",
|
380
|
+
"--without-crypto",
|
381
|
+
"--with-debug",
|
382
|
+
"--with-libxml-prefix=#{libxml2_recipe.path}"
|
383
|
+
]
|
384
|
+
end
|
176
385
|
|
177
|
-
|
386
|
+
$CFLAGS << ' ' << '-DNOKOGIRI_USE_PACKAGED_LIBRARIES'
|
387
|
+
$LIBPATH = ["#{zlib_recipe.path}/lib"] | $LIBPATH if zlib_recipe
|
388
|
+
$LIBPATH = ["#{libiconv_recipe.path}/lib"] | $LIBPATH if libiconv_recipe
|
389
|
+
|
390
|
+
have_lzma = preserving_globals {
|
391
|
+
have_library('lzma')
|
392
|
+
}
|
393
|
+
|
394
|
+
$libs = $libs.shellsplit.tap { |libs|
|
395
|
+
[libxml2_recipe, libxslt_recipe].each { |recipe|
|
396
|
+
libname = recipe.name[/\Alib(.+)\z/, 1]
|
397
|
+
File.join(recipe.path, "bin", "#{libname}-config").tap { |config|
|
398
|
+
# call config scripts explicit with 'sh' for compat with Windows
|
399
|
+
$CPPFLAGS = `sh #{config} --cflags`.strip << ' ' << $CPPFLAGS
|
400
|
+
`sh #{config} --libs`.strip.shellsplit.each { |arg|
|
401
|
+
case arg
|
402
|
+
when /\A-L(.+)\z/
|
403
|
+
# Prioritize ports' directories
|
404
|
+
if $1.start_with?(ROOT + '/')
|
405
|
+
$LIBPATH = [$1] | $LIBPATH
|
406
|
+
else
|
407
|
+
$LIBPATH = $LIBPATH | [$1]
|
408
|
+
end
|
409
|
+
when /\A-l./
|
410
|
+
libs.unshift(arg)
|
411
|
+
else
|
412
|
+
$LDFLAGS << ' ' << arg.shellescape
|
413
|
+
end
|
414
|
+
}
|
415
|
+
}
|
416
|
+
|
417
|
+
$CPPFLAGS << ' ' << "-DNOKOGIRI_#{recipe.name.upcase}_PATH=\"#{recipe.path}\"".shellescape
|
418
|
+
|
419
|
+
case libname
|
420
|
+
when 'xml2'
|
421
|
+
# xslt-config --libs or pkg-config libxslt --libs does not include
|
422
|
+
# -llzma, so we need to add it manually when linking statically.
|
423
|
+
if static_p && have_lzma
|
424
|
+
# Add it at the end; GH #988
|
425
|
+
libs << '-llzma'
|
426
|
+
end
|
427
|
+
when 'xslt'
|
428
|
+
# xslt-config does not have a flag to emit options including
|
429
|
+
# -lexslt, so add it manually.
|
430
|
+
libs.unshift('-lexslt')
|
431
|
+
end
|
432
|
+
}
|
433
|
+
}.shelljoin
|
434
|
+
|
435
|
+
if static_p
|
436
|
+
message 'checking for linker flags for static linking... '
|
437
|
+
|
438
|
+
case
|
439
|
+
when try_link('int main(void) { return 0; }',
|
440
|
+
['-Wl,-Bstatic', '-lxml2', '-Wl,-Bdynamic'].shelljoin)
|
441
|
+
message "-Wl,-Bstatic\n"
|
442
|
+
|
443
|
+
$libs = $libs.shellsplit.flat_map { |arg|
|
444
|
+
case arg
|
445
|
+
when '-lxml2', '-lxslt', '-lexslt'
|
446
|
+
['-Wl,-Bstatic', arg, '-Wl,-Bdynamic']
|
447
|
+
else
|
448
|
+
arg
|
449
|
+
end
|
450
|
+
}.shelljoin
|
451
|
+
else
|
452
|
+
message "NONE\n"
|
453
|
+
end
|
454
|
+
end
|
178
455
|
end
|
179
456
|
|
180
|
-
|
457
|
+
{
|
458
|
+
"xml2" => ['xmlParseDoc', 'libxml/parser.h'],
|
459
|
+
"xslt" => ['xsltParseStylesheetDoc', 'libxslt/xslt.h'],
|
460
|
+
"exslt" => ['exsltFuncRegister', 'libexslt/exslt.h'],
|
461
|
+
}.each { |lib, (func, header)|
|
462
|
+
have_func(func, header) ||
|
463
|
+
have_library(lib, func, header) ||
|
464
|
+
have_library("lib#{lib}", func, header) or
|
465
|
+
asplode("lib#{lib}")
|
466
|
+
}
|
467
|
+
|
468
|
+
have_func('xmlHasFeature') or abort "xmlHasFeature() is missing."
|
469
|
+
have_func('xmlFirstElementChild')
|
181
470
|
have_func('xmlRelaxNGSetParserStructuredErrors')
|
182
471
|
have_func('xmlRelaxNGSetParserStructuredErrors')
|
183
472
|
have_func('xmlRelaxNGSetValidStructuredErrors')
|
@@ -192,4 +481,16 @@ end
|
|
192
481
|
|
193
482
|
create_makefile('nokogiri/nokogiri')
|
194
483
|
|
484
|
+
if enable_config('clean', true)
|
485
|
+
# Do not clean if run in a development work tree.
|
486
|
+
File.open('Makefile', 'at') { |mk|
|
487
|
+
mk.print <<EOF
|
488
|
+
all: clean-ports
|
489
|
+
|
490
|
+
clean-ports: $(DLLIB)
|
491
|
+
-$(Q)$(RUBY) $(srcdir)/extconf.rb --clean --#{static_p ? 'enable' : 'disable'}-static
|
492
|
+
EOF
|
493
|
+
}
|
494
|
+
end
|
495
|
+
|
195
496
|
# :startdoc:
|