thermite 0.9.0 → 0.10.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f5be6d2dadd7ecc7511529c5c02bc2a8b818b2c2
4
- data.tar.gz: 93507f6f71a4135fb8a26d9188a59bfe7ae9e02f
3
+ metadata.gz: 67d13d93b823cb59cfaee97258a453554c37776b
4
+ data.tar.gz: 6b43c2078ca42b9968f66de7eb8c1f195d8344c3
5
5
  SHA512:
6
- metadata.gz: fd95587e1e64983ca41e37bf597ed87564a6f929f5fcd05d5972fd59348bc871995c02e6328c02bd619f7b7914020ea016b5987198e02dedca28598b5917caa0
7
- data.tar.gz: 6480dbe2896f46ff2126cf650049e239caaf8171999390fa6f1480c57e21fc6e1e96a4f24b6fdbe687f5ba728aed3c7bf5c6ef0a85e9dcbe79368136ff1d6836
6
+ metadata.gz: 2751b4bfd2bfba6a2e1a8819216a434d24ef3e5b8b52fe941684316d39a5fc0738f1ae9327c7ce7507f4cbbd6e45b2d825516414750c4eee5f1fff3ac741fab3
7
+ data.tar.gz: 84708d23d5cbd0ee9ef48cf24fef94b99ab1b25b3d1ab717ff8682c1a7d1d13768fdb848027043ac4bbb903afe80cac4029c6ca8b41bee1e8ede2ad37d933c95
data/NEWS.md CHANGED
@@ -2,6 +2,18 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## [0.10.0] - 2017-01-22
6
+
7
+ ### Fixed
8
+
9
+ * Adjust OSX dylib library paths upon installation (#28)
10
+ * Don't use UNIX shell escaping on Windows
11
+
12
+ ### Changed
13
+
14
+ * `cargo build` has been replaced by `cargo rustc` - non-Windows builds use DLDFLAGS as linker
15
+ arguments (#27)
16
+
5
17
  ## [0.9.0] - 2017-01-18
6
18
 
7
19
  ### Fixed
@@ -102,6 +114,7 @@
102
114
 
103
115
  Initial release.
104
116
 
117
+ [0.10.0]: https://github.com/malept/thermite/compare/v0.9.0...v0.10.0
105
118
  [0.9.0]: https://github.com/malept/thermite/compare/v0.8.0...v0.9.0
106
119
  [0.8.0]: https://github.com/malept/thermite/compare/v0.7.0...v0.8.0
107
120
  [0.7.0]: https://github.com/malept/thermite/compare/v0.6.0...v0.7.0
@@ -38,7 +38,8 @@ module Thermite
38
38
  #
39
39
  def run_cargo(*args)
40
40
  Dir.chdir(config.rust_toplevel_dir) do
41
- sh "#{cargo} #{Shellwords.join(args)}"
41
+ shell_args = config.target_os == 'mingw32' ? args.join(' ') : Shellwords.join(args)
42
+ sh "#{cargo} #{shell_args}"
42
43
  end
43
44
  end
44
45
 
@@ -50,11 +51,12 @@ module Thermite
50
51
  end
51
52
 
52
53
  #
53
- # Run `cargo build`, given a target (i.e., `release` [default] or `debug`).
54
+ # Run `cargo rustc`, given a target (i.e., `release` [default] or `debug`).
54
55
  #
55
- def run_cargo_build(target)
56
- cargo_args = %w(build)
56
+ def run_cargo_rustc(target)
57
+ cargo_args = %w(rustc)
57
58
  cargo_args << '--release' if target == 'release'
59
+ cargo_args.push(*cargo_rustc_args)
58
60
  run_cargo(*cargo_args)
59
61
  end
60
62
 
@@ -96,5 +98,20 @@ EOM
96
98
  def cargo_recommended_msg
97
99
  cargo_msg('recommended (but not required)')
98
100
  end
101
+
102
+ private
103
+
104
+ def cargo_rustc_args
105
+ args = []
106
+ unless config.dynamic_linker_flags == '' || config.target_os == 'mingw32'
107
+ args.push(
108
+ '--',
109
+ '-C',
110
+ "link-args=#{config.dynamic_linker_flags}"
111
+ )
112
+ end
113
+
114
+ args
115
+ end
99
116
  end
100
117
  end
@@ -142,6 +142,17 @@ module Thermite
142
142
  File.join(ruby_toplevel_dir, *path_components)
143
143
  end
144
144
 
145
+ # :nocov:
146
+
147
+ #
148
+ # Absolute path to the shared libruby.
149
+ #
150
+ def libruby_path
151
+ @libruby_path ||= File.join(RbConfig::CONFIG['libdir'], RbConfig::CONFIG['LIBRUBY_SO'])
152
+ end
153
+
154
+ # :nocov:
155
+
145
156
  #
146
157
  # The top-level directory of the Cargo project. Defaults to the current working directory.
147
158
  #
@@ -212,10 +223,17 @@ module Thermite
212
223
  end
213
224
  end
214
225
 
215
- private
216
-
217
226
  # :nocov:
218
227
 
228
+ #
229
+ # Linker flags for libruby.
230
+ #
231
+ def dynamic_linker_flags
232
+ @dynamic_linker_flags ||= RbConfig::CONFIG['DLDFLAGS'].strip
233
+ end
234
+
235
+ private
236
+
219
237
  def dlext
220
238
  RbConfig::CONFIG['DLEXT']
221
239
  end
@@ -38,15 +38,17 @@ module Thermite
38
38
  return false unless config.binary_uri_format
39
39
 
40
40
  version = config.crate_version
41
- uri ||= config.binary_uri_format % {
41
+ uri ||= format(
42
+ config.binary_uri_format,
42
43
  filename: config.tarball_filename(version),
43
44
  version: version
44
- }
45
+ )
45
46
 
46
47
  return false unless (tgz = download_versioned_binary(uri, version))
47
48
 
48
49
  debug "Unpacking binary from Cargo version: #{File.basename(uri)}"
49
50
  unpack_tarball(tgz)
51
+ prepare_downloaded_library
50
52
  true
51
53
  end
52
54
 
@@ -61,6 +61,7 @@ module Thermite
61
61
 
62
62
  debug "Unpacking GitHub release from Cargo version: #{File.basename(uri)}"
63
63
  unpack_tarball(tgz)
64
+ prepare_downloaded_library
64
65
  true
65
66
  end
66
67
 
@@ -75,6 +76,7 @@ module Thermite
75
76
  next unless tgz
76
77
  debug "Unpacking GitHub release: #{File.basename(download_uri)}"
77
78
  unpack_tarball(tgz)
79
+ prepare_downloaded_library
78
80
  installed_binary = true
79
81
  break
80
82
  end
@@ -33,6 +33,7 @@ module Thermite
33
33
  def build_package
34
34
  filename = config.tarball_filename(config.toml[:package][:version])
35
35
  relative_library_path = config.ruby_extension_path.sub("#{config.ruby_toplevel_dir}/", '')
36
+ prepare_built_library
36
37
  Zlib::GzipWriter.open(filename) do |tgz|
37
38
  Dir.chdir(config.ruby_toplevel_dir) do
38
39
  Archive::Tar::Minitar.pack(relative_library_path, tgz)
@@ -55,6 +56,19 @@ module Thermite
55
56
  end
56
57
  end
57
58
 
59
+ # :nocov:
60
+
61
+ def prepare_downloaded_library
62
+ return unless config.target_os.start_with?('darwin')
63
+
64
+ libruby_path = Shellwords.escape(config.libruby_path)
65
+ library_path = Shellwords.escape(config.ruby_extension_path)
66
+ `install_name_tool -id #{library_path} #{library_path}`
67
+ `install_name_tool -change @libruby_path@ #{libruby_path} #{library_path}`
68
+ end
69
+
70
+ # :nocov:
71
+
58
72
  private
59
73
 
60
74
  def each_compressed_file(tgz)
@@ -68,5 +82,15 @@ module Thermite
68
82
  end
69
83
  end
70
84
  end
85
+
86
+ # :nocov:
87
+
88
+ def prepare_built_library
89
+ return unless config.target_os.start_with?('darwin')
90
+
91
+ libruby_path = Shellwords.escape(config.libruby_path)
92
+ library_path = Shellwords.escape(config.ruby_extension_path)
93
+ `install_name_tool -change #{libruby_path} @libruby_path@ #{library_path}`
94
+ end
71
95
  end
72
96
  end
@@ -118,7 +118,7 @@ module Thermite
118
118
  # if cargo found, build. Otherwise, grab binary (when github_releases is enabled).
119
119
  if cargo
120
120
  target = ENV.fetch('CARGO_TARGET', 'release')
121
- run_cargo_build(target)
121
+ run_cargo_rustc(target)
122
122
  FileUtils.cp(config.rust_path('target', target, config.shared_library),
123
123
  config.ruby_path('lib'))
124
124
  elsif !download_binary_from_custom_uri && !download_binary_from_github_release
@@ -22,14 +22,26 @@ module Thermite
22
22
  mock_module.run_cargo_if_exists('foo', 'bar')
23
23
  end
24
24
 
25
- def test_run_cargo_debug_build
26
- mock_module.expects(:run_cargo).with('build').once
27
- mock_module.run_cargo_build('debug')
25
+ def test_run_cargo_debug_rustc
26
+ mock_module.config.stubs(:dynamic_linker_flags).returns('')
27
+ mock_module.expects(:run_cargo).with('rustc').once
28
+ mock_module.run_cargo_rustc('debug')
28
29
  end
29
30
 
30
- def test_run_cargo_release_build
31
- mock_module.expects(:run_cargo).with('build', '--release').once
32
- mock_module.run_cargo_build('release')
31
+ def test_run_cargo_release_rustc
32
+ mock_module.config.stubs(:dynamic_linker_flags).returns('')
33
+ mock_module.expects(:run_cargo).with('rustc', '--release').once
34
+ mock_module.run_cargo_rustc('release')
35
+ end
36
+
37
+ def test_run_cargo_rustc_with_dynamic_linker_flags
38
+ mock_module.config.stubs(:dynamic_linker_flags).returns('foo bar')
39
+ if RbConfig::CONFIG['target_os'] == 'mingw32'
40
+ mock_module.expects(:run_cargo).with('rustc').once
41
+ else
42
+ mock_module.expects(:run_cargo).with('rustc', '--', '-C', 'link-args=foo bar').once
43
+ end
44
+ mock_module.run_cargo_rustc('debug')
33
45
  end
34
46
 
35
47
  def test_inform_user_about_cargo_exception
@@ -26,6 +26,7 @@ module Thermite
26
26
  Net::HTTP.stubs(:get_response).returns('location' => 'redirect')
27
27
  mock_module.stubs(:http_get).returns('tarball')
28
28
  mock_module.expects(:unpack_tarball).once
29
+ mock_module.expects(:prepare_downloaded_library).once
29
30
 
30
31
  assert mock_module.download_binary_from_custom_uri
31
32
  end
@@ -56,6 +56,7 @@ module Thermite
56
56
  Net::HTTP.stubs(:get_response).returns('location' => 'redirect')
57
57
  mock_module.stubs(:http_get).returns('tarball')
58
58
  mock_module.expects(:unpack_tarball).once
59
+ mock_module.expects(:prepare_downloaded_library).once
59
60
 
60
61
  assert mock_module.download_binary_from_github_release
61
62
  end
@@ -67,6 +68,7 @@ module Thermite
67
68
  Net::HTTP.stubs(:get_response).returns('location' => 'redirect')
68
69
  mock_module.stubs(:http_get).returns('tarball')
69
70
  mock_module.expects(:unpack_tarball).once
71
+ mock_module.expects(:prepare_downloaded_library).once
70
72
 
71
73
  assert mock_module.download_binary_from_github_release
72
74
  end
@@ -114,6 +116,7 @@ module Thermite
114
116
  stub_releases_atom
115
117
  mock_module.stubs(:download_versioned_github_release_binary).returns(StringIO.new('tarball'))
116
118
  mock_module.expects(:unpack_tarball).once
119
+ mock_module.expects(:prepare_downloaded_library).once
117
120
 
118
121
  assert mock_module.download_binary_from_github_release
119
122
  end
@@ -131,6 +134,7 @@ module Thermite
131
134
  stub_releases_atom
132
135
  mock_module.stubs(:download_versioned_github_release_binary).returns(nil)
133
136
  mock_module.expects(:unpack_tarball).never
137
+ mock_module.expects(:prepare_downloaded_library).never
134
138
 
135
139
  assert !mock_module.download_binary_from_github_release
136
140
  end
data/thermite.gemspec CHANGED
@@ -3,7 +3,7 @@ require 'English'
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = 'thermite'
6
- s.version = '0.9.0'
6
+ s.version = '0.10.0'
7
7
  s.summary = 'Rake helpers for Rust+Ruby'
8
8
  s.description = 'A Rake-based helper for building and distributing Rust-based Ruby extensions'
9
9
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thermite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Lee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-19 00:00:00.000000000 Z
11
+ date: 2017-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake