google-protobuf 4.31.0.rc.1-x86-linux-gnu
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/ext/google/protobuf_c/Rakefile +3 -0
- data/ext/google/protobuf_c/convert.c +335 -0
- data/ext/google/protobuf_c/convert.h +50 -0
- data/ext/google/protobuf_c/defs.c +1932 -0
- data/ext/google/protobuf_c/defs.h +82 -0
- data/ext/google/protobuf_c/extconf.rb +44 -0
- data/ext/google/protobuf_c/glue.c +135 -0
- data/ext/google/protobuf_c/map.c +731 -0
- data/ext/google/protobuf_c/map.h +48 -0
- data/ext/google/protobuf_c/message.c +1426 -0
- data/ext/google/protobuf_c/message.h +82 -0
- data/ext/google/protobuf_c/protobuf.c +357 -0
- data/ext/google/protobuf_c/protobuf.h +102 -0
- data/ext/google/protobuf_c/repeated_field.c +691 -0
- data/ext/google/protobuf_c/repeated_field.h +45 -0
- data/ext/google/protobuf_c/ruby-upb.c +18305 -0
- data/ext/google/protobuf_c/ruby-upb.h +16315 -0
- data/ext/google/protobuf_c/shared_convert.c +69 -0
- data/ext/google/protobuf_c/shared_convert.h +26 -0
- data/ext/google/protobuf_c/shared_message.c +37 -0
- data/ext/google/protobuf_c/shared_message.h +21 -0
- data/ext/google/protobuf_c/third_party/utf8_range/LICENSE +22 -0
- data/ext/google/protobuf_c/third_party/utf8_range/utf8_range.c +207 -0
- data/ext/google/protobuf_c/third_party/utf8_range/utf8_range.h +22 -0
- data/ext/google/protobuf_c/third_party/utf8_range/utf8_range_neon.inc +117 -0
- data/ext/google/protobuf_c/third_party/utf8_range/utf8_range_sse.inc +272 -0
- data/ext/google/protobuf_c/wrap_memcpy.c +29 -0
- data/lib/google/3.1/protobuf_c.so +0 -0
- data/lib/google/3.2/protobuf_c.so +0 -0
- data/lib/google/3.3/protobuf_c.so +0 -0
- data/lib/google/3.4/protobuf_c.so +0 -0
- data/lib/google/protobuf/any_pb.rb +17 -0
- data/lib/google/protobuf/api_pb.rb +22 -0
- data/lib/google/protobuf/descriptor_pb.rb +70 -0
- data/lib/google/protobuf/duration_pb.rb +17 -0
- data/lib/google/protobuf/empty_pb.rb +17 -0
- data/lib/google/protobuf/ffi/descriptor.rb +175 -0
- data/lib/google/protobuf/ffi/descriptor_pool.rb +79 -0
- data/lib/google/protobuf/ffi/enum_descriptor.rb +183 -0
- data/lib/google/protobuf/ffi/ffi.rb +214 -0
- data/lib/google/protobuf/ffi/field_descriptor.rb +346 -0
- data/lib/google/protobuf/ffi/file_descriptor.rb +85 -0
- data/lib/google/protobuf/ffi/internal/arena.rb +60 -0
- data/lib/google/protobuf/ffi/internal/convert.rb +292 -0
- data/lib/google/protobuf/ffi/internal/pointer_helper.rb +36 -0
- data/lib/google/protobuf/ffi/internal/type_safety.rb +25 -0
- data/lib/google/protobuf/ffi/map.rb +433 -0
- data/lib/google/protobuf/ffi/message.rb +783 -0
- data/lib/google/protobuf/ffi/method_descriptor.rb +124 -0
- data/lib/google/protobuf/ffi/object_cache.rb +30 -0
- data/lib/google/protobuf/ffi/oneof_descriptor.rb +107 -0
- data/lib/google/protobuf/ffi/repeated_field.rb +411 -0
- data/lib/google/protobuf/ffi/service_descriptor.rb +117 -0
- data/lib/google/protobuf/field_mask_pb.rb +17 -0
- data/lib/google/protobuf/internal/object_cache.rb +99 -0
- data/lib/google/protobuf/message_exts.rb +39 -0
- data/lib/google/protobuf/plugin_pb.rb +25 -0
- data/lib/google/protobuf/repeated_field.rb +177 -0
- data/lib/google/protobuf/source_context_pb.rb +17 -0
- data/lib/google/protobuf/struct_pb.rb +20 -0
- data/lib/google/protobuf/timestamp_pb.rb +17 -0
- data/lib/google/protobuf/type_pb.rb +27 -0
- data/lib/google/protobuf/well_known_types.rb +211 -0
- data/lib/google/protobuf/wrappers_pb.rb +25 -0
- data/lib/google/protobuf.rb +61 -0
- data/lib/google/protobuf_ffi.rb +52 -0
- data/lib/google/protobuf_native.rb +19 -0
- data/lib/google/tasks/ffi.rake +100 -0
- metadata +215 -0
@@ -0,0 +1,211 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
# Protocol Buffers - Google's data interchange format
|
3
|
+
# Copyright 2008 Google Inc. All rights reserved.
|
4
|
+
#
|
5
|
+
# Use of this source code is governed by a BSD-style
|
6
|
+
# license that can be found in the LICENSE file or at
|
7
|
+
# https://developers.google.com/open-source/licenses/bsd
|
8
|
+
|
9
|
+
require 'google/protobuf/any_pb'
|
10
|
+
require 'google/protobuf/duration_pb'
|
11
|
+
require 'google/protobuf/field_mask_pb'
|
12
|
+
require 'google/protobuf/struct_pb'
|
13
|
+
require 'google/protobuf/timestamp_pb'
|
14
|
+
|
15
|
+
module Google
|
16
|
+
module Protobuf
|
17
|
+
|
18
|
+
Any.class_eval do
|
19
|
+
def self.pack(msg, type_url_prefix='type.googleapis.com/')
|
20
|
+
any = self.new
|
21
|
+
any.pack(msg, type_url_prefix)
|
22
|
+
any
|
23
|
+
end
|
24
|
+
|
25
|
+
def pack(msg, type_url_prefix='type.googleapis.com/')
|
26
|
+
if type_url_prefix.empty? or type_url_prefix[-1] != '/' then
|
27
|
+
self.type_url = "#{type_url_prefix}/#{msg.class.descriptor.name}"
|
28
|
+
else
|
29
|
+
self.type_url = "#{type_url_prefix}#{msg.class.descriptor.name}"
|
30
|
+
end
|
31
|
+
self.value = msg.to_proto
|
32
|
+
end
|
33
|
+
|
34
|
+
def unpack(klass)
|
35
|
+
if self.is(klass) then
|
36
|
+
klass.decode(self.value)
|
37
|
+
else
|
38
|
+
nil
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def type_name
|
43
|
+
return self.type_url.split("/")[-1]
|
44
|
+
end
|
45
|
+
|
46
|
+
def is(klass)
|
47
|
+
return self.type_name == klass.descriptor.name
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
Timestamp.class_eval do
|
52
|
+
def to_time
|
53
|
+
Time.at(seconds, nanos, :nanosecond)
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.from_time(time)
|
57
|
+
new.from_time(time)
|
58
|
+
end
|
59
|
+
|
60
|
+
def from_time(time)
|
61
|
+
self.seconds = time.to_i
|
62
|
+
self.nanos = time.nsec
|
63
|
+
self
|
64
|
+
end
|
65
|
+
|
66
|
+
def to_i
|
67
|
+
self.seconds
|
68
|
+
end
|
69
|
+
|
70
|
+
def to_f
|
71
|
+
self.seconds + (self.nanos.quo(1_000_000_000))
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
Duration.class_eval do
|
76
|
+
def to_f
|
77
|
+
self.seconds + (self.nanos.to_f / 1_000_000_000)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
class UnexpectedStructType < Google::Protobuf::Error; end
|
82
|
+
|
83
|
+
Value.class_eval do
|
84
|
+
def to_ruby(recursive = false)
|
85
|
+
case self.kind
|
86
|
+
when :struct_value
|
87
|
+
if recursive
|
88
|
+
self.struct_value.to_h
|
89
|
+
else
|
90
|
+
self.struct_value
|
91
|
+
end
|
92
|
+
when :list_value
|
93
|
+
if recursive
|
94
|
+
self.list_value.to_a
|
95
|
+
else
|
96
|
+
self.list_value
|
97
|
+
end
|
98
|
+
when :null_value
|
99
|
+
nil
|
100
|
+
when :number_value
|
101
|
+
self.number_value
|
102
|
+
when :string_value
|
103
|
+
self.string_value
|
104
|
+
when :bool_value
|
105
|
+
self.bool_value
|
106
|
+
else
|
107
|
+
raise UnexpectedStructType
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def self.from_ruby(value)
|
112
|
+
self.new.from_ruby(value)
|
113
|
+
end
|
114
|
+
|
115
|
+
def from_ruby(value)
|
116
|
+
case value
|
117
|
+
when NilClass
|
118
|
+
self.null_value = :NULL_VALUE
|
119
|
+
when Numeric
|
120
|
+
self.number_value = value
|
121
|
+
when String
|
122
|
+
self.string_value = value
|
123
|
+
when TrueClass
|
124
|
+
self.bool_value = true
|
125
|
+
when FalseClass
|
126
|
+
self.bool_value = false
|
127
|
+
when Struct
|
128
|
+
self.struct_value = value
|
129
|
+
when Hash
|
130
|
+
self.struct_value = Struct.from_hash(value)
|
131
|
+
when ListValue
|
132
|
+
self.list_value = value
|
133
|
+
when Array
|
134
|
+
self.list_value = ListValue.from_a(value)
|
135
|
+
else
|
136
|
+
raise UnexpectedStructType
|
137
|
+
end
|
138
|
+
|
139
|
+
self
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
Struct.class_eval do
|
144
|
+
def [](key)
|
145
|
+
self.fields[key].to_ruby
|
146
|
+
rescue NoMethodError
|
147
|
+
nil
|
148
|
+
end
|
149
|
+
|
150
|
+
def []=(key, value)
|
151
|
+
unless key.is_a?(String)
|
152
|
+
raise UnexpectedStructType, "Struct keys must be strings."
|
153
|
+
end
|
154
|
+
self.fields[key] ||= Google::Protobuf::Value.new
|
155
|
+
self.fields[key].from_ruby(value)
|
156
|
+
end
|
157
|
+
|
158
|
+
def to_h
|
159
|
+
ret = {}
|
160
|
+
self.fields.each { |key, val| ret[key] = val.to_ruby(true) }
|
161
|
+
ret
|
162
|
+
end
|
163
|
+
|
164
|
+
def self.from_hash(hash)
|
165
|
+
ret = Struct.new
|
166
|
+
hash.each { |key, val| ret[key] = val }
|
167
|
+
ret
|
168
|
+
end
|
169
|
+
|
170
|
+
def has_key?(key)
|
171
|
+
self.fields.has_key?(key)
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
ListValue.class_eval do
|
176
|
+
include Enumerable
|
177
|
+
|
178
|
+
def length
|
179
|
+
self.values.length
|
180
|
+
end
|
181
|
+
|
182
|
+
def [](index)
|
183
|
+
self.values[index].to_ruby
|
184
|
+
end
|
185
|
+
|
186
|
+
def []=(index, value)
|
187
|
+
self.values[index].from_ruby(value)
|
188
|
+
end
|
189
|
+
|
190
|
+
def <<(value)
|
191
|
+
wrapper = Google::Protobuf::Value.new
|
192
|
+
wrapper.from_ruby(value)
|
193
|
+
self.values << wrapper
|
194
|
+
end
|
195
|
+
|
196
|
+
def each
|
197
|
+
self.values.each { |x| yield(x.to_ruby) }
|
198
|
+
end
|
199
|
+
|
200
|
+
def to_a
|
201
|
+
self.values.map { |x| x.to_ruby(true) }
|
202
|
+
end
|
203
|
+
|
204
|
+
def self.from_a(arr)
|
205
|
+
ret = ListValue.new
|
206
|
+
arr.each { |val| ret << val }
|
207
|
+
ret
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
3
|
+
# source: google/protobuf/wrappers.proto
|
4
|
+
|
5
|
+
require 'google/protobuf'
|
6
|
+
|
7
|
+
|
8
|
+
descriptor_data = "\n\x1egoogle/protobuf/wrappers.proto\x12\x0fgoogle.protobuf\"\x1c\n\x0b\x44oubleValue\x12\r\n\x05value\x18\x01 \x01(\x01\"\x1b\n\nFloatValue\x12\r\n\x05value\x18\x01 \x01(\x02\"\x1b\n\nInt64Value\x12\r\n\x05value\x18\x01 \x01(\x03\"\x1c\n\x0bUInt64Value\x12\r\n\x05value\x18\x01 \x01(\x04\"\x1b\n\nInt32Value\x12\r\n\x05value\x18\x01 \x01(\x05\"\x1c\n\x0bUInt32Value\x12\r\n\x05value\x18\x01 \x01(\r\"\x1a\n\tBoolValue\x12\r\n\x05value\x18\x01 \x01(\x08\"\x1c\n\x0bStringValue\x12\r\n\x05value\x18\x01 \x01(\t\"\x1b\n\nBytesValue\x12\r\n\x05value\x18\x01 \x01(\x0c\x42\x83\x01\n\x13\x63om.google.protobufB\rWrappersProtoP\x01Z1google.golang.org/protobuf/types/known/wrapperspb\xf8\x01\x01\xa2\x02\x03GPB\xaa\x02\x1eGoogle.Protobuf.WellKnownTypesb\x06proto3"
|
9
|
+
|
10
|
+
pool = ::Google::Protobuf::DescriptorPool.generated_pool
|
11
|
+
pool.add_serialized_file(descriptor_data)
|
12
|
+
|
13
|
+
module Google
|
14
|
+
module Protobuf
|
15
|
+
DoubleValue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.DoubleValue").msgclass
|
16
|
+
FloatValue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FloatValue").msgclass
|
17
|
+
Int64Value = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Int64Value").msgclass
|
18
|
+
UInt64Value = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.UInt64Value").msgclass
|
19
|
+
Int32Value = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Int32Value").msgclass
|
20
|
+
UInt32Value = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.UInt32Value").msgclass
|
21
|
+
BoolValue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.BoolValue").msgclass
|
22
|
+
StringValue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.StringValue").msgclass
|
23
|
+
BytesValue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.BytesValue").msgclass
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# Protocol Buffers - Google's data interchange format
|
2
|
+
# Copyright 2008 Google Inc. All rights reserved.
|
3
|
+
#
|
4
|
+
# Use of this source code is governed by a BSD-style
|
5
|
+
# license that can be found in the LICENSE file or at
|
6
|
+
# https://developers.google.com/open-source/licenses/bsd
|
7
|
+
|
8
|
+
# require mixins before we hook them into the java & c code
|
9
|
+
require 'google/protobuf/message_exts'
|
10
|
+
require 'google/protobuf/internal/object_cache'
|
11
|
+
|
12
|
+
# We define these before requiring the platform-specific modules.
|
13
|
+
# That way the module init can grab references to these.
|
14
|
+
module Google
|
15
|
+
module Protobuf
|
16
|
+
class Error < StandardError; end
|
17
|
+
class ParseError < Error; end
|
18
|
+
class TypeError < ::TypeError; end
|
19
|
+
|
20
|
+
PREFER_FFI = case ENV['PROTOCOL_BUFFERS_RUBY_IMPLEMENTATION']
|
21
|
+
when nil, "", /^native$/i
|
22
|
+
false
|
23
|
+
when /^ffi$/i
|
24
|
+
true
|
25
|
+
else
|
26
|
+
warn "Unexpected value `#{ENV['PROTOCOL_BUFFERS_RUBY_IMPLEMENTATION']}` for environment variable `PROTOCOL_BUFFERS_RUBY_IMPLEMENTATION`. Should be either \"FFI\", \"NATIVE\"."
|
27
|
+
false
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.encode(msg, options = {})
|
31
|
+
msg.to_proto(options)
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.encode_json(msg, options = {})
|
35
|
+
msg.to_json(options)
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.decode(klass, proto, options = {})
|
39
|
+
klass.decode(proto, options)
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.decode_json(klass, json, options = {})
|
43
|
+
klass.decode_json(json, options)
|
44
|
+
end
|
45
|
+
|
46
|
+
IMPLEMENTATION = if PREFER_FFI
|
47
|
+
begin
|
48
|
+
require 'google/protobuf_ffi'
|
49
|
+
:FFI
|
50
|
+
rescue LoadError
|
51
|
+
warn "Caught exception `#{$!.message}` while loading FFI implementation of google/protobuf."
|
52
|
+
warn "Falling back to native implementation."
|
53
|
+
require 'google/protobuf_native'
|
54
|
+
:NATIVE
|
55
|
+
end
|
56
|
+
else
|
57
|
+
require 'google/protobuf_native'
|
58
|
+
:NATIVE
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# Protocol Buffers - Google's data interchange format
|
2
|
+
# Copyright 2023 Google Inc. All rights reserved.
|
3
|
+
#
|
4
|
+
# Use of this source code is governed by a BSD-style
|
5
|
+
# license that can be found in the LICENSE file or at
|
6
|
+
# https://developers.google.com/open-source/licenses/bsd
|
7
|
+
|
8
|
+
require 'ffi-compiler/loader'
|
9
|
+
require 'google/protobuf/ffi/ffi'
|
10
|
+
require 'google/protobuf/ffi/internal/type_safety'
|
11
|
+
require 'google/protobuf/ffi/internal/pointer_helper'
|
12
|
+
require 'google/protobuf/ffi/internal/arena'
|
13
|
+
require 'google/protobuf/ffi/internal/convert'
|
14
|
+
require 'google/protobuf/ffi/descriptor'
|
15
|
+
require 'google/protobuf/ffi/enum_descriptor'
|
16
|
+
require 'google/protobuf/ffi/field_descriptor'
|
17
|
+
require 'google/protobuf/ffi/oneof_descriptor'
|
18
|
+
require 'google/protobuf/ffi/method_descriptor'
|
19
|
+
require 'google/protobuf/ffi/service_descriptor'
|
20
|
+
require 'google/protobuf/ffi/file_descriptor'
|
21
|
+
require 'google/protobuf/ffi/descriptor_pool'
|
22
|
+
require 'google/protobuf/ffi/map'
|
23
|
+
require 'google/protobuf/ffi/object_cache'
|
24
|
+
require 'google/protobuf/ffi/repeated_field'
|
25
|
+
require 'google/protobuf/ffi/message'
|
26
|
+
|
27
|
+
module Google
|
28
|
+
module Protobuf
|
29
|
+
def self.deep_copy(object)
|
30
|
+
case object
|
31
|
+
when RepeatedField
|
32
|
+
RepeatedField.send(:deep_copy, object)
|
33
|
+
when Google::Protobuf::Map
|
34
|
+
Google::Protobuf::Map.deep_copy(object)
|
35
|
+
when Google::Protobuf::MessageExts
|
36
|
+
object.class.send(:deep_copy, object.instance_variable_get(:@msg))
|
37
|
+
else
|
38
|
+
raise NotImplementedError
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.discard_unknown(message)
|
43
|
+
raise FrozenError if message.frozen?
|
44
|
+
raise ArgumentError.new "Expected message, got #{message.class} instead." if message.instance_variable_get(:@msg).nil?
|
45
|
+
pool_def = message.class.descriptor.instance_variable_get(:@descriptor_pool).descriptor_pool
|
46
|
+
unless Google::Protobuf::FFI.message_discard_unknown(message.instance_variable_get(:@msg), message.class.descriptor, pool_def, 128)
|
47
|
+
raise RuntimeError.new "Messages nested too deeply."
|
48
|
+
end
|
49
|
+
nil
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# Protocol Buffers - Google's data interchange format
|
2
|
+
# Copyright 2023 Google Inc. All rights reserved.
|
3
|
+
#
|
4
|
+
# Use of this source code is governed by a BSD-style
|
5
|
+
# license that can be found in the LICENSE file or at
|
6
|
+
# https://developers.google.com/open-source/licenses/bsd
|
7
|
+
|
8
|
+
if RUBY_PLATFORM == "java"
|
9
|
+
require 'json'
|
10
|
+
require 'google/protobuf_java'
|
11
|
+
else
|
12
|
+
begin
|
13
|
+
require "google/#{RUBY_VERSION.sub(/\.\d+$/, '')}/protobuf_c"
|
14
|
+
rescue LoadError
|
15
|
+
require 'google/protobuf_c'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
require 'google/protobuf/repeated_field'
|
@@ -0,0 +1,100 @@
|
|
1
|
+
# # @param task [FFI::Compiler::CompileTask] task to configure
|
2
|
+
def configure_common_compile_task(task)
|
3
|
+
if FileUtils.pwd.include? 'ext'
|
4
|
+
src_dir = '.'
|
5
|
+
third_party_path = 'third_party/utf8_range'
|
6
|
+
else
|
7
|
+
src_dir = 'ext/google/protobuf_c'
|
8
|
+
third_party_path = 'ext/google/protobuf_c/third_party/utf8_range'
|
9
|
+
end
|
10
|
+
|
11
|
+
task.add_include_path third_party_path
|
12
|
+
task.add_define 'NDEBUG'
|
13
|
+
task.cflags << "-std=gnu99 -O3"
|
14
|
+
[
|
15
|
+
:convert, :defs, :map, :message, :protobuf, :repeated_field, :wrap_memcpy
|
16
|
+
].each { |file| task.exclude << "/#{file}.c" }
|
17
|
+
task.ext_dir = src_dir
|
18
|
+
task.source_dirs = [src_dir]
|
19
|
+
if RbConfig::CONFIG['target_os'] =~ /darwin|linux/
|
20
|
+
task.cflags << "-Wall -Wsign-compare -Wno-declaration-after-statement"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# FFI::CompilerTask's constructor walks the filesystem at task definition time
|
25
|
+
# to create subtasks for each source file, so files from third_party must be
|
26
|
+
# copied into place before the task is defined for it to work correctly.
|
27
|
+
# TODO Is there a sane way to check for generated protos under lib too?
|
28
|
+
def with_generated_files
|
29
|
+
expected_path = FileUtils.pwd.include?('ext') ? 'third_party/utf8_range' : 'ext/google/protobuf_c/third_party/utf8_range'
|
30
|
+
if File.directory?(expected_path)
|
31
|
+
yield
|
32
|
+
else
|
33
|
+
task :default do
|
34
|
+
# It is possible, especially in cases like the first invocation of
|
35
|
+
# `rake test` following `rake clean` or a fresh checkout that the
|
36
|
+
# `copy_third_party` task has been executed since initial task definition.
|
37
|
+
# If so, run the task definition block now and invoke it explicitly.
|
38
|
+
if File.directory?(expected_path)
|
39
|
+
yield
|
40
|
+
Rake::Task[:default].invoke
|
41
|
+
else
|
42
|
+
raise "Missing directory #{File.absolute_path(expected_path)}." +
|
43
|
+
" Did you forget to run `rake copy_third_party` before building" +
|
44
|
+
" native extensions?"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
begin
|
51
|
+
require "ffi-compiler/compile_task"
|
52
|
+
|
53
|
+
desc "Compile Protobuf library for FFI"
|
54
|
+
namespace "ffi-protobuf" do
|
55
|
+
with_generated_files do
|
56
|
+
# Compile Ruby UPB separately in order to limit use of -DUPB_BUILD_API to one
|
57
|
+
# compilation unit.
|
58
|
+
desc "Compile UPB library for FFI"
|
59
|
+
namespace "ffi-upb" do
|
60
|
+
with_generated_files do
|
61
|
+
FFI::Compiler::CompileTask.new('ruby-upb') do |c|
|
62
|
+
configure_common_compile_task c
|
63
|
+
c.add_define "UPB_BUILD_API"
|
64
|
+
c.exclude << "/glue.c"
|
65
|
+
c.exclude << "/shared_message.c"
|
66
|
+
c.exclude << "/shared_convert.c"
|
67
|
+
if RbConfig::CONFIG['target_os'] =~ /darwin|linux/
|
68
|
+
c.cflags << "-fvisibility=hidden"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
FFI::Compiler::CompileTask.new 'protobuf_c_ffi' do |c|
|
75
|
+
configure_common_compile_task c
|
76
|
+
# Ruby UPB was already compiled with different flags.
|
77
|
+
c.exclude << "/utf8_range.c"
|
78
|
+
c.exclude << "/ruby-upb.c"
|
79
|
+
end
|
80
|
+
|
81
|
+
# Setup dependencies so that the .o files generated by building ffi-upb are
|
82
|
+
# available to link here.
|
83
|
+
# TODO Can this be simplified? Can the single shared library be used
|
84
|
+
# instead of the object files?
|
85
|
+
protobuf_c_task = Rake::Task[:default]
|
86
|
+
protobuf_c_shared_lib_task = Rake::Task[protobuf_c_task.prereqs.last]
|
87
|
+
ruby_upb_shared_lib_task = Rake::Task[:"ffi-upb:default"].prereqs.first
|
88
|
+
Rake::Task[ruby_upb_shared_lib_task].prereqs.each do |dependency|
|
89
|
+
protobuf_c_shared_lib_task.prereqs.prepend dependency
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
rescue LoadError
|
94
|
+
desc "Compile Protobuf library for FFI"
|
95
|
+
namespace "ffi-protobuf" do
|
96
|
+
task :default do
|
97
|
+
warn "Skipping build of FFI; `gem install ffi-compiler` to enable."
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
metadata
ADDED
@@ -0,0 +1,215 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: google-protobuf
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 4.31.0.rc.1
|
5
|
+
platform: x86-linux-gnu
|
6
|
+
authors:
|
7
|
+
- Protobuf Authors
|
8
|
+
bindir: bin
|
9
|
+
cert_chain: []
|
10
|
+
date: 2025-04-17 00:00:00.000000000 Z
|
11
|
+
dependencies:
|
12
|
+
- !ruby/object:Gem::Dependency
|
13
|
+
name: bigdecimal
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - ">="
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '0'
|
19
|
+
type: :runtime
|
20
|
+
prerelease: false
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
requirements:
|
23
|
+
- - ">="
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: '0'
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: rake
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '13'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '13'
|
40
|
+
- !ruby/object:Gem::Dependency
|
41
|
+
name: ffi
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '1'
|
47
|
+
type: :development
|
48
|
+
prerelease: false
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '1'
|
54
|
+
- !ruby/object:Gem::Dependency
|
55
|
+
name: ffi-compiler
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '1'
|
61
|
+
type: :development
|
62
|
+
prerelease: false
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '1'
|
68
|
+
- !ruby/object:Gem::Dependency
|
69
|
+
name: rake-compiler
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '1.2'
|
75
|
+
type: :development
|
76
|
+
prerelease: false
|
77
|
+
version_requirements: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '1.2'
|
82
|
+
- !ruby/object:Gem::Dependency
|
83
|
+
name: rake-compiler-dock
|
84
|
+
requirement: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '1.9'
|
89
|
+
type: :development
|
90
|
+
prerelease: false
|
91
|
+
version_requirements: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '1.9'
|
96
|
+
- !ruby/object:Gem::Dependency
|
97
|
+
name: test-unit
|
98
|
+
requirement: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '3.0'
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: 3.0.9
|
106
|
+
type: :development
|
107
|
+
prerelease: false
|
108
|
+
version_requirements: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - "~>"
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '3.0'
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: 3.0.9
|
116
|
+
description: Protocol Buffers are Google's data interchange format.
|
117
|
+
email: protobuf@googlegroups.com
|
118
|
+
executables: []
|
119
|
+
extensions: []
|
120
|
+
extra_rdoc_files: []
|
121
|
+
files:
|
122
|
+
- ext/google/protobuf_c/Rakefile
|
123
|
+
- ext/google/protobuf_c/convert.c
|
124
|
+
- ext/google/protobuf_c/convert.h
|
125
|
+
- ext/google/protobuf_c/defs.c
|
126
|
+
- ext/google/protobuf_c/defs.h
|
127
|
+
- ext/google/protobuf_c/extconf.rb
|
128
|
+
- ext/google/protobuf_c/glue.c
|
129
|
+
- ext/google/protobuf_c/map.c
|
130
|
+
- ext/google/protobuf_c/map.h
|
131
|
+
- ext/google/protobuf_c/message.c
|
132
|
+
- ext/google/protobuf_c/message.h
|
133
|
+
- ext/google/protobuf_c/protobuf.c
|
134
|
+
- ext/google/protobuf_c/protobuf.h
|
135
|
+
- ext/google/protobuf_c/repeated_field.c
|
136
|
+
- ext/google/protobuf_c/repeated_field.h
|
137
|
+
- ext/google/protobuf_c/ruby-upb.c
|
138
|
+
- ext/google/protobuf_c/ruby-upb.h
|
139
|
+
- ext/google/protobuf_c/shared_convert.c
|
140
|
+
- ext/google/protobuf_c/shared_convert.h
|
141
|
+
- ext/google/protobuf_c/shared_message.c
|
142
|
+
- ext/google/protobuf_c/shared_message.h
|
143
|
+
- ext/google/protobuf_c/third_party/utf8_range/LICENSE
|
144
|
+
- ext/google/protobuf_c/third_party/utf8_range/utf8_range.c
|
145
|
+
- ext/google/protobuf_c/third_party/utf8_range/utf8_range.h
|
146
|
+
- ext/google/protobuf_c/third_party/utf8_range/utf8_range_neon.inc
|
147
|
+
- ext/google/protobuf_c/third_party/utf8_range/utf8_range_sse.inc
|
148
|
+
- ext/google/protobuf_c/wrap_memcpy.c
|
149
|
+
- lib/google/3.1/protobuf_c.so
|
150
|
+
- lib/google/3.2/protobuf_c.so
|
151
|
+
- lib/google/3.3/protobuf_c.so
|
152
|
+
- lib/google/3.4/protobuf_c.so
|
153
|
+
- lib/google/protobuf.rb
|
154
|
+
- lib/google/protobuf/any_pb.rb
|
155
|
+
- lib/google/protobuf/api_pb.rb
|
156
|
+
- lib/google/protobuf/descriptor_pb.rb
|
157
|
+
- lib/google/protobuf/duration_pb.rb
|
158
|
+
- lib/google/protobuf/empty_pb.rb
|
159
|
+
- lib/google/protobuf/ffi/descriptor.rb
|
160
|
+
- lib/google/protobuf/ffi/descriptor_pool.rb
|
161
|
+
- lib/google/protobuf/ffi/enum_descriptor.rb
|
162
|
+
- lib/google/protobuf/ffi/ffi.rb
|
163
|
+
- lib/google/protobuf/ffi/field_descriptor.rb
|
164
|
+
- lib/google/protobuf/ffi/file_descriptor.rb
|
165
|
+
- lib/google/protobuf/ffi/internal/arena.rb
|
166
|
+
- lib/google/protobuf/ffi/internal/convert.rb
|
167
|
+
- lib/google/protobuf/ffi/internal/pointer_helper.rb
|
168
|
+
- lib/google/protobuf/ffi/internal/type_safety.rb
|
169
|
+
- lib/google/protobuf/ffi/map.rb
|
170
|
+
- lib/google/protobuf/ffi/message.rb
|
171
|
+
- lib/google/protobuf/ffi/method_descriptor.rb
|
172
|
+
- lib/google/protobuf/ffi/object_cache.rb
|
173
|
+
- lib/google/protobuf/ffi/oneof_descriptor.rb
|
174
|
+
- lib/google/protobuf/ffi/repeated_field.rb
|
175
|
+
- lib/google/protobuf/ffi/service_descriptor.rb
|
176
|
+
- lib/google/protobuf/field_mask_pb.rb
|
177
|
+
- lib/google/protobuf/internal/object_cache.rb
|
178
|
+
- lib/google/protobuf/message_exts.rb
|
179
|
+
- lib/google/protobuf/plugin_pb.rb
|
180
|
+
- lib/google/protobuf/repeated_field.rb
|
181
|
+
- lib/google/protobuf/source_context_pb.rb
|
182
|
+
- lib/google/protobuf/struct_pb.rb
|
183
|
+
- lib/google/protobuf/timestamp_pb.rb
|
184
|
+
- lib/google/protobuf/type_pb.rb
|
185
|
+
- lib/google/protobuf/well_known_types.rb
|
186
|
+
- lib/google/protobuf/wrappers_pb.rb
|
187
|
+
- lib/google/protobuf_ffi.rb
|
188
|
+
- lib/google/protobuf_native.rb
|
189
|
+
- lib/google/tasks/ffi.rake
|
190
|
+
homepage: https://developers.google.com/protocol-buffers
|
191
|
+
licenses:
|
192
|
+
- BSD-3-Clause
|
193
|
+
metadata:
|
194
|
+
source_code_uri: https://github.com/protocolbuffers/protobuf/tree/v4.31.0-rc1/ruby
|
195
|
+
rdoc_options: []
|
196
|
+
require_paths:
|
197
|
+
- lib
|
198
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
199
|
+
requirements:
|
200
|
+
- - ">="
|
201
|
+
- !ruby/object:Gem::Version
|
202
|
+
version: '3.1'
|
203
|
+
- - "<"
|
204
|
+
- !ruby/object:Gem::Version
|
205
|
+
version: 3.5.dev
|
206
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
207
|
+
requirements:
|
208
|
+
- - ">="
|
209
|
+
- !ruby/object:Gem::Version
|
210
|
+
version: 3.3.22
|
211
|
+
requirements: []
|
212
|
+
rubygems_version: 3.6.2
|
213
|
+
specification_version: 4
|
214
|
+
summary: Protocol Buffers
|
215
|
+
test_files: []
|