Add rule to generate javastream proto for perfetto
So that we can use and import the Perfetto protos in framework.
Bug: 309630341
Test: tools/gen_android_bp
Change-Id: I9ff326d07047c329a9e21ebfe0a053aa3165db3d
diff --git a/Android.bp b/Android.bp
index 3b4f823..528172c 100644
--- a/Android.bp
+++ b/Android.bp
@@ -15481,3 +15481,29 @@
"LICENSE",
],
}
+
+// TODO(b/315118713): use list of proto file sources instead of merged proto
+gensrcs {
+ name: "perfetto_trace_javastream_protos",
+ srcs: [
+ "protos/perfetto/trace/perfetto_trace.proto",
+ ],
+ tools: [
+ "aprotoc",
+ "protoc-gen-javastream",
+ "soong_zip",
+ ],
+ cmd: "mkdir -p $(genDir)/$(in) " +
+ "&& $(location aprotoc) " +
+ "--plugin=$(location protoc-gen-javastream) " +
+ "--javastream_out=$(genDir)/$(in) " +
+ "-Iexternal/protobuf/src " +
+ "-Iexternal/perfetto " +
+ "-I . $(in) " +
+ "&& $(location soong_zip) " +
+ "-jar -o $(out) -C $(genDir)/$(in) -D $(genDir)/$(in)",
+ data: [
+ ":libprotobuf-internal-protos",
+ ],
+ output_extension: "srcjar",
+}
diff --git a/Android.bp.extras b/Android.bp.extras
index 3292ad9..9c7b0b0 100644
--- a/Android.bp.extras
+++ b/Android.bp.extras
@@ -171,3 +171,29 @@
"LICENSE",
],
}
+
+// TODO(b/315118713): use list of proto file sources instead of merged proto
+gensrcs {
+ name: "perfetto_trace_javastream_protos",
+ srcs: [
+ "protos/perfetto/trace/perfetto_trace.proto",
+ ],
+ tools: [
+ "aprotoc",
+ "protoc-gen-javastream",
+ "soong_zip",
+ ],
+ cmd: "mkdir -p $(genDir)/$(in) " +
+ "&& $(location aprotoc) " +
+ "--plugin=$(location protoc-gen-javastream) " +
+ "--javastream_out=$(genDir)/$(in) " +
+ "-Iexternal/protobuf/src " +
+ "-Iexternal/perfetto " +
+ "-I . $(in) " +
+ "&& $(location soong_zip) " +
+ "-jar -o $(out) -C $(genDir)/$(in) -D $(genDir)/$(in)",
+ data: [
+ ":libprotobuf-internal-protos",
+ ],
+ output_extension: "srcjar",
+}
diff --git a/tools/gen_android_bp b/tools/gen_android_bp
index 6d00144..c1c1ea1 100755
--- a/tools/gen_android_bp
+++ b/tools/gen_android_bp
@@ -536,6 +536,7 @@
self.apex_available = set()
self.min_sdk_version = None
self.proto = dict()
+ self.output_extension: Optional[str] = None
# The genrule_XXX below are properties that must to be propagated back
# on the module(s) that depend on the genrule.
self.genrule_headers = set()
@@ -587,6 +588,7 @@
self._output_field(output, 'stubs')
self._output_field(output, 'proto')
self._output_field(output, 'main')
+ self._output_field(output, 'output_extension')
target_out = []
self._output_field(target_out, 'android')