pw_protobuf_compiler: Rename generated GN targets
This updates generated protobuf targets to use the format
<target>.<generator> instead of <target>_<generator> to improve
readability.
Change-Id: I52d1e398d5bbece7f79ae87e9a1df7fdce880a6b
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/22222
Reviewed-by: Wyatt Hepler <hepler@google.com>
Reviewed-by: Armando Montanez <amontanez@google.com>
Commit-Queue: Alexei Frolov <frolv@google.com>
diff --git a/pw_protobuf_compiler/proto.gni b/pw_protobuf_compiler/proto.gni
index 37a1c28..59f57e9 100644
--- a/pw_protobuf_compiler/proto.gni
+++ b/pw_protobuf_compiler/proto.gni
@@ -295,7 +295,7 @@
# The generators to use are defined in the pw_protobuf_GENERATORS build
# variable. Each listed generator creates a generated code target called
#
-# <target_name>_<generator>
+# <target_name>.<generator>
#
# For example, with the following definitions:
#
@@ -307,8 +307,8 @@
#
# Two build targets will be created for the declared "my_protos" target.
#
-# "my_protos_pwpb" <-- C++ source_set containing generated proto code
-# "my_protos_py" <-- Python module containing generated proto code
+# "my_protos.pwpb" <-- C++ source_set containing generated proto code
+# "my_protos.py" <-- Python module containing generated proto code
#
# Args:
# sources: List of input .proto files.
@@ -361,20 +361,20 @@
}
foreach(_gen, _generators) {
- _lang_target = "${target_name}_${_gen}"
+ _lang_target = "${target_name}.${_gen}"
_gen_deps = []
if (_gen == "nanopb_rpc") {
# Generated RPC code depends on the library's core protos.
- _gen_deps += [ ":${target_name}_nanopb" ]
+ _gen_deps += [ ":${target_name}.nanopb" ]
}
if (defined(invoker.deps)) {
- _gen_deps += process_file_template(invoker.deps, "{{source}}_${_gen}")
+ _gen_deps += process_file_template(invoker.deps, "{{source}}.${_gen}")
if (_gen == "nanopb_rpc") {
# RPC dependencies also depend on their core generated protos.
- _gen_deps += process_file_template(invoker.deps, "{{source}}_nanopb")
+ _gen_deps += process_file_template(invoker.deps, "{{source}}.nanopb")
}
}
@@ -427,6 +427,12 @@
"generator '$_gen'. Please add support if you require it.",
]))
}
+
+ # TODO(frolv): Remove this after migrating existing code.
+ _legacy_target = "${target_name}_${_gen}"
+ group(_legacy_target) {
+ public_deps = [ ":$_lang_target" ]
+ }
}
# All supported pw_protobuf generators.
@@ -439,7 +445,7 @@
# Create stub versions of the proto library for other protobuf generators.
foreach(_gen, _protobuf_generators - _generators) {
- pw_python_action("${target_name}_${_gen}") {
+ pw_python_action("${target_name}.${_gen}") {
forward_variables_from(invoker, _forwarded_vars)
script = string_join("/",
[
@@ -450,7 +456,7 @@
])
args = [
"--library",
- "${target_name}_${_gen}",
+ target_name,
"--generator",
_gen,
]