Move proto compilation to RuleBuilder

Using blueprint.Rule for protoc commands was causing code duplication
because there was no good way to run the same protoc for cc, java and
python but then run custom source packaging steps for java and python.
Move most of the code into a common function that returns a
RuleBuilder, and then let java and python add their own commands at
the end of the rule.

Bug: 70706119
Test: All Soong tests
Test: m checkbuild
Change-Id: Ic692136775d273bcc4f4de99620ab4878667c83a
diff --git a/python/python.go b/python/python.go
index 6eb9b6e..3c3c396 100644
--- a/python/python.go
+++ b/python/python.go
@@ -516,9 +516,11 @@
 	}
 	var zips android.Paths
 	if len(protoSrcs) > 0 {
+		protoFlags := android.GetProtoFlags(ctx, &p.protoProperties)
+		protoFlags.OutTypeFlag = "--python_out"
+
 		for _, srcFile := range protoSrcs {
-			zip := genProto(ctx, &p.protoProperties, srcFile,
-				android.ProtoFlags(ctx, &p.protoProperties), pkgPath)
+			zip := genProto(ctx, srcFile, protoFlags, pkgPath)
 			zips = append(zips, zip)
 		}
 	}