Commit 42740715 authored by Eric Seckler's avatar Eric Seckler Committed by Commit Bot

protobuf: Allow disabling public_config propagation in gn targets

When depending on multiple similar proto_library targets, each target
can create its own public_config. In the case of perfetto, this adds up
to about a dozen configs, each adding the exact same include path.

Because gn doesn't eliminate duplicate include paths (crbug.com/gn/142),
these configs end up adding duplicate -I command line flags to build
commands. On some bots, this recently caused us to exceed command line
length limits (see crbug.com/1043279).

This patch adds an invoker argument to the proto_library gn template,
which disables the public_config propgation of the proto_library target
and will allow perfetto to define and propagate a separate
public_config instead to avoid this duplication.

Bug: 1043279, gn:142
Change-Id: Ifa68c164b2b4c631bdaf98f63ba5bf7537e8e166
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2010860
Commit-Queue: Eric Seckler <eseckler@chromium.org>
Reviewed-by: default avatarSami Kyöstilä <skyostil@chromium.org>
Reviewed-by: default avatarTommy Nyquist <nyquist@chromium.org>
Cr-Commit-Position: refs/heads/master@{#734043}
parent 7b079656
......@@ -99,6 +99,15 @@
# A list of config labels that will be removed from the configs apllying
# to the source set.
#
# propagate_imports_configs (optional)
# A boolean value (defaults to true) that specifies whether the config
# generated for the library's import directories will be propagated to
# dependents as one of the library target's public_configs. See
# crbug.com/1043279#c11 and crbug.com/gn/142 for why this option exists.
# WARNING: If set to false, the embedder target is responsible for
# propagating a suitable config, so that any dependent headers can resolve
# includes generated by proto imports.
#
# Example:
# proto_library("mylib") {
# sources = [
......@@ -391,9 +400,19 @@ template("proto_library") {
if (generate_cc || generate_with_plugin) {
# Not necessary if all protos are located in the same directory.
if (has_nested_dirs || defined(invoker.import_dirs)) {
# It's not enough to set |include_dirs| for target since public imports
# expose corresponding includes to header files as well.
public_configs += [ ":$config_name" ]
# By default, propagate the config for |include_dirs| to dependent
# targets, so that public imports can be resolved to corresponding
# header files. In some cases, the embedder target handles include
# directory propagation itself, e.g. via a common config.
propagate_imports_configs =
!defined(invoker.propagate_imports_configs) ||
invoker.propagate_imports_configs
if (propagate_imports_configs) {
public_configs += [ ":$config_name" ]
} else {
# Embedder handles include directory propagation to dependents.
configs += [ ":$config_name" ]
}
}
# If using built-in cc generator, the resulting headers reference headers
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment