rules_swift icon indicating copy to clipboard operation
rules_swift copied to clipboard

Allow `_V2` protoc option

Open Clement-Jean opened this issue 1 year ago • 2 comments

I would like to be able to generate V2 protobuf code (https://github.com/grpc/grpc-swift/blob/f3380d217ebd7f5a939115736bcc19fe1752fee9/Plugins/GRPCSwiftPlugin/plugin.swift#L73). I was able to do it manually like the following:

protoc --swift_out=. \
       --swift_opt=FileNaming=DropPath \
       --grpc-swift_out=. \
       --grpc-swift_opt=Client=true,Server=false,FileNaming=DropPath,_V2=true \
       proto/my.proto

but it seems the rules_swift doesn't accept this option (https://github.com/bazelbuild/rules_swift/blob/86dc0f046269b3001f6f20cec38342c03120a209/proto/compilers/swift_proto_compiler_macros.bzl#L39).

would it be possible to add it?

Clement-Jean avatar Sep 17 '24 07:09 Clement-Jean

cc @AttilaTheFun

keith avatar Jul 05 '25 17:07 keith

@Clement-Jean @keith You can make your own swift_proto_compiler target and plug that into the swift_proto_library rule in order to customize the protoc binary and plugin.

I'm able to use this together with rules_swift_package_manager to generate GRPC-swift V2 protos.

If you want to use the included protoc and grpc-swift in the rules_swift repo, those would need to be updated.

TBH I really would like to get rid of all the hardcoded BUILD.overlay files in the rules_swift repo so we don't need to keep updating them. @keith maybe there's a way we could use prebuilt protoc and grpc plugin binaries?

AttilaTheFun avatar Jul 05 '25 20:07 AttilaTheFun