thermite 0.10.0 → 0.11.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: 67d13d93b823cb59cfaee97258a453554c37776b
4
- data.tar.gz: 6b43c2078ca42b9968f66de7eb8c1f195d8344c3
3
+ metadata.gz: 1d002cb267d9a1d645dd17f2367d51085c89bf04
4
+ data.tar.gz: 4d1d9325d79676569e8cf2289c627d3211da672f
5
5
  SHA512:
6
- metadata.gz: 2751b4bfd2bfba6a2e1a8819216a434d24ef3e5b8b52fe941684316d39a5fc0738f1ae9327c7ce7507f4cbbd6e45b2d825516414750c4eee5f1fff3ac741fab3
7
- data.tar.gz: 84708d23d5cbd0ee9ef48cf24fef94b99ab1b25b3d1ab717ff8682c1a7d1d13768fdb848027043ac4bbb903afe80cac4029c6ca8b41bee1e8ede2ad37d933c95
6
+ metadata.gz: 108c54cafd7afe98df4f3bbfeb332f5dea0b00b159c0d684a25a7f8b64fea8f99174029d075a76fb6b4be9de3280bb635e29aeeb62651d2fa0c5379f9e78a683
7
+ data.tar.gz: 7becbcb989abedc663104d9fc5f024929833468dc801863a6585fd02b3a506302903cb867e77b5b3c5b76501f3deb61538107008407e1d4aeee3651314866af9
@@ -3,6 +3,10 @@ AllCops:
3
3
  - 'vendor/**/*'
4
4
  TargetRubyVersion: 2.1
5
5
 
6
+ Lint/EndAlignment:
7
+ Enabled: true
8
+ EnforcedStyleAlignWith: variable
9
+
6
10
  Metrics/AbcSize:
7
11
  Max: 20
8
12
 
