Skip to content

Commit b7d8e22

Browse files
authored
Update fetch and generate scripts for reflection (#20)
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 b7d8e22

File tree

12 files changed

+1345
-3
lines changed

12 files changed

+1345
-3
lines changed

.licenseignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,4 @@ dev/version-bump.commit.template
3939
LICENSE
4040
**/*.swift
4141
dev/protos/**/*.proto
42+
**/*.pb

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.
362 Bytes
Binary file not shown.
3.35 KB
Binary file not shown.
2.5 KB
Binary file not shown.
7.48 KB
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: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,63 @@ 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+
generate_message "$proto" "$(dirname "$proto")" "$output" "Visibility=Package" "UseAccessLevelOnImports=true"
102+
generate_grpc "$proto" "$(dirname "$proto")" "$output" "Visibility=Package" "UseAccessLevelOnImports=true"
103+
}
104+
105+
#- TEST DATA ------------------------------------------------------------------
106+
107+
function generate_reflection_service_descriptor_set {
108+
local proto="$here/upstream/grpc/reflection/v1/reflection.proto"
109+
local proto_path="$here/upstream"
110+
local output="$root/Tests/GRPCReflectionServiceTests/Generated/DescriptorSets/reflection.pb"
111+
112+
invoke_protoc --descriptor_set_out="$output" "$proto" -I "$proto_path" \
113+
--include_source_info \
114+
--include_imports
115+
}
116+
117+
function generate_health_service_descriptor_set {
118+
local proto="$here/upstream/grpc/health/v1/health.proto"
119+
local proto_path="$here/upstream"
120+
local output="$root/Tests/GRPCReflectionServiceTests/Generated/DescriptorSets/health.pb"
121+
122+
invoke_protoc --descriptor_set_out="$output" "$proto" -I "$proto_path" \
123+
--include_source_info \
124+
--include_imports
125+
}
126+
127+
function generate_base_message_descriptor_set {
128+
local proto="$here/tests/reflection/base_message.proto"
129+
local proto_path="$here/tests/reflection"
130+
local output="$root/Tests/GRPCReflectionServiceTests/Generated/DescriptorSets/base_message.pb"
131+
132+
invoke_protoc --descriptor_set_out="$output" "$proto" -I "$proto_path" \
133+
--include_source_info \
134+
--include_imports
135+
}
136+
137+
function generate_message_with_dependency_descriptor_set {
138+
local proto="$here/tests/reflection/message_with_dependency.proto"
139+
local proto_path="$here/tests/reflection"
140+
local output="$root/Tests/GRPCReflectionServiceTests/Generated/DescriptorSets/message_with_dependency.pb"
141+
142+
invoke_protoc --descriptor_set_out="$output" "$proto" -I "$proto_path" \
143+
--include_source_info \
144+
--include_imports
145+
}
146+
97147
#------------------------------------------------------------------------------
98148

99-
# Interoperability tests
100149
generate_interop_test_service
101-
102-
# Health service
103150
generate_health_service
151+
generate_reflection_service
152+
153+
generate_reflection_service_descriptor_set
154+
generate_health_service_descriptor_set
155+
generate_base_message_descriptor_set
156+
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+
}

0 commit comments

Comments
 (0)