Add support for protoc plugins

Add a proto.plugin property to allow specifying a custom protoc
plugin to generate the code.

Fixes: 70706119
Test: m am StreamingProtoTest
Change-Id: I1ecdd346284b42bbcc8297019d98d2cd564eb94c
diff --git a/cc/proto_test.go b/cc/proto_test.go
index 6fee924..4f0de78 100644
--- a/cc/proto_test.go
+++ b/cc/proto_test.go
@@ -17,6 +17,8 @@
 import (
 	"strings"
 	"testing"
+
+	"android/soong/android"
 )
 
 func TestProto(t *testing.T) {
@@ -33,4 +35,37 @@
 			t.Errorf("expected '--cpp_out' in %q", cmd)
 		}
 	})
+
+	t.Run("plugin", func(t *testing.T) {
+		ctx := testCc(t, `
+		cc_binary_host {
+			name: "protoc-gen-foobar",
+			stl: "none",
+		}
+
+		cc_library_shared {
+			name: "libfoo",
+			srcs: ["a.proto"],
+			proto: {
+				plugin: "foobar",
+			},
+		}`)
+
+		buildOS := android.BuildOs.String()
+
+		proto := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_core_shared").Output("proto/a.pb.cc")
+		foobar := ctx.ModuleForTests("protoc-gen-foobar", buildOS+"_x86_64")
+
+		cmd := proto.RuleParams.Command
+		if w := "--foobar_out="; !strings.Contains(cmd, w) {
+			t.Errorf("expected %q in %q", w, cmd)
+		}
+
+		foobarPath := foobar.Module().(android.HostToolProvider).HostToolPath().String()
+
+		if w := "--plugin=protoc-gen-foobar=" + foobarPath; !strings.Contains(cmd, w) {
+			t.Errorf("expected %q in %q", w, cmd)
+		}
+	})
+
 }