Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use RbSys::ExtensionTask when creating new rust gems #6352

Merged
merged 1 commit into from
Mar 10, 2023

Conversation

ianks
Copy link
Collaborator

@ianks ianks commented Feb 6, 2023

This PR makes it so bundle gem --ext=rust will use RbSys::ExtensionTask. This is a thin wrapper over Rake::ExtensionTask, which is tailored for Rust and addresses a number of shortcomings of using the default configuration. Namely:

  • Removes duplicative target directories (reducing compilation times and cache bloat)
  • Uses cargo metadata to find extension dir (similar to @matsadler PR).
  • Adds some helpers for compiling debug-friendly builds

Links

@ianks ianks added Bundler bundler: enhancement rust Pull requests that update Rust code labels Feb 6, 2023
@ianks ianks requested a review from simi February 6, 2023 19:24
Copy link
Member

@hsbt hsbt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I confirmed to usage for rb_sys/extensiontask via https://github.com/oxidize-rb/rb-sys/tree/main/gem#rbsysextensiontask

@hsbt hsbt added this pull request to the merge queue Mar 10, 2023
Merged via the queue into rubygems:master with commit 6a62e46 Mar 10, 2023

task build: :compile

RbSys::ExtensionTask.new(<%= config[:name].inspect %>) do |ext|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ianks
Don't need to pass gemspec here? According to the document, it requires here.
https://github.com/oxidize-rb/rb-sys/tree/main/gem#rbsysextensiontask

If my understanding is correct, it is needed to check some data in the gemspec.
https://github.com/oxidize-rb/rb-sys/blob/dfc51c60bef89925bfded1713e9ec02c5dfb639d/gem/lib/rb_sys/extensiontask.rb#L139-L149

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's needed for cross-compilation, but it's optional. Probably a good idea to add it though.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I understood the intent. I was curious because using RbSys::ExtensionTask without gemspec raises an error now. It seems it's not intended so I will create a patch to rb-sys.

Copy link
Collaborator Author

@ianks ianks Mar 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deivid-rodriguez pushed a commit that referenced this pull request Mar 20, 2023
Use `RbSys::ExtensionTask` when creating new rust gems

(cherry picked from commit 6a62e46)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bundler: enhancement Bundler rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants