From 6f205093a4a72b6f91f799cdc32a3ccee442d9cb Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Tue, 13 Aug 2019 16:53:19 -0700 Subject: [PATCH] Make javamicro a plugin Treat proto.type: "javamicro" as a plugin by explicitly passing the path to protoc-gen-javamicro. This allows removing the javamicro customizations from the core plugin code. Bug: 117607748 Test: m checkbuild Change-Id: I703a8c1b788d77dcf6c656e79cab1c02171aa94e --- java/proto.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/java/proto.go b/java/proto.go index 0ec64997e..22a3eed2a 100644 --- a/java/proto.go +++ b/java/proto.go @@ -75,9 +75,11 @@ func protoFlags(ctx android.ModuleContext, j *CompilerProperties, p *android.Pro flags.proto = android.GetProtoFlags(ctx, p) if String(p.Proto.Plugin) == "" { + var typeToPlugin string switch String(p.Proto.Type) { case "micro": flags.proto.OutTypeFlag = "--javamicro_out" + typeToPlugin = "javamicro" case "nano": flags.proto.OutTypeFlag = "--javanano_out" case "lite": @@ -89,6 +91,12 @@ func protoFlags(ctx android.ModuleContext, j *CompilerProperties, p *android.Pro ctx.PropertyErrorf("proto.type", "unknown proto type %q", String(p.Proto.Type)) } + + if typeToPlugin != "" { + hostTool := ctx.Config().HostToolPath(ctx, "protoc-gen-"+typeToPlugin) + flags.proto.Deps = append(flags.proto.Deps, hostTool) + flags.proto.Flags = append(flags.proto.Flags, "--plugin=protoc-gen-"+typeToPlugin+"="+hostTool.String()) + } } flags.proto.OutParams = append(flags.proto.OutParams, j.Proto.Output_params...)