nokogiri 1.6.6.4-x86-mingw32 → 1.6.7.rc2-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of nokogiri might be problematic. Click here for more details.

data/Rakefile CHANGED
@@ -12,7 +12,6 @@ Hoe.add_include_dirs '.'
12
12
 
13
13
  GENERATED_PARSER = "lib/nokogiri/css/parser.rb"
14
14
  GENERATED_TOKENIZER = "lib/nokogiri/css/tokenizer.rb"
15
- CROSS_DIR = File.join(File.dirname(__FILE__), 'ports')
16
15
 
17
16
  def java?
18
17
  /java/ === RUBY_PLATFORM
@@ -25,14 +24,18 @@ CrossRuby = Struct.new(:version, :host) {
25
24
  @ver ||= version[/\A[^-]+/]
26
25
  end
27
26
 
27
+ def minor_ver
28
+ @minor_ver ||= ver[/\A\d\.\d(?=\.)/]
29
+ end
30
+
28
31
  def api_ver_suffix
29
- case ver
30
- when /\A([2-9])\.([0-9])\./
31
- "#{$1}#{$2}0"
32
- when /\A1\.9\./
32
+ case minor_ver
33
+ when nil
34
+ raise "unsupported version: #{ver}"
35
+ when '1.9'
33
36
  '191'
34
37
  else
35
- raise "unsupported version: #{ver}"
38
+ minor_ver.delete('.') << '0'
36
39
  end
37
40
  end
38
41
 
@@ -110,7 +113,7 @@ HOE = Hoe.spec 'nokogiri' do
110
113
 
111
114
  license "MIT"
112
115
 
113
- self.readme_file = ['README', ENV['HLANG'], 'rdoc'].compact.join('.')
116
+ self.readme_file = "README.md"
114
117
  self.history_file = ['CHANGELOG', ENV['HLANG'], 'rdoc'].compact.join('.')
115
118
 
116
119
  self.extra_rdoc_files = FileList['*.rdoc','ext/nokogiri/*.c']
@@ -119,22 +122,13 @@ HOE = Hoe.spec 'nokogiri' do
119
122
  self.clean_globs += [
120
123
  'nokogiri.gemspec',
121
124
  'lib/nokogiri/nokogiri.{bundle,jar,rb,so}',
122
- 'lib/nokogiri/[0-9].[0-9]',
123
- 'ports/*.installed',
124
- 'ports/{i[3-6]86,x86_64}-{w64-,}mingw32*',
125
- 'ports/libxml2',
126
- 'ports/libxslt',
127
- # GENERATED_PARSER,
128
- # GENERATED_TOKENIZER
125
+ 'lib/nokogiri/[0-9].[0-9]'
129
126
  ]
127
+ self.clean_globs += Dir.glob("ports/*").reject { |d| d =~ %r{/archives$} }
130
128
 
131
129
  unless java?
132
130
  self.extra_deps += [
133
- # this dependency locked because we're monkey-punching mini_portile.
134
- # for more details, see:
135
- # - https://github.com/sparklemotion/nokogiri/issues/1102
136
- # - https://github.com/luislavena/mini_portile/issues/32
137
- ["mini_portile", "~> 0.6.0"],
131
+ ["mini_portile", "~> 0.7.0.rc2"],
138
132
  ]
139
133
  end
140
134
 
@@ -146,6 +140,7 @@ HOE = Hoe.spec 'nokogiri' do
146
140
  ["minitest", "~> 2.2.2"],
147
141
  ["rake", ">= 0.9"],
148
142
  ["rake-compiler", "~> 0.9.2"],
143
+ ["rake-compiler-dock", "~> 0.4.2"],
149
144
  ["racc", ">= 1.4.6"],
150
145
  ["rexical", ">= 1.0.5"]
151
146
  ]
@@ -200,7 +195,6 @@ else
200
195
  Rake::ExtensionCompiler.mingw_host
201
196
  mingw_available = true
202
197
  rescue
203
- puts "WARNING: cross compilation not available: #{$!}"
204
198
  mingw_available = false
205
199
  end
206
200
  require "rake/extensiontask"
@@ -214,7 +208,7 @@ else
214
208
  version = dependencies[lib]
215
209
  archive = File.join("ports", "archives", "#{lib}-#{version}.tar.gz")
216
210
  add_file_to_gem archive
