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)
16
16
def self . generate_initial_go_file ( go_file_path )
17
17
return if File . exist? ( go_file_path )
18
18
19
+ ruby_build_tag = ruby_minor_version_build_tag ( RUBY_VERSION )
20
+
19
21
File . binwrite ( go_file_path , <<~GO )
20
22
// THE AUTOGENERATED LICENSE. ALL THE RIGHTS ARE RESERVED BY ROBOTS.
21
23
22
24
// WARNING: This file has automatically been generated
23
25
// Code generated by ruby_h_to_go. DO NOT EDIT.
24
26
27
+ //go:build #{ ruby_build_tag }
28
+
25
29
package ruby
26
30
27
31
/*
@@ -36,6 +40,12 @@ def self.generate_initial_go_file(go_file_path)
36
40
GO
37
41
end
38
42
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
+
39
49
C_TYPE_TO_GO_TYPE = {
40
50
"RUBY_DATA_FUNC" => "unsafe.Pointer" ,
41
51
"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