Browse Source

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

Motivation:

We refer to this package as 'grpc-swift', the 'protoc' plugin should be
consistent with this.

The plugin was also not listed as a product of the package which means
that a dependency is not able to build the plugin withough checking out
the repository.

Modifications:

- Rename the protoc plugin to 'protoc-gen-grpc-swift'.
- Update references to this.
- Include the plugin as an executable product.

Result:

- More consistent naming.
- It is possible to build the plugin with `swift build --product
  protoc-gen-grpc-swift` when grpc-swift is used as a
  dependency.
George Barnett 6 years ago
parent
commit
ca6831549c

+ 1 - 1
Docker/Dockerfile

@@ -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

+ 2 - 2
Examples/Cocoapods/NaturalLanguage/RUNME

@@ -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
@@ -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 \;

+ 2 - 2
Examples/Google/Datastore/RUNME

@@ -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
@@ -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 \;

+ 2 - 2
Examples/Google/NaturalLanguage/RUNME

@@ -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
@@ -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 \;

+ 2 - 2
Examples/Google/Spanner/RUNME

@@ -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
@@ -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 \;

+ 9 - 9
Makefile

@@ -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
@@ -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 ####################################################################
 
@@ -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. ######################################################################

+ 2 - 1
Package.swift

@@ -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:
@@ -71,7 +72,7 @@ let package = Package(
 
     // The `protoc` plugin.
     .target(
-      name: "protoc-gen-swiftgrpc",
+      name: "protoc-gen-grpc-swift",
       dependencies: [
         "SwiftProtobuf",
         "SwiftProtobufPluginLibrary",

+ 5 - 5
README.md

@@ -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`.
 
@@ -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
@@ -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

+ 7 - 7
Sources/GRPCInteroperabilityTestModels/generate.sh

@@ -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"
@@ -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"

+ 0 - 0
Sources/protoc-gen-swiftgrpc/Generator-Client.swift → Sources/protoc-gen-grpc-swift/Generator-Client.swift


+ 0 - 0
Sources/protoc-gen-swiftgrpc/Generator-Names.swift → Sources/protoc-gen-grpc-swift/Generator-Names.swift


+ 0 - 0
Sources/protoc-gen-swiftgrpc/Generator-Server.swift → Sources/protoc-gen-grpc-swift/Generator-Server.swift


+ 0 - 0
Sources/protoc-gen-swiftgrpc/Generator.swift → Sources/protoc-gen-grpc-swift/Generator.swift


+ 5 - 5
Sources/protoc-gen-swiftgrpc/README.md → Sources/protoc-gen-grpc-swift/README.md

@@ -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.

+ 0 - 0
Sources/protoc-gen-swiftgrpc/StreamingType.swift → Sources/protoc-gen-grpc-swift/StreamingType.swift


+ 0 - 0
Sources/protoc-gen-swiftgrpc/io.swift → Sources/protoc-gen-grpc-swift/io.swift


+ 0 - 0
Sources/protoc-gen-swiftgrpc/main.swift → Sources/protoc-gen-grpc-swift/main.swift


+ 0 - 0
Sources/protoc-gen-swiftgrpc/options.swift → Sources/protoc-gen-grpc-swift/options.swift