Skip to content

Commit

Permalink
Build protoc plugins in release mode (#647)
Browse files Browse the repository at this point in the history
Motivation:

It's easy for users to build the protoc plugins in debug mode (the
default for the Makefile) without realising. They then have to dig
through the build output to find the right binaries. This should be
easier for users.

Modifications:

- Build the plugins in release mode when invoked via `make plugins`
- Copy the plugins to the current directory after building them

Result:

Easier to find the protoc plugins.
  • Loading branch information
glbrntt authored Dec 9, 2019
1 parent a27e85b commit 27dc451
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ DerivedData/
.build
build
/protoc-gen-swift
/protoc-gen-swiftgrpc
/protoc-gen-grpc-swift
third_party/**
/Echo
/EchoNIO
Expand Down
16 changes: 10 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@
SWIFT:=swift
# Where products will be built; this is the SPM default.
SWIFT_BUILD_PATH:=./.build
SWIFT_BUILD_CONFIGURATION:=debug
SWIFT_FLAGS:=--build-path=${SWIFT_BUILD_PATH} --configuration=${SWIFT_BUILD_CONFIGURATION}
SWIFT_BUILD_CONFIGURATION=debug
SWIFT_FLAGS=--build-path=${SWIFT_BUILD_PATH} --configuration=${SWIFT_BUILD_CONFIGURATION}
# Force release configuration (for plugins)
SWIFT_FLAGS_RELEASE=$(patsubst --configuration=%,--configuration=release,$(SWIFT_FLAGS))

# protoc plugins.
PROTOC_GEN_SWIFT=${SWIFT_BUILD_PATH}/${SWIFT_BUILD_CONFIGURATION}/protoc-gen-swift
PROTOC_GEN_GRPC_SWIFT=${SWIFT_BUILD_PATH}/${SWIFT_BUILD_CONFIGURATION}/protoc-gen-grpc-swift
PROTOC_GEN_SWIFT=${SWIFT_BUILD_PATH}/release/protoc-gen-swift
PROTOC_GEN_GRPC_SWIFT=${SWIFT_BUILD_PATH}/release/protoc-gen-grpc-swift

SWIFT_BUILD:=${SWIFT} build ${SWIFT_FLAGS}
SWIFT_BUILD_RELEASE:=${SWIFT} build ${SWIFT_FLAGS_RELEASE}
SWIFT_TEST:=${SWIFT} test ${SWIFT_FLAGS}
SWIFT_PACKAGE:=${SWIFT} package ${SWIFT_FLAGS}

Expand All @@ -23,12 +26,13 @@ all:

.PHONY:
plugins: ${PROTOC_GEN_SWIFT} ${PROTOC_GEN_GRPC_SWIFT}
cp $^ .

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

${PROTOC_GEN_GRPC_SWIFT}:
${SWIFT_BUILD} --product protoc-gen-grpc-swift
${SWIFT_BUILD_RELEASE} --product protoc-gen-grpc-swift

interop-test-runner:
${SWIFT_BUILD} --product GRPCInteroperabilityTests
Expand Down

0 comments on commit 27dc451

Please sign in to comment.