perfetto: rework proto descriptor gen to inform gn about deps
The state before today:
1) All the non descriptor rules (lite, zero, gen, ipc) all need
to know about all the recursive proto deps to ensure rebuilds
when files are changeds (even though techincally the protoc
compiler does not actually look at this info)
2) For descriptor rules, we actually rely on protoc to do all
the lookups on its side.
3) For Bazel/Android.bp, we hacked soemthing custom to propogate
the depenendencies instead of using gn properly (at the time
I did not understand gn enough to write the correct templates)
The problem:
If we are using RBE, we need GN to know about deps so that scheduling
of compile actions can correctly figure out which sources are necessary
to build which others. We cannot just rely on protoc for this
The solution:
Unhack a bunch of custom stufff around how we handle descriptors to
teach GN properly about the deps. This involes the following:
1) Make source_sets groups instead of actions which allows proper
propogation of deps (which was something badly missing with action)
2) Remove source_set and descriptor from being proto_generators:
proto_generators now strictly corresponds to C++ codegen.
3) Always generate a source_set target (behind the scenes) to allow
depending on it from any other proto target (this is very similar
to how Bazel/Blaze work)
4) Make descriptors just rely on generate_descriptor option and
specify the top level proto with descriptor_root_source (which is
what will be passed to protoc in the end)
This should have a minimal diff for bazel/gn which fixing the RBE
problem. It also reduces the complexity of a bunch of random proto
build rules throughout the codebase.
Really as hard as it is to believe, this is noop change...
Change-Id: Ieab7ea58efe75ad919d45763965529b3cda02751
diff --git a/Android.bp b/Android.bp
index bd33cb0..a7de450 100644
--- a/Android.bp
+++ b/Android.bp
@@ -11697,27 +11697,6 @@
],
}
-// GN: //src/protozero:test_messages_descriptor
-genrule {
- name: "perfetto_src_protozero_test_messages_descriptor",
- srcs: [
- "src/protozero/test/example_proto/extensions.proto",
- "src/protozero/test/example_proto/library.proto",
- "src/protozero/test/example_proto/library_internals/galaxies.proto",
- "src/protozero/test/example_proto/other_package/test_messages.proto",
- "src/protozero/test/example_proto/subpackage/test_messages.proto",
- "src/protozero/test/example_proto/test_messages.proto",
- "src/protozero/test/example_proto/upper_import.proto",
- ],
- tools: [
- "aprotoc",
- ],
- cmd: "mkdir -p $(genDir)/external/perfetto/ && $(location aprotoc) --proto_path=external/perfetto --descriptor_set_out=$(out) $(in)",
- out: [
- "perfetto_src_protozero_test_messages_descriptor.bin",
- ],
-}
-
// GN: //src/protozero:testing_messages_cpp
filegroup {
name: "perfetto_src_protozero_testing_messages_cpp",
@@ -11778,6 +11757,27 @@
],
}
+// GN: //src/protozero:testing_messages_descriptor
+genrule {
+ name: "perfetto_src_protozero_testing_messages_descriptor",
+ srcs: [
+ "src/protozero/test/example_proto/extensions.proto",
+ "src/protozero/test/example_proto/library.proto",
+ "src/protozero/test/example_proto/library_internals/galaxies.proto",
+ "src/protozero/test/example_proto/other_package/test_messages.proto",
+ "src/protozero/test/example_proto/subpackage/test_messages.proto",
+ "src/protozero/test/example_proto/test_messages.proto",
+ "src/protozero/test/example_proto/upper_import.proto",
+ ],
+ tools: [
+ "aprotoc",
+ ],
+ cmd: "mkdir -p $(genDir)/external/perfetto/ && $(location aprotoc) --proto_path=external/perfetto --descriptor_set_out=$(out) $(in)",
+ out: [
+ "perfetto_src_protozero_testing_messages_descriptor.bin",
+ ],
+}
+
// GN: //src/protozero:testing_messages_lite
filegroup {
name: "perfetto_src_protozero_testing_messages_lite",
@@ -12359,7 +12359,7 @@
genrule {
name: "perfetto_src_trace_processor_gen_cc_test_messages_descriptor",
srcs: [
- ":perfetto_src_protozero_test_messages_descriptor",
+ ":perfetto_src_protozero_testing_messages_descriptor",
],
cmd: "$(location tools/gen_cc_proto_descriptor.py) --gen_dir=$(genDir) --cpp_out=$(out) $(in)",
out: [