pw_protobuf_compiler: Use Python group for proto alias
This allows referring to pw_proto_library Python packages by
abbreviated labels (e.g. //foo:foo.python as //foo:python).
Change-Id: I5cb35054e42593f994228a1bfa5b9d198742f611
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/40140
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
Pigweed-Auto-Submit: Wyatt Hepler <hepler@google.com>
Reviewed-by: Alexei Frolov <frolv@google.com>
diff --git a/pw_protobuf_compiler/docs.rst b/pw_protobuf_compiler/docs.rst
index c228850..eeb1620 100644
--- a/pw_protobuf_compiler/docs.rst
+++ b/pw_protobuf_compiler/docs.rst
@@ -65,6 +65,13 @@
//path/to/my_protos:my_protos.pwpb
//path/to/my_protos:pwpb
+``pw_python_package`` subtargets are also available on the ``python`` subtarget:
+
+.. code-block::
+
+ //path/to/my_protos:my_protos.python.lint
+ //path/to/my_protos:python.lint
+
**Arguments**
* ``sources``: List of input .proto files.
diff --git a/pw_protobuf_compiler/proto.gni b/pw_protobuf_compiler/proto.gni
index 2195b3b..a6ec15e 100644
--- a/pw_protobuf_compiler/proto.gni
+++ b/pw_protobuf_compiler/proto.gni
@@ -612,11 +612,15 @@
# directory (e.g. //foo:nanopb is an alias for //foo:foo.nanopb).
if (get_label_info(":$target_name", "name") ==
get_path_info(get_label_info(":$target_name", "dir"), "name")) {
- foreach(_generator, _protobuf_generators) {
- group("$_generator") {
+ foreach(_generator, _protobuf_generators - [ "python" ]) {
+ group(_generator) {
public_deps = [ ":${invoker.target_name}.$_generator" ]
}
}
+
+ pw_python_group("python") {
+ python_deps = [ ":${invoker.target_name}.python" ]
+ }
}
# If the user attempts to use the target directly instead of one of the