@@ -96,22 +96,8 @@ def initialize(gem_name)
96
96
#
97
97
# @return [Hash<String, String>]
98
98
def self . build_env_vars
99
- goflags = "-tags=#{ GoGem ::Util . ruby_minor_version_build_tag } "
100
-
101
- ldflags = "-L#{ RbConfig ::CONFIG [ "libdir" ] } -l#{ RbConfig ::CONFIG [ "RUBY_SO_NAME" ] } "
102
-
103
- case `#{ RbConfig ::CONFIG [ "CC" ] } --version` # rubocop:disable Lint/LiteralAsCondition
104
- when /Free Software Foundation/
105
- ldflags << " -Wl,--unresolved-symbols=ignore-all"
106
- when /clang/
107
- ldflags << " -undefined dynamic_lookup"
108
- end
109
-
110
- cflags = [
111
- RbConfig ::CONFIG [ "CFLAGS" ] ,
112
- "-I#{ RbConfig ::CONFIG [ "rubyarchhdrdir" ] } " ,
113
- "-I#{ RbConfig ::CONFIG [ "rubyhdrdir" ] } " ,
114
- ] . join ( " " )
99
+ ldflags = generate_ldflags
100
+ cflags = generate_cflags
115
101
116
102
# FIXME: Workaround for Ubuntu (GitHub Actions)
117
103
if RUBY_PLATFORM =~ /linux/i
@@ -127,13 +113,44 @@ def self.build_env_vars
127
113
ld_library_path = RbConfig ::CONFIG [ "libdir" ] . to_s
128
114
129
115
{
130
- "GOFLAGS" => goflags ,
116
+ "GOFLAGS" => generate_goflags ,
131
117
"CGO_CFLAGS" => cflags ,
132
118
"CGO_LDFLAGS" => ldflags ,
133
119
"LD_LIBRARY_PATH" => ld_library_path ,
134
120
}
135
121
end
136
122
123
+ # @return [String]
124
+ def self . generate_goflags
125
+ "-tags=#{ GoGem ::Util . ruby_minor_version_build_tag } "
126
+ end
127
+ private_class_method :generate_goflags
128
+
129
+ # @return [String]
130
+ def self . generate_ldflags
131
+ ldflags = "-L#{ RbConfig ::CONFIG [ "libdir" ] } -l#{ RbConfig ::CONFIG [ "RUBY_SO_NAME" ] } "
132
+
133
+ case `#{ RbConfig ::CONFIG [ "CC" ] } --version` # rubocop:disable Lint/LiteralAsCondition
134
+ when /Free Software Foundation/
135
+ ldflags << " -Wl,--unresolved-symbols=ignore-all"
136
+ when /clang/
137
+ ldflags << " -undefined dynamic_lookup"
138
+ end
139
+
140
+ ldflags
141
+ end
142
+ private_class_method :generate_ldflags
143
+
144
+ # @return [String]
145
+ def self . generate_cflags
146
+ [
147
+ RbConfig ::CONFIG [ "CFLAGS" ] ,
148
+ "-I#{ RbConfig ::CONFIG [ "rubyarchhdrdir" ] } " ,
149
+ "-I#{ RbConfig ::CONFIG [ "rubyhdrdir" ] } " ,
150
+ ] . join ( " " )
151
+ end
152
+ private_class_method :generate_cflags
153
+
137
154
# @yield
138
155
def within_target_dir
139
156
Dir . chdir ( target_dir ) do # rubocop:disable Style/ExplicitBlockArgument
0 commit comments