Enabling the ruby extension to automatically build grpc.

pull/1589/head
Nicolas "Pixel" Noble 10 years ago
parent 357cb81c7d
commit 2e4b735f61
  1. 25
      src/ruby/ext/grpc/extconf.rb

@ -34,13 +34,25 @@ INCLUDEDIR = RbConfig::CONFIG['includedir']
if ENV.key? 'GRPC_ROOT' if ENV.key? 'GRPC_ROOT'
GRPC_ROOT = ENV['GRPC_ROOT'] GRPC_ROOT = ENV['GRPC_ROOT']
if ENV.key? 'GRPC_LIB_DIR' else
GRPC_LIB_DIR = ENV['GRPC_LIB_DIR'] grpc_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
if File.exist?(File.join(grpc_root, 'include/grpc/grpc.h'))
GRPC_ROOT = grpc_root
else else
GRPC_LIB_DIR = 'libs/opt' GRPC_ROOT = nil
end end
end
if ENV.key? 'CONFIG'
GRPC_CONFIG = ENV['CONFIG']
else else
GRPC_ROOT = nil GRPC_CONFIG = 'opt'
end
if (ENV.key? 'GRPC_LIB_DIR') && (!GRPC_ROOT.nil?)
GRPC_LIB_DIR = File.join(GRPC_ROOT, ENV['GRPC_LIB_DIR'])
else
GRPC_LIB_DIR = File.join(File.join(GRPC_ROOT, 'libs'), GRPC_CONFIG)
end end
HEADER_DIRS = [ HEADER_DIRS = [
@ -67,7 +79,10 @@ LIB_DIRS = [
unless GRPC_ROOT.nil? unless GRPC_ROOT.nil?
HEADER_DIRS.unshift File.join(GRPC_ROOT, 'include') HEADER_DIRS.unshift File.join(GRPC_ROOT, 'include')
LIB_DIRS.unshift File.join(GRPC_ROOT, GRPC_LIB_DIR) LIB_DIRS.unshift GRPC_LIB_DIR
unless File.exist?(File.join(GRPC_LIB_DIR, 'libgrpc.a'))
system("make -C #{GRPC_ROOT} static_c CONFIG=#{GRPC_CONFIG}")
end
end end
def crash(msg) def crash(msg)

Loading…
Cancel
Save