thermite 0.11.1 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d46ed87fb7a828cd7419b99e0b72497080cb706e
4
- data.tar.gz: 79a9493717ca440209d37375b332e7ef5b598a01
3
+ metadata.gz: 45077a1b81efe633a758315d0b521b208d6467d7
4
+ data.tar.gz: f13423bc8bc0e57df51329dffed5e9dade52760b
5
5
  SHA512:
6
- metadata.gz: acedce2b841de01077166fc765ce33e10d9d600274b4ba99c6acdbdb6990bb8f48496bc9807a645c9c7f2116a7edffdcb784c704e29b5155cf8c8f73ee66d189
7
- data.tar.gz: 9c7ae1c09eff27c99ddf9525c17f68c4683af53f2917edb14df8aa54e0daf28b7b426ef0daa0765e1d06efffd0164199a2e32ebd2fd56660876ed1208d44059d
6
+ metadata.gz: a1f52ff2ece0053428f4dc5ea9e7fe72c7608c634a58bd211a9b9669b8d32384d60cd09702aac57d0bba919a8ea2ef465c86459a8321a932f4949cc7bd17895a
7
+ data.tar.gz: 5d77f221ae5889c33e4bd72c980e1300343f805be6c760a3c65fe334c2da15a73a403847a5f58c2cbc1d6a3a1dc0cd39e5f169ec5a3d88714e917a764316b86b
@@ -24,3 +24,10 @@ Metrics/LineLength:
24
24
 
25
25
  Metrics/MethodLength:
26
26
  Max: 20
