From 5ece5258ef2de2360107dba50e21b1de55644581 Mon Sep 17 00:00:00 2001 From: Mohit Saini Date: Thu, 23 Jun 2022 16:44:35 +0100 Subject: [PATCH] Add exclude_imports flag to proto_library |exclude_imports| flag is set in some of the perfetto's proto_library targets to indicate that we don't need to generate the proto-descriptor for the protos included in those `x.proto` files. In this CL we use that flag to conditionally pass `--include_imports` argument to protoc. This is similar to the CL (https://crrev.com/c/2632759) Bug: b:236945541 Change-Id: I0689003978096798d1e966ec8485cd6af7237804 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3721616 Reviewed-by: Michael Achenbach Commit-Queue: Mohit Saini Cr-Commit-Position: refs/heads/main@{#81356} --- gni/proto_library.gni | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/gni/proto_library.gni b/gni/proto_library.gni index 583057e0a5..a8690999f9 100644 --- a/gni/proto_library.gni +++ b/gni/proto_library.gni @@ -76,6 +76,17 @@ template("proto_library") { out_dir = "$root_gen_dir/" + proto_out_dir rel_out_dir = rebase_path(out_dir, root_build_dir) + # exclude_imports is only used for generating the descriptor. Therefore, the + # check needs to be here to avoid complaints from GN about the unused + # variable. + if (generate_descriptor != "") { + if (defined(invoker.exclude_imports)) { + exclude_imports = invoker.exclude_imports + } else { + exclude_imports = false + } + } + # Prevent unused errors when generating descriptor only. if (generate_descriptor != "") { not_needed([ "rel_out_dir" ]) @@ -163,8 +174,10 @@ template("proto_library") { } if (generate_descriptor != "") { depfile = "$out_dir/$generate_descriptor.d" + if (!exclude_imports) { + args += [ "--include_imports" ] + } args += [ - "--include_imports", "--descriptor_set_out", rebase_path("$out_dir/$generate_descriptor", root_build_dir), "--dependency_out",