File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed
Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -16,12 +16,16 @@ def self.snake_to_camel(str)
1616 def self . generate_initial_go_file ( go_file_path )
1717 return if File . exist? ( go_file_path )
1818
19+ ruby_build_tag = ruby_minor_version_build_tag ( RUBY_VERSION )
20+
1921 File . binwrite ( go_file_path , <<~GO )
2022 // THE AUTOGENERATED LICENSE. ALL THE RIGHTS ARE RESERVED BY ROBOTS.
2123
2224 // WARNING: This file has automatically been generated
2325 // Code generated by ruby_h_to_go. DO NOT EDIT.
2426
27+ //go:build #{ ruby_build_tag }
28+
2529 package ruby
2630
2731 /*
@@ -36,6 +40,12 @@ def self.generate_initial_go_file(go_file_path)
3640 GO
3741 end
3842
43+ # @param ruby_version [String]
44+ # @return [String]
45+ def self . ruby_minor_version_build_tag ( ruby_version = RUBY_VERSION )
46+ "ruby_#{ ruby_version . to_f . to_s . gsub ( "." , "_" ) } "
47+ end
48+
3949 C_TYPE_TO_GO_TYPE = {
4050 "RUBY_DATA_FUNC" => "unsafe.Pointer" ,
4151 "long long" => "Longlong" ,
Original file line number Diff line number Diff line change 1+ # frozen_string_literal: true
2+
3+ RSpec . describe RubyHToGo ::GoUtil do
4+ describe ".ruby_minor_version_build_tag" do
5+ subject { RubyHToGo ::GoUtil . ruby_minor_version_build_tag ( ruby_version ) }
6+
7+ let ( :ruby_version ) { "3.4.1" }
8+
9+ it { should eq "ruby_3_4" }
10+ end
11+ end
You can’t perform that action at this time.
0 commit comments