Skip to content

Commit 11cb6fa

Browse files
authored
Merge pull request #141 from danielpclark/pr_88
Pr 88: Build with Thermite
2 parents 42f6380 + bf92df2 commit 11cb6fa

File tree

11 files changed

+60
-129
lines changed

11 files changed

+60
-129
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,8 @@ mkmf.log
1414
**/*.gem
1515
.idea
1616
/rubyspec_temp/
17+
*.dll
18+
*.dylib
19+
*.so
1720
.ruby-version
1821
/tags

.rubocop.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ AllCops:
22
Include:
33
- 'Gemfile'
44
- 'Rakefile'
5-
- 'lib/**/*'
5+
- 'lib/**/*.rb'
66
- '*.gemspec'
77
Exclude:
88
- 'assets/**/*'
@@ -672,7 +672,7 @@ Layout/ExtraSpacing:
672672
Naming/FileName:
673673
Description: 'Use snake_case for source file names.'
674674
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#snake-case-files'
675-
Enabled: true
675+
Enabled: false
676676

677677
Layout/InitialIndentation:
678678
Description: >-

.travis.yml

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
1-
sudo: true
1+
sudo: false
22
language: ruby
33
os:
44
- linux
55
- osx
66
cache:
7-
- bundler
8-
- cargo
7+
bundler: true
8+
directories:
9+
- $HOME/.cargo
10+
- $TRAVIS_BUILD_DIR/target
911
rvm:
10-
- 2.3
11-
- 2.4
12+
- 2.3.4
13+
- 2.4.1
1214
# - 2.5 # Travis doesn't have this for Mac yet
1315
env:
1416
global:
17+
- PATH=$PATH:$HOME/.cargo/bin
1518
- secure: UCarEfq9wDpD6FV0dIdfDMCWfeLoKBAM2PS+xZ82K1uoFBMtwet/UuEuz06OnX6B9k2TwV0aqQpkUuo6o+h9YoHKAGz1/O5iB5uJaHcoII8yL43LH4YUADqupsgbvFzUCdcLuKCvDVG5RD96tt5XX87UdyZMgHvBV41wKOoUF+0ZyIWq8sKFPlItM+oYN55gY+PZ5ZadsOOkWDbTAG/LuxDi1GJxb/ObiYkjk4b93xzKEx1t7H2LSs8/f8dg0w1gnM6bVXQHjdXGuAw8jqy6IoszFh2oKDyttix4yB5l5xxj/NwO/aJNmOLBRNf611WskH6RLKWteCxwyY0gIZnDlC7q+SMYJtDapuffvqqKdlC5ECcVNimw9D3DwuxizP/5IGoC5+X+RIJiWBx/RJgFV2dw22/XvC62rOMttQL1K1dUByMRJL1pjLoauofbTdJgZgdrb1eDxGNyxL+Rg8za2wqs5NtENnXY6RIX4NvSXUPE9vRLdYnmGtH5hLF36hRh5AwvgOZ544xYT2ss6FxUJNo/zphlE7zfZrD+waeUBRUabzi6S5xEBXainj01UjtfVXRDtcjV9vbh5pYYjZsX8lLZAdW8OZeKxhaOv7zQyUtAwMHE/sGfKj1yQSDh2fscY48mepV7xUPVE7jRgUDk1ayt2a+WeGE2DCR3KBv5gkk=
1619
matrix:
1720
- WITH_REGRESSION=true
@@ -21,8 +24,15 @@ matrix:
2124
allow_failures:
2225
- env: RUST_BACKTRACE=1 ENCODING=true TEST_MONKEYPATCHES=true WITH_REGRESSION=true
2326
before_install:
24-
- gem install bundler --pre
25-
- git submodule update --init
26-
- curl -sSf https://static.rust-lang.org/rustup.sh | sudo sh -s -- --channel=nightly
27-
- bundle && bundle exec rake build_src && rake clean_src
28-
script: bundle exec rake test
27+
- curl -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain nightly
28+
deploy:
29+
provider: releases
30+
api_key:
31+
secure: wflOVYn4aAkhM1LlpqFnUpw7YPrTOumNnfUiQETTBMgOY2IYYPHFo5wgCWeW7/O2galmNFJCVlFQ3GYnepV2GdLyNM8uRl+13XA9V6wE6qCP6NmskxXwR09Nonx8PrdtnuQJvAg5DgSsP5aciWf9bM6xwmspzebJx44s2jiir6ODKNAoGxG+xV6ZT9FVDHNoVgDePTYry8nPLt5XewR8D8CBL3Np//laR4y08hHajGOZXHimJYG+PXoHadZaaIqnlLHkZ9TLkT1q3LCyMa5So3/NmNSIKA01QQA0625XOfSK1ZnhFx7XgPR7eKNzD930x/FP6G46RUMBDh2mG7NgaGeMWerJgfg5rBm0o5eBH92lDpOw8ew47l5bcrPLiMeokE38uPnxUK1/+z7Y4YmamHvwaY48H88JXmmmS2LlxkoeVdFqbgMjdclORF+ktx7FIHGzhkbuPoTSLCs6feKjk3J24Nn/plHbEsYAOVTClPbzawA8JnPJp3lmXHTVhgi0rVBoUYcZs+8m998/Sr5OfYJZl47f6sr2VnenUwSjX8ylLcKRbyOl7y23AMxAbRUomrcDceTjj0fcsUppZZBXPM/6cpjVlQlTyVOhgL/2qhZaAMZ3OtG4ittazfvF0+xclRkfshc1bnqZ5PmmBG6OMtEk072nLwHTVwr0n8ZTxXw=
32+
file: faster_path-*.tar.gz
33+
file_glob: true
34+
skip_cleanup: true
35+
on:
36+
condition: -z ${TEST_MONKEYPATCHES}
37+
repo: danielpclark/faster_path
38+
tags: true

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ repository = "https://github.com/danielpclark/faster_path"
88
license = "MIT OR Apache-2.0"
99
readme = "README.md"
1010

