Module: GoGem::Mkmf
- Defined in:
- _gem/lib/go_gem/mkmf.rb
Overview
Helper module for creating Go Makefiles
Instance Method Summary collapse
-
#create_go_makefile(target, srcprefix = nil) ⇒ Object
Create Makefile for go-gem.
Instance Method Details
#create_go_makefile(target, srcprefix = nil) ⇒ Object
Create Makefile for go-gem
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File '_gem/lib/go_gem/mkmf.rb', line 18 def create_go_makefile(target, srcprefix = nil) find_executable("go") # rubocop:disable Style/GlobalVars $objs = [] # @private def $objs.empty?; false; end # rubocop:enable Style/GlobalVars create_makefile(target, srcprefix) 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 current_dir = File.(".") File.open("Makefile", "a") do |f| f.write <<~MAKEFILE.gsub(/^ {8}/, "\t") $(DLLIB): Makefile $(srcdir)/*.go cd $(srcdir); \ CGO_CFLAGS='$(INCFLAGS)' CGO_LDFLAGS='#{ldflags}' \ go build -p 4 -buildmode=c-shared -o #{current_dir}/$(DLLIB) MAKEFILE end end |