Skip to content

Commit 6bd9fe8

Browse files
committed
Update fetch and generate scripts for reflection
Motivation: To add the reflection service we need to fetch it and generate the appropriate code. Modifications: - Update proto fetching script to get v1 reflection service - Update proto generating script to generate reflection service code and messages - Also add protos used in tests for the reflection service and generate their descriptor sets Result: Generated code is in place
1 parent aadf8c9 commit 6bd9fe8

File tree

11 files changed

+1346
-3
lines changed

11 files changed

+1346
-3
lines changed

Sources/GRPCReflectionService/Generated/reflection.grpc.swift

Lines changed: 346 additions & 0 deletions
Large diffs are not rendered by default.

Sources/GRPCReflectionService/Generated/reflection.pb.swift

Lines changed: 775 additions & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

dev/protos/fetch.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ rm -rf "$upstream"
3030
# Create new directories to poulate. These are based on proto package name
3131
# rather than source repository name.
3232
mkdir -p "$upstream/grpc/health/v1"
33+
mkdir -p "$upstream/grpc/reflection/v1"
3334

3435
# Copy over the grpc-proto protos.
3536
cp -rp "$checkouts/grpc-proto/grpc/health/v1/health.proto" "$upstream/grpc/health/v1/health.proto"
37+
cp -rp "$checkouts/grpc-proto/grpc/reflection/v1/reflection.proto" "$upstream/grpc/reflection/v1/reflection.proto"

dev/protos/generate.sh

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,65 @@ function generate_health_service {
9494
generate_grpc "$proto" "$(dirname "$proto")" "$output" "Visibility=Package" "Client=true" "Server=true" "UseAccessLevelOnImports=true"
9595
}
9696

97+
function generate_reflection_service {
98+
local proto="$here/upstream/grpc/reflection/v1/reflection.proto"
99+
local output="$root/Sources/GRPCReflectionService/Generated"
100+
101+
# Messages were accidentally leaked into public API, they shouldn't be but we
102+
# can't undo that change until the next major version.
103+
generate_message "$proto" "$(dirname "$proto")" "$output" "Visibility=Package" "UseAccessLevelOnImports=true"
104+
generate_grpc "$proto" "$(dirname "$proto")" "$output" "Visibility=Package" "UseAccessLevelOnImports=true"
105+
}
106+
107+
#- TEST DATA ------------------------------------------------------------------
108+
109+
function generate_reflection_service_descriptor_set {
110+
local proto="$here/upstream/grpc/reflection/v1/reflection.proto"
111+
local proto_path="$here/upstream"
112+
local output="$root/Tests/GRPCReflectionServiceTests/Generated/DescriptorSets/reflection.pb"
113+
114+
invoke_protoc --descriptor_set_out="$output" "$proto" -I "$proto_path" \
115+
--include_source_info \
116+
--include_imports
117+
}
118+
119+
function generate_health_service_descriptor_set {
120+
local proto="$here/upstream/grpc/health/v1/health.proto"
121+
local proto_path="$here/upstream"
122+
local output="$root/Tests/GRPCReflectionServiceTests/Generated/DescriptorSets/health.pb"
123+
124+
invoke_protoc --descriptor_set_out="$output" "$proto" -I "$proto_path" \
125+
--include_source_info \
126+
--include_imports
127+
}
128+
129+
function generate_extended_message_descriptor_set {
130+
local proto="$here/tests/reflection/base_message.proto"
131+
local proto_path="$here/tests/reflection"
132+
local output="$root/Tests/GRPCReflectionServiceTests/Generated/DescriptorSets/base_message.pb"
133+
134+
invoke_protoc --descriptor_set_out="$output" "$proto" -I "$proto_path" \
135+
--include_source_info \
136+
--include_imports
137+
}
138+
139+
function generate_message_with_dependency_descriptor_set {
140+
local proto="$here/tests/reflection/message_with_dependency.proto"
141+
local proto_path="$here/tests/reflection"
142+
local output="$root/Tests/GRPCReflectionServiceTests/Generated/DescriptorSets/message_with_dependency.pb"
143+
144+
invoke_protoc --descriptor_set_out="$output" "$proto" -I "$proto_path" \
145+
--include_source_info \
146+
--include_imports
147+
}
148+
97149
#------------------------------------------------------------------------------
98150

99-
# Interoperability tests
100151
generate_interop_test_service
101-
102-
# Health service
103152
generate_health_service
153+
generate_reflection_service
154+
155+
generate_reflection_service_descriptor_set
156+
generate_health_service_descriptor_set
157+
generate_extended_message_descriptor_set
158+
generate_message_with_dependency_descriptor_set
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
syntax = "proto2";
2+
3+
message BaseMessage {
4+
required string id = 1;
5+
6+
extensions 100 to 101;
7+
}
8+
9+
extend BaseMessage {
10+
optional int32 extended_field = 100;
11+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
syntax = "proto3";
2+
3+
import "google/protobuf/empty.proto";
4+
5+
message MessageWithDependency {
6+
google.protobuf.Empty empty = 1;
7+
}

0 commit comments

Comments
 (0)