data/NEWS.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## [0.11.0] - 2017-02-03
6
+
7
+ ### Added
8
+
9
+ * Add support for Cargo workspaces (#30)
10
+
5
11
  ## [0.10.0] - 2017-01-22
6
12
 
7
13
  ### Fixed
@@ -114,6 +120,7 @@
114
120
 
115
121
  Initial release.
116
122
 
123
+ [0.11.0]: https://github.com/malept/thermite/compare/v0.10.0...v0.11.0
117
124
  [0.10.0]: https://github.com/malept/thermite/compare/v0.9.0...v0.10.0
118
125
  [0.9.0]: https://github.com/malept/thermite/compare/v0.8.0...v0.9.0
119
126
  [0.8.0]: https://github.com/malept/thermite/compare/v0.7.0...v0.8.0
data/README.md CHANGED
@@ -76,7 +76,10 @@ Possible options:
76
76
  Example: `https://example.com/download/%{version}/%{filename}`. Replacement variables:
77
77
  - `filename` - The value of `Config.tarball_filename`
78
78
  - `version` - the crate version from `Cargo.toml`
79
- * `cargo_project_path` - the path to the Cargo project. Defaults to the current working directory.
79
+ * `cargo_project_path` - the path to the top-level Cargo project. Defaults to the current working
80
+ directory.
81
+ * `cargo_workspace_member` - if set, the relative path to the Cargo workspace member. Usually used
82
+ when it is part of a repository containing multiple crates.
80
83
  * `github_releases` - whether to look for Rust binaries via GitHub releases when installing
81
84
  the gem, and `cargo` is not found. Defaults to `false`.
82
85
  * `github_release_type` - when `github_releases` is `true`, the mode to use to download the Rust
@@ -55,6 +55,10 @@ module Thermite
55
55
  #
56
56
  def run_cargo_rustc(target)
57
57
  cargo_args = %w(rustc)
58
+ if config.cargo_workspace_member
59
+ manifest = File.join(config.cargo_workspace_member, 'Cargo.toml')
60
+ cargo_args.push('--manifest-path', manifest)
61
+ end
58
62
  cargo_args << '--release' if target == 'release'
59
63
  cargo_args.push(*cargo_rustc_args)
60
64
  run_cargo(*cargo_args)
@@ -168,6 +168,27 @@ module Thermite
168
168
  File.join(rust_toplevel_dir, *path_components)
169
169
  end
170
170
 
171
+ #
172
+ # If run in a multi-crate environment, the Cargo workspace member that contains the
173
+ # Ruby extension.
174
+ #
175
+ def cargo_workspace_member
176
+ @cargo_workspace_member ||= @options[:cargo_workspace_member]
177
+ end
178
+
179
+ #
180
+ # The absolute path to the `Cargo.toml` file. The path depends on the existence of the
181
+ # `cargo_workspace_member` configuration option.
182
+ #
183
+ def cargo_toml_path
184
+ @cargo_toml_path ||= begin
185
+ components = ['Cargo.toml']
186
+ components.unshift(cargo_workspace_member) if cargo_workspace_member
187
+
188
+ rust_path(*components)
189
+ end
190
+ end
191
+
171
192
  #
172
193
  # Path to the Rust shared library in the context of the Ruby project.
173
194
  #
@@ -198,7 +219,7 @@ module Thermite
198
219
  # Parsed TOML object (courtesy of `tomlrb`).
199
220
  #
200
221
  def toml
201
- @toml ||= Tomlrb.load_file(rust_path('Cargo.toml'), symbolize_keys: true)
222
+ @toml ||= Tomlrb.load_file(cargo_toml_path, symbolize_keys: true)
202
223
  end
203
224
 
204
225
  #
@@ -63,6 +63,8 @@ module Thermite
63
63
  # - `version` - the crate version from the `Cargo.toml` file
64
64
  # * `cargo_project_path` - the path to the Cargo project. Defaults to the current
65
65
  # working directory.
66
+ # * `cargo_workspace_member` - if set, the relative path to the Cargo workspace member. Usually
67
+ # used when it is part of a repository containing multiple crates.
66
68
  # * `github_releases` - whether to look for rust binaries via GitHub releases when installing
67
69
  # the gem, and `cargo` is not found. Defaults to `false`.
68
70
  # * `github_release_type` - when `github_releases` is `true`, the mode to use to download the
@@ -34,6 +34,13 @@ module Thermite
34
34
  mock_module.run_cargo_rustc('release')
35
35
  end
36
36
 
37
+ def test_run_cargo_rustc_with_workspace_member
38
+ mock_module.config.stubs(:dynamic_linker_flags).returns('')
39
+ mock_module.config.stubs(:cargo_workspace_member).returns('foo/bar')
40
+ mock_module.expects(:run_cargo).with('rustc', '--manifest-path', 'foo/bar/Cargo.toml').once
41
+ mock_module.run_cargo_rustc('debug')
42
+ end
43
+
37
44
  def test_run_cargo_rustc_with_dynamic_linker_flags
38
45
  mock_module.config.stubs(:dynamic_linker_flags).returns('foo bar')
39
46
  if RbConfig::CONFIG['target_os'] == 'mingw32'
@@ -109,6 +109,12 @@ module Thermite
109
109
  assert_equal '/tmp/foobar/baz/quux', config.rust_path('baz', 'quux')
110
110
  end
111
111
 
112
+ def test_cargo_toml_path_with_workspace_member
113
+ FileUtils.stubs(:pwd).returns('/tmp/foobar')
114
+ config(cargo_workspace_member: 'baz')
115
+ assert_equal '/tmp/foobar/baz/Cargo.toml', config.cargo_toml_path
116
+ end
117
+
112
118
  def test_default_git_tag_regex
113
119
  assert_equal described_class::DEFAULT_TAG_REGEX, config.git_tag_regex
114
120
  end
@@ -3,7 +3,7 @@ require 'English'
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = 'thermite'
6
- s.version = '0.10.0'
6
+ s.version = '0.11.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.10.0
4
+ version: 0.11.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-22 00:00:00.000000000 Z
11
+ date: 2017-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake