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_cpu_exception_armv7m/BUILD.gn b/pw_cpu_exception_armv7m/BUILD.gn
index a3a4b35..7cd545f 100644
--- a/pw_cpu_exception_armv7m/BUILD.gn
+++ b/pw_cpu_exception_armv7m/BUILD.gn
@@ -43,7 +43,7 @@
dir_pw_stream,
]
public = [ "public/pw_cpu_exception_armv7m/proto_dump.h" ]
- deps = [ ":cpu_state_protos_pwpb" ]
+ deps = [ ":cpu_state_protos.pwpb" ]
sources = [ "proto_dump.cc" ]
}
diff --git a/pw_log_rpc/BUILD.gn b/pw_log_rpc/BUILD.gn
index 6cbaef1..b2eac44 100644
--- a/pw_log_rpc/BUILD.gn
+++ b/pw_log_rpc/BUILD.gn
@@ -35,7 +35,7 @@
"$dir_pw_status",
]
sources = [ "log_queue.cc" ]
- deps = [ ":protos_pwpb" ]
+ deps = [ ":protos.pwpb" ]
}
pw_proto_library("protos") {
@@ -50,7 +50,7 @@
sources = [ "log_queue_test.cc" ]
deps = [
":log_queue",
- ":protos_pwpb",
+ ":protos.pwpb",
dir_pw_protobuf,
]
}
diff --git a/pw_metric/BUILD.gn b/pw_metric/BUILD.gn
index 86b31ff..0abc449 100644
--- a/pw_metric/BUILD.gn
+++ b/pw_metric/BUILD.gn
@@ -63,12 +63,12 @@
pw_source_set("metric_service_nanopb") {
public_configs = [ ":default_config" ]
public_deps = [
- ":metric_service_proto_nanopb_rpc",
+ ":metric_service_proto.nanopb_rpc",
":pw_metric",
]
public = [ "public/pw_metric/metric_service_nanopb.h" ]
deps = [
- ":metric_service_proto_nanopb_rpc",
+ ":metric_service_proto.nanopb_rpc",
"$dir_pw_containers:vector",
dir_pw_tokenizer,
]
diff --git a/pw_protobuf/BUILD.gn b/pw_protobuf/BUILD.gn
index e83139a..2923932 100644
--- a/pw_protobuf/BUILD.gn
+++ b/pw_protobuf/BUILD.gn
@@ -99,7 +99,7 @@
}
pw_test("codegen_test") {
- deps = [ ":codegen_test_protos_pwpb" ]
+ deps = [ ":codegen_test_protos.pwpb" ]
sources = [ "codegen_test.cc" ]
}
diff --git a/pw_protobuf_compiler/BUILD.gn b/pw_protobuf_compiler/BUILD.gn
index 793e0a7..76549c3 100644
--- a/pw_protobuf_compiler/BUILD.gn
+++ b/pw_protobuf_compiler/BUILD.gn
@@ -35,7 +35,7 @@
if (_compiling_for_nanopb) {
pw_test("nanopb_test") {
- deps = [ ":nanopb_test_protos_nanopb" ]
+ deps = [ ":nanopb_test_protos.nanopb" ]
sources = [ "nanopb_test.cc" ]
}
diff --git a/pw_protobuf_compiler/docs.rst b/pw_protobuf_compiler/docs.rst
index 9f04a26..1b8f16c 100644
--- a/pw_protobuf_compiler/docs.rst
+++ b/pw_protobuf_compiler/docs.rst
@@ -45,13 +45,13 @@
.. code::
- pw_protobuf_GENERATORS = [ "pwpb", "py" ]
+ pw_protobuf_GENERATORS = [ "pwpb", "go" ]
pw_proto_library("test_protos") {
sources = [ "test.proto" ]
}
-Two targets are created, named ``test_protos_pwpb`` and ``test_protos_py``,
+Two targets are created, named ``test_protos.pwpb`` and ``test_protos.go``,
containing the generated code from their respective generators.
**Arguments**
@@ -74,11 +74,11 @@
pw_proto_library("my_other_protos") {
sources = [
- "baz.proto", # imports foo.proto
+ "baz.proto", # imports foo.proto
]
- deps = [
- ":my_protos",
- ]
+
+ # Proto libraries depend on other proto libraries directly.
+ deps = [ ":my_protos" ]
}
source_set("my_cc_code") {
@@ -87,7 +87,7 @@
"bar.cc",
"baz.cc",
]
- deps = [
- ":my_other_protos_cc",
- ]
+
+ # When depending on protos in a source_set, specify the generator suffix.
+ deps = [ ":my_other_protos.pwpb" ]
}
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,
]
diff --git a/pw_protobuf_compiler/py/pw_protobuf_compiler/proto_target_invalid.py b/pw_protobuf_compiler/py/pw_protobuf_compiler/proto_target_invalid.py
index 7878dfa..72894b4 100644
--- a/pw_protobuf_compiler/py/pw_protobuf_compiler/proto_target_invalid.py
+++ b/pw_protobuf_compiler/py/pw_protobuf_compiler/proto_target_invalid.py
@@ -58,7 +58,7 @@
_LOG.error('Depend on one of the following targets instead:')
_LOG.error('')
for gen in args.generators:
- _LOG.error(' //%s:%s_%s', relative_dir, args.target, gen)
+ _LOG.error(' //%s:%s.%s', relative_dir, args.target, gen)
_LOG.error('')
return 1
diff --git a/pw_rpc/BUILD.gn b/pw_rpc/BUILD.gn
index 26a0042..b524080 100644
--- a/pw_rpc/BUILD.gn
+++ b/pw_rpc/BUILD.gn
@@ -67,7 +67,7 @@
pw_source_set("common") {
public_configs = [ ":default_config" ]
public_deps = [
- ":protos_pwpb",
+ ":protos.pwpb",
"$dir_pw_containers:intrusive_list",
dir_pw_assert,
dir_pw_bytes,
@@ -221,7 +221,7 @@
pw_test("service_test") {
deps = [
- ":protos_pwpb",
+ ":protos.pwpb",
":server",
dir_pw_assert,
]
@@ -246,7 +246,7 @@
pw_test("server_test") {
deps = [
- ":protos_pwpb",
+ ":protos.pwpb",
":server",
":test_utils",
dir_pw_assert,
diff --git a/pw_rpc/nanopb/BUILD.gn b/pw_rpc/nanopb/BUILD.gn
index 452c0d5..532f641 100644
--- a/pw_rpc/nanopb/BUILD.gn
+++ b/pw_rpc/nanopb/BUILD.gn
@@ -95,7 +95,7 @@
pw_source_set("echo_service") {
public_configs = [ ":public" ]
- public_deps = [ "..:echo_service_proto_nanopb_rpc" ]
+ public_deps = [ "..:echo_service_proto.nanopb_rpc" ]
sources = [ "public/pw_rpc/echo_service_nanopb.h" ]
}
@@ -118,7 +118,7 @@
deps = [
":client",
":internal_test_utils",
- "..:test_protos_nanopb",
+ "..:test_protos.nanopb",
"..:test_utils",
]
sources = [ "nanopb_client_call_test.cc" ]
@@ -129,7 +129,7 @@
deps = [
":test_method_context",
"..:server",
- "..:test_protos_nanopb_rpc",
+ "..:test_protos.nanopb_rpc",
]
sources = [ "codegen_test.cc" ]
enable_if = dir_pw_third_party_nanopb != ""
@@ -140,7 +140,7 @@
":internal_test_utils",
":method_union",
"..:server",
- "..:test_protos_nanopb",
+ "..:test_protos.nanopb",
"..:test_utils",
]
sources = [ "nanopb_method_test.cc" ]
@@ -151,7 +151,7 @@
deps = [
":internal_test_utils",
":method_union",
- "..:test_protos_nanopb",
+ "..:test_protos.nanopb",
"..:test_utils",
]
sources = [ "nanopb_method_union_test.cc" ]
@@ -174,7 +174,7 @@
":method",
":service_method_traits",
":test_method_context",
- "..:test_protos_nanopb_rpc",
+ "..:test_protos.nanopb_rpc",
]
sources = [ "service_method_traits_test.cc" ]
enable_if = dir_pw_third_party_nanopb != ""
diff --git a/pw_rpc/raw/BUILD.gn b/pw_rpc/raw/BUILD.gn
index 2faa9c8..0e2bf3e 100644
--- a/pw_rpc/raw/BUILD.gn
+++ b/pw_rpc/raw/BUILD.gn
@@ -50,7 +50,7 @@
pw_test("raw_method_test") {
deps = [
":method_union",
- "..:test_protos_pwpb",
+ "..:test_protos.pwpb",
"..:test_utils",
dir_pw_protobuf,
]
@@ -60,7 +60,7 @@
pw_test("raw_method_union_test") {
deps = [
":method_union",
- "..:test_protos_pwpb",
+ "..:test_protos.pwpb",
"..:test_utils",
dir_pw_protobuf,
]
diff --git a/pw_target_runner/go/src/pigweed.dev/pw_target_runner/BUILD.gn b/pw_target_runner/go/src/pigweed.dev/pw_target_runner/BUILD.gn
index 746f549..8fff0e2 100644
--- a/pw_target_runner/go/src/pigweed.dev/pw_target_runner/BUILD.gn
+++ b/pw_target_runner/go/src/pigweed.dev/pw_target_runner/BUILD.gn
@@ -22,7 +22,7 @@
"server.go",
"worker_pool.go",
]
- deps = [ "$dir_pw_target_runner:target_runner_proto_go" ]
+ deps = [ "$dir_pw_target_runner:target_runner_proto.go" ]
external_deps = [ "google.golang.org/grpc" ]
gopath = "$dir_pw_target_runner/go"
}
diff --git a/pw_target_runner/go/src/pigweed.dev/pw_target_runner_client/BUILD.gn b/pw_target_runner/go/src/pigweed.dev/pw_target_runner_client/BUILD.gn
index 4375e0c..b8d7cd8 100644
--- a/pw_target_runner/go/src/pigweed.dev/pw_target_runner_client/BUILD.gn
+++ b/pw_target_runner/go/src/pigweed.dev/pw_target_runner_client/BUILD.gn
@@ -18,6 +18,6 @@
pw_go_package("pw_target_runner_client") {
sources = [ "main.go" ]
- deps = [ "$dir_pw_target_runner:target_runner_proto_go" ]
+ deps = [ "$dir_pw_target_runner:target_runner_proto.go" ]
gopath = "$dir_pw_target_runner/go"
}
diff --git a/pw_target_runner/go/src/pigweed.dev/pw_target_runner_server/BUILD.gn b/pw_target_runner/go/src/pigweed.dev/pw_target_runner_server/BUILD.gn
index ac2c4cc..b1956ce 100644
--- a/pw_target_runner/go/src/pigweed.dev/pw_target_runner_server/BUILD.gn
+++ b/pw_target_runner/go/src/pigweed.dev/pw_target_runner_server/BUILD.gn
@@ -19,7 +19,7 @@
pw_go_package("pw_target_runner_server") {
sources = [ "main.go" ]
deps = [
- "$dir_pw_target_runner:exec_server_config_proto_go",
+ "$dir_pw_target_runner:exec_server_config_proto.go",
"$dir_pw_target_runner/go/src/pigweed.dev/pw_target_runner",
]
external_deps = [ "github.com/golang/protobuf/proto" ]