-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Add --ext=go to bundle gem
#8183
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
base: master
Are you sure you want to change the base?
Conversation
|
Thanks for opening a pull request and helping make RubyGems and Bundler better! Someone from the RubyGems team will take a look at your pull request shortly and leave any feedback. Please make sure that your pull request has tests for any changes or added functionality. We use GitHub Actions to test and make sure your change works functionally and uses acceptable conventions, you can review the current progress of GitHub Actions in the PR status window below. If you have any questions or concerns that you wish to ask, feel free to leave a comment in this PR or join our #rubygems or #bundler channel on Slack. For more information about contributing to the RubyGems project feel free to review our CONTRIBUTING guide |
7b95f6b to
e8f6a39
Compare
e01b1f9 to
66d9e67
Compare
|
Hello @sue445, I tried to test locally, but I can't get gem installed. Is there anything I do wrong? ruby spec/support/bundle.rb gem --ext=go goryba
cd goryba
# edit ext/goryba/go.mod with proper module name
cd ext/goryba
go mod tidy # get sum file
cd ../..
git add ext # add sum file
gem build --force && gem install goryba-0.1.0.gem |
66d9e67 to
768b801
Compare
|
@simi This was my mistake. A generated gem didn't contains header file. So I fixed this at 3536b25. Also, I saw your log and thought it would be strange and inconvenient to manually modify files or run commands after running Therefore, I made sure that all of this was done within the |
|
@sue445 it is ok to let users run |
|
Sorry, I found a small bug and change to draft until this is fixed. |
|
I fixed |
|
@simi ping |
7d75320 to
e0bc728
Compare
Respect to 9b0ec80
To avoid test failure in environments where Go is not installed
0181f1d to
8c22b8f
Compare
|
I can check again if ready. |
What was the end-user or developer problem that led to this PR?
ref. https://github.com/orgs/rubygems/discussions/8128
Original idea is @mmasaki 's https://rubykaigi.org/2015/presentations/mmasaki/
At the time of his talk (2015), Go did not have a standard package manager.
So I think he had to create his own binding to call CRuby functions from Go.
However, there is now a standard package manager called Go module.
I auto-generated (almost) all of Go's bindings automatically from ruby.h. (about 1,100 functions)
https://github.com/ruby-go-gem/go-gem-wrapper/blob/v0.2.0/ruby/function_generated.go
Pros
Go has some excellent features that other languages do not have, such as goroutine and Channels.
I believe these would be more convenient if these features were available from Ruby.
Below is a benchmark comparing Ractor and goroutine.
In my benchmark, goroutine is about x26-28 faster than Ractor 💨
What is your fix for the problem, implemented in this PR?
Support
--ext=goinbundle gembundle gem --ext=gocreates the following filesext/newgem/go.modext/newgem/extconf.rb(Patched for Go-gem)ext/newgem/newgem.goext/newgem/newgem.c(Patched for Go-gem)Gemfile(Add https://rubygems.org/gems/go_gem as dependency).github/workflows/main.yml(Install Go in GitHub Actions).gitlab-ci.yml(Install Go in GitLab CI).circleci/config.yml(Install Go in CircleCI)Please refer to spec files and
.ttfiles for the contents of the generated file.Skeleton generated by this patch utilizes https://github.com/ruby-go-gem/go-gem-wrapper functionality. This was all created by me.
go-gem-wrapperoffers following two for Go-gem.create_go_makefileforextconf.rbgo-gem-wrapperis similar to the https://github.com/oxidize-rb/rb-sys in Rust-gem.Make sure the following tasks are checked