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