summaryrefslogtreecommitdiff
path: root/rust/protobuf.go
diff options
context:
space:
mode:
author Matthew Maurer <mmaurer@google.com> 2020-11-06 01:40:41 +0000
committer Matthew Maurer <mmaurer@google.com> 2020-11-06 01:40:41 +0000
commit5819e58fdcdcfffa5718d252102e3a050dc10c1f (patch)
tree54bc52f848ce5e1a5636d13dadb9b6929e6319d4 /rust/protobuf.go
parentb0a713acf918d87137cb8cfe7de77d47c111f483 (diff)
rust: Fix GRPC generator invocation
When using the grpc generator, the plugin expects to also have access to the protobuf generator. This patch ensures that aprotoc will use the Soong copy of the protobuf generator, rather than trying to use a locally installed version from PATH. Test: m nothing Change-Id: I26da4d18c97017da7d8cd9515a07a2b7b2575342
Diffstat (limited to 'rust/protobuf.go')
-rw-r--r--rust/protobuf.go22
1 files changed, 13 insertions, 9 deletions
diff --git a/rust/protobuf.go b/rust/protobuf.go
index 28a4597f9..ca4015402 100644
--- a/rust/protobuf.go
+++ b/rust/protobuf.go
@@ -55,17 +55,17 @@ type protobufDecorator struct {
func (proto *protobufDecorator) GenerateSource(ctx ModuleContext, deps PathDeps) android.Path {
var protoFlags android.ProtoFlags
- var pluginPath android.Path
+ var pluginPaths android.Paths
protoFlags.OutTypeFlag = "--rust_out"
outDir := android.PathForModuleOut(ctx)
- pluginPath, protoFlags = proto.setupPlugin(ctx, protoFlags, outDir)
+ pluginPaths, protoFlags = proto.setupPlugin(ctx, protoFlags, outDir)
protoFlags.Flags = append(protoFlags.Flags, defaultProtobufFlags...)
protoFlags.Flags = append(protoFlags.Flags, proto.Properties.Proto_flags...)
- protoFlags.Deps = append(protoFlags.Deps, pluginPath)
+ protoFlags.Deps = append(protoFlags.Deps, pluginPaths...)
protoFile := android.OptionalPathForModuleSrc(ctx, proto.Properties.Proto)
if !protoFile.Valid() {
@@ -90,21 +90,25 @@ func (proto *protobufDecorator) GenerateSource(ctx ModuleContext, deps PathDeps)
return modFile
}
-func (proto *protobufDecorator) setupPlugin(ctx ModuleContext, protoFlags android.ProtoFlags, outDir android.ModuleOutPath) (android.Path, android.ProtoFlags) {
- var pluginPath android.Path
+func (proto *protobufDecorator) setupPlugin(ctx ModuleContext, protoFlags android.ProtoFlags, outDir android.ModuleOutPath) (android.Paths, android.ProtoFlags) {
+ pluginPaths := []android.Path{}
if proto.plugin == Protobuf {
- pluginPath = ctx.Config().HostToolPath(ctx, "protoc-gen-rust")
+ pluginPath := ctx.Config().HostToolPath(ctx, "protoc-gen-rust")
+ pluginPaths = append(pluginPaths, pluginPath)
protoFlags.Flags = append(protoFlags.Flags, "--plugin="+pluginPath.String())
} else if proto.plugin == Grpc {
- pluginPath = ctx.Config().HostToolPath(ctx, "grpc_rust_plugin")
+ grpcPath := ctx.Config().HostToolPath(ctx, "grpc_rust_plugin")
+ protobufPath := ctx.Config().HostToolPath(ctx, "protoc-gen-rust")
+ pluginPaths = append(pluginPaths, grpcPath, protobufPath)
protoFlags.Flags = append(protoFlags.Flags, "--grpc_out="+outDir.String())
- protoFlags.Flags = append(protoFlags.Flags, "--plugin=protoc-gen-grpc="+pluginPath.String())
+ protoFlags.Flags = append(protoFlags.Flags, "--plugin=protoc-gen-grpc="+grpcPath.String())
+ protoFlags.Flags = append(protoFlags.Flags, "--plugin=protoc-gen-rust="+protobufPath.String())
} else {
ctx.ModuleErrorf("Unknown protobuf plugin type requested")
}
- return pluginPath, protoFlags
+ return pluginPaths, protoFlags
}
func (proto *protobufDecorator) SourceProviderProps() []interface{} {