File tree Expand file tree Collapse file tree 1 file changed +25
-4
lines changed
_tools/ruby_h_to_go/lib/ruby_h_to_go Expand file tree Collapse file tree 1 file changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -16,16 +16,35 @@ 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 = GoGem ::Util . ruby_minor_version_build_tag
20
-
21
- File . binwrite ( go_file_path , <<~GO )
19
+ header = +<<~GO
22
20
// THE AUTOGENERATED LICENSE. ALL THE RIGHTS ARE RESERVED BY ROBOTS.
23
21
24
22
// WARNING: This file has automatically been generated
25
23
// Code generated by ruby_h_to_go. DO NOT EDIT.
26
24
27
- //go:build #{ ruby_build_tag }
25
+ GO
26
+
27
+ ruby_build_tag = GoGem ::Util . ruby_minor_version_build_tag
28
+
29
+ header <<
30
+ if ruby_build_tag == RubyHToGo . config . default_tag
31
+ other_tags = RubyHToGo . config . available_tags - [ RubyHToGo . config . default_tag ]
32
+ condition = other_tags . map { |tag | "!#{ tag } " } . join ( " && " )
28
33
34
+ <<~GO
35
+ // FIXME: https://pkg.go.dev/ doesn't support custom build tag.
36
+ // Therefore, if no build tag is passed, treat it as the default tag
37
+ //go:build #{ ruby_build_tag } || (#{ condition } )
38
+
39
+ GO
40
+ else
41
+ <<~GO
42
+ //go:build #{ ruby_build_tag }
43
+
44
+ GO
45
+ end
46
+
47
+ header << <<~GO
29
48
package ruby
30
49
31
50
/*
@@ -38,6 +57,8 @@ def self.generate_initial_go_file(go_file_path)
38
57
)
39
58
40
59
GO
60
+
61
+ File . binwrite ( go_file_path , header )
41
62
end
42
63
43
64
C_TYPE_TO_GO_TYPE = {
You can’t perform that action at this time.
0 commit comments