11+
[package.metadata.thermite]
12+
github_releases = true
13+
1114
[lib]
1215
name = "faster_path"
1316
crate-type = ["dylib"]

Rakefile

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
require "bundler/gem_tasks"
2-
require "rake/testtask"
3-
require 'fileutils'
1+
require 'bundler/gem_tasks'
2+
require 'rake/testtask'
3+
require 'thermite/tasks'
44

55
desc 'System Details'
66
task :sysinfo do
@@ -24,6 +24,8 @@ task :sysinfo do
2424
end
2525
end
2626

27+
thermite = Thermite::Tasks.new
28+
2729
desc "Generate Contriburs.md Manifest"
2830
task :contrib do
2931
puts "Generating Contriburs.md Manifest"
@@ -61,36 +63,16 @@ task :libruby_debug do
6163
puts "libruby.so copied."
6264
end
6365

64-
desc "Build Rust extension"
65-
task build_src: :libruby_release do
66-
puts "Building extension..."
67-
sh "cargo build --release"
68-
end
69-
70-
desc "Clean up Rust build"
71-
task :clean_src do
72-
puts "Cleaning up build..."
73-
# Remove all but library file
74-
FileUtils.
75-
rm_rf(
76-
Dir.
77-
glob('target/release/*').
78-
keep_if do |f|
79-
!f[/\.(?:so|dll|dylib|deps)\z/]
80-
end
81-
)
66+
desc 'Build + clean up Rust extension'
67+
task build_lib: 'thermite:build' do
68+
thermite.run_cargo 'clean'
8269
end
8370

84-
desc "Build + clean up Rust extension"
85-
task build_lib: [:build_src, :clean_src] do
86-
puts "Completed build!"
87-
end
88-
89-
desc "Code Quality Check"
71+
desc 'Code Quality Check'
9072
task :lint do
9173
puts
92-
puts "Quality check starting..."
93-
sh "rubocop"
74+
puts 'Quality check starting...'
75+
sh 'rubocop'
9476
puts
9577
end
9678

@@ -100,9 +82,8 @@ task cargo: :libruby_debug do
10082
end
10183

10284
Rake::TestTask.new(minitest: :build_lib) do |t|
103-
t.libs << "test"
104-
t.libs << "lib"
105-
t.test_files = FileList['test/**/*_test.rb']
85+
t.libs = %w[lib test]
86+
t.pattern = 'test/**/*_test.rb'
10687
end
10788

10889
task :init_mspec do |_t|

ext/Rakefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
require 'thermite/tasks'
2+
3+
project_toplevel_dir = File.dirname(File.dirname(__FILE__))
4+
Thermite::Tasks.new(cargo_project_path: project_toplevel_dir,
5+
ruby_project_path: project_toplevel_dir)
6+
7+
task default: 'thermite:build'

ext/faster_path/extconf.rb

Lines changed: 0 additions & 19 deletions
This file was deleted.

faster_path.gemspec

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,17 @@ Gem::Specification.new do |spec|
1616
spec.files = [
1717
"Cargo.lock", "Cargo.toml", "Gemfile",
1818
"MIT-LICENSE.txt", "README.md", "Rakefile", "bin/console", "bin/setup",
19-
"ext/faster_path/extconf.rb", "faster_path.gemspec"
19+
"ext/Rakefile", "faster_path.gemspec"
2020
]
2121
spec.files += Dir['lib/**/*']
2222
spec.files += Dir['src/**/*']
2323

24-
spec.extensions << "ext/faster_path/extconf.rb"
24+
spec.extensions = ["ext/Rakefile"]
2525
spec.require_paths = ["lib"]
2626

2727
spec.add_dependency "bundler", "~> 1.12"
2828
spec.add_dependency "rake", "~> 12.0"
29+
spec.add_dependency "thermite", "~> 0.13.0"
2930
spec.add_development_dependency "read_source", "~> 0.2.6"
3031
spec.add_development_dependency "minitest", "~> 5.10"
3132
spec.add_development_dependency "minitest-reporters", "~> 1.1"

lib/faster_path.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1-
require "faster_path/version"
1+
require 'faster_path/version'
22
require 'pathname'
3-
require 'faster_path/platform'
3+
require 'thermite/config'
44
require 'fiddle'
55
require 'fiddle/import'
66

77
module FasterPath
8-
FFI_LIBRARY = FasterPath::Platform.ffi_library()
8+
FFI_LIBRARY = begin
9+
toplevel_dir = File.dirname(__dir__)
10+
config = Thermite::Config.new(cargo_project_path: toplevel_dir,
11+
ruby_project_path: toplevel_dir)
12+
config.ruby_extension_path
13+
end
914

1015
Fiddle::Function.
1116
new(Fiddle.dlopen(FFI_LIBRARY)['Init_faster_pathname'], [], Fiddle::TYPE_VOIDP).

lib/faster_path/platform.rb

Lines changed: 0 additions & 60 deletions
This file was deleted.

lib/faster_path/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module FasterPath
2-
VERSION = "0.2.6"
2+
VERSION = "0.3.0"
33
end

0 commit comments

Comments
 (0)