Skip to content

Commit ecd104b

Browse files
committed
path for go-gem
1 parent fadfbc9 commit ecd104b

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

gem/lib/go_gem/mkmf.rb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,32 @@ module Mkmf
88
# @param target [String]
99
# @param srcprefix [String,nil]
1010
def create_go_makefile(target, srcprefix = nil)
11+
find_executable("go")
12+
13+
# rubocop:disable Style/GlobalVars
14+
$objs = []
15+
def $objs.empty?; false; end
16+
# rubocop:enable Style/GlobalVars
17+
1118
create_makefile(target, srcprefix)
19+
20+
case `#{CONFIG["CC"]} --version` # rubocop:disable Lint/LiteralAsCondition
21+
when /Free Software Foundation/
22+
ldflags = "-Wl,--unresolved-symbols=ignore-all"
23+
when /clang/
24+
ldflags = "-undefined dynamic_lookup"
25+
end
26+
27+
current_dir = File.expand_path(".")
28+
29+
File.open("Makefile", "a") do |f|
30+
f.write <<~MAKEFILE.gsub(/^ {8}/, "\t")
31+
$(DLLIB): Makefile $(srcdir)/*.go
32+
cd $(srcdir); \
33+
CGO_CFLAGS='$(INCFLAGS)' CGO_LDFLAGS='#{ldflags}' \
34+
go build -p 4 -buildmode=c-shared -o #{current_dir}/$(DLLIB)
35+
MAKEFILE
36+
end
1237
end
1338
end
1439
end

0 commit comments

Comments
 (0)