nokogiri 1.6.1-java → 1.6.2-java

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

Potentially problematic release.


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

Files changed (137) hide show
  1. checksums.yaml +4 -4
  2. data/.editorconfig +17 -0
  3. data/.travis.yml +6 -6
  4. data/CHANGELOG.ja.rdoc +61 -8
  5. data/CHANGELOG.rdoc +58 -3
  6. data/Gemfile +3 -3
  7. data/Manifest.txt +57 -1
  8. data/README.ja.rdoc +22 -17
  9. data/README.rdoc +23 -18
  10. data/ROADMAP.md +1 -2
  11. data/Rakefile +162 -58
  12. data/build_all +56 -31
  13. data/dependencies.yml +3 -3
  14. data/ext/java/nokogiri/NokogiriService.java +9 -5
  15. data/ext/java/nokogiri/XmlDocument.java +95 -54
  16. data/ext/java/nokogiri/XmlNode.java +93 -42
  17. data/ext/java/nokogiri/XmlReader.java +1 -1
  18. data/ext/java/nokogiri/XmlSaxParserContext.java +33 -0
  19. data/ext/java/nokogiri/XmlSchema.java +4 -2
  20. data/ext/java/nokogiri/XmlXpathContext.java +118 -76
  21. data/ext/java/nokogiri/internals/IgnoreSchemaErrorsErrorHandler.java +20 -0
  22. data/ext/java/nokogiri/internals/NokogiriHandler.java +3 -10
  23. data/ext/java/nokogiri/internals/NokogiriHelpers.java +40 -23
  24. data/ext/java/nokogiri/internals/NokogiriNamespaceCache.java +59 -54
  25. data/ext/java/nokogiri/internals/NokogiriXPathFunctionResolver.java +1 -1
  26. data/ext/java/nokogiri/internals/ParserContext.java +1 -4
  27. data/ext/java/nokogiri/internals/SaveContextVisitor.java +6 -2
  28. data/ext/java/nokogiri/internals/c14n/AttrCompare.java +119 -0
  29. data/ext/java/nokogiri/internals/c14n/C14nHelper.java +159 -0
  30. data/ext/java/nokogiri/internals/c14n/CanonicalFilter.java +37 -0
  31. data/ext/java/nokogiri/internals/c14n/CanonicalizationException.java +93 -0
  32. data/ext/java/nokogiri/internals/c14n/Canonicalizer.java +252 -0
  33. data/ext/java/nokogiri/internals/c14n/Canonicalizer11.java +639 -0
  34. data/ext/java/nokogiri/internals/c14n/Canonicalizer11_OmitComments.java +38 -0
  35. data/ext/java/nokogiri/internals/c14n/Canonicalizer11_WithComments.java +38 -0
  36. data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315.java +368 -0
  37. data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315Excl.java +295 -0
  38. data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315ExclOmitComments.java +40 -0
  39. data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315ExclWithComments.java +44 -0
  40. data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315OmitComments.java +44 -0
  41. data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315WithComments.java +43 -0
  42. data/ext/java/nokogiri/internals/c14n/CanonicalizerBase.java +630 -0
  43. data/ext/java/nokogiri/internals/c14n/CanonicalizerPhysical.java +173 -0
  44. data/ext/java/nokogiri/internals/c14n/CanonicalizerSpi.java +76 -0
  45. data/ext/java/nokogiri/internals/c14n/Constants.java +42 -0
  46. data/ext/java/nokogiri/internals/c14n/ElementProxy.java +293 -0
  47. data/ext/java/nokogiri/internals/c14n/HelperNodeList.java +93 -0
  48. data/ext/java/nokogiri/internals/c14n/IgnoreAllErrorHandler.java +79 -0
  49. data/ext/java/nokogiri/internals/c14n/InclusiveNamespaces.java +165 -0
  50. data/ext/java/nokogiri/internals/c14n/InvalidCanonicalizerException.java +76 -0
  51. data/ext/java/nokogiri/internals/c14n/NameSpaceSymbTable.java +402 -0
  52. data/ext/java/nokogiri/internals/c14n/NodeFilter.java +51 -0
  53. data/ext/java/nokogiri/internals/c14n/UtfHelpper.java +179 -0
  54. data/ext/java/nokogiri/internals/c14n/XMLUtils.java +507 -0
  55. data/ext/nokogiri/extconf.rb +429 -128
  56. data/ext/nokogiri/html_document.c +2 -2
  57. data/ext/nokogiri/nokogiri.c +6 -1
  58. data/ext/nokogiri/xml_document.c +5 -4
  59. data/ext/nokogiri/xml_node.c +76 -7
  60. data/ext/nokogiri/xml_reader.c +1 -1
  61. data/ext/nokogiri/xml_sax_parser_context.c +40 -0
  62. data/ext/nokogiri/xml_syntax_error.c +10 -5
  63. data/ext/nokogiri/xml_syntax_error.h +1 -1
  64. data/ext/nokogiri/xml_xpath_context.c +2 -14
  65. data/ext/nokogiri/xslt_stylesheet.c +1 -1
  66. data/lib/nokogiri.rb +31 -22
  67. data/lib/nokogiri/css/node.rb +0 -50
  68. data/lib/nokogiri/css/parser.rb +213 -218
  69. data/lib/nokogiri/css/parser.y +21 -30
  70. data/lib/nokogiri/css/xpath_visitor.rb +62 -14
  71. data/lib/nokogiri/html/document.rb +97 -18
  72. data/lib/nokogiri/html/sax/parser.rb +2 -2
  73. data/lib/nokogiri/nokogiri.jar +0 -0
  74. data/lib/nokogiri/version.rb +1 -1
  75. data/lib/nokogiri/xml/builder.rb +1 -1
  76. data/lib/nokogiri/xml/document.rb +2 -2
  77. data/lib/nokogiri/xml/dtd.rb +10 -0
  78. data/lib/nokogiri/xml/node.rb +26 -1
  79. data/lib/nokogiri/xml/sax/parser.rb +1 -1
  80. data/ports/patches/libxml2/0001-Fix-parser-local-buffers-size-problems.patch +265 -0
  81. data/ports/patches/libxml2/0002-Fix-entities-local-buffers-size-problems.patch +102 -0
  82. data/ports/patches/libxml2/0003-Fix-an-error-in-previous-commit.patch +26 -0
  83. data/ports/patches/libxml2/0004-Fix-potential-out-of-bound-access.patch +26 -0
  84. data/ports/patches/libxml2/0005-Detect-excessive-entities-expansion-upon-replacement.patch +158 -0
  85. data/ports/patches/libxml2/0006-Do-not-fetch-external-parsed-entities.patch +78 -0
  86. data/ports/patches/libxml2/0007-Enforce-XML_PARSER_EOF-state-handling-through-the-pa.patch +480 -0
  87. data/ports/patches/libxml2/0008-Improve-handling-of-xmlStopParser.patch +315 -0
  88. data/ports/patches/libxml2/0009-Fix-a-couple-of-return-without-value.patch +37 -0
  89. data/ports/patches/libxslt/0001-Adding-doc-update-related-to-1.1.28.patch +222 -0
  90. data/ports/patches/libxslt/0002-Fix-a-couple-of-places-where-f-printf-parameters-wer.patch +53 -0
  91. data/ports/patches/libxslt/0003-Initialize-pseudo-random-number-generator-with-curre.patch +60 -0
  92. data/ports/patches/libxslt/0004-EXSLT-function-str-replace-is-broken-as-is.patch +42 -0
  93. data/ports/patches/libxslt/0006-Fix-str-padding-to-work-with-UTF-8-strings.patch +164 -0
  94. data/ports/patches/libxslt/0007-Separate-function-for-predicate-matching-in-patterns.patch +587 -0
  95. data/ports/patches/libxslt/0008-Fix-direct-pattern-matching.patch +80 -0
  96. data/ports/patches/libxslt/0009-Fix-certain-patterns-with-predicates.patch +185 -0
  97. data/ports/patches/libxslt/0010-Fix-handling-of-UTF-8-strings-in-EXSLT-crypto-module.patch +126 -0
  98. data/ports/patches/libxslt/0013-Memory-leak-in-xsltCompileIdKeyPattern-error-path.patch +25 -0
  99. data/ports/patches/libxslt/0014-Fix-for-bug-436589.patch +43 -0
  100. data/ports/patches/libxslt/0015-Fix-mkdir-for-mingw.patch +41 -0
  101. data/suppressions/README.txt +1 -0
  102. data/suppressions/nokogiri_ree-1.8.7.358.supp +61 -0
  103. data/suppressions/nokogiri_ruby-1.8.7.370.supp +0 -0
  104. data/suppressions/nokogiri_ruby-1.9.2.320.supp +28 -0
  105. data/suppressions/nokogiri_ruby-1.9.3.327.supp +28 -0
  106. data/test/css/test_nthiness.rb +65 -2
  107. data/test/css/test_parser.rb +27 -10
  108. data/test/css/test_tokenizer.rb +1 -1
  109. data/test/css/test_xpath_visitor.rb +6 -1
  110. data/test/files/atom.xml +344 -0
  111. data/test/files/shift_jis_no_charset.html +9 -0
  112. data/test/helper.rb +10 -0
  113. data/test/html/test_document.rb +74 -7
  114. data/test/html/test_document_encoding.rb +10 -0
  115. data/test/html/test_document_fragment.rb +9 -3
  116. data/test/namespaces/test_namespaces_aliased_default.rb +24 -0
  117. data/test/namespaces/test_namespaces_in_cloned_doc.rb +31 -0
  118. data/test/namespaces/test_namespaces_preservation.rb +31 -0
  119. data/test/test_nokogiri.rb +6 -0
  120. data/test/test_reader.rb +7 -4
  121. data/test/test_xslt_transforms.rb +25 -0
  122. data/test/xml/sax/test_parser.rb +16 -0
  123. data/test/xml/sax/test_parser_context.rb +9 -0
  124. data/test/xml/test_builder.rb +9 -0
  125. data/test/xml/test_c14n.rb +12 -2
  126. data/test/xml/test_document.rb +66 -0
  127. data/test/xml/test_document_fragment.rb +5 -0
  128. data/test/xml/test_dtd.rb +84 -0
  129. data/test/xml/test_entity_reference.rb +3 -3
  130. data/test/xml/test_node.rb +21 -3
  131. data/test/xml/test_node_attributes.rb +17 -0
  132. data/test/xml/test_schema.rb +26 -0
  133. data/test/xml/test_text.rb +15 -0
  134. data/test/xml/test_xpath.rb +87 -0
  135. data/test_all +3 -3
  136. metadata +119 -68
  137. data/tasks/cross_compile.rb +0 -134
