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