gem-compiler 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/CHANGELOG.md +18 -1
- data/lib/rubygems/commands/compile_command.rb +4 -0
- data/lib/rubygems/compiler.rb +29 -11
- data/lib/rubygems/compiler/version.rb +1 -1
- data/test/rubygems/test_gem_compiler.rb +84 -5
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2f88322755fee2322a31c6516b5f52dc9470bc132e2fde88628f6a0f449987ac
|
4
|
+
data.tar.gz: 53a1dc54a53791f6a106d012e6306228f548a906549dd601c7c273c252048013
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc22e52f9e0328c93b90a0ed5e8dce3d63aece8377af375aba94e3c0d2d6e30dbd3bf37a91d6043fb859cb561e3e94622998b237509040f32b45e12cc694c381
|
7
|
+
data.tar.gz: 149623d4a832894032c1a249fabe912a8a6af1028faf9ad62a5735ebdb7aebe2b7e283f416c63f78ed69c4d3d03df89fe1b965ab1f71e96a30445cb66a91985c
|
data/CHANGELOG.md
CHANGED
@@ -10,6 +10,22 @@ upgrading.
|
|
10
10
|
|
11
11
|
## [Unreleased]
|
12
12
|
|
13
|
+
## [0.8.0] - 2017-12-28
|
14
|
+
|
15
|
+
### Added
|
16
|
+
- Introduce `--include-shared-dir` to specify additional directory where to
|
17
|
+
lookup platform-specific shared libraries to bundle in the package. (#34)
|
18
|
+
|
19
|
+
### Fixed
|
20
|
+
- Solve RubyGems 2.6.x changes on exception hierarchy. Thanks to @MSP-Greg (#30)
|
21
|
+
|
22
|
+
### Removed
|
23
|
+
- Drop support for Ruby 2.1.x and 2.2.x, as they reached EOL (End Of Life)
|
24
|
+
- Drop support for RubyGems older than 2.5.0
|
25
|
+
|
26
|
+
### Changed
|
27
|
+
- CI: Avoid possible issues when installing Bundler on AppVeyor
|
28
|
+
|
13
29
|
## [0.7.0] - 2017-10-01
|
14
30
|
|
15
31
|
### Added
|
@@ -78,7 +94,8 @@ upgrading.
|
|
78
94
|
|
79
95
|
- Initial public release, extracted from internal project.
|
80
96
|
|
81
|
-
[Unreleased]: https://github.com/luislavena/gem-compiler/compare/v0.
|
97
|
+
[Unreleased]: https://github.com/luislavena/gem-compiler/compare/v0.8.0...HEAD
|
98
|
+
[0.8.0]: https://github.com/luislavena/gem-compiler/compare/v0.7.0...v0.8.0
|
82
99
|
[0.7.0]: https://github.com/luislavena/gem-compiler/compare/v0.6.0...v0.7.0
|
83
100
|
[0.6.0]: https://github.com/luislavena/gem-compiler/compare/v0.5.0...v0.6.0
|
84
101
|
[0.5.0]: https://github.com/luislavena/gem-compiler/compare/v0.4.0...v0.5.0
|
@@ -9,6 +9,10 @@ class Gem::Commands::CompileCommand < Gem::Command
|
|
9
9
|
options[:output] = File.expand_path(value, Dir.pwd)
|
10
10
|
end
|
11
11
|
|
12
|
+
add_option "--include-shared-dir DIR", "Additional directory for shared libraries" do |value, options|
|
13
|
+
options[:include_shared_dir] = value
|
14
|
+
end
|
15
|
+
|
12
16
|
add_option "--prune", "Clean non-existing files during re-packaging" do |value, options|
|
13
17
|
options[:prune] = true
|
14
18
|
end
|
data/lib/rubygems/compiler.rb
CHANGED
@@ -2,12 +2,7 @@ require "fileutils"
|
|
2
2
|
require "rbconfig"
|
3
3
|
require "tmpdir"
|
4
4
|
require "rubygems/installer"
|
5
|
-
|
6
|
-
if Gem::VERSION >= "2.0.0"
|
7
|
-
require "rubygems/package"
|
8
|
-
else
|
9
|
-
require "rubygems/builder"
|
10
|
-
end
|
5
|
+
require "rubygems/package"
|
11
6
|
|
12
7
|
class Gem::Compiler
|
13
8
|
include Gem::UserInteraction
|
@@ -30,6 +25,12 @@ class Gem::Compiler
|
|
30
25
|
|
31
26
|
artifacts = collect_artifacts
|
32
27
|
|
28
|
+
if shared_dir = options[:include_shared_dir]
|
29
|
+
shared_libs = collect_shared(shared_dir)
|
30
|
+
|
31
|
+
artifacts.concat shared_libs
|
32
|
+
end
|
33
|
+
|
33
34
|
# build a new gemspec from the original one
|
34
35
|
gemspec = installer.spec.dup
|
35
36
|
|
@@ -80,6 +81,12 @@ class Gem::Compiler
|
|
80
81
|
Dir.glob("#{target_dir}/{#{lib_dirs}}/**/*.#{dlext}")
|
81
82
|
end
|
82
83
|
|
84
|
+
def collect_shared(shared_dir)
|
85
|
+
libext = platform_shared_ext
|
86
|
+
|
87
|
+
Dir.glob("#{target_dir}/#{shared_dir}/**/*.#{libext}")
|
88
|
+
end
|
89
|
+
|
83
90
|
def info(msg)
|
84
91
|
say msg if Gem.configuration.verbose
|
85
92
|
end
|
@@ -92,6 +99,21 @@ class Gem::Compiler
|
|
92
99
|
@installer ||= prepare_installer
|
93
100
|
end
|
94
101
|
|
102
|
+
def platform_shared_ext
|
103
|
+
platform = Gem::Platform.local
|
104
|
+
|
105
|
+
case platform.os
|
106
|
+
when /darwin/
|
107
|
+
"dylib"
|
108
|
+
when /linux|bsd|solaris/
|
109
|
+
"so"
|
110
|
+
when /mingw|mswin|cygwin|msys/
|
111
|
+
"dll"
|
112
|
+
else
|
113
|
+
"so"
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
95
117
|
def prepare_installer
|
96
118
|
# RubyGems 2.5 specifics
|
97
119
|
unpack_options = options.dup.merge(unpack: true)
|
@@ -149,11 +171,7 @@ class Gem::Compiler
|
|
149
171
|
output_gem = nil
|
150
172
|
|
151
173
|
Dir.chdir target_dir do
|
152
|
-
output_gem =
|
153
|
-
Gem::Builder.new(gemspec).build
|
154
|
-
else
|
155
|
-
Gem::Package.build(gemspec)
|
156
|
-
end
|
174
|
+
output_gem = Gem::Package.build(gemspec)
|
157
175
|
end
|
158
176
|
|
159
177
|
unless output_gem
|
@@ -1,6 +1,14 @@
|
|
1
1
|
require "rubygems/test_case"
|
2
2
|
require "rubygems/compiler"
|
3
3
|
|
4
|
+
# RubyGems 2.6.x introduced a new exception class for unmet requirements
|
5
|
+
# Evalute if is present and use it in tests
|
6
|
+
if defined?(Gem::RuntimeRequirementNotMetError)
|
7
|
+
GEM_REQUIREMENT_EXCEPTION = Gem::RuntimeRequirementNotMetError
|
8
|
+
else
|
9
|
+
GEM_REQUIREMENT_EXCEPTION = Gem::InstallError
|
10
|
+
end
|
11
|
+
|
4
12
|
class TestGemCompiler < Gem::TestCase
|
5
13
|
def setup
|
6
14
|
super
|
@@ -71,13 +79,13 @@ class TestGemCompiler < Gem::TestCase
|
|
71
79
|
|
72
80
|
compiler = Gem::Compiler.new(gem_file, :output => @output_dir)
|
73
81
|
|
74
|
-
e = assert_raises
|
82
|
+
e = assert_raises GEM_REQUIREMENT_EXCEPTION do
|
75
83
|
use_ui @ui do
|
76
84
|
compiler.compile
|
77
85
|
end
|
78
86
|
end
|
79
87
|
|
80
|
-
|
88
|
+
assert_match %r|old_required requires Ruby version = 1.4.6|, e.message
|
81
89
|
end
|
82
90
|
|
83
91
|
def test_compile_required_rubygems
|
@@ -85,14 +93,13 @@ class TestGemCompiler < Gem::TestCase
|
|
85
93
|
|
86
94
|
compiler = Gem::Compiler.new(gem_file, :output => @output_dir)
|
87
95
|
|
88
|
-
e = assert_raises
|
96
|
+
e = assert_raises GEM_REQUIREMENT_EXCEPTION do
|
89
97
|
use_ui @ui do
|
90
98
|
compiler.compile
|
91
99
|
end
|
92
100
|
end
|
93
101
|
|
94
|
-
|
95
|
-
"Try 'gem update --system' to update RubyGems itself.", e.message
|
102
|
+
assert_match %r|old_rubygems requires RubyGems version < 0|, e.message
|
96
103
|
end
|
97
104
|
|
98
105
|
def test_compile_succeed
|
@@ -228,6 +235,78 @@ class TestGemCompiler < Gem::TestCase
|
|
228
235
|
end
|
229
236
|
end
|
230
237
|
|
238
|
+
def test_compile_bundle_extra_artifacts_linux
|
239
|
+
util_set_arch "x86_64-linux"
|
240
|
+
|
241
|
+
name = 'a'
|
242
|
+
|
243
|
+
artifact = "shared.so"
|
244
|
+
old_spec = ''
|
245
|
+
|
246
|
+
gem_file = util_bake_gem(name) { |spec|
|
247
|
+
old_spec = spec
|
248
|
+
util_fake_extension spec, name, <<-EOF
|
249
|
+
require "fileutils"
|
250
|
+
|
251
|
+
FileUtils.touch "#{artifact}"
|
252
|
+
|
253
|
+
File.open 'Rakefile', 'w' do |rf| rf.puts "task :default" end
|
254
|
+
EOF
|
255
|
+
}
|
256
|
+
|
257
|
+
compiler = Gem::Compiler.new(gem_file,
|
258
|
+
:output => @output_dir, :include_shared_dir => "ext")
|
259
|
+
|
260
|
+
output_gem = nil
|
261
|
+
|
262
|
+
use_ui @ui do
|
263
|
+
output_gem = compiler.compile
|
264
|
+
end
|
265
|
+
|
266
|
+
assert_path_exists File.join(@output_dir, output_gem)
|
267
|
+
actual_spec = util_read_spec File.join(@output_dir, output_gem)
|
268
|
+
|
269
|
+
assert_includes actual_spec.files, "ext/#{name}/#{artifact}"
|
270
|
+
ensure
|
271
|
+
util_reset_arch
|
272
|
+
end
|
273
|
+
|
274
|
+
def test_compile_bundle_extra_artifacts_windows
|
275
|
+
util_set_arch "i386-mingw32"
|
276
|
+
|
277
|
+
name = 'a'
|
278
|
+
|
279
|
+
artifact = "shared.dll"
|
280
|
+
old_spec = ''
|
281
|
+
|
282
|
+
gem_file = util_bake_gem(name) { |spec|
|
283
|
+
old_spec = spec
|
284
|
+
util_fake_extension spec, name, <<-EOF
|
285
|
+
require "fileutils"
|
286
|
+
|
287
|
+
FileUtils.touch "#{artifact}"
|
288
|
+
|
289
|
+
File.open 'Rakefile', 'w' do |rf| rf.puts "task :default" end
|
290
|
+
EOF
|
291
|
+
}
|
292
|
+
|
293
|
+
compiler = Gem::Compiler.new(gem_file,
|
294
|
+
:output => @output_dir, :include_shared_dir => "ext")
|
295
|
+
|
296
|
+
output_gem = nil
|
297
|
+
|
298
|
+
use_ui @ui do
|
299
|
+
output_gem = compiler.compile
|
300
|
+
end
|
301
|
+
|
302
|
+
assert_path_exists File.join(@output_dir, output_gem)
|
303
|
+
actual_spec = util_read_spec File.join(@output_dir, output_gem)
|
304
|
+
|
305
|
+
assert_includes actual_spec.files, "ext/#{name}/#{artifact}"
|
306
|
+
ensure
|
307
|
+
util_reset_arch
|
308
|
+
end
|
309
|
+
|
231
310
|
def test_compile_lock_ruby_abi
|
232
311
|
util_reset_arch
|
233
312
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gem-compiler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luis Lavena
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -74,15 +74,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
74
74
|
requirements:
|
75
75
|
- - ">="
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
version: 2.
|
77
|
+
version: 2.3.0
|
78
78
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 2.5.0
|
83
83
|
requirements: []
|
84
84
|
rubyforge_project:
|
85
|
-
rubygems_version: 2.
|
85
|
+
rubygems_version: 2.7.4
|
86
86
|
signing_key:
|
87
87
|
specification_version: 4
|
88
88
|
summary: A RubyGems plugin that generates binary gems.
|