Skip to content

Files

Latest commit

Mar 6, 2025
d87b8ab · Mar 6, 2025

History

History

ruby_h_to_go

ruby_h_to_go

Convert Ruby C function definition in ruby.h to Go source and dump to dist/.

Requirements

  • Ruby
  • Go
  • ctags
    • macOS: brew install universal-ctags
    • Ubuntu: apt-get install -y universal-ctags
  • goimports
    • go install golang.org/x/tools/cmd/goimports@latest

Usage

Output binding to /ruby/ using Ruby available in current context (recommended)

bundle exec rake ruby_h_to_go

Customize Ruby version to be used, output directory.

./exe/ruby_h_to_go
  • -H, --header-file : ruby header file. (default: "#{RbConfig::CONFIG["rubyhdrdir"]}/ruby.h")
  • -I, --include-path : include paths (default: [RbConfig::CONFIG["rubyarchhdrdir"], RbConfig::CONFIG["rubyhdrdir"]])
  • --dist-dir : dist dir for auto-generated Go code (default: ../../ruby/)
  • -t, --temp-file : temporary dist preprocessed ruby header file (default: "#{Dir.tmpdir}/ruby_preprocessed.h")