Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename the plugin: protoc-gen-swiftgrpc -> protoc-gen-grpc-swift #584

Merged
merged 1 commit into from
Sep 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ RUN curl -O -L https://github.com/google/protobuf/releases/download/v${PROTOC_VE
RUN git clone https://github.com/grpc/grpc-swift \
&& cd grpc-swift \
&& make \
&& cp protoc-gen-swift protoc-gen-swiftgrpc /usr/bin \
&& cp protoc-gen-swift protoc-gen-grpc-swift /usr/bin \
&& cd / \
&& rm -rf grpc-swift
4 changes: 2 additions & 2 deletions Examples/Cocoapods/NaturalLanguage/RUNME
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# needed to build the example.
#
# Note that it requires protoc, protoc-gen-swift, and
# protoc-gen-swiftgrpc binaries.
# protoc-gen-grpc-swift binaries.

if [ ! -d "googleapis" ]; then
curl -L -O https://github.com/googleapis/googleapis/archive/master.zip
Expand All @@ -21,7 +21,7 @@ protoc \
-Igoogleapis \
-I../../Google/common/include \
--swift_out=googleapis \
--swiftgrpc_out=googleapis
--grpc-swift_out=googleapis

# move Swift files to the sources directory
find googleapis -name "*.swift" -exec mv {} NaturalLanguage \;
4 changes: 2 additions & 2 deletions Examples/Google/Datastore/RUNME
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# needed to build the example.
#
# Note that it requires updated protoc, protoc-gen-swift, and
# protoc-gen-swiftgrpc binaries and assumes that protoc-gen-swift
# protoc-gen-grpc-swift binaries and assumes that protoc-gen-swift
# is installed in $HOME/local/bin.

if [ ! -d "googleapis" ]; then
Expand All @@ -21,7 +21,7 @@ protoc \
googleapis/google/type/latlng.proto \
-Igoogleapis \
--swift_out=googleapis \
--swiftgrpc_out=googleapis
--grpc-swift_out=googleapis

# move Swift files to the Sources directory
find googleapis -name "*.swift" -exec mv {} Sources \;
Expand Down
4 changes: 2 additions & 2 deletions Examples/Google/NaturalLanguage/RUNME
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# needed to build the example.
#
# Note that it requires updated protoc, protoc-gen-swift, and
# protoc-gen-swiftgrpc binaries and assumes that protoc-gen-swift
# protoc-gen-grpc-swift binaries and assumes that protoc-gen-swift
# is installed in $HOME/local/bin.

if [ ! -d "googleapis" ]; then
Expand All @@ -22,7 +22,7 @@ protoc \
-Igoogleapis \
-I../common/include \
--swift_out=googleapis \
--swiftgrpc_out=googleapis
--grpc-swift_out=googleapis

# move Swift files to the Sources directory
find googleapis -name "*.swift" -exec mv {} Sources \;
4 changes: 2 additions & 2 deletions Examples/Google/Spanner/RUNME
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# needed to build the example.
#
# Note that it requires updated protoc, protoc-gen-swift, and
# protoc-gen-swiftgrpc binaries and assumes that protoc-gen-swift
# protoc-gen-grpc-swift binaries and assumes that protoc-gen-swift
# is installed in $HOME/local/bin.

if [ ! -d "googleapis" ]; then
Expand All @@ -30,7 +30,7 @@ protoc \
google/iam/v1/policy.proto \
-Igoogleapis \
--swift_out=googleapis \
--swiftgrpc_out=googleapis
--grpc-swift_out=googleapis

# move Swift files to the Sources directory
find googleapis -name "*.swift" -exec mv {} Sources \;
18 changes: 9 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ XCODEPROJ:=GRPC.xcodeproj
all:
${SWIFT_BUILD}

plugins: protoc-gen-swift protoc-gen-swiftgrpc
plugins: protoc-gen-swift protoc-gen-grpc-swift

protoc-gen-swift:
${SWIFT_BUILD} --product protoc-gen-swift

protoc-gen-swiftgrpc:
${SWIFT_BUILD} --product protoc-gen-swiftgrpc
protoc-gen-grpc-swift:
${SWIFT_BUILD} --product protoc-gen-grpc-swift

