Module: GoGem::Util
- Defined in:
- _gem/lib/go_gem/util.rb
Overview
Class Method Summary collapse
- .generate_cflags ⇒ String
- .generate_goflags ⇒ String
- .generate_ldflags ⇒ String
-
.ruby_minor_version_build_tag(ruby_version = RUBY_VERSION) ⇒ String
Return ruby version build tag for
go build
andgo test
.
Class Method Details
.generate_cflags ⇒ String
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File '_gem/lib/go_gem/util.rb', line 36 def self.generate_cflags cflags = [ RbConfig::CONFIG["CFLAGS"], "-I#{RbConfig::CONFIG["rubyarchhdrdir"]}", "-I#{RbConfig::CONFIG["rubyhdrdir"]}", ].join(" ") # FIXME: Workaround for Ubuntu (GitHub Actions) if RUBY_PLATFORM =~ /linux/i cflags.gsub!("-Wno-self-assign", "") cflags.gsub!("-Wno-parentheses-equality", "") cflags.gsub!("-Wno-constant-logical-operand", "") cflags.gsub!("-Wsuggest-attribute=format", "") cflags.gsub!("-Wold-style-definition", "") cflags.gsub!("-Wsuggest-attribute=noreturn", "") end # FIXME: Workaround for Alpine cflags.gsub!("-Wpointer-arith", "") if RUBY_PLATFORM =~ /linux-musl/i cflags.strip end |
.generate_goflags ⇒ String
61 62 63 |
# File '_gem/lib/go_gem/util.rb', line 61 def self.generate_goflags "-tags=#{ruby_minor_version_build_tag}" end |
.generate_ldflags ⇒ String
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File '_gem/lib/go_gem/util.rb', line 19 def self.generate_ldflags ldflags = "-L#{RbConfig::CONFIG["libdir"]} -l#{RbConfig::CONFIG["RUBY_SO_NAME"]}" case `#{RbConfig::CONFIG["CC"]} --version` # rubocop:disable Lint/LiteralAsCondition when /Free Software Foundation/ ldflags << " -Wl,--unresolved-symbols=ignore-all" when /clang/ ldflags << " -undefined dynamic_lookup" end # FIXME: Workaround for Ubuntu (GitHub Actions) ldflags.gsub!("-Wl,--unresolved-symbols=ignore-all", "") if RUBY_PLATFORM =~ /linux/i ldflags.strip end |
.ruby_minor_version_build_tag(ruby_version = RUBY_VERSION) ⇒ String
Return ruby version build tag for go build
and go test
14 15 16 |
# File '_gem/lib/go_gem/util.rb', line 14 def self.ruby_minor_version_build_tag(ruby_version = RUBY_VERSION) "ruby_#{ruby_version.to_f.to_s.gsub(".", "_")}" end |