grpc 1.60.0.pre1-aarch64-linux
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/etc/roots.pem +4337 -0
- data/grpc_c.32-msvcrt.ruby +0 -0
- data/grpc_c.64-msvcrt.ruby +0 -0
- data/grpc_c.64-ucrt.ruby +0 -0
- data/src/ruby/bin/math_client.rb +140 -0
- data/src/ruby/bin/math_pb.rb +40 -0
- data/src/ruby/bin/math_server.rb +191 -0
- data/src/ruby/bin/math_services_pb.rb +51 -0
- data/src/ruby/bin/noproto_client.rb +93 -0
- data/src/ruby/bin/noproto_server.rb +97 -0
- data/src/ruby/ext/grpc/ext-export-truffleruby-with-ruby-abi-version.clang +2 -0
- data/src/ruby/ext/grpc/ext-export-truffleruby-with-ruby-abi-version.gcc +7 -0
- data/src/ruby/ext/grpc/ext-export-with-ruby-abi-version.clang +2 -0
- data/src/ruby/ext/grpc/ext-export-with-ruby-abi-version.gcc +7 -0
- data/src/ruby/ext/grpc/ext-export.clang +1 -0
- data/src/ruby/ext/grpc/ext-export.gcc +6 -0
- data/src/ruby/ext/grpc/extconf.rb +270 -0
- data/src/ruby/ext/grpc/rb_byte_buffer.c +65 -0
- data/src/ruby/ext/grpc/rb_byte_buffer.h +35 -0
- data/src/ruby/ext/grpc/rb_call.c +1075 -0
- data/src/ruby/ext/grpc/rb_call.h +57 -0
- data/src/ruby/ext/grpc/rb_call_credentials.c +340 -0
- data/src/ruby/ext/grpc/rb_call_credentials.h +31 -0
- data/src/ruby/ext/grpc/rb_channel.c +875 -0
- data/src/ruby/ext/grpc/rb_channel.h +35 -0
- data/src/ruby/ext/grpc/rb_channel_args.c +172 -0
- data/src/ruby/ext/grpc/rb_channel_args.h +42 -0
- data/src/ruby/ext/grpc/rb_channel_credentials.c +285 -0
- data/src/ruby/ext/grpc/rb_channel_credentials.h +37 -0
- data/src/ruby/ext/grpc/rb_completion_queue.c +101 -0
- data/src/ruby/ext/grpc/rb_completion_queue.h +36 -0
- data/src/ruby/ext/grpc/rb_compression_options.c +470 -0
- data/src/ruby/ext/grpc/rb_compression_options.h +29 -0
- data/src/ruby/ext/grpc/rb_enable_cpp.cc +22 -0
- data/src/ruby/ext/grpc/rb_event_thread.c +161 -0
- data/src/ruby/ext/grpc/rb_event_thread.h +22 -0
- data/src/ruby/ext/grpc/rb_grpc.c +496 -0
- data/src/ruby/ext/grpc/rb_grpc.h +83 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +603 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +910 -0
- data/src/ruby/ext/grpc/rb_loader.c +61 -0
- data/src/ruby/ext/grpc/rb_loader.h +25 -0
- data/src/ruby/ext/grpc/rb_server.c +405 -0
- data/src/ruby/ext/grpc/rb_server.h +32 -0
- data/src/ruby/ext/grpc/rb_server_credentials.c +258 -0
- data/src/ruby/ext/grpc/rb_server_credentials.h +37 -0
- data/src/ruby/ext/grpc/rb_xds_channel_credentials.c +217 -0
- data/src/ruby/ext/grpc/rb_xds_channel_credentials.h +37 -0
- data/src/ruby/ext/grpc/rb_xds_server_credentials.c +169 -0
- data/src/ruby/ext/grpc/rb_xds_server_credentials.h +37 -0
- data/src/ruby/lib/grpc/2.7/grpc_c.so +0 -0
- data/src/ruby/lib/grpc/3.0/grpc_c.so +0 -0
- data/src/ruby/lib/grpc/3.1/grpc_c.so +0 -0
- data/src/ruby/lib/grpc/3.2/grpc_c.so +0 -0
- data/src/ruby/lib/grpc/core/status_codes.rb +135 -0
- data/src/ruby/lib/grpc/core/time_consts.rb +56 -0
- data/src/ruby/lib/grpc/errors.rb +277 -0
- data/src/ruby/lib/grpc/generic/active_call.rb +670 -0
- data/src/ruby/lib/grpc/generic/bidi_call.rb +237 -0
- data/src/ruby/lib/grpc/generic/client_stub.rb +503 -0
- data/src/ruby/lib/grpc/generic/interceptor_registry.rb +53 -0
- data/src/ruby/lib/grpc/generic/interceptors.rb +186 -0
- data/src/ruby/lib/grpc/generic/rpc_desc.rb +204 -0
- data/src/ruby/lib/grpc/generic/rpc_server.rb +551 -0
- data/src/ruby/lib/grpc/generic/service.rb +211 -0
- data/src/ruby/lib/grpc/google_rpc_status_utils.rb +40 -0
- data/src/ruby/lib/grpc/grpc.rb +24 -0
- data/src/ruby/lib/grpc/logconfig.rb +44 -0
- data/src/ruby/lib/grpc/notifier.rb +45 -0
- data/src/ruby/lib/grpc/structs.rb +15 -0
- data/src/ruby/lib/grpc/version.rb +18 -0
- data/src/ruby/lib/grpc.rb +37 -0
- data/src/ruby/pb/README.md +42 -0
- data/src/ruby/pb/generate_proto_ruby.sh +46 -0
- data/src/ruby/pb/grpc/health/checker.rb +75 -0
- data/src/ruby/pb/grpc/health/v1/health_pb.rb +42 -0
- data/src/ruby/pb/grpc/health/v1/health_services_pb.rb +62 -0
- data/src/ruby/pb/grpc/testing/duplicate/echo_duplicate_services_pb.rb +44 -0
- data/src/ruby/pb/grpc/testing/metrics_pb.rb +28 -0
- data/src/ruby/pb/grpc/testing/metrics_services_pb.rb +49 -0
- data/src/ruby/pb/src/proto/grpc/testing/empty_pb.rb +38 -0
- data/src/ruby/pb/src/proto/grpc/testing/messages_pb.rb +71 -0
- data/src/ruby/pb/src/proto/grpc/testing/test_pb.rb +40 -0
- data/src/ruby/pb/src/proto/grpc/testing/test_services_pb.rb +174 -0
- data/src/ruby/pb/test/client.rb +785 -0
- data/src/ruby/pb/test/server.rb +252 -0
- data/src/ruby/pb/test/xds_client.rb +415 -0
- data/src/ruby/spec/call_credentials_spec.rb +42 -0
- data/src/ruby/spec/call_spec.rb +180 -0
- data/src/ruby/spec/channel_connection_spec.rb +126 -0
- data/src/ruby/spec/channel_credentials_spec.rb +124 -0
- data/src/ruby/spec/channel_spec.rb +207 -0
- data/src/ruby/spec/client_auth_spec.rb +152 -0
- data/src/ruby/spec/client_server_spec.rb +676 -0
- data/src/ruby/spec/compression_options_spec.rb +149 -0
- data/src/ruby/spec/debug_message_spec.rb +134 -0
- data/src/ruby/spec/error_sanity_spec.rb +49 -0
- data/src/ruby/spec/errors_spec.rb +142 -0
- data/src/ruby/spec/generic/active_call_spec.rb +692 -0
- data/src/ruby/spec/generic/client_interceptors_spec.rb +153 -0
- data/src/ruby/spec/generic/client_stub_spec.rb +1083 -0
- data/src/ruby/spec/generic/interceptor_registry_spec.rb +65 -0
- data/src/ruby/spec/generic/rpc_desc_spec.rb +374 -0
- data/src/ruby/spec/generic/rpc_server_pool_spec.rb +127 -0
- data/src/ruby/spec/generic/rpc_server_spec.rb +748 -0
- data/src/ruby/spec/generic/server_interceptors_spec.rb +218 -0
- data/src/ruby/spec/generic/service_spec.rb +263 -0
- data/src/ruby/spec/google_rpc_status_utils_spec.rb +282 -0
- data/src/ruby/spec/pb/codegen/grpc/testing/package_options.proto +28 -0
- data/src/ruby/spec/pb/codegen/grpc/testing/package_options_import.proto +22 -0
- data/src/ruby/spec/pb/codegen/grpc/testing/package_options_import2.proto +23 -0
- data/src/ruby/spec/pb/codegen/grpc/testing/package_options_ruby_style.proto +41 -0
- data/src/ruby/spec/pb/codegen/grpc/testing/same_package_service_name.proto +27 -0
- data/src/ruby/spec/pb/codegen/grpc/testing/same_ruby_package_service_name.proto +29 -0
- data/src/ruby/spec/pb/codegen/package_option_spec.rb +98 -0
- data/src/ruby/spec/pb/duplicate/codegen_spec.rb +57 -0
- data/src/ruby/spec/pb/health/checker_spec.rb +236 -0
- data/src/ruby/spec/server_credentials_spec.rb +104 -0
- data/src/ruby/spec/server_spec.rb +231 -0
- data/src/ruby/spec/spec_helper.rb +61 -0
- data/src/ruby/spec/support/helpers.rb +107 -0
- data/src/ruby/spec/support/services.rb +160 -0
- data/src/ruby/spec/testdata/README +1 -0
- data/src/ruby/spec/testdata/ca.pem +20 -0
- data/src/ruby/spec/testdata/client.key +28 -0
- data/src/ruby/spec/testdata/client.pem +20 -0
- data/src/ruby/spec/testdata/server1.key +28 -0
- data/src/ruby/spec/testdata/server1.pem +22 -0
- data/src/ruby/spec/time_consts_spec.rb +74 -0
- data/src/ruby/spec/user_agent_spec.rb +74 -0
- metadata +405 -0
@@ -0,0 +1,270 @@
|
|
1
|
+
# Copyright 2015 gRPC authors.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require 'etc'
|
16
|
+
require 'mkmf'
|
17
|
+
require_relative '../../lib/grpc/version.rb'
|
18
|
+
|
19
|
+
windows = RUBY_PLATFORM =~ /mingw|mswin/
|
20
|
+
windows_ucrt = RUBY_PLATFORM =~ /(mingw|mswin).*ucrt/
|
21
|
+
bsd = RUBY_PLATFORM =~ /bsd/
|
22
|
+
darwin = RUBY_PLATFORM =~ /darwin/
|
23
|
+
linux = RUBY_PLATFORM =~ /linux/
|
24
|
+
cross_compiling = ENV['RCD_HOST_RUBY_VERSION'] # set by rake-compiler-dock in build containers
|
25
|
+
# TruffleRuby uses the Sulong LLVM runtime, which is different from Apple's.
|
26
|
+
apple_toolchain = darwin && RUBY_ENGINE != 'truffleruby'
|
27
|
+
|
28
|
+
grpc_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
|
29
|
+
|
30
|
+
grpc_config = ENV['GRPC_CONFIG'] || 'opt'
|
31
|
+
|
32
|
+
ENV['MACOSX_DEPLOYMENT_TARGET'] = '10.10'
|
33
|
+
|
34
|
+
def debug_symbols_output_dir
|
35
|
+
d = ENV['GRPC_RUBY_DEBUG_SYMBOLS_OUTPUT_DIR']
|
36
|
+
return nil if d.nil? or d.size == 0
|
37
|
+
d
|
38
|
+
end
|
39
|
+
|
40
|
+
def maybe_remove_strip_all_linker_flag(flags)
|
41
|
+
if debug_symbols_output_dir
|
42
|
+
# Hack to prevent automatic stripping during shared library linking.
|
43
|
+
# rake-compiler-dock sets the -s LDFLAG when building rubies for
|
44
|
+
# cross compilation, and this -s flag propagates into RbConfig. Stripping
|
45
|
+
# during the link is problematic because it prevents us from saving
|
46
|
+
# debug symbols. We want to first link our shared library, then save
|
47
|
+
# debug symbols, and only after that strip.
|
48
|
+
flags = flags.split(' ')
|
49
|
+
flags = flags.reject {|flag| flag == '-s'}
|
50
|
+
flags = flags.join(' ')
|
51
|
+
end
|
52
|
+
flags
|
53
|
+
end
|
54
|
+
|
55
|
+
def env_unset?(name)
|
56
|
+
ENV[name].nil? || ENV[name].size == 0
|
57
|
+
end
|
58
|
+
|
59
|
+
def inherit_env_or_rbconfig(name)
|
60
|
+
ENV[name] = inherit_rbconfig(name) if env_unset?(name)
|
61
|
+
end
|
62
|
+
|
63
|
+
def inherit_rbconfig(name, linker_flag: false)
|
64
|
+
value = RbConfig::CONFIG[name] || ''
|
65
|
+
if linker_flag
|
66
|
+
value = maybe_remove_strip_all_linker_flag(value)
|
67
|
+
end
|
68
|
+
p "extconf.rb setting ENV[#{name}] = #{value}"
|
69
|
+
ENV[name] = value
|
70
|
+
end
|
71
|
+
|
72
|
+
def env_append(name, string)
|
73
|
+
ENV[name] += ' ' + string
|
74
|
+
end
|
75
|
+
|
76
|
+
# build grpc C-core
|
77
|
+
inherit_env_or_rbconfig 'AR'
|
78
|
+
inherit_env_or_rbconfig 'CC'
|
79
|
+
inherit_env_or_rbconfig 'CXX'
|
80
|
+
inherit_env_or_rbconfig 'RANLIB'
|
81
|
+
inherit_env_or_rbconfig 'STRIP'
|
82
|
+
inherit_rbconfig 'CPPFLAGS'
|
83
|
+
inherit_rbconfig('LDFLAGS', linker_flag: true)
|
84
|
+
|
85
|
+
ENV['LD'] = ENV['CC'] if env_unset?('LD')
|
86
|
+
ENV['LDXX'] = ENV['CXX'] if env_unset?('LDXX')
|
87
|
+
|
88
|
+
if RUBY_ENGINE == 'truffleruby'
|
89
|
+
# ensure we can find the system's OpenSSL
|
90
|
+
env_append 'CPPFLAGS', RbConfig::CONFIG['cppflags']
|
91
|
+
end
|
92
|
+
|
93
|
+
if apple_toolchain && !cross_compiling
|
94
|
+
ENV['AR'] = 'libtool'
|
95
|
+
ENV['ARFLAGS'] = '-o'
|
96
|
+
end
|
97
|
+
|
98
|
+
# Don't embed on TruffleRuby (constant-time crypto is unsafe with Sulong, slow build times)
|
99
|
+
ENV['EMBED_OPENSSL'] = (RUBY_ENGINE != 'truffleruby').to_s
|
100
|
+
# Don't embed on TruffleRuby (the system zlib is already linked for the zlib C extension, slow build times)
|
101
|
+
ENV['EMBED_ZLIB'] = (RUBY_ENGINE != 'truffleruby').to_s
|
102
|
+
|
103
|
+
ENV['EMBED_CARES'] = 'true'
|
104
|
+
|
105
|
+
ENV['ARCH_FLAGS'] = RbConfig::CONFIG['ARCH_FLAG']
|
106
|
+
if apple_toolchain && !cross_compiling
|
107
|
+
if RUBY_PLATFORM =~ /arm64/
|
108
|
+
ENV['ARCH_FLAGS'] = '-arch arm64'
|
109
|
+
else
|
110
|
+
ENV['ARCH_FLAGS'] = '-arch i386 -arch x86_64'
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
env_append 'CPPFLAGS', '-DGPR_BACKWARDS_COMPATIBILITY_MODE'
|
115
|
+
env_append 'CPPFLAGS', '-DGRPC_XDS_USER_AGENT_NAME_SUFFIX="\"RUBY\""'
|
116
|
+
|
117
|
+
require_relative '../../lib/grpc/version'
|
118
|
+
env_append 'CPPFLAGS', '-DGRPC_XDS_USER_AGENT_VERSION_SUFFIX="\"' + GRPC::VERSION + '\""'
|
119
|
+
env_append 'CPPFLAGS', '-DGRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK=1'
|
120
|
+
|
121
|
+
output_dir = File.expand_path(RbConfig::CONFIG['topdir'])
|
122
|
+
grpc_lib_dir = File.join(output_dir, 'libs', grpc_config)
|
123
|
+
ENV['BUILDDIR'] = output_dir
|
124
|
+
|
125
|
+
strip_tool = RbConfig::CONFIG['STRIP']
|
126
|
+
strip_tool += ' -x' if apple_toolchain
|
127
|
+
|
128
|
+
unless windows
|
129
|
+
puts 'Building internal gRPC into ' + grpc_lib_dir
|
130
|
+
nproc = 4
|
131
|
+
nproc = Etc.nprocessors if Etc.respond_to? :nprocessors
|
132
|
+
nproc_override = ENV['GRPC_RUBY_BUILD_PROCS']
|
133
|
+
unless nproc_override.nil? or nproc_override.size == 0
|
134
|
+
nproc = nproc_override
|
135
|
+
puts "Overriding make parallelism to #{nproc}"
|
136
|
+
end
|
137
|
+
make = bsd ? 'gmake' : 'make'
|
138
|
+
cmd = "#{make} -j#{nproc} -C #{grpc_root} #{grpc_lib_dir}/libgrpc.a CONFIG=#{grpc_config} Q="
|
139
|
+
puts "Building grpc native library: #{cmd}"
|
140
|
+
system(cmd)
|
141
|
+
exit 1 unless $? == 0
|
142
|
+
end
|
143
|
+
|
144
|
+
# C-core built, generate Makefile for ruby extension
|
145
|
+
$LDFLAGS = maybe_remove_strip_all_linker_flag($LDFLAGS)
|
146
|
+
$DLDFLAGS = maybe_remove_strip_all_linker_flag($DLDFLAGS)
|
147
|
+
|
148
|
+
$CFLAGS << ' -DGRPC_RUBY_WINDOWS_UCRT' if windows_ucrt
|
149
|
+
$CFLAGS << ' -I' + File.join(grpc_root, 'include')
|
150
|
+
$CFLAGS << ' -g'
|
151
|
+
|
152
|
+
def have_ruby_abi_version()
|
153
|
+
return true if RUBY_ENGINE == 'truffleruby'
|
154
|
+
# ruby_abi_version is only available in development versions: https://github.com/ruby/ruby/pull/6231
|
155
|
+
return false if RUBY_PATCHLEVEL >= 0
|
156
|
+
|
157
|
+
m = /(\d+)\.(\d+)/.match(RUBY_VERSION)
|
158
|
+
if m.nil?
|
159
|
+
puts "Failed to parse ruby version: #{RUBY_VERSION}. Assuming ruby_abi_version symbol is NOT present."
|
160
|
+
return false
|
161
|
+
end
|
162
|
+
major = m[1].to_i
|
163
|
+
minor = m[2].to_i
|
164
|
+
if major >= 3 and minor >= 2
|
165
|
+
puts "Ruby version #{RUBY_VERSION} >= 3.2. Assuming ruby_abi_version symbol is present."
|
166
|
+
return true
|
167
|
+
end
|
168
|
+
puts "Ruby version #{RUBY_VERSION} < 3.2. Assuming ruby_abi_version symbol is NOT present."
|
169
|
+
false
|
170
|
+
end
|
171
|
+
|
172
|
+
def ext_export_filename()
|
173
|
+
name = 'ext-export'
|
174
|
+
name += '-truffleruby' if RUBY_ENGINE == 'truffleruby'
|
175
|
+
name += '-with-ruby-abi-version' if have_ruby_abi_version()
|
176
|
+
name
|
177
|
+
end
|
178
|
+
|
179
|
+
ext_export_file = File.join(grpc_root, 'src', 'ruby', 'ext', 'grpc', ext_export_filename())
|
180
|
+
$LDFLAGS << ' -Wl,--version-script="' + ext_export_file + '.gcc"' if linux
|
181
|
+
if apple_toolchain
|
182
|
+
$LDFLAGS << ' -weak_framework CoreFoundation'
|
183
|
+
$LDFLAGS << ' -Wl,-exported_symbols_list,"' + ext_export_file + '.clang"'
|
184
|
+
end
|
185
|
+
|
186
|
+
$LDFLAGS << ' ' + File.join(grpc_lib_dir, 'libgrpc.a') unless windows
|
187
|
+
if grpc_config == 'gcov'
|
188
|
+
$CFLAGS << ' -O0 -fprofile-arcs -ftest-coverage'
|
189
|
+
$LDFLAGS << ' -fprofile-arcs -ftest-coverage -rdynamic'
|
190
|
+
end
|
191
|
+
|
192
|
+
if grpc_config == 'dbg'
|
193
|
+
$CFLAGS << ' -O0'
|
194
|
+
end
|
195
|
+
|
196
|
+
$LDFLAGS << ' -Wl,-wrap,memcpy' if linux
|
197
|
+
# Do not statically link standard libraries on TruffleRuby as this does not work when compiling to bitcode
|
198
|
+
if linux && RUBY_ENGINE != 'truffleruby'
|
199
|
+
$LDFLAGS << ' -static-libgcc -static-libstdc++'
|
200
|
+
end
|
201
|
+
$LDFLAGS << ' -static' if windows
|
202
|
+
|
203
|
+
$CFLAGS << ' -std=c11 '
|
204
|
+
$CFLAGS << ' -Wall '
|
205
|
+
$CFLAGS << ' -Wextra '
|
206
|
+
$CFLAGS << ' -pedantic '
|
207
|
+
|
208
|
+
output = File.join('grpc', 'grpc_c')
|
209
|
+
puts "extconf.rb $LDFLAGS: #{$LDFLAGS}"
|
210
|
+
puts "extconf.rb $DLDFLAGS: #{$DLDFLAGS}"
|
211
|
+
puts "extconf.rb $CFLAGS: #{$CFLAGS}"
|
212
|
+
puts 'Generating Makefile for ' + output
|
213
|
+
create_makefile(output)
|
214
|
+
|
215
|
+
ruby_major_minor = /(\d+\.\d+)/.match(RUBY_VERSION).to_s
|
216
|
+
debug_symbols = "grpc-#{GRPC::VERSION}-#{RUBY_PLATFORM}-ruby-#{ruby_major_minor}.dbg"
|
217
|
+
|
218
|
+
File.open('Makefile.new', 'w') do |o|
|
219
|
+
o.puts 'hijack_remove_unused_artifacts: all remove_unused_artifacts'
|
220
|
+
o.puts
|
221
|
+
o.write(File.read('Makefile'))
|
222
|
+
o.puts
|
223
|
+
o.puts 'remove_unused_artifacts: $(DLLIB)'
|
224
|
+
# Now that the extension library has been linked, we can remove unused artifacts
|
225
|
+
# that take up a lot of disk space.
|
226
|
+
rm_obj_cmd = "rm -rf #{File.join(output_dir, 'objs')}"
|
227
|
+
o.puts "\t$(ECHO) Removing unused object artifacts: #{rm_obj_cmd}"
|
228
|
+
o.puts "\t$(Q) #{rm_obj_cmd}"
|
229
|
+
rm_grpc_core_libs = "rm -f #{grpc_lib_dir}/*.a"
|
230
|
+
o.puts "\t$(ECHO) Removing unused grpc core libraries: #{rm_grpc_core_libs}"
|
231
|
+
o.puts "\t$(Q) #{rm_grpc_core_libs}"
|
232
|
+
end
|
233
|
+
File.rename('Makefile.new', 'Makefile')
|
234
|
+
|
235
|
+
if grpc_config == 'opt'
|
236
|
+
File.open('Makefile.new', 'w') do |o|
|
237
|
+
o.puts 'hijack: all strip'
|
238
|
+
o.puts
|
239
|
+
o.write(File.read('Makefile'))
|
240
|
+
o.puts
|
241
|
+
o.puts 'strip: $(DLLIB)'
|
242
|
+
if debug_symbols_output_dir
|
243
|
+
o.puts "\t$(ECHO) Saving debug symbols in #{debug_symbols_output_dir}/#{debug_symbols}"
|
244
|
+
o.puts "\t$(Q) objcopy --only-keep-debug $(DLLIB) #{debug_symbols_output_dir}/#{debug_symbols}"
|
245
|
+
end
|
246
|
+
o.puts "\t$(ECHO) Stripping $(DLLIB)"
|
247
|
+
o.puts "\t$(Q) #{strip_tool} $(DLLIB)"
|
248
|
+
end
|
249
|
+
File.rename('Makefile.new', 'Makefile')
|
250
|
+
end
|
251
|
+
|
252
|
+
if ENV['GRPC_RUBY_TEST_ONLY_WORKAROUND_MAKE_INSTALL_BUG']
|
253
|
+
# Note: this env var setting is intended to work around a problem observed
|
254
|
+
# with the ginstall command on grpc's macos automated test infrastructure,
|
255
|
+
# and is not guaranteed to work in the wild.
|
256
|
+
# Also see https://github.com/rake-compiler/rake-compiler/issues/210.
|
257
|
+
puts 'Overriding the generated Makefile install target to use cp'
|
258
|
+
File.open('Makefile.new', 'w') do |o|
|
259
|
+
File.foreach('Makefile') do |i|
|
260
|
+
if i.start_with?('INSTALL_PROG = ')
|
261
|
+
override = 'INSTALL_PROG = cp'
|
262
|
+
puts "Replacing generated Makefile line: |#{i}|, with: |#{override}|"
|
263
|
+
o.puts override
|
264
|
+
else
|
265
|
+
o.puts i
|
266
|
+
end
|
267
|
+
end
|
268
|
+
end
|
269
|
+
File.rename('Makefile.new', 'Makefile')
|
270
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
/*
|
2
|
+
*
|
3
|
+
* Copyright 2015 gRPC authors.
|
4
|
+
*
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
* you may not use this file except in compliance with the License.
|
7
|
+
* You may obtain a copy of the License at
|
8
|
+
*
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
*
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
* See the License for the specific language governing permissions and
|
15
|
+
* limitations under the License.
|
16
|
+
*
|
17
|
+
*/
|
18
|
+
|
19
|
+
#include <ruby/ruby.h>
|
20
|
+
|
21
|
+
#include "rb_byte_buffer.h"
|
22
|
+
|
23
|
+
#include "rb_grpc.h"
|
24
|
+
#include "rb_grpc_imports.generated.h"
|
25
|
+
|
26
|
+
#include <grpc/byte_buffer_reader.h>
|
27
|
+
#include <grpc/grpc.h>
|
28
|
+
#include <grpc/slice.h>
|
29
|
+
|
30
|
+
grpc_byte_buffer* grpc_rb_s_to_byte_buffer(char* string, size_t length) {
|
31
|
+
grpc_slice slice = grpc_slice_from_copied_buffer(string, length);
|
32
|
+
grpc_byte_buffer* buffer = grpc_raw_byte_buffer_create(&slice, 1);
|
33
|
+
grpc_slice_unref(slice);
|
34
|
+
return buffer;
|
35
|
+
}
|
36
|
+
|
37
|
+
VALUE grpc_rb_byte_buffer_to_s(grpc_byte_buffer* buffer) {
|
38
|
+
VALUE rb_string;
|
39
|
+
grpc_byte_buffer_reader reader;
|
40
|
+
grpc_slice next;
|
41
|
+
if (buffer == NULL) {
|
42
|
+
return Qnil;
|
43
|
+
}
|
44
|
+
rb_string = rb_str_buf_new(grpc_byte_buffer_length(buffer));
|
45
|
+
if (!grpc_byte_buffer_reader_init(&reader, buffer)) {
|
46
|
+
rb_raise(rb_eRuntimeError, "Error initializing byte buffer reader.");
|
47
|
+
return Qnil;
|
48
|
+
}
|
49
|
+
while (grpc_byte_buffer_reader_next(&reader, &next) != 0) {
|
50
|
+
rb_str_cat(rb_string, (const char*)GRPC_SLICE_START_PTR(next),
|
51
|
+
GRPC_SLICE_LENGTH(next));
|
52
|
+
grpc_slice_unref(next);
|
53
|
+
}
|
54
|
+
grpc_byte_buffer_reader_destroy(&reader);
|
55
|
+
return rb_string;
|
56
|
+
}
|
57
|
+
|
58
|
+
VALUE grpc_rb_slice_to_ruby_string(grpc_slice slice) {
|
59
|
+
if (GRPC_SLICE_START_PTR(slice) == NULL) {
|
60
|
+
rb_raise(rb_eRuntimeError,
|
61
|
+
"attempt to convert uninitialized grpc_slice to ruby string");
|
62
|
+
}
|
63
|
+
return rb_str_new((char*)GRPC_SLICE_START_PTR(slice),
|
64
|
+
GRPC_SLICE_LENGTH(slice));
|
65
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
/*
|
2
|
+
*
|
3
|
+
* Copyright 2015 gRPC authors.
|
4
|
+
*
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
* you may not use this file except in compliance with the License.
|
7
|
+
* You may obtain a copy of the License at
|
8
|
+
*
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
*
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
* See the License for the specific language governing permissions and
|
15
|
+
* limitations under the License.
|
16
|
+
*
|
17
|
+
*/
|
18
|
+
|
19
|
+
#ifndef GRPC_RB_BYTE_BUFFER_H_
|
20
|
+
#define GRPC_RB_BYTE_BUFFER_H_
|
21
|
+
|
22
|
+
#include <ruby/ruby.h>
|
23
|
+
|
24
|
+
#include <grpc/grpc.h>
|
25
|
+
|
26
|
+
/* Converts a char* with a length to a grpc_byte_buffer */
|
27
|
+
grpc_byte_buffer* grpc_rb_s_to_byte_buffer(char* string, size_t length);
|
28
|
+
|
29
|
+
/* Converts a grpc_byte_buffer to a ruby string */
|
30
|
+
VALUE grpc_rb_byte_buffer_to_s(grpc_byte_buffer* buffer);
|
31
|
+
|
32
|
+
/* Converts a grpc_slice to a ruby string */
|
33
|
+
VALUE grpc_rb_slice_to_ruby_string(grpc_slice slice);
|
34
|
+
|
35
|
+
#endif /* GRPC_RB_BYTE_BUFFER_H_ */
|