interop-test-runner:
${SWIFT_BUILD} --product InteroperabilityTestRunner
Expand Down Expand Up @@ -51,11 +51,11 @@ generate-echo: plugins
protoc Sources/Examples/Echo/Model/echo.proto \
--proto_path=Sources/Examples/Echo/Model \
--plugin=${SWIFT_BUILD_PATH}/${SWIFT_BUILD_CONFIGURATION}/protoc-gen-swift \
--plugin=${SWIFT_BUILD_PATH}/${SWIFT_BUILD_CONFIGURATION}/protoc-gen-swiftgrpc \
--plugin=${SWIFT_BUILD_PATH}/${SWIFT_BUILD_CONFIGURATION}/protoc-gen-grpc-swift \
--swift_opt=Visibility=Public \
--swift_out=Sources/Examples/Echo/Model/Generated \
--swiftgrpc_opt=Visibility=Public \
--swiftgrpc_out=Sources/Examples/Echo/Model/Generated
--grpc-swift_opt=Visibility=Public \
--grpc-swift_out=Sources/Examples/Echo/Model/Generated

### Testing ####################################################################

Expand All @@ -73,9 +73,9 @@ test-plugin: plugins
protoc Sources/Examples/Echo/Model/echo.proto \
--proto_path=Sources/Examples/Echo/Model \
--plugin=${SWIFT_BUILD_PATH}/${SWIFT_BUILD_CONFIGURATION}/protoc-gen-swift \
--plugin=${SWIFT_BUILD_PATH}/${SWIFT_BUILD_CONFIGURATION}/protoc-gen-swiftgrpc \
--swiftgrpc_opt=Visibility=Public \
--swiftgrpc_out=/tmp
--plugin=${SWIFT_BUILD_PATH}/${SWIFT_BUILD_CONFIGURATION}/protoc-gen-grpc-swift \
--grpc-swift_opt=Visibility=Public \
--grpc-swift_out=/tmp
diff -u /tmp/echo.grpc.swift Sources/Examples/Echo/Model/Generated/echo.grpc.swift

