diff --git a/src/ruby/ext/grpc/extconf.rb b/src/ruby/ext/grpc/extconf.rb index f15f85bf56dca4b52e0ac57fa11fb3085df46448..1b801edc8ecfc13e82722b1fcc4a8736ab3e98c7 100644 --- a/src/ruby/ext/grpc/extconf.rb +++ b/src/ruby/ext/grpc/extconf.rb @@ -34,13 +34,25 @@ INCLUDEDIR = RbConfig::CONFIG['includedir'] if ENV.key? 'GRPC_ROOT' GRPC_ROOT = ENV['GRPC_ROOT'] - if ENV.key? 'GRPC_LIB_DIR' - GRPC_LIB_DIR = ENV['GRPC_LIB_DIR'] +else + 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 - GRPC_LIB_DIR = 'libs/opt' + GRPC_ROOT = nil end +end + +if ENV.key? 'CONFIG' + GRPC_CONFIG = ENV['CONFIG'] 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 HEADER_DIRS = [ @@ -67,7 +79,10 @@ LIB_DIRS = [ unless GRPC_ROOT.nil? 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 def crash(msg) diff --git a/src/ruby/ext/grpc/rb_byte_buffer.c b/src/ruby/ext/grpc/rb_byte_buffer.c index e3a5277f54420cdc082ba7392f10da74ccb2a501..edf0d3b115eb2e9ca5a4ea282fdf205b25611c7d 100644 --- a/src/ruby/ext/grpc/rb_byte_buffer.c +++ b/src/ruby/ext/grpc/rb_byte_buffer.c @@ -33,7 +33,7 @@ #include "rb_byte_buffer.h" -#include <ruby.h> +#include <ruby/ruby.h> #include <grpc/grpc.h> #include <grpc/support/slice.h> diff --git a/src/ruby/ext/grpc/rb_byte_buffer.h b/src/ruby/ext/grpc/rb_byte_buffer.h index 96b9009dae99612694669daf3b217c52d1f953f1..c7ddd76489034e8b7fe809239204ad565035fa82 100644 --- a/src/ruby/ext/grpc/rb_byte_buffer.h +++ b/src/ruby/ext/grpc/rb_byte_buffer.h @@ -34,8 +34,9 @@ #ifndef GRPC_RB_BYTE_BUFFER_H_ #define GRPC_RB_BYTE_BUFFER_H_ +#include <ruby/ruby.h> + #include <grpc/grpc.h> -#include <ruby.h> /* Converts a char* with a length to a grpc_byte_buffer */ grpc_byte_buffer *grpc_rb_s_to_byte_buffer(char *string, size_t length); diff --git a/src/ruby/ext/grpc/rb_call.c b/src/ruby/ext/grpc/rb_call.c index c46af250cd7370510f202a1e582e5624726e5deb..29f870f92982a07dcc747c429d578653bea6ab61 100644 --- a/src/ruby/ext/grpc/rb_call.c +++ b/src/ruby/ext/grpc/rb_call.c @@ -33,7 +33,7 @@ #include "rb_call.h" -#include <ruby.h> +#include <ruby/ruby.h> #include <grpc/grpc.h> #include <grpc/support/alloc.h> diff --git a/src/ruby/ext/grpc/rb_call.h b/src/ruby/ext/grpc/rb_call.h index 003ce0429e05b98aefa98009721d795826ecfd48..1d2fbc3580ef48b943462ffbe918b0c3bfb4055e 100644 --- a/src/ruby/ext/grpc/rb_call.h +++ b/src/ruby/ext/grpc/rb_call.h @@ -34,8 +34,9 @@ #ifndef GRPC_RB_CALL_H_ #define GRPC_RB_CALL_H_ +#include <ruby/ruby.h> + #include <grpc/grpc.h> -#include <ruby.h> /* Gets the wrapped call from a VALUE. */ grpc_call* grpc_rb_get_wrapped_call(VALUE v); diff --git a/src/ruby/ext/grpc/rb_channel.c b/src/ruby/ext/grpc/rb_channel.c index 214675af927cb3d0402ee89600ac8060c248fa20..d6876bc5546fed04de1541422fcb7a7ec46f7fce 100644 --- a/src/ruby/ext/grpc/rb_channel.c +++ b/src/ruby/ext/grpc/rb_channel.c @@ -33,7 +33,7 @@ #include "rb_channel.h" -#include <ruby.h> +#include <ruby/ruby.h> #include <grpc/grpc.h> #include <grpc/grpc_security.h> diff --git a/src/ruby/ext/grpc/rb_channel.h b/src/ruby/ext/grpc/rb_channel.h index 6e3c087689e70ce1c2583f94c3d44492ce8fd35a..77e1f6acbca9dac26fa3f5969f17e5cc86a171fb 100644 --- a/src/ruby/ext/grpc/rb_channel.h +++ b/src/ruby/ext/grpc/rb_channel.h @@ -34,7 +34,8 @@ #ifndef GRPC_RB_CHANNEL_H_ #define GRPC_RB_CHANNEL_H_ -#include <ruby.h> +#include <ruby/ruby.h> + #include <grpc/grpc.h> /* Initializes the Channel class. */ diff --git a/src/ruby/ext/grpc/rb_channel_args.c b/src/ruby/ext/grpc/rb_channel_args.c index acd545f5d2f0a16afe5daa1e565fcb44ef09f471..42ed3a1ec8053108ac670e516b2303b31306dae9 100644 --- a/src/ruby/ext/grpc/rb_channel_args.c +++ b/src/ruby/ext/grpc/rb_channel_args.c @@ -33,7 +33,8 @@ #include "rb_channel_args.h" -#include <ruby.h> +#include <ruby/ruby.h> + #include <grpc/grpc.h> #include "rb_grpc.h" diff --git a/src/ruby/ext/grpc/rb_channel_args.h b/src/ruby/ext/grpc/rb_channel_args.h index 78a333bd0826b25c57f3dad29907ef2065540f08..591dd848accd04940c9b43e6aa5a648c853289a1 100644 --- a/src/ruby/ext/grpc/rb_channel_args.h +++ b/src/ruby/ext/grpc/rb_channel_args.h @@ -34,7 +34,8 @@ #ifndef GRPC_RB_CHANNEL_ARGS_H_ #define GRPC_RB_CHANNEL_ARGS_H_ -#include <ruby.h> +#include <ruby/ruby.h> + #include <grpc/grpc.h> /* Converts a hash object containing channel args to a channel args instance. diff --git a/src/ruby/ext/grpc/rb_completion_queue.h b/src/ruby/ext/grpc/rb_completion_queue.h index e4d04b10c8391003ceb613722f94bfbc0ab5d135..6cc4e96589b92d2b3af08e2953671bc021b39247 100644 --- a/src/ruby/ext/grpc/rb_completion_queue.h +++ b/src/ruby/ext/grpc/rb_completion_queue.h @@ -34,8 +34,9 @@ #ifndef GRPC_RB_COMPLETION_QUEUE_H_ #define GRPC_RB_COMPLETION_QUEUE_H_ +#include <ruby/ruby.h> + #include <grpc/grpc.h> -#include <ruby.h> /* Gets the wrapped completion queue from the ruby wrapper */ grpc_completion_queue *grpc_rb_get_wrapped_completion_queue(VALUE v); diff --git a/src/ruby/ext/grpc/rb_credentials.c b/src/ruby/ext/grpc/rb_credentials.c index 1ec88914e463be3f45d64b0be172975373af27b6..3fca848b2b4b4cc92ab1b170b994f673f76c7b76 100644 --- a/src/ruby/ext/grpc/rb_credentials.c +++ b/src/ruby/ext/grpc/rb_credentials.c @@ -33,7 +33,7 @@ #include "rb_credentials.h" -#include <ruby.h> +#include <ruby/ruby.h> #include <grpc/grpc.h> #include <grpc/grpc_security.h> diff --git a/src/ruby/ext/grpc/rb_credentials.h b/src/ruby/ext/grpc/rb_credentials.h index e7c43c9c781909e198ece24e4e2411af2daa8a48..840f7d5f9cfcac3fda595ff53ec7e3589b54c122 100644 --- a/src/ruby/ext/grpc/rb_credentials.h +++ b/src/ruby/ext/grpc/rb_credentials.h @@ -34,7 +34,8 @@ #ifndef GRPC_RB_CREDENTIALS_H_ #define GRPC_RB_CREDENTIALS_H_ -#include <ruby.h> +#include <ruby/ruby.h> + #include <grpc/grpc_security.h> /* Initializes the ruby Credentials class. */ diff --git a/src/ruby/ext/grpc/rb_grpc.h b/src/ruby/ext/grpc/rb_grpc.h index a502273de1b2ee36a4c38f3b00956f2ae83e438b..6ea6cbd0b6c98d2655869260e3a01a5762cabb76 100644 --- a/src/ruby/ext/grpc/rb_grpc.h +++ b/src/ruby/ext/grpc/rb_grpc.h @@ -35,7 +35,8 @@ #define GRPC_RB_H_ #include <sys/time.h> -#include <ruby.h> +#include <ruby/ruby.h> + #include <grpc/support/time.h> /* grpc_rb_mGrpcCore is the module containing the ruby wrapper GRPC classes. */ diff --git a/src/ruby/ext/grpc/rb_server.c b/src/ruby/ext/grpc/rb_server.c index 0651c36c0b484bff9b5c06e4a94343c099829cd3..3182d03fab7156381eff6fcec57e8781a1e5f93d 100644 --- a/src/ruby/ext/grpc/rb_server.c +++ b/src/ruby/ext/grpc/rb_server.c @@ -33,7 +33,7 @@ #include "rb_server.h" -#include <ruby.h> +#include <ruby/ruby.h> #include <grpc/grpc.h> #include <grpc/grpc_security.h> diff --git a/src/ruby/ext/grpc/rb_server.h b/src/ruby/ext/grpc/rb_server.h index 5e4b711d35b8816eb11cd87d3d280c7baa79e4cd..59c9e6905b97c4efdd7a65c83517fa8fef741f66 100644 --- a/src/ruby/ext/grpc/rb_server.h +++ b/src/ruby/ext/grpc/rb_server.h @@ -34,7 +34,8 @@ #ifndef GRPC_RB_SERVER_H_ #define GRPC_RB_SERVER_H_ -#include <ruby.h> +#include <ruby/ruby.h> + #include <grpc/grpc.h> /* Initializes the Server class. */ diff --git a/src/ruby/ext/grpc/rb_server_credentials.c b/src/ruby/ext/grpc/rb_server_credentials.c index a86389445fb22fe52f4cd709e268b99b500cfc90..23271c40b731938f02a5490099d32eb640306e05 100644 --- a/src/ruby/ext/grpc/rb_server_credentials.c +++ b/src/ruby/ext/grpc/rb_server_credentials.c @@ -33,7 +33,7 @@ #include "rb_server_credentials.h" -#include <ruby.h> +#include <ruby/ruby.h> #include <grpc/grpc.h> #include <grpc/grpc_security.h> diff --git a/src/ruby/ext/grpc/rb_server_credentials.h b/src/ruby/ext/grpc/rb_server_credentials.h index 35b395ad5ccd757081eb4a23cf816f65e2b5ae5d..69d919b740636e5c2c6b70f5a8db044e775d8749 100644 --- a/src/ruby/ext/grpc/rb_server_credentials.h +++ b/src/ruby/ext/grpc/rb_server_credentials.h @@ -34,7 +34,8 @@ #ifndef GRPC_RB_SERVER_CREDENTIALS_H_ #define GRPC_RB_SERVER_CREDENTIALS_H_ -#include <ruby.h> +#include <ruby/ruby.h> + #include <grpc/grpc_security.h> /* Initializes the ruby ServerCredentials class. */ diff --git a/tools/run_tests/build_ruby.sh b/tools/run_tests/build_ruby.sh index 53a69cf0798bcc70411fe4893ec08e0272eec123..de96413bc127486644f4f4c99aec757409e4767c 100755 --- a/tools/run_tests/build_ruby.sh +++ b/tools/run_tests/build_ruby.sh @@ -31,17 +31,10 @@ set -ex -CONFIG=${CONFIG:-opt} +export CONFIG=${CONFIG:-opt} -# change to grpc repo root -cd $(dirname $0)/../.. - -# tells npm install to look for files in that directory -export GRPC_ROOT=`pwd` -# tells npm install the subdirectory with library files -export GRPC_LIB_SUBDIR=libs/$CONFIG - -cd src/ruby +# change to grpc's ruby directory +cd $(dirname $0)/../../src/ruby bundle install rake compile:grpc diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index 7150ebb553185b073e0cf3b871637029e15abe18..41f53a434a7b2ac10ad49ab9a364b5f99a403411 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -214,7 +214,7 @@ class RubyLanguage(object): return [config.job_spec(['tools/run_tests/run_ruby.sh'], None)] def make_targets(self): - return ['static_c'] + return ['run_dep_checks'] def build_steps(self): return [['tools/run_tests/build_ruby.sh']]