Skip to content

Commit

Permalink
Merge pull request #141 from danielpclark/pr_88
Browse files Browse the repository at this point in the history
Pr 88: Build with Thermite
  • Loading branch information
danielpclark authored Mar 4, 2018
2 parents 42f6380 + bf92df2 commit 11cb6fa
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 129 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,8 @@ mkmf.log
**/*.gem
.idea
/rubyspec_temp/
*.dll
*.dylib
*.so
.ruby-version
/tags
4 changes: 2 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ AllCops:
Include:
- 'Gemfile'
- 'Rakefile'
- 'lib/**/*'
- 'lib/**/*.rb'
- '*.gemspec'
Exclude:
- 'assets/**/*'
Expand Down Expand Up @@ -672,7 +672,7 @@ Layout/ExtraSpacing:
Naming/FileName:
Description: 'Use snake_case for source file names.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#snake-case-files'
Enabled: true
Enabled: false

Layout/InitialIndentation:
Description: >-
Expand Down
30 changes: 20 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
sudo: true
sudo: false
language: ruby
os:
- linux
- osx
cache:
- bundler
- cargo
bundler: true
directories:
- $HOME/.cargo
- $TRAVIS_BUILD_DIR/target
rvm:
- 2.3
- 2.4
- 2.3.4
- 2.4.1
# - 2.5 # Travis doesn't have this for Mac yet
env:
global:
- PATH=$PATH:$HOME/.cargo/bin
- 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=
matrix:
- WITH_REGRESSION=true
Expand All @@ -21,8 +24,15 @@ matrix:
allow_failures:
- env: RUST_BACKTRACE=1 ENCODING=true TEST_MONKEYPATCHES=true WITH_REGRESSION=true
before_install:
- gem install bundler --pre
- git submodule update --init
- curl -sSf https://static.rust-lang.org/rustup.sh | sudo sh -s -- --channel=nightly
- bundle && bundle exec rake build_src && rake clean_src
script: bundle exec rake test
- curl -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain nightly
deploy:
provider: releases
api_key:
secure: wflOVYn4aAkhM1LlpqFnUpw7YPrTOumNnfUiQETTBMgOY2IYYPHFo5wgCWeW7/O2galmNFJCVlFQ3GYnepV2GdLyNM8uRl+13XA9V6wE6qCP6NmskxXwR09Nonx8PrdtnuQJvAg5DgSsP5aciWf9bM6xwmspzebJx44s2jiir6ODKNAoGxG+xV6ZT9FVDHNoVgDePTYry8nPLt5XewR8D8CBL3Np//laR4y08hHajGOZXHimJYG+PXoHadZaaIqnlLHkZ9TLkT1q3LCyMa5So3/NmNSIKA01QQA0625XOfSK1ZnhFx7XgPR7eKNzD930x/FP6G46RUMBDh2mG7NgaGeMWerJgfg5rBm0o5eBH92lDpOw8ew47l5bcrPLiMeokE38uPnxUK1/+z7Y4YmamHvwaY48H88JXmmmS2LlxkoeVdFqbgMjdclORF+ktx7FIHGzhkbuPoTSLCs6feKjk3J24Nn/plHbEsYAOVTClPbzawA8JnPJp3lmXHTVhgi0rVBoUYcZs+8m998/Sr5OfYJZl47f6sr2VnenUwSjX8ylLcKRbyOl7y23AMxAbRUomrcDceTjj0fcsUppZZBXPM/6cpjVlQlTyVOhgL/2qhZaAMZ3OtG4ittazfvF0+xclRkfshc1bnqZ5PmmBG6OMtEk072nLwHTVwr0n8ZTxXw=
file: faster_path-*.tar.gz
file_glob: true
skip_cleanup: true
on:
condition: -z ${TEST_MONKEYPATCHES}
repo: danielpclark/faster_path
tags: true
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ repository = "https://github.com/danielpclark/faster_path"
license = "MIT OR Apache-2.0"
readme = "README.md"

[package.metadata.thermite]
github_releases = true

[lib]
name = "faster_path"
crate-type = ["dylib"]
Expand Down
45 changes: 13 additions & 32 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "bundler/gem_tasks"
require "rake/testtask"
require 'fileutils'
require 'bundler/gem_tasks'
require 'rake/testtask'
require 'thermite/tasks'