### Misc. ######################################################################
Expand Down
3 changes: 2 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ let package = Package(
.executable(name: "ConnectionBackoffInteropTestRunner", targets: ["GRPCConnectionBackoffInteropTest"]),
.executable(name: "PerformanceTestRunner", targets: ["GRPCPerformanceTests"]),
.executable(name: "Echo", targets: ["Echo"]),
.executable(name: "protoc-gen-grpc-swift", targets: ["protoc-gen-grpc-swift"]),
],
dependencies: [
// GRPC dependencies:
Expand Down Expand Up @@ -71,7 +72,7 @@ let package = Package(

// The `protoc` plugin.
.target(
name: "protoc-gen-swiftgrpc",
name: "protoc-gen-grpc-swift",
dependencies: [
"SwiftProtobuf",
"SwiftProtobufPluginLibrary",
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ Binary releases of `protoc`, the Protocol Buffer Compiler, are available on
To build the plugins, run `make plugin` in the main directory. This uses the
Swift Package Manager to build both of the necessary plugins:
`protoc-gen-swift`, which generates Protocol Buffer support code and
`protoc-gen-swiftgrpc`, which generates gRPC interface code.
`protoc-gen-grpc-swift`, which generates gRPC interface code.

To install these plugins, just copy the two executables (`protoc-gen-swift` and
`protoc-gen-swiftgrpc`) that show up in the main directory into a directory that
`protoc-gen-grpc-swift`) that show up in the main directory into a directory that
is part of your `PATH` environment variable. Alternatively the full path to the
plugins can be specified when using `protoc`.

Expand Down Expand Up @@ -148,12 +148,12 @@ directory:
protoc echo.proto --swift_out=.
```

gRPC Swift provides a plugin (`protoc-gen-swiftgrpc`) to generate the client
gRPC Swift provides a plugin (`protoc-gen-grpc-swift`) to generate the client
and server for the `Echo` service defined above. It can be invoked to produce
`echo.grpc.swift` as such:

```sh
protoc echo.proto --swiftgrpc_out=.
protoc echo.proto --grpc-swift_out=.
```

By default both the client and service code is generated (see [Plugin
Expand Down Expand Up @@ -450,7 +450,7 @@ separated from the output directory by a colon.
For example, to generate only client stubs:

```sh
protoc <your proto> --swiftgrpc_out=Client=true,Server=false:.
protoc <your proto> --grpc-swift_out=Client=true,Server=false:.
```

## License
Expand Down
14 changes: 7 additions & 7 deletions Sources/GRPCInteroperabilityTestModels/generate.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

PLUGIN_SWIFT=../../.build/debug/protoc-gen-swift
PLUGIN_SWIFTGRPC=../../.build/debug/protoc-gen-swiftgrpc
PLUGIN_SWIFTGRPC=../../.build/debug/protoc-gen-grpc-swift
PROTO="src/proto/grpc/testing/test.proto"

OUTPUT="Generated"
Expand All @@ -13,24 +13,24 @@ protoc "src/proto/grpc/testing/test.proto" \
--plugin=${PLUGIN_SWIFTGRPC} \
--swift_out=${OUTPUT} \
--swift_opt=FileNaming=${FILE_NAMING},Visibility=${VISIBILITY} \
--swiftgrpc_out=${OUTPUT} \
--swiftgrpc_opt=FileNaming=${FILE_NAMING},Visibility=${VISIBILITY}
--grpc-swift_out=${OUTPUT} \
--grpc-swift_opt=FileNaming=${FILE_NAMING},Visibility=${VISIBILITY}

protoc "src/proto/grpc/testing/empty.proto" \
--plugin=${PLUGIN_SWIFT} \
--plugin=${PLUGIN_SWIFTGRPC} \
--swift_out=${OUTPUT} \
--swift_opt=FileNaming=${FILE_NAMING},Visibility=${VISIBILITY} \
--swiftgrpc_out=${OUTPUT} \
--swiftgrpc_opt=FileNaming=${FILE_NAMING},Visibility=${VISIBILITY}
--grpc-swift_out=${OUTPUT} \
--grpc-swift_opt=FileNaming=${FILE_NAMING},Visibility=${VISIBILITY}

protoc "src/proto/grpc/testing/messages.proto" \
--plugin=${PLUGIN_SWIFT} \
--plugin=${PLUGIN_SWIFTGRPC} \
--swift_out=${OUTPUT} \
--swift_opt=FileNaming=${FILE_NAMING},Visibility=${VISIBILITY} \
--swiftgrpc_out=${OUTPUT} \
--swiftgrpc_opt=FileNaming=${FILE_NAMING},Visibility=${VISIBILITY}
--grpc-swift_out=${OUTPUT} \
--grpc-swift_opt=FileNaming=${FILE_NAMING},Visibility=${VISIBILITY}

echo "The generated code needs to be modified to support testing an unimplemented method."
echo "On the server side, the generated code needs to be removed so the server has no"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ This directory contains the Swift gRPC plugin for `protoc`,
the Protocol Buffer Compiler.

It is built with the Swift Package Manager and the included
Makefile. The resulting binary is named `protoc-gen-swiftgrpc`
and can be called from `protoc` by adding the `--swiftgrpc_out`
Makefile. The resulting binary is named `protoc-gen-grpc-swift`
and can be called from `protoc` by adding the `--grpc-swift_out`
command-line option and `--plugin` option. For example, here's an
invocation from the Makefile:

protoc ../Examples/Echo/echo.proto --proto_path=../Examples/Echo --plugin=./protoc-gen-swiftgrpc --swiftgrpc_out=.
protoc ../Examples/Echo/echo.proto --proto_path=../Examples/Echo --plugin=./protoc-gen-grpc-swift --grpc-swift_out=.

The Swift gRPC plugin can be installed by placing the
`protoc-gen-swiftgrpc` binary into one of the directories in your
path. Specifying `--swiftgrpc_out` to `protoc` will automatically
`protoc-gen-grpc-swift` binary into one of the directories in your
path. Specifying `--grpc-swift_out` to `protoc` will automatically
search the `PATH` environment variable for this binary.