@@ -44,7 +44,7 @@ module GoGem
4444 # end
4545 # end
4646 # end
47- class RakeTask < ::Rake ::TaskLib # rubocop:disable Metrics/ClassLength
47+ class RakeTask < ::Rake ::TaskLib
4848 DEFAULT_TASK_NAMESPACE = :go
4949
5050 DEFAULT_GO_BIN_PATH = "go"
@@ -99,61 +99,19 @@ def initialize(gem_name)
9999 #
100100 # @return [Hash<String, String>]
101101 def self . build_env_vars
102- ldflags = generate_ldflags
103- cflags = generate_cflags
104-
105- # FIXME: Workaround for Ubuntu (GitHub Actions)
106- if RUBY_PLATFORM =~ /linux/i
107- cflags . gsub! ( "-Wno-self-assign" , "" )
108- cflags . gsub! ( "-Wno-parentheses-equality" , "" )
109- cflags . gsub! ( "-Wno-constant-logical-operand" , "" )
110- cflags . gsub! ( "-Wsuggest-attribute=format" , "" )
111- cflags . gsub! ( "-Wold-style-definition" , "" )
112- cflags . gsub! ( "-Wsuggest-attribute=noreturn" , "" )
113- ldflags . gsub! ( "-Wl,--unresolved-symbols=ignore-all" , "" )
114- end
102+ ldflags = GoGem ::Util . generate_ldflags
103+ cflags = GoGem ::Util . generate_cflags
115104
116105 ld_library_path = RbConfig ::CONFIG [ "libdir" ] . to_s
117106
118107 {
119- "GOFLAGS" => generate_goflags ,
108+ "GOFLAGS" => GoGem :: Util . generate_goflags ,
120109 "CGO_CFLAGS" => cflags ,
121110 "CGO_LDFLAGS" => ldflags ,
122111 "LD_LIBRARY_PATH" => ld_library_path ,
123112 }
124113 end
125114
126- # @return [String]
127- def self . generate_goflags
128- "-tags=#{ GoGem ::Util . ruby_minor_version_build_tag } "
129- end
130- private_class_method :generate_goflags
131-
132- # @return [String]
133- def self . generate_ldflags
134- ldflags = "-L#{ RbConfig ::CONFIG [ "libdir" ] } -l#{ RbConfig ::CONFIG [ "RUBY_SO_NAME" ] } "
135-
136- case `#{ RbConfig ::CONFIG [ "CC" ] } --version` # rubocop:disable Lint/LiteralAsCondition
137- when /Free Software Foundation/
138- ldflags << " -Wl,--unresolved-symbols=ignore-all"
139- when /clang/
140- ldflags << " -undefined dynamic_lookup"
141- end
142-
143- ldflags
144- end
145- private_class_method :generate_ldflags
146-
147- # @return [String]
148- def self . generate_cflags
149- [
150- RbConfig ::CONFIG [ "CFLAGS" ] ,
151- "-I#{ RbConfig ::CONFIG [ "rubyarchhdrdir" ] } " ,
152- "-I#{ RbConfig ::CONFIG [ "rubyhdrdir" ] } " ,
153- ] . join ( " " )
154- end
155- private_class_method :generate_cflags
156-
157115 # @yield
158116 def within_target_dir
159117 Dir . chdir ( target_dir ) do # rubocop:disable Style/ExplicitBlockArgument
0 commit comments