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