malept / thermite

A Rake-based helper for building and distributing Rust-based Ruby extensions
http://www.rubydoc.info/github/malept/thermite
MIT License
139 stars 11 forks source link

Add support for Cargo workspaces #30

Closed malept closed 7 years ago

malept commented 7 years ago

Adds a new config variable, cargo_workspace_member, which is the path relative to the cargo_project_path directory where the member crate is located.

Fixes #29.

CC: @matthiasbeyer

matthiasbeyer commented 7 years ago

Is there a way to test this? Maybe even within my travis setup? Would love some input here or in https://github.com/matthiasbeyer/imag/pull/871 ! :+1:

malept commented 7 years ago

@matthiasbeyer In the Gemfile, after the gemspec line, add:

gem 'thermite', git: 'https://github.com/malept/thermite.git', branch: 'cargo-workspaces'

Then, in any file where you call Thermite::Tasks.new, you have to specify the correct cargo_workspace_member value as a named parameter.

matthiasbeyer commented 7 years ago

I guess I have to do it in another way, as you can see in https://github.com/matthiasbeyer/imag/pull/871/commits/98530f2dc555d85dd74b782b96421c4c99d97f4a , I do not have a Gemfile but rather a gemspec.

I also call thermite from the workspace member, so would rather need to specify the workspace root, am I right?

matthiasbeyer commented 7 years ago

As of https://github.com/matthiasbeyer/imag/pull/871/commits/565cdb3f2dbad2d847d51a4db9feef8c608418b3 I get:

rake aborted!
Errno::ENOENT: No such file or directory @ rb_sysopen - /home/m/archive/development/rust/imag/libimagruby/target/release/liblibimagruby.so
/home/m/archive/development/rust/imag/libimagruby/vendor/bundle/ruby/2.3.0/bundler/gems/thermite-055c0909cff1/lib/thermite/tasks.rb:124:in `block in define_build_task'
/nix/store/sznvnn582dqxl1v1fsciywdbw8984271-bundler-1.13.7/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/lib/bundler/cli/exec.rb:74:in `load'
/nix/store/sznvnn582dqxl1v1fsciywdbw8984271-bundler-1.13.7/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/lib/bundler/cli/exec.rb:74:in `kernel_load'
/nix/store/sznvnn582dqxl1v1fsciywdbw8984271-bundler-1.13.7/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/lib/bundler/cli/exec.rb:27:in `run'
/nix/store/sznvnn582dqxl1v1fsciywdbw8984271-bundler-1.13.7/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/lib/bundler/cli.rb:332:in `exec'
/nix/store/sznvnn582dqxl1v1fsciywdbw8984271-bundler-1.13.7/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/nix/store/sznvnn582dqxl1v1fsciywdbw8984271-bundler-1.13.7/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/nix/store/sznvnn582dqxl1v1fsciywdbw8984271-bundler-1.13.7/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/lib/bundler/vendor/thor/lib/thor.rb:359:in `dispatch'
/nix/store/sznvnn582dqxl1v1fsciywdbw8984271-bundler-1.13.7/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/lib/bundler/cli.rb:20:in `dispatch'
/nix/store/sznvnn582dqxl1v1fsciywdbw8984271-bundler-1.13.7/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/lib/bundler/vendor/thor/lib/thor/base.rb:440:in `start'
/nix/store/sznvnn582dqxl1v1fsciywdbw8984271-bundler-1.13.7/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/lib/bundler/cli.rb:11:in `start'
/nix/store/sznvnn582dqxl1v1fsciywdbw8984271-bundler-1.13.7/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/exe/bundle:34:in `block in <top (required)>'
/nix/store/sznvnn582dqxl1v1fsciywdbw8984271-bundler-1.13.7/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/lib/bundler/friendly_errors.rb:100:in `with_friendly_errors'
/nix/store/sznvnn582dqxl1v1fsciywdbw8984271-bundler-1.13.7/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/exe/bundle:26:in `<top (required)>'
/nix/store/sznvnn582dqxl1v1fsciywdbw8984271-bundler-1.13.7/bin/bundle:18:in `load'
/nix/store/sznvnn582dqxl1v1fsciywdbw8984271-bundler-1.13.7/bin/bundle:18:in `<main>'
Tasks: TOP => thermite:build
(See full trace by running task with --trace)
malept commented 7 years ago

Oh, I forgot one part. cargo_project_path needs to point to the workspace Cargo.toml. Sorry about that.

matthiasbeyer commented 7 years ago