@@ -1,10 +1,9 @@
1
- = Nokogiri {<img src="https://secure.travis-ci.org/sparklemotion/nokogiri.png?rvm=1.9.3" />}[http://travis-ci.org/sparklemotion/nokogiri] {<img src="https://codeclimate.com/badge.png" />}[https://codeclimate.com/github/sparklemotion/nokogiri]
1
+ = Nokogiri {<img src="https://secure.travis-ci.org/sparklemotion/nokogiri.png?rvm=1.9.3" />}[http://travis-ci.org/sparklemotion/nokogiri] {<img src="https://codeclimate.com/github/sparklemotion/nokogiri.png" />}[https://codeclimate.com/github/sparklemotion/nokogiri] {<img src="https://www.versioneye.com/ruby/nokogiri/badge.png" alt="Dependency Status" />}[https://www.versioneye.com/ruby/nokogiri]
2
2
 
3
3
  * http://nokogiri.org
4
- * http://github.com/sparklemotion/nokogiri/wikis
5
- * http://github.com/sparklemotion/nokogiri/tree/master
6
- * http://groups.google.com/group/nokogiri-talk
7
- * http://github.com/sparklemotion/nokogiri/issues
4
+ * https://github.com/sparklemotion/nokogiri
5
+ * https://groups.google.com/group/nokogiri-talk
6
+ * https://github.com/sparklemotion/nokogiri/issues
8
7
 
9
8
  == DESCRIPTION:
10
9
 
@@ -16,12 +15,12 @@ enough of it.
16
15
 
17
16
  == FEATURES:
18
17
 
19
- * XPath support for document searching
18
+ * XPath 1.0 support for document searching
20
19
  * CSS3 selector support for document searching
21
20
  * XML/HTML builder
22
21
 
23
22
  Nokogiri parses and searches XML/HTML very quickly, and also has
24
- correctly implemented CSS3 selector support as well as XPath support.
23
+ correctly implemented CSS3 selector support as well as XPath 1.0 support.
25
24
 
26
25
  == SUPPORT:
27
26
 
@@ -29,15 +28,15 @@ Before filing a bug report, please read our {submission guidelines}[http://nokog
29
28
 
30
29
  * http://nokogiri.org/tutorials/getting_help.html
31
30
 
32
- The Nokogiri {mailing list}[http://groups.google.com/group/nokogiri-talk]
31
+ The Nokogiri {mailing list}[https://groups.google.com/group/nokogiri-talk]
33
32
  is available here:
34
33
 
35
- * http://groups.google.com/group/nokogiri-talk
34
+ * https://groups.google.com/group/nokogiri-talk
36
35
 
37
- The {bug tracker}[http://github.com/sparklemotion/nokogiri/issues]
36
+ The {bug tracker}[https://github.com/sparklemotion/nokogiri/issues]
38
37
  is available here:
39
38
 
40
- * http://github.com/sparklemotion/nokogiri/issues
39
+ * https://github.com/sparklemotion/nokogiri/issues
41
40
 
42
41
  The IRC channel is #nokogiri on freenode.
43
42
 
@@ -73,11 +72,16 @@ The IRC channel is #nokogiri on freenode.
73
72
 
74
73
  == REQUIREMENTS:
75
74
 
76
- * ruby 1.8 or 1.9
77
- * libxml2
78
- * libxml2-dev
79
- * libxslt
80
- * libxslt-dev
75
+ * ruby 1.9.3 or higher
76
+
77
+ * in Nokogiri 1.6.0 and later libxml2 and libxslt are bundled with the
78
+ gem, but if you want to use them installed on the system:
79
+
80
+ * libxml2 >=2.6.21 and <2.9.0, with iconv support
81
+ (libxml2-dev/-devel is required too)
82
+
83
+ * libxslt, built with and supported by the given libxml2
84
+ (libxslt-dev/-devel is required too)
81
85
 
82
86
  == ENCODING:
83
87
 
@@ -111,7 +115,7 @@ explicitly setting the encoding to EUC-JP on the parser:
111
115
 
112
116
  Binary packages are available for:
113
117
 
114
- * SuSE[http://download.opensuse.org/repositories/devel:/languages:/ruby:/extensions/]
118
+ * SuSE[https://download.opensuse.org/repositories/devel:/languages:/ruby:/extensions/]
115
119
  * Fedora[http://s390.koji.fedoraproject.org/koji/packageinfo?packageID=6756]
116
120
 
117
121
  == DEVELOPMENT:
@@ -146,7 +150,7 @@ Then run rake:
146
150
 
147
151
  (The MIT License)
148
152
 
149
- Copyright (c) 2008 - 2012:
153
+ Copyright (c) 2008 - 2013:
150
154
 
151
155
  * {Aaron Patterson}[http://tenderlovemaking.com]
152
156
  * {Mike Dalessio}[http://mike.daless.io]
@@ -154,6 +158,7 @@ Copyright (c) 2008 - 2012:
154
158
  * {Sergio Arbeo}[http://www.serabe.com]
155
159
  * {Patrick Mahoney}[http://polycrystal.org]
156
160
  * {Yoko Harada}[http://yokolet.blogspot.com]
161
+ * {Akinori MUSHA}[https://akinori.org]
157
162
 
158
163
  Permission is hereby granted, free of charge, to any person obtaining
159
164
  a copy of this software and associated documentation files (the
data/ROADMAP.md CHANGED
@@ -77,8 +77,7 @@
77
77
  ## Encoding
78
78
 
79
79
  We have a lot of issues open around encoding. How bad are things?
80
- Would it help if we deprecated support for Ruby 1.8.7? Somebody who
81
- knows encoding well should head this up.
80
+ Somebody who knows encoding well should head this up.
82
81
 
83
82
  * Extract EncodingReader as a real object that can be injected
84
83
  https://groups.google.com/forum/#!msg/nokogiri-talk/arJeAtMqvkg/tGihB-iBRSAJ
data/Rakefile CHANGED
@@ -1,5 +1,6 @@
1
1
  # -*- ruby -*-
2
2
  require 'rubygems'
3
+ require 'shellwords'
3
4
 
4
5
  gem 'hoe'
5
6
  require 'hoe'
@@ -14,11 +15,92 @@ GENERATED_TOKENIZER = "lib/nokogiri/css/tokenizer.rb"
14
15
  CROSS_DIR = File.join(File.dirname(__FILE__), 'ports')
15
16
 
16
17
  def java?
17
- !! (RUBY_PLATFORM =~ /java/)
18
+ /java/ === RUBY_PLATFORM
18
19
  end
19
20
 
20
21
  ENV['LANG'] = "en_US.UTF-8" # UBUNTU 10.04, Y U NO DEFAULT TO UTF-8?
21
22
 
23
+ CrossRuby = Struct.new(:version, :host) {
24
+ def ver
25
+ @ver ||= version[/\A[^-]+/]
26
+ end
27
+
28
+ def api_ver_suffix
29
+ case ver
30
+ when /\A([2-9])\.([0-9])\./
31
+ "#{$1}#{$2}0"
32
+ when /\A1\.9\./
33
+ '191'
34
+ else
35
+ raise "unsupported version: #{ver}"
36
+ end
37
+ end
38
+
39
+ def platform
40
+ @platform ||=
41
+ case host
42
+ when /\Ax86_64-/
43
+ 'x64-mingw32'
44
+ when /\Ai[3-6]86-/
45
+ 'x86-mingw32'
46
+ else
47
+ raise "unsupported host: #{host}"
48
+ end
49
+ end
50
+
51
+ def tool(name)
52
+ (@binutils_prefix ||=
53
+ case platform
54
+ when 'x64-mingw32'
55
+ 'x86_64-w64-mingw32-'
56
+ when 'x86-mingw32'
57
+ 'i686-w64-mingw32-'
58
+ end) + name
59
+ end
60
+
61
+ def target
62
+ case platform
63
+ when 'x64-mingw32'
64
+ 'pei-x86-64'
65
+ when 'x86-mingw32'
66
+ 'pei-i386'
67
+ end
68
+ end
69
+
70
+ def libruby_dll
71
+ case platform
72
+ when 'x64-mingw32'
73
+ "x64-msvcrt-ruby#{api_ver_suffix}.dll"
74
+ when 'x86-mingw32'
75
+ "msvcrt-ruby#{api_ver_suffix}.dll"
76
+ end
77
+ end
78
+
79
+ def dlls
80
+ [
81
+ 'kernel32.dll',
82
+ 'msvcrt.dll',
83
+ 'ws2_32.dll',
84
+ *(case
85
+ when ver >= '2.0.0'
86
+ 'user32.dll'
87
+ end),
88
+ libruby_dll
89
+ ]
90
+ end
91
+ }
92
+
93
+ CROSS_RUBIES = File.read('.cross_rubies').lines.flat_map { |line|
94
+ case line
95
+ when /\A([^#]+):([^#]+)/
96
+ CrossRuby.new($1, $2)
97
+ else
98
+ []
99
+ end
100
+ }
101
+
102
+ ENV['RUBY_CC_VERSION'] ||= CROSS_RUBIES.map(&:ver).uniq.join(":")
103
+
22
104
  require 'tasks/nokogiri.org'
23
105
 
24
106
  HOE = Hoe.spec 'nokogiri' do
@@ -26,25 +108,33 @@ HOE = Hoe.spec 'nokogiri' do
26
108
  developer 'Mike Dalessio', 'mike.dalessio@gmail.com'
27
109
  developer 'Yoko Harada', 'yokolet@gmail.com'
28
110
  developer 'Tim Elliott', 'tle@holymonkey.com'
111
+ developer 'Akinori MUSHA', 'knu@idaemons.org'
112
+
113
+ license "MIT"
29
114
 
30
115
  self.readme_file = ['README', ENV['HLANG'], 'rdoc'].compact.join('.')
31
116
  self.history_file = ['CHANGELOG', ENV['HLANG'], 'rdoc'].compact.join('.')
32
117
 
33
118
  self.extra_rdoc_files = FileList['*.rdoc','ext/nokogiri/*.c']
34
119
 
35
- self.licenses = ['MIT']
36
120
 
37
121
  self.clean_globs += [
38
122
  'nokogiri.gemspec',
39
123
  'lib/nokogiri/nokogiri.{bundle,jar,rb,so}',
40
- 'lib/nokogiri/{1.9,2.0}',
124
+ 'lib/nokogiri/[0-9].[0-9]',
125
+ 'ports/*.installed',
126
+ 'ports/{i[3-6]86,x86_64}-{w64-,}mingw32*',
127
+ 'ports/libxml2',
128
+ 'ports/libxslt',
41
129
  # GENERATED_PARSER,
42
130
  # GENERATED_TOKENIZER
43
131
  ]
44
132
 
45
- self.extra_deps += [
46
- ["mini_portile", "~> 0.5.0"],
47
- ]
133
+ unless java?
134
+ self.extra_deps += [
135
+ ["mini_portile", "~> 0.5.2"],
136
+ ]
137
+ end
48
138
 
49
139
  self.extra_dev_deps += [
50
140
  ["hoe-bundler", ">= 1.1"],
@@ -53,7 +143,7 @@ HOE = Hoe.spec 'nokogiri' do
53
143
  ["hoe-git", ">= 1.4"],
54
144
  ["minitest", "~> 2.2.2"],
55
145
  ["rake", ">= 0.9"],
56
- ["rake-compiler", "~> 0.8.0"],
146
+ ["rake-compiler", "~> 0.9.2"],
57
147
  ["racc", ">= 1.4.6"],
58
148
  ["rexical", ">= 1.0.5"]
59
149
  ]
@@ -77,7 +167,7 @@ def add_file_to_gem relative_path
77
167
  target_dir = File.dirname(target_path)
78
168
  mkdir_p target_dir unless File.directory?(target_dir)
79
169
  rm_f target_path
80
- ln relative_path, target_path
170
+ safe_ln relative_path, target_path
81
171
  HOE.spec.files += [relative_path]
82
172
  end
83
173
 
@@ -92,6 +182,8 @@ if java?
92
182
  jruby_home = RbConfig::CONFIG['prefix']
93
183
  ext.ext_dir = 'ext/java'
94
184
  ext.lib_dir = 'lib/nokogiri'
185
+ ext.source_version = '1.6'
186
+ ext.target_version = '1.6'
95
187
  jars = ["#{jruby_home}/lib/jruby.jar"] + FileList['lib/*.jar']
96
188
  ext.classpath = jars.map { |x| File.expand_path x }.join ':'
97
189
  end
@@ -100,9 +192,11 @@ if java?
100
192
  add_file_to_gem 'lib/nokogiri/nokogiri.jar'
101
193
  end
102
194
  else
103
- mingw_available = true
104
195
  begin
105
- require 'tasks/cross_compile'
196
+ require 'rake/extensioncompiler'
197
+ # Ensure mingw compiler is installed
198
+ Rake::ExtensionCompiler.mingw_host
199
+ mingw_available = true
106
200
  rescue
107
201
  puts "WARNING: cross compilation not available: #{$!}"
108
202
  mingw_available = false
@@ -111,18 +205,24 @@ else
111
205
 
112
206
  HOE.spec.files.reject! { |f| f =~ %r{\.(java|jar)$} }
113
207
 
114
- windows_p = RbConfig::CONFIG['target_os'] == 'mingw32' || RbConfig::CONFIG['target_os'] =~ /mswin/
115
-
116
- unless windows_p || java?
117
- task gem_build_path do
118
- add_file_to_gem "dependencies.yml"
119
-
120
- dependencies = YAML.load_file("dependencies.yml")
121
- %w[libxml2 libxslt].each do |lib|
122
- version = dependencies[lib]
123
- archive = File.join("ports", "archives", "#{lib}-#{version}.tar.gz")
124
- add_file_to_gem archive
125
- end
208
+ dependencies = YAML.load_file("dependencies.yml")
209
+
210
+ task gem_build_path do
211
+ %w[libxml2 libxslt].each do |lib|
212
+ version = dependencies[lib]
213
+ archive = File.join("ports", "archives", "#{lib}-#{version}.tar.gz")
214
+ add_file_to_gem archive
215
+ patchesdir = File.join("ports", "patches", lib)
216
+ patches = `#{['git', 'ls-files', patchesdir].shelljoin}`.split("\n").grep(/\.patch\z/)
217
+ patches.each { |patch|
218
+ add_file_to_gem patch
219
+ }
220
+ (untracked = Dir[File.join(patchesdir, '*.patch')] - patches).empty? or
221
+ at_exit {
222
+ untracked.each { |patch|
223
+ puts "** WARNING: untracked patch file not added to gem: #{patch}"
224
+ }
225
+ }
126
226
  end
127
227
  end
128
228
 
@@ -131,12 +231,16 @@ else
131
231
  ext.config_options << ENV['EXTOPTS']
132
232
  if mingw_available
133
233
  ext.cross_compile = true
134
- ext.cross_platform = ["x86-mswin32-60", "x86-mingw32"]
135
- ext.cross_config_options << "--with-xml2-include=#{File.join($recipes["libxml2"].path, 'include', 'libxml2')}"
136
- ext.cross_config_options << "--with-xml2-lib=#{File.join($recipes["libxml2"].path, 'lib')}"
137
- ext.cross_config_options << "--with-iconv-dir=#{$recipes["libiconv"].path}"
138
- ext.cross_config_options << "--with-xslt-dir=#{$recipes["libxslt"].path}"
139
- ext.cross_config_options << "--with-zlib-dir=#{CROSS_DIR}"
234
+ ext.cross_platform = CROSS_RUBIES.map(&:platform).uniq
235
+ ext.cross_config_options << "--enable-cross-build"
236
+ ext.cross_compiling do |spec|
237
+ libs = dependencies.map { |name, version| "#{name}-#{version}" }.join(', ')
238
+
239
+ spec.post_install_message = <<-EOS
240
+ Nokogiri is built with the packaged libraries: #{libs}.
241
+ EOS
242
+ spec.files.reject! { |path| File.fnmatch?('ports/*', path) }
243
+ end
140
244
  end
141
245
  end
142
246
  end
@@ -193,9 +297,9 @@ task :java_debug do
193
297
  end
194
298
 
195
299
  if java?
196
- task :test_18 => :test
197
- task :test_19 do
198
- ENV['JRUBY_OPTS'] = "--1.9"
300
+ task :test_19 => :test
301
+ task :test_20 do
302
+ ENV['JRUBY_OPTS'] = "--2.0"
199
303
  Rake::Task["test"].invoke
200
304
  end
201
305
  end
@@ -212,37 +316,37 @@ end
212
316
 
213
317
  # ----------------------------------------
214
318
 
215
- desc "build a windows gem without all the ceremony."
216
- task "gem:windows" => "gem" do
217
- cross_rubies = ["1.9.3-p194", "2.0.0-p0"]
218
- ruby_cc_version = cross_rubies.collect { |_| _.split("-").first }.join(":") # e.g., "1.8.7:1.9.2"
219
- rake_compiler_config_path = "#{ENV['HOME']}/.rake-compiler/config.yml"
319
+ def verify_dll(dll, cross_ruby)
320
+ dll_imports = cross_ruby.dlls
321
+ dump = `#{['env', 'LANG=C', cross_ruby.tool('objdump'), '-p', dll].shelljoin}`
322
+ raise "unexpected file format for generated dll #{dll}" unless /file format #{Regexp.quote(cross_ruby.target)}\s/ === dump
323
+ raise "export function Init_nokogiri not in dll #{dll}" unless /Table.*\sInit_nokogiri\s/mi === dump
324
+
325
+ # Verify that the expected DLL dependencies match the actual dependencies
326
+ # and that no further dependencies exist.
327
+ dll_imports_is = dump.scan(/DLL Name: (.*)$/).map(&:first).map(&:downcase).uniq
328
+ if dll_imports_is.sort != dll_imports.sort
329
+ raise "unexpected dll imports #{dll_imports_is.inspect} in #{dll}"
330
+ end
331
+ puts "#{dll}: Looks good!"
332
+ end
220
333
 
334
+ task :cross do
335
+ rake_compiler_config_path = File.expand_path("~/.rake-compiler/config.yml")
221
336
  unless File.exists? rake_compiler_config_path
222
- raise "rake-compiler has not installed any cross rubies. try running 'env --unset=HOST rake-compiler cross-ruby VERSION=#{cross_rubies.first}'"
223
- end
224
- rake_compiler_config = YAML.load_file(rake_compiler_config_path)
225
-
226
- # check that rake-compiler config contains the right patchlevels. see #279 for background,
227
- # and http://blog.mmediasys.com/2011/01/22/rake-compiler-updated-list-of-supported-ruby-versions-for-cross-compilation/
228
- # for more up-to-date docs.
229
- cross_rubies.each do |version|
230
- majmin, patchlevel = version.split("-")
231
- rbconfig = "rbconfig-#{majmin}"
232
- unless rake_compiler_config.key?(rbconfig) && rake_compiler_config[rbconfig] =~ /-#{patchlevel}/
233
- raise "rake-compiler '#{rbconfig}' not #{patchlevel}. try running 'env --unset=HOST rake-compiler cross-ruby VERSION=#{version}'"
234
- end
337
+ raise "rake-compiler has not installed any cross rubies. Try using rake-compiler-dev-box for building binary windows gems.'"
235
338
  end
236
339
 
237
- # verify that --export-all is in the 1.9 rbconfig. see #279,#374,#375.
238
- rbconfig_19 = rake_compiler_config["rbconfig-1.9.3"]
239
- raise "rbconfig #{rbconfig_19} needs --export-all in its DLDFLAGS value" if File.read(rbconfig_19).split("\n").grep(/CONFIG\["DLDFLAGS"\].*--export-all/).empty?
240
-
241
- rbconfig_20 = rake_compiler_config["rbconfig-2.0.0"]
242
- raise "rbconfig #{rbconfig_20} needs --export-all in its DLDFLAGS value" if File.read(rbconfig_20).split("\n").grep(/CONFIG\["DLDFLAGS"\].*--export-all/).empty?
243
-
244
- pkg_config_path = %w[libxslt libxml2].collect { |pkg| File.join($recipes[pkg].path, "lib/pkgconfig") }.join(":")
245
- sh("env PKG_CONFIG_PATH=#{pkg_config_path} RUBY_CC_VERSION=#{ruby_cc_version} rake cross native gem") || raise("build failed!")
340
+ CROSS_RUBIES.each do |cross_ruby|
341
+ task "tmp/#{cross_ruby.platform}/nokogiri/#{cross_ruby.ver}/nokogiri.so" do |t|
342
+ # To reduce the gem file size strip mingw32 dlls before packaging
343
+ sh [cross_ruby.tool('strip'), '-S', t.name].shelljoin
344
+ verify_dll t.name, cross_ruby
345
+ end
346
+ end
246
347
  end
247
348
 
349
+ desc "build a windows gem without all the ceremony."
350
+ task "gem:windows" => %w[cross native gem]
351
+
248
352
  # vim: syntax=Ruby
data/build_all CHANGED
@@ -2,14 +2,19 @@
2
2
  #
3
3
  # script to build gems for all relevant platforms:
4
4
  # - MRI et al (standard gem)
5
- # - windows (x86-mingw32 and x86-mswin32-60)
5
+ # - windows (x86-mingw32 and x64-mingw32)
6
6
  # - jruby
7
7
  #
8
8
  # here's what I recommend for building all the gems:
9
9
  #
10
- # 1. set up a vagrant VM guest running ubuntu lucid 32-bit.
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
11
16
  # 2. install rvm, and install 1.9.3, 2.0.0 and jruby.
12
- # 3. `sudo apt-get install mingw32`
17
+ # 3. `sudo apt-get install mingw32 gcc-mingw-w64-i686 gcc-mingw-w64-x86-64`
13
18
  #
14
19
  # as you build, you may run into these problems:
15
20
  #
@@ -34,6 +39,8 @@
34
39
  # RUBY_ENGINE (just comment it out)
35
40
  #
36
41
 
42
+ DEFAULT_RUBY=2.0.0
43
+
37
44
  HOST=
38
45
 
39
46
  # Load RVM into a shell session *as a function*
@@ -45,16 +52,37 @@ else
45
52
  echo "ERROR: An RVM installation was not found.\n"
46
53
  fi
47
54
 
48
- function rvm_use {
55
+ rvm_use () {
49
56
  current_ruby=$1
50
57
  rvm use "${1}@nokogiri" --create || rvm -v
51
58
  }
52
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
+
53
76
  set -o errexit
54
77
 
55
- # initialize
56
- rvm_use 1.8.7
57
- bundle install --quiet --local || bundle install
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
85
+
58
86
  rm -rf tmp pkg
59
87
  bundle exec rake clean
60
88
 
@@ -63,42 +91,39 @@ rm -rf gems
63
91
  mkdir -p gems
64
92
 
65
93
  # windows
66
- platform=$(uname -i)
67
- if [[ $platform =~ "64" ]] ; then
68
- echo ""
69
- echo "ERROR: You need to build the windows gem on a 32-bit machine!"
70
- echo ""
71
- exit 1
72
- fi
73
- rvm_use 1.8.7
74
- if [[ ! -a ${HOME}/.rake-compiler/ruby/ruby-1.8.7-p358/lib/ruby/1.8.7/x86_64-linux/rbconfig.rb ]] ; then
75
94
 
76
- # if this fails around the purelib.rb thing, try varying the ruby
77
- # used to run this script, and whether the HOST env var is set
78
- # below.
95
+ for verspec in `cross_rubies`; do
96
+ version="${verspec%%:*}"
97
+ ver="${version%%-*}"
98
+ host="${verspec#*:}"
99
+
100
+ case $ver in
101
+ 1.9.3)
102
+ # Parallel make does not work in 1.9.3, as it has a
103
+ # missing dependency problem with main.o.
104
+ make="make"
105
+ ;;
106
+ *)
107
+ make="$MAKE"
108
+ esac
109
+
110
+ MAKE="$make" rvm_do $ver rake-compiler cross-ruby VERSION=$version HOST=$host debugflags="-g"
111
+ done
79
112
 
80
- bundle exec rake-compiler cross-ruby VERSION=1.8.7-p358 # HOST=i386-mingw32
81
- fi
82
- if [[ ! -a ${HOME}/.rake-compiler/ruby/ruby-1.9.3-p194/lib/ruby/1.9.1/x86_64-linux/rbconfig.rb ]] ; then
83
- bundle exec rake-compiler cross-ruby VERSION=1.9.3-p194
84
- fi
85
- if [[ ! -a ${HOME}/.rake-compiler/ruby/ruby-2.0.0-p0/lib/ruby/2.0.0/x86_64-linux/rbconfig.rb ]] ; then
86
- bundle exec rake-compiler cross-ruby VERSION=2.0.0-p0
87
- fi
88
- bundle exec rake cross
89
113
  bundle exec rake gem:windows
90
- cp -v pkg/nokogiri*x86-{mingw32,mswin32}*.gem gems
114
+ cp -v pkg/nokogiri*{x86,x64}-mingw32*.gem gems
91
115
 
92
116
  # MRI
93
- rvm_use 1.8.7
117
+ bundle exec rake clean
94
118
  bundle exec rake gem
95
119
  cp -v pkg/nokogiri*.gem gems # should only be one at this point in the script
96
120
 
97
121
  # jruby
98
122
  rvm_use jruby
123
+ gem install bundler --conservative
99
124
  bundle install --quiet --local || bundle install
100
125
  bundle exec rake clean clobber
101
- rvm_use 1.8.7
126
+ rvm_use $DEFAULT_RUBY
102
127
  bundle exec rake generate
103
128
  rvm_use jruby
104
129
  bundle exec rake gem