Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6f205093 authored by Colin Cross's avatar Colin Cross
Browse files

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
parent f02f3095
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -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...)