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
This commit is contained in:
Colin Cross
2019-08-13 16:53:19 -07:00
parent f02f30952d
commit 6f205093a4

View File

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