desc 'System Details'
task :sysinfo do
Expand All @@ -24,6 +24,8 @@ task :sysinfo do
end
end

thermite = Thermite::Tasks.new

desc "Generate Contriburs.md Manifest"
task :contrib do
puts "Generating Contriburs.md Manifest"
Expand Down Expand Up @@ -61,36 +63,16 @@ task :libruby_debug do
puts "libruby.so copied."
end

desc "Build Rust extension"
task build_src: :libruby_release do
puts "Building extension..."
sh "cargo build --release"
end

desc "Clean up Rust build"
task :clean_src do
puts "Cleaning up build..."
# Remove all but library file
FileUtils.
rm_rf(
Dir.
glob('target/release/*').
keep_if do |f|
!f[/\.(?:so|dll|dylib|deps)\z/]
end
)
desc 'Build + clean up Rust extension'
task build_lib: 'thermite:build' do
thermite.run_cargo 'clean'
end

desc "Build + clean up Rust extension"
task build_lib: [:build_src, :clean_src] do
puts "Completed build!"
end

desc "Code Quality Check"
desc 'Code Quality Check'
task :lint do
puts
puts "Quality check starting..."
sh "rubocop"
puts 'Quality check starting...'
sh 'rubocop'
puts
end

Expand All @@ -100,9 +82,8 @@ task cargo: :libruby_debug do
end

Rake::TestTask.new(minitest: :build_lib) do |t|
t.libs << "test"
t.libs << "lib"
t.test_files = FileList['test/**/*_test.rb']
t.libs = %w[lib test]
t.pattern = 'test/**/*_test.rb'
end

task :init_mspec do |_t|
Expand Down
7 changes: 7 additions & 0 deletions ext/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'thermite/tasks'

project_toplevel_dir = File.dirname(File.dirname(__FILE__))
Thermite::Tasks.new(cargo_project_path: project_toplevel_dir,
ruby_project_path: project_toplevel_dir)

task default: 'thermite:build'
19 changes: 0 additions & 19 deletions ext/faster_path/extconf.rb

This file was deleted.

5 changes: 3 additions & 2 deletions faster_path.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@ Gem::Specification.new do |spec|
spec.files = [
"Cargo.lock", "Cargo.toml", "Gemfile",
"MIT-LICENSE.txt", "README.md", "Rakefile", "bin/console", "bin/setup",
"ext/faster_path/extconf.rb", "faster_path.gemspec"
"ext/Rakefile", "faster_path.gemspec"
]
spec.files += Dir['lib/**/*']
spec.files += Dir['src/**/*']

spec.extensions << "ext/faster_path/extconf.rb"
spec.extensions = ["ext/Rakefile"]
spec.require_paths = ["lib"]

spec.add_dependency "bundler", "~> 1.12"
spec.add_dependency "rake", "~> 12.0"
spec.add_dependency "thermite", "~> 0.13.0"
spec.add_development_dependency "read_source", "~> 0.2.6"
spec.add_development_dependency "minitest", "~> 5.10"
spec.add_development_dependency "minitest-reporters", "~> 1.1"
Expand Down
11 changes: 8 additions & 3 deletions lib/faster_path.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
require "faster_path/version"
require 'faster_path/version'
require 'pathname'
require 'faster_path/platform'
require 'thermite/config'
require 'fiddle'
require 'fiddle/import'

module FasterPath
FFI_LIBRARY = FasterPath::Platform.ffi_library()
FFI_LIBRARY = begin
toplevel_dir = File.dirname(__dir__)
config = Thermite::Config.new(cargo_project_path: toplevel_dir,
ruby_project_path: toplevel_dir)
config.ruby_extension_path
end

Fiddle::Function.
new(Fiddle.dlopen(FFI_LIBRARY)['Init_faster_pathname'], [], Fiddle::TYPE_VOIDP).
Expand Down
60 changes: 0 additions & 60 deletions lib/faster_path/platform.rb

This file was deleted.

2 changes: 1 addition & 1 deletion lib/faster_path/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module FasterPath
VERSION = "0.2.6"
VERSION = "0.3.0"
end

0 comments on commit 11cb6fa

Please sign in to comment.