27
+
28
+ Style/EmptyLineAfterMagicComment:
29
+ Enabled: false
30
+
31
+ # When support for Ruby < 2.3 is dropped, re-enable
32
+ Style/IndentHeredoc:
33
+ Enabled: false
data/NEWS.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## [0.12.0] - 2017-04-05
6
+
7
+ ### Added
8
+
9
+ * Support for CARGO_TARGET_DIR environment variable (#33)
10
+
11
+ ### Fixed
12
+
13
+ * Cargo executable and arguments with paths using spaces are supported properly
14
+
15
+ ### Changed
16
+
17
+ * CARGO_TARGET is now CARGO_PROFILE, for less confusion (#35)
18
+
5
19
  ## [0.11.1] - 2017-02-04
6
20
 
7
21
  ### Fixed
@@ -126,6 +140,7 @@
126
140
 
127
141
  Initial release.
128
142
 
143
+ [0.12.0]: https://github.com/malept/thermite/compare/v0.11.1...v0.12.0
129
144
  [0.11.1]: https://github.com/malept/thermite/compare/v0.11.0...v0.11.1
130
145
  [0.11.0]: https://github.com/malept/thermite/compare/v0.10.0...v0.11.0
131
146
  [0.10.0]: https://github.com/malept/thermite/compare/v0.9.0...v0.10.0
@@ -19,7 +19,6 @@
19
19
  # OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
20
 
21
21
  require 'mkmf'
22
- require 'shellwords'
23
22
 
24
23
  module Thermite
25
24
  #
@@ -38,8 +37,7 @@ module Thermite
38
37
  #
39
38
  def run_cargo(*args)
40
39
  Dir.chdir(config.rust_toplevel_dir) do
41
- shell_args = config.target_os == 'mingw32' ? args.join(' ') : Shellwords.join(args)
42
- sh "#{cargo} #{shell_args}"
40
+ sh cargo, *args
43
41
  end
44
42
  end
45
43
 
@@ -30,7 +30,7 @@ module Thermite
30
30
  #
31
31
  # Creates a new configuration object.
32
32
  #
33
- # `options` is the same as the `Thermite::Tasks.new` parameter.
33
+ # `options` is the same as the {Thermite::Tasks#initialize} parameter.
34
34
  #
35
35
  def initialize(options = {})
36
36
  @options = options
@@ -135,7 +135,7 @@ module Thermite
135
135
  end
136
136
 
137
137
  #
138
- # Generate a path relative to `ruby_toplevel_dir`, given the `path_components` that are passed
138
+ # Generate a path relative to {#ruby_toplevel_dir}, given the `path_components` that are passed
139
139
  # to `File.join`.
140
140
  #
141
141
  def ruby_path(*path_components)
@@ -161,13 +161,22 @@ module Thermite
161
161
  end
162
162
 
163
163
  #
164
- # Generate a path relative to `rust_toplevel_dir`, given the `path_components` that are
164
+ # Generate a path relative to {#rust_toplevel_dir}, given the `path_components` that are
165
165
  # passed to `File.join`.
166
166
  #
167
167
  def rust_path(*path_components)
168
168
  File.join(rust_toplevel_dir, *path_components)
169
169
  end
170
170
 
171
+ #
172
+ # Generate a path relative to the `CARGO_TARGET_DIR` environment variable, or
173
+ # {#rust_toplevel_dir} if that is not set.
174
+ #
175
+ def cargo_target_path(target, *path_components)
176
+ target_base = ENV.fetch('CARGO_TARGET_DIR', rust_toplevel_dir)
177
+ File.join(target_base, target, *path_components)
178
+ end
179
+
171
180
  #
172
181
  # If run in a multi-crate environment, the Cargo workspace member that contains the
173
182
  # Ruby extension.
@@ -178,7 +187,7 @@ module Thermite
178
187
 
179
188
  #
180
189
  # The absolute path to the `Cargo.toml` file. The path depends on the existence of the
181
- # `cargo_workspace_member` configuration option.
190
+ # {#cargo_workspace_member} configuration option.
182
191
  #
183
192
  def cargo_toml_path
184
193
  @cargo_toml_path ||= begin
@@ -47,7 +47,7 @@ module Thermite
47
47
  include Thermite::Util
48
48
 
49
49
  #
50
- # The configuration used for the Rake tasks.
50
+ # The configuration used for the Rake tasks. See: {Thermite::Config}
51
51
  #
52
52
  attr_reader :config
53
53
 
@@ -96,7 +96,7 @@ module Thermite
96
96
  attr_reader :options
97
97
 
98
98
  #
99
- # Define the Thermite tasks with the given configuration parameters (see `options`).
99
+ # Define the Thermite tasks with the given configuration parameters (see {#options}).
100
100
  #
101
101
  # Example:
102
102
  #
@@ -117,13 +117,13 @@ module Thermite
117
117
  private
118
118
 
119
119
  def define_build_task
120
- desc 'Build or download the Rust shared library: CARGO_TARGET controls Cargo target'
120
+ desc 'Build or download the Rust shared library: CARGO_PROFILE controls Cargo profile'
121
121
  task 'thermite:build' do
122
122
  # if cargo found, build. Otherwise, grab binary (when github_releases is enabled).
123
123
  if cargo
124
- target = ENV.fetch('CARGO_TARGET', 'release')
125
- run_cargo_rustc(target)
126
- FileUtils.cp(config.rust_path('target', target, config.shared_library),
124
+ profile = ENV.fetch('CARGO_PROFILE', 'release')
125
+ run_cargo_rustc(profile)
126
+ FileUtils.cp(config.cargo_target_path(profile, config.shared_library),
127
127
  config.ruby_path('lib'))
128
128
  elsif !download_binary_from_custom_uri && !download_binary_from_github_release
129
129
  inform_user_about_cargo
@@ -12,7 +12,7 @@ module Thermite
12
12
 
13
13
  def test_run_cargo_if_exists
14
14
  mock_module.stubs(:find_executable).returns('/opt/cargo-test/bin/cargo')
15
- mock_module.expects(:sh).with('/opt/cargo-test/bin/cargo foo bar').once
15
+ mock_module.expects(:sh).with('/opt/cargo-test/bin/cargo', 'foo', 'bar').once
16
16
  mock_module.run_cargo_if_exists('foo', 'bar')
17
17
  end
18
18
 
@@ -109,6 +109,20 @@ module Thermite
109
109
  assert_equal '/tmp/foobar/baz/quux', config.rust_path('baz', 'quux')
110
110
  end
111
111
 
112
+ def test_cargo_target_path_with_env_var
113
+ FileUtils.stubs(:pwd).returns('/tmp/foobar')
114
+ ENV['CARGO_TARGET_DIR'] = 'foo'
115
+ assert_equal File.join('foo', 'debug', 'bar'), config.cargo_target_path('debug', 'bar')
116
+ ENV['CARGO_TARGET_DIR'] = nil
117
+ end
118
+
119
+ def test_cargo_target_path_without_env_var
120
+ FileUtils.stubs(:pwd).returns('/tmp/foobar')
121
+ ENV['CARGO_TARGET_DIR'] = nil
122
+ assert_equal File.join('/tmp/foobar', 'debug', 'bar'),
123
+ config.cargo_target_path('debug', 'bar')
124
+ end
125
+
112
126
  def test_cargo_toml_path_with_workspace_member
113
127
  FileUtils.stubs(:pwd).returns('/tmp/foobar')
114
128
  config(cargo_workspace_member: 'baz')
@@ -3,7 +3,7 @@ require 'English'
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = 'thermite'
6
- s.version = '0.11.1'
6
+ s.version = '0.12.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.11.1
4
+ version: 0.12.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-02-05 00:00:00.000000000 Z
11
+ date: 2017-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake