+38
-15
lines changedFilter options
+38
-15
lines changed Original file line number Diff line number Diff line change
@@ -172,7 +172,7 @@ genrule(
172
172
set -eux
173
173
mkdir tmp
174
174
for src in $(SRCS); do
175
-
cp --parents -L "$$src" tmp
175
+
mkdir -p "tmp/$$(dirname $$src)" && cp -L "$$src" "tmp/$$src"
176
176
done
177
177
mkdir -p "tmp/ruby/ext/google/protobuf_c/third_party/utf8_range"
178
178
for utf in $(execpaths //third_party/utf8_range:utf8_range_srcs) $(execpath //third_party/utf8_range:LICENSE); do
@@ -210,7 +210,7 @@ genrule(
210
210
set -eux
211
211
mkdir tmp
212
212
for src in $(SRCS); do
213
-
cp --parents -L "$$src" "tmp"
213
+
mkdir -p "tmp/$$(dirname $$src)" && cp -L "$$src" "tmp/$$src"
214
214
done
215
215
mkdir -p "tmp/ruby/ext/google/protobuf_c/third_party/utf8_range"
216
216
for utf in $(execpaths //third_party/utf8_range:utf8_range_srcs) $(execpath //third_party/utf8_range:LICENSE); do
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@ well_known_protos = %w[
18
18
google/protobuf/timestamp.proto
19
19
google/protobuf/type.proto
20
20
google/protobuf/wrappers.proto
21
+
google/protobuf/compiler/plugin.proto
21
22
]
22
23
23
24
test_protos = %w[
@@ -38,12 +39,6 @@ test_protos = %w[
38
39
tests/utf8.proto
39
40
]
40
41
41
-
# These are omitted for now because we don't support proto2.
42
-
proto2_protos = %w[
43
-
google/protobuf/descriptor.proto
44
-
google/protobuf/compiler/plugin.proto
45
-
]
46
-
47
42
if !ENV['PROTOC'].nil?
48
43
protoc_command = ENV['PROTOC']
49
44
elsif system('../bazel-bin/protoc --version')
@@ -52,17 +47,27 @@ else
52
47
protoc_command = 'protoc'
53
48
end
54
49
50
+
tmp_protoc_out = "tmp/protoc-out"
51
+
52
+
directory tmp_protoc_out
53
+
55
54
genproto_output = []
56
55
57
56
# We won't have access to .. from within docker, but the proto files
58
57
# will be there, thanks to the :genproto rule dependency for gem:native.
59
58
unless ENV['IN_DOCKER'] == 'true' or ENV['BAZEL'] == 'true'
60
59
well_known_protos.each do |proto_file|
61
-
input_file = "../src/" + proto_file
62
-
output_file = "lib/" + proto_file.sub(/\.proto$/, "_pb.rb")
60
+
input_file = File.join("../src/", proto_file)
61
+
output_basename = File.basename(proto_file).sub(/\.proto$/, "_pb.rb")
62
+
tmp_output_file = File.join(tmp_protoc_out, File.dirname(proto_file), output_basename)
63
+
# Generated _pb.rb for files in subdirectories of google/protobuf
64
+
# (eg: ../src/google/protobuf/compiler/plugin.proto) should all still end up
65
+
# in lib/google/protobuf.
66
+
output_file = File.join("lib/google/protobuf", output_basename)
63
67
genproto_output << output_file
64
-
file output_file => input_file do |file_task|
65
-
sh "#{protoc_command} -I../src --ruby_out=lib #{input_file}"
68
+
file output_file => [input_file, tmp_protoc_out] do |file_task|
69
+
sh "#{protoc_command} -I../src --ruby_out=#{tmp_protoc_out} #{input_file}"
70
+
FileUtils.cp tmp_output_file, output_file
66
71
end
67
72
end
68
73
@@ -177,6 +182,16 @@ task :clean do
177
182
end
178
183
179
184
Gem::PackageTask.new(spec) do |pkg|
185
+
# When packaging the gem via `rake gem`, we only want to define
186
+
# "ext/google/protobuf_c/extconf.rb" as the extension to build the C
187
+
# extension.
188
+
pkg.gem_spec.extensions = pkg.gem_spec.extensions.map do |extension|
189
+
extension == "Rakefile" ? "ext/google/protobuf_c/extconf.rb" : extension
190
+
end
191
+
192
+
pkg.gem_spec.files.reject! { |f| f == "Rakefile" }
193
+
194
+
pkg.package_files.exclude("Rakefile")
180
195
end
181
196
182
197
# Skip build/genproto in Bazel builds, where we expect this to
Original file line number Diff line number Diff line change
@@ -25,9 +25,17 @@ Gem::Specification.new do |s|
25
25
s.files += Dir.glob('ext/**/*').reject do |file|
26
26
File.basename(file) =~ /^(BUILD\.bazel)$/
27
27
end
28
-
s.extensions = %w[
29
-
ext/google/protobuf_c/extconf.rb
30
-
ext/google/protobuf_c/Rakefile
28
+
29
+
# When installing this gem from git via bundler
30
+
# (ie: 'gem "google-protobuf", git: "https://.../protobuf.git"' in your
31
+
# Gemfile), Rakefile is necessary so the prerequisite tasks run to copy
32
+
# third party C libraries and generate well known protobufs. When building
33
+
# the gem via `rake gem`, these steps will have already occurred, and so we
34
+
# replace the `Rakefile` extension with `ext/google/protobuf_c/extconf.rb`.
35
+
# See the `Gem::PackageTask.new` declaration in `Rakefile` for more details.
36
+
s.extensions = [
37
+
File.exist?("Rakefile") ? "Rakefile" : "ext/google/protobuf_c/extconf.rb",
38
+
"ext/google/protobuf_c/Rakefile"
31
39
]
32
40
end
33
41
s.required_ruby_version = '>= 3.1'
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4