Another try with https://github.com/matthiasbeyer/imag/pull/871/commits/e6cc09857ee866b4432b103593a6025006bd232f yields

checking for cargo... yes
/nix/store/3b1qps1ixm60vsy1i4f48g6360vjg8d0-cargo-0.15.0/bin/cargo rustc --release
warning: unused manifest key: package.website
   Compiling imag-root v0.2.0 (file:///home/m/archive/development/rust/imag)
error[E0463]: can't find crate for `crossbeam`
  --> bin/src/main.rs:20:1
   |
20 | extern crate crossbeam;
   | ^^^^^^^^^^^^^^^^^^^^^^^ can't find crate

error: aborting due to previous error

error: Could not compile `imag-root`.

To learn more, run the command again with --verbose.
rake aborted!
Command failed with status (101): [/nix/store/3b1qps1ixm60vsy1i4f48g6360vjg8d...]
/home/m/archive/development/rust/imag/libimagruby/vendor/bundle/ruby/2.3.0/bundler/gems/thermite-055c0909cff1/lib/thermite/cargo.rb:42:in `block in run_cargo'
/home/m/archive/development/rust/imag/libimagruby/vendor/bundle/ruby/2.3.0/bundler/gems/thermite-055c0909cff1/lib/thermite/cargo.rb:40:in `chdir'
/home/m/archive/development/rust/imag/libimagruby/vendor/bundle/ruby/2.3.0/bundler/gems/thermite-055c0909cff1/lib/thermite/cargo.rb:40:in `run_cargo'
/home/m/archive/development/rust/imag/libimagruby/vendor/bundle/ruby/2.3.0/bundler/gems/thermite-055c0909cff1/lib/thermite/cargo.rb:60:in `run_cargo_rustc'
/home/m/archive/development/rust/imag/libimagruby/vendor/bundle/ruby/2.3.0/bundler/gems/thermite-055c0909cff1/lib/thermite/tasks.rb:123:in `block in define_build_task'
/nix/store/sznvnn582dqxl1v1fsciywdbw8984271-bundler-1.13.7/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/lib/bundler/cli/exec.rb:74:in `load'
/nix/store/sznvnn582dqxl1v1fsciywdbw8984271-bundler-1.13.7/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/lib/bundler/cli/exec.rb:74:in `kernel_load'
/nix/store/sznvnn582dqxl1v1fsciywdbw8984271-bundler-1.13.7/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/lib/bundler/cli/exec.rb:27:in `run'
/nix/store/sznvnn582dqxl1v1fsciywdbw8984271-bundler-1.13.7/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/lib/bundler/cli.rb:332:in `exec'
/nix/store/sznvnn582dqxl1v1fsciywdbw8984271-bundler-1.13.7/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/nix/store/sznvnn582dqxl1v1fsciywdbw8984271-bundler-1.13.7/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/nix/store/sznvnn582dqxl1v1fsciywdbw8984271-bundler-1.13.7/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/lib/bundler/vendor/thor/lib/thor.rb:359:in `dispatch'
/nix/store/sznvnn582dqxl1v1fsciywdbw8984271-bundler-1.13.7/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/lib/bundler/cli.rb:20:in `dispatch'
/nix/store/sznvnn582dqxl1v1fsciywdbw8984271-bundler-1.13.7/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/lib/bundler/vendor/thor/lib/thor/base.rb:440:in `start'
/nix/store/sznvnn582dqxl1v1fsciywdbw8984271-bundler-1.13.7/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/lib/bundler/cli.rb:11:in `start'
/nix/store/sznvnn582dqxl1v1fsciywdbw8984271-bundler-1.13.7/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/exe/bundle:34:in `block in <top (required)>'
/nix/store/sznvnn582dqxl1v1fsciywdbw8984271-bundler-1.13.7/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/lib/bundler/friendly_errors.rb:100:in `with_friendly_errors'
/nix/store/sznvnn582dqxl1v1fsciywdbw8984271-bundler-1.13.7/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/exe/bundle:26:in `<top (required)>'
/nix/store/sznvnn582dqxl1v1fsciywdbw8984271-bundler-1.13.7/bin/bundle:18:in `load'
/nix/store/sznvnn582dqxl1v1fsciywdbw8984271-bundler-1.13.7/bin/bundle:18:in `<main>'
Tasks: TOP => thermite:build
(See full trace by running task with --trace)

which is also clearly not what I want...

malept commented 7 years ago

Oh, I think I have to specify --manifest-path here? I'll need to think about how to test this, aside from running your PR locally. (Because I also want to have an integration test - I currently use rusty_blank for that.)