thermite 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/NEWS.md +8 -0
- data/README.md +30 -6
- data/lib/thermite/fiddle.rb +46 -0
- data/lib/thermite/github_release_binary.rb +5 -5
- data/lib/thermite/util.rb +4 -4
- data/test/test_helper.rb +1 -0
- data/thermite.gemspec +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39f322b4da859f7e40da6a34e28af9cece1266d1
|
4
|
+
data.tar.gz: f185a33fa330c7e8e9bd79f3b6e006a8a64dc5f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27c5e1722048accc76e5cc6f92609aaf1e2a83188d4a19953158fb67d95b0de30333919d8acecf6604f08768ea84379d34878344af462cda96e4999ccd480acd
|
7
|
+
data.tar.gz: 1442ca9c640268a5905ffce5735f23e8b77680253c342ae242ca7e5a633b3d44a29da8f6f051b6fbb9e14eafd3780e1c05992e6755c7eaed75d3d629f9f6c076
|
data/NEWS.md
CHANGED
@@ -2,6 +2,12 @@
|
|
2
2
|
|
3
3
|
## Unreleased
|
4
4
|
|
5
|
+
## [0.7.0] - 2016-09-26
|
6
|
+
|
7
|
+
### Added
|
8
|
+
|
9
|
+
* Helper module for loading extensions via Fiddle (#13)
|
10
|
+
|
5
11
|
## [0.6.0] - 2016-09-12
|
6
12
|
|
7
13
|
### Added
|
@@ -79,6 +85,8 @@
|
|
79
85
|
|
80
86
|
Initial release.
|
81
87
|
|
88
|
+
[0.7.0]: https://github.com/malept/thermite/compare/v0.6.0...v0.7.0
|
89
|
+
[0.6.0]: https://github.com/malept/thermite/compare/v0.5.0...v0.6.0
|
82
90
|
[0.5.0]: https://github.com/malept/thermite/compare/v0.4.0...v0.5.0
|
83
91
|
[0.4.0]: https://github.com/malept/thermite/compare/v0.3.0...v0.4.0
|
84
92
|
[0.3.0]: https://github.com/malept/thermite/compare/v0.2.0...v0.3.0
|
data/README.md
CHANGED
@@ -14,16 +14,40 @@ Thermite is a Rake-based helper for building and distributing Rust-based Ruby ex
|
|
14
14
|
* Provides wrappers for `cargo` commands.
|
15
15
|
* Handles non-standard `cargo` installations via the `CARGO` environment variable.
|
16
16
|
* Opt-in to allow users to install pre-compiled Rust extensions hosted on GitHub releases.
|
17
|
+
* Provides a wrapper for initializing a Rust extension via Fiddle.
|
17
18
|
|
18
19
|
## Usage
|
19
20
|
|
20
|
-
1. Add
|
21
|
-
2. In your gemspec, add `Rakefile` to the specification's `extensions` list.
|
22
|
-
3. In `Rakefile`, add `require 'thermite/tasks'` and then add the tasks to the file by running:
|
21
|
+
1. Add the following to your gemspec file:
|
23
22
|
|
24
|
-
```ruby
|
25
|
-
|
26
|
-
|
23
|
+
```ruby
|
24
|
+
spec.extensions << 'ext/Rakefile'
|
25
|
+
spec.add_runtime_dependency 'thermite', '~> 0'
|
26
|
+
```
|
27
|
+
|
28
|
+
2. Create `ext/Rakefile` with the following code, assuming that the Cargo project root is the same
|
29
|
+
as the Ruby project root:
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
require 'thermite/tasks'
|
33
|
+
|
34
|
+
project_dir = File.dirname(File.dirname(__FILE__))
|
35
|
+
Thermite::Tasks.new(cargo_project_path: project_dir, ruby_project_path: project_dir)
|
36
|
+
task default: %w(thermite:build)
|
37
|
+
```
|
38
|
+
|
39
|
+
3. In `Rakefile`, integrate Thermite into your build-test workflow:
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
require 'thermite/tasks'
|
43
|
+
|
44
|
+
Thermite::Tasks.new
|
45
|
+
|
46
|
+
desc 'Run Rust & Ruby testsuites'
|
47
|
+
task test: ['thermite:build', 'thermite:test'] do
|
48
|
+
# …
|
49
|
+
end
|
50
|
+
```
|
27
51
|
|
28
52
|
Run `rake -T` to view all of the available tasks in the `thermite` namespace.
|
29
53
|
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# frozen_string_literal: true
|
3
|
+
#
|
4
|
+
# Copyright (c) 2016 Mark Lee and contributors
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
7
|
+
# associated documentation files (the "Software"), to deal in the Software without restriction,
|
8
|
+
# including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
9
|
+
# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in all copies or
|
13
|
+
# substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
16
|
+
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
18
|
+
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
|
19
|
+
# OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
20
|
+
|
21
|
+
require 'fiddle'
|
22
|
+
require 'thermite/config'
|
23
|
+
|
24
|
+
module Thermite
|
25
|
+
#
|
26
|
+
# Fiddle helper functions.
|
27
|
+
#
|
28
|
+
module Fiddle
|
29
|
+
#
|
30
|
+
# Loads a native extension using {Thermite::Config} and the builtin `Fiddle` extension.
|
31
|
+
#
|
32
|
+
# @param init_function_name [String] the name of the native function that initializes
|
33
|
+
# the extension
|
34
|
+
# @param config_options [Hash] {Thermite::Tasks#options options} passed to {Thermite::Config}.
|
35
|
+
# Options likely needed to be set:
|
36
|
+
# `cargo_project_path`, `ruby_project_path`
|
37
|
+
#
|
38
|
+
def self.load_module(init_function_name, config_options)
|
39
|
+
config = Thermite::Config.new(config_options)
|
40
|
+
library = ::Fiddle.dlopen(config.ruby_extension_path)
|
41
|
+
func = ::Fiddle::Function.new(library[init_function_name],
|
42
|
+
[], ::Fiddle::TYPE_VOIDP)
|
43
|
+
func.call
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -57,11 +57,11 @@ module Thermite
|
|
57
57
|
version = config.toml[:package][:version]
|
58
58
|
tag = options.fetch(:git_tag_format, 'v%s') % version
|
59
59
|
uri = github_download_uri(tag, version)
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
60
|
+
return unless (tgz = download_binary_from_github_release(uri, version))
|
61
|
+
|
62
|
+
debug "Unpacking GitHub release from Cargo version: #{File.basename(uri)}"
|
63
|
+
unpack_tarball(tgz)
|
64
|
+
true
|
65
65
|
end
|
66
66
|
|
67
67
|
#
|
data/lib/thermite/util.rb
CHANGED
@@ -28,10 +28,10 @@ module Thermite
|
|
28
28
|
#
|
29
29
|
def debug(msg)
|
30
30
|
# Should probably replace with a Logger
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
31
|
+
return unless config.debug_filename
|
32
|
+
|
33
|
+
@debug ||= File.open(config.debug_filename, 'w')
|
34
|
+
@debug.write("#{msg}\n")
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
data/test/test_helper.rb
CHANGED
data/thermite.gemspec
CHANGED
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.
|
4
|
+
version: 0.7.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: 2016-09-
|
11
|
+
date: 2016-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -128,6 +128,7 @@ files:
|
|
128
128
|
- ci/after_success.py
|
129
129
|
- lib/thermite/cargo.rb
|
130
130
|
- lib/thermite/config.rb
|
131
|
+
- lib/thermite/fiddle.rb
|
131
132
|
- lib/thermite/github_release_binary.rb
|
132
133
|
- lib/thermite/package.rb
|
133
134
|
- lib/thermite/tasks.rb
|