217
- patchesdir = File.join("ports", "patches", lib)
211
+ patchesdir = File.join("patches", lib)
218
212
  patches = `#{['git', 'ls-files', patchesdir].shelljoin}`.split("\n").grep(/\.patch\z/)
219
213
  patches.each { |patch|
220
214
  add_file_to_gem patch
@@ -238,6 +232,11 @@ else
238
232
  ext.cross_compiling do |spec|
239
233
  libs = dependencies.map { |name, version| "#{name}-#{version}" }.join(', ')
240
234
 
235
+ spec.required_ruby_version = [
236
+ '>= 1.9.2',
237
+ "< #{CROSS_RUBIES.max_by(&:ver).minor_ver.succ}"
238
+ ]
239
+
241
240
  spec.post_install_message = <<-EOS
242
241
  Nokogiri is built with the packaged libraries: #{libs}.
243
242
  EOS
@@ -349,6 +348,9 @@ task :cross do
349
348
  end
350
349
 
351
350
  desc "build a windows gem without all the ceremony."
352
- task "gem:windows" => %w[cross native gem]
351
+ task "gem:windows" do
352
+ require "rake_compiler_dock"
353
+ RakeCompilerDock.sh "bundle && rake cross native gem MAKE='nice make -j`nproc`' RUBY_CC_VERSION=#{ENV['RUBY_CC_VERSION']}"
354
+ end
353
355
 
354
356
  # vim: syntax=Ruby
@@ -0,0 +1,22 @@
1
+ install:
2
+ - SET PATH=C:\Ruby%ruby_version%\bin;%PATH%
3
+ - SET PATH=C:\MinGW\bin;%PATH%
4
+ - SET RAKEOPT=-rdevkit
5
+ - ruby --version
6
+ - gem --version
7
+ - bundle install
8
+
9
+ build: off
10
+
11
+ test_script:
12
+ - bundle exec rake
13
+
14
+ environment:
15
+ matrix:
16
+ - ruby_version: "22"
17
+ - ruby_version: "22-x64"
18
+ - ruby_version: "21"
19
+ - ruby_version: "21-x64"
20
+ - ruby_version: "200"
21
+ - ruby_version: "200-x64"
22
+ - ruby_version: "193"
data/build_all CHANGED
@@ -5,43 +5,6 @@
5
5
  # - windows (x86-mingw32 and x64-mingw32)
6
6
  # - jruby
7
7
  #
8
- # here's what I recommend for building all the gems:
9
- #
10
- # set up a rake-compiler-dev-box as described here:
11
- # https://github.com/tjschuck/rake-compiler-dev-box
12
- # It is prepared with all the necessary build tools and environments.
13
- #
14
- # or alternatively do:
15
- # 1. Setup a ubuntu 12.04+ machine
16
- # 2. install rvm, and install 1.9.3, 2.0.0 and jruby.
17
- # 3. `sudo apt-get install mingw32 gcc-mingw-w64-i686 gcc-mingw-w64-x86-64`
18
- #
19
- # as you build, you may run into these problems:
20
- #
21
- # - if you're using Virtualbox shared directories, you'll get a mingw
22
- # "Protocol error" at linktime. Boo! Either use NFS or a
23
- # locally-checked-out repository.
24
- #
25
- # - on ubuntus 11 and later, you may have issues with building
26
- # rake-compiler's rubies against openssl v2. Just comment the lines
27
- # out from ossl_ssl.c and you'll be fine.
28
- #
29
- # - you may have issues with Pathname conversion to String in
30
- # bundler. Add this to the offending bundler file:
31
- #
32
- # class Pathname
33
- # def to_str
34
- # to_s
35
- # end
36
- # end
37
- #
38
- # - you may also have to hack rubygems.rb to eliminate a reference to
39
- # RUBY_ENGINE (just comment it out)
40
- #
41
-
42
- DEFAULT_RUBY=2.0.0
43
-
44
- HOST=
45
8
 
46
9
  # Load RVM into a shell session *as a function*
47
10
  if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then
@@ -52,63 +15,17 @@ else
52
15
  echo "ERROR: An RVM installation was not found.\n"
53
16
  fi
54
17
 
55
- rvm_use () {
56
- current_ruby=$1
57
- rvm use "${1}@nokogiri" --create
58
- }
59
-
60
- rvm_do () {
61
- local ver=$1
62
- shift
63
- rvm "${ver}@nokogiri" do "$@"
64
- }
65
-
66
- cross_rubies () {
67
- grep -v '#' .cross_rubies
68
- }
69
-
70
- ruby_vers () {
71
- cross_rubies | while read -r line; do
72
- echo "${line%%[-:]*}"
73
- done | uniq
74
- }
75
-
76
18
  set -o errexit
77
-
78
- for ver in `ruby_vers`; do
79
- rvm_use $ver
80
- gem install bundler --conservative
81
- bundle install --quiet --local || bundle install
82
- done
83
-
84
- rvm_use $DEFAULT_RUBY
19
+ set -x
85
20
 
86
21
  rm -rf tmp pkg
87
- bundle exec rake clean
22
+ bundle exec rake clean clobber
88
23
 
89
24
  # holding pen
90
25
  rm -rf gems
91
26
  mkdir -p gems
92
27
 
93
28
  # windows
94
- for verspec in `cross_rubies`; do
95
- version="${verspec%%:*}"
96
- ver="${version%%-*}"
97
- host="${verspec#*:}"
98
-
99
- case $ver in
100
- 1.9.3)
101
- # Parallel make does not work in 1.9.3, as it has a
102
- # missing dependency problem with main.o.
103
- make="make"
104
- ;;
105
- *)
106
- make="$MAKE"
107
- esac
108
-
109
- MAKE="$make" rvm_do $ver rake-compiler cross-ruby VERSION=$version HOST=$host debugflags="-g"
110
- done
111
-
112
29
  bundle exec rake gem:windows
113
30
  cp -v pkg/nokogiri*{x86,x64}-mingw32*.gem gems
114
31
 
@@ -118,12 +35,11 @@ bundle exec rake gem
118
35
  cp -v pkg/nokogiri*.gem gems
119
36
 
120
37
  # jruby
121
- rvm_use jruby
122
- gem install bundler --conservative
123
- bundle install --quiet --local || bundle install
124
38
  bundle exec rake clean clobber
125
- rvm_use $DEFAULT_RUBY
126
39
  bundle exec rake generate
127
- rvm_use jruby
40
+
41
+ rvm jruby-1.7.19
42
+ gem install bundler --conservative
43
+ bundle install --quiet --local || bundle install
128
44
  bundle exec rake gem
129
45
  cp -v pkg/nokogiri*java.gem gems
@@ -148,8 +148,8 @@ def iconv_configure_flags
148
148
 
149
149
  return [
150
150
  '--with-iconv=yes',
151
- *("CPPFLAGS=#{idirs.map { |dir| '-I' << dir }.join(' ')}".quote if idirs),
152
- *("LDFLAGS=#{ldirs.map { |dir| '-L' << dir }.join(' ')}".quote if ldirs),
151
+ *("CPPFLAGS=#{idirs.map { |dir| '-I' << dir }.join(' ')}" if idirs),
152
+ *("LDFLAGS=#{ldirs.map { |dir| '-L' << dir }.join(' ')}" if ldirs),
153
153
  ]
154
154
  end
155
155
  }
@@ -164,22 +164,32 @@ def iconv_configure_flags
164
164
 
165
165
  return [
166
166
  '--with-iconv=yes',
167
- "CPPFLAGS=#{cflags}".quote,
168
- "LDFLAGS=#{ldflags}".quote,
169
- "LIBS=#{libs}".quote,
167
+ "CPPFLAGS=#{cflags}",
168
+ "LDFLAGS=#{ldflags}",
169
+ "LIBS=#{libs}",
170
170
  ]
171
171
  end
172
172
 
173
173
  asplode "libiconv"
174
174
  end
175
175
 
176
+ # When using rake-compiler-dock on Windows, the underlying Virtualbox shared
177
+ # folders don't support symlinks, but libiconv expects it for a build on
178
+ # Linux. We work around this limitation by using the temp dir for cooking.
179
+ def chdir_for_build
180
+ build_dir = ENV['RCD_HOST_RUBY_PLATFORM'].to_s =~ /mingw|mswin|cygwin/ ? '/tmp' : '.'
181
+ Dir.chdir(build_dir) do
182
+ yield
183
+ end
184
+ end
185
+
176
186
  def process_recipe(name, version, static_p, cross_p)
177
187
  MiniPortile.new(name, version).tap do |recipe|
178
188
  recipe.target = portsdir = File.join(ROOT, "ports")
179
189
  # Prefer host_alias over host in order to use i586-mingw32msvc as
180
190
  # correct compiler prefix for cross build, but use host if not set.
181
191
  recipe.host = RbConfig::CONFIG["host_alias"].empty? ? RbConfig::CONFIG["host"] : RbConfig::CONFIG["host_alias"]
182
- recipe.patch_files = Dir[File.join(portsdir, "patches", name, "*.patch")].sort
192
+ recipe.patch_files = Dir[File.join(ROOT, "patches", name, "*.patch")].sort
183
193
 
184
194
  yield recipe
185
195
 
@@ -190,7 +200,7 @@ def process_recipe(name, version, static_p, cross_p)
190
200
  recipe.configure_options.flatten!
191
201
 
192
202
  recipe.configure_options.delete_if { |option|
193
- case option.shellsplit.first
203
+ case option
194
204
  when /\A(\w+)=(.*)\z/
195
205
  env[$1] = $2
196
206
  true
@@ -221,14 +231,14 @@ def process_recipe(name, version, static_p, cross_p)
221
231
 
222
232
  if RbConfig::CONFIG['target_cpu'] == 'universal'
223
233
  %w[CFLAGS LDFLAGS].each { |key|
224
- unless env[key].shellsplit.include?('-arch')
234
+ unless env[key].include?('-arch')
225
235
  env[key] << ' ' << RbConfig::CONFIG['ARCH_FLAG']
226
236
  end
227
237
  }
228
238
  end
229
239
 
230
240
  recipe.configure_options += env.map { |key, value|
231
- "#{key}=#{value}".shellescape
241
+ "#{key}=#{value}"
232
242
  }
233
243
 
234
244
  message <<-"EOS"
@@ -275,7 +285,9 @@ versions of libxml2 provided by OS/package vendors.
275
285
 
276
286
  checkpoint = "#{recipe.target}/#{recipe.name}-#{recipe.version}-#{recipe.host}.installed"
277
287
  unless File.exist?(checkpoint)
278
- recipe.cook
288
+ chdir_for_build do
289
+ recipe.cook
290
+ end
279
291
  FileUtils.touch checkpoint
280
292
  end
281
293
  recipe.activate
@@ -301,19 +313,6 @@ end
301
313
  # https://bugs.ruby-lang.org/issues/8074
302
314
  @libdir_basename = "lib" if RUBY_VERSION < '2.1.0'
303
315
 
304
- # Workaround for #1102
305
- def monkey_patch_mini_portile
306
- MiniPortile.class_eval do
307
- def patch
308
- @patch_files.each do |full_path|
309
- next unless File.exists?(full_path)
310
- output "Running patch with #{full_path}..."
311
- execute('patch', %Q(patch -p1 < "#{full_path}"))
312
- end
313
- end
314
- end
315
- end
316
-
317
316
  #
318
317
  # main
319
318
  #
@@ -393,7 +392,6 @@ else
393
392
  message "Building nokogiri using packaged libraries.\n"
394
393
 
395
394
  require 'mini_portile'
396
- monkey_patch_mini_portile
397
395
  require 'yaml'
398
396
 
399
397
  static_p = enable_config('static', true) or
@@ -443,9 +441,9 @@ else
443
441
  libiconv_recipe = process_recipe("libiconv", dependencies["libiconv"], static_p, cross_build_p) do |recipe|
444
442
  recipe.files = ["http://ftp.gnu.org/pub/gnu/libiconv/#{recipe.name}-#{recipe.version}.tar.gz"]
445
443
  recipe.configure_options += [
446
- "CPPFLAGS='-Wall'",
447
- "CFLAGS='-O2 -g'",
448
- "CXXFLAGS='-O2 -g'",
444
+ "CPPFLAGS=-Wall",
445
+ "CFLAGS=-O2 -g",
446
+ "CXXFLAGS=-O2 -g",
449
447
  "LDFLAGS="
450
448
  ]
451
449
  end
@@ -473,7 +471,7 @@ EOM
473
471
  end
474
472
 
475
473
  libxml2_recipe = process_recipe("libxml2", dependencies["libxml2"], static_p, cross_build_p) do |recipe|
476
- recipe.files = ["ftp://ftp.xmlsoft.org/libxml2/#{recipe.name}-#{recipe.version}.tar.gz"]
474
+ recipe.files = ["http://xmlsoft.org/sources/#{recipe.name}-#{recipe.version}.tar.gz"]
477
475
  recipe.configure_options += [
478
476
  "--without-python",
479
477
  "--without-readline",
@@ -485,7 +483,7 @@ EOM
485
483
  end
486
484
 
487
485
  libxslt_recipe = process_recipe("libxslt", dependencies["libxslt"], static_p, cross_build_p) do |recipe|
488
- recipe.files = ["ftp://ftp.xmlsoft.org/libxml2/#{recipe.name}-#{recipe.version}.tar.gz"]
486
+ recipe.files = ["http://xmlsoft.org/sources/#{recipe.name}-#{recipe.version}.tar.gz"]
489
487
  recipe.configure_options += [
490
488
  "--without-python",
491
489
  "--without-crypto",
@@ -526,8 +524,8 @@ EOM
526
524
  }
527
525
 
528
526
  # Defining a macro that expands to a C string; double quotes are significant.
529
- $CPPFLAGS << ' ' << "-DNOKOGIRI_#{recipe.name.upcase}_PATH=\"#{recipe.path}\"".shellescape
530
- $CPPFLAGS << ' ' << "-DNOKOGIRI_#{recipe.name.upcase}_PATCHES=\"#{recipe.patch_files.map { |path| File.basename(path) }.join(' ')}\"".shellescape
527
+ $CPPFLAGS << ' ' << "-DNOKOGIRI_#{recipe.name.upcase}_PATH=\"#{recipe.path}\"".inspect
528
+ $CPPFLAGS << ' ' << "-DNOKOGIRI_#{recipe.name.upcase}_PATCHES=\"#{recipe.patch_files.map { |path| File.basename(path) }.join(' ')}\"".inspect
531
529
 
532
530
  case libname
533
531
  when 'xml2'
@@ -778,11 +778,19 @@ static VALUE namespaced_key_eh(VALUE self, VALUE attribute, VALUE namespace)
778
778
  *
779
779
  * Set the +property+ to +value+
780
780
  */
781
- static VALUE set(VALUE self, VALUE property, VALUE value)
781
+ static VALUE set(VALUE node_rb, VALUE property_name_rb, VALUE property_value_rb)
782
782
  {
783
783
  xmlNodePtr node, cur;
784
- xmlAttrPtr prop;
785
- Data_Get_Struct(self, xmlNode, node);
784
+ xmlChar* property_name ;
785
+ xmlAttrPtr property;
786
+
787
+ Data_Get_Struct(node_rb, xmlNode, node);
788
+
789
+ if (node->type != XML_ELEMENT_NODE) {
790
+ return(Qnil); // TODO: would raising an exception be more appropriate?
791
+ }
792
+
793
+ property_name = (xmlChar *)StringValuePtr(property_name_rb);
786
794
 
787
795
  /* If a matching attribute node already exists, then xmlSetProp will destroy
788
796
  * the existing node's children. However, if Nokogiri has a node object
@@ -790,11 +798,9 @@ static VALUE set(VALUE self, VALUE property, VALUE value)
790
798
  *
791
799
  * We can avoid this by unlinking these nodes first.
792
800
  */
793
- if (node->type != XML_ELEMENT_NODE)
794
- return(Qnil);
795
- prop = xmlHasProp(node, (xmlChar *)StringValuePtr(property));
796
- if (prop && prop->children) {
797
- for (cur = prop->children; cur; cur = cur->next) {
801
+ property = xmlHasProp(node, property_name);
802
+ if (property && property->children) {
803
+ for (cur = property->children; cur; cur = cur->next) {
798
804
  if (cur->_private) {
799
805
  nokogiri_root_node(cur);
800
806
  xmlUnlinkNode(cur);
@@ -802,10 +808,14 @@ static VALUE set(VALUE self, VALUE property, VALUE value)
802
808
  }
803
809
  }
804
810
 
805
- xmlSetProp(node, (xmlChar *)StringValuePtr(property),
806
- (xmlChar *)StringValuePtr(value));
811
+ xmlResetLastError();
812
+ xmlSetStructuredErrorFunc(NULL, Nokogiri_error_silencer);
813
+
814
+ xmlSetProp(node, property_name, (xmlChar *)StringValuePtr(property_value_rb));
815
+
816
+ xmlSetStructuredErrorFunc(NULL, NULL);
807
817
 
808
- return value;
818
+ return property_value_rb;
809
819
  }
810
820
 
811
821
  /*