From 90b1ac7cf3a1ac8a2cd7f82409e3aba1b328fe1b Mon Sep 17 00:00:00 2001 From: Richard Leitner Date: Wed, 11 Jan 2023 13:34:49 +0100 Subject: [PATCH 1/3] tonic-build: update prost-build to v0.11.6 Signed-off-by: Richard Leitner --- tests/disable_comments/Cargo.toml | 2 +- tests/extern_path/uuid/Cargo.toml | 2 +- tests/wellknown-compiled/Cargo.toml | 2 +- tonic-build/Cargo.toml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/disable_comments/Cargo.toml b/tests/disable_comments/Cargo.toml index 90bc0e4ed..c694fc01d 100644 --- a/tests/disable_comments/Cargo.toml +++ b/tests/disable_comments/Cargo.toml @@ -13,5 +13,5 @@ prost = "0.11" tonic = { path = "../../tonic" } [build-dependencies] -prost-build = "0.11.4" +prost-build = "0.11.6" tonic-build = { path = "../../tonic-build" } diff --git a/tests/extern_path/uuid/Cargo.toml b/tests/extern_path/uuid/Cargo.toml index b65b8fe0b..df1e49716 100644 --- a/tests/extern_path/uuid/Cargo.toml +++ b/tests/extern_path/uuid/Cargo.toml @@ -11,4 +11,4 @@ version = "0.1.0" [dependencies] prost = "0.11" [build-dependencies] -prost-build = "0.11.4" +prost-build = "0.11.6" diff --git a/tests/wellknown-compiled/Cargo.toml b/tests/wellknown-compiled/Cargo.toml index 2b816d884..60842b4ec 100644 --- a/tests/wellknown-compiled/Cargo.toml +++ b/tests/wellknown-compiled/Cargo.toml @@ -16,5 +16,5 @@ prost = "0.11" tonic = {path = "../../tonic"} [build-dependencies] -prost-build = "0.11.4" +prost-build = "0.11.6" tonic-build = {path = "../../tonic-build"} diff --git a/tonic-build/Cargo.toml b/tonic-build/Cargo.toml index 74d096e18..6a4f4b964 100644 --- a/tonic-build/Cargo.toml +++ b/tonic-build/Cargo.toml @@ -17,7 +17,7 @@ version = "0.8.4" [dependencies] prettyplease = { version = "0.1" } proc-macro2 = "1.0" -prost-build = { version = "0.11.4", optional = true } +prost-build = { version = "0.11.6", optional = true } quote = "1.0" syn = "1.0" From bd5e0d31c26a40f270d5736a6524467d6173d0a6 Mon Sep 17 00:00:00 2001 From: Richard Leitner Date: Wed, 11 Jan 2023 13:22:42 +0100 Subject: [PATCH 2/3] tonic-build: prost: add enum_attribute configuration Signed-off-by: Richard Leitner --- tonic-build/src/prost.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tonic-build/src/prost.rs b/tonic-build/src/prost.rs index 5368c34f6..3843e3a79 100644 --- a/tonic-build/src/prost.rs +++ b/tonic-build/src/prost.rs @@ -23,6 +23,7 @@ pub fn configure() -> Builder { out_dir: None, extern_path: Vec::new(), field_attributes: Vec::new(), + enum_attributes: Vec::new(), type_attributes: Vec::new(), server_attributes: Attributes::default(), client_attributes: Attributes::default(), @@ -225,6 +226,7 @@ pub struct Builder { pub(crate) extern_path: Vec<(String, String)>, pub(crate) field_attributes: Vec<(String, String)>, pub(crate) type_attributes: Vec<(String, String)>, + pub(crate) enum_attributes: Vec<(String, String)>, pub(crate) server_attributes: Attributes, pub(crate) client_attributes: Attributes, pub(crate) proto_path: String, @@ -306,6 +308,15 @@ impl Builder { self } + /// Add additional attribute to matched enums. + /// + /// Passed directly to `prost_build::Config.enum_attribute`. + pub fn enum_attribute, A: AsRef>(mut self, path: P, attribute: A) -> Self { + self.enum_attributes + .push((path.as_ref().to_string(), attribute.as_ref().to_string())); + self + } + /// Add additional attribute to matched server `mod`s. Matches on the package name. pub fn server_mod_attribute, A: AsRef>( mut self, @@ -447,6 +458,9 @@ impl Builder { for (prost_path, attr) in self.type_attributes.iter() { config.type_attribute(prost_path, attr); } + for (prost_path, attr) in self.enum_attributes.iter() { + config.enum_attribute(prost_path, attr); + } if self.compile_well_known_types { config.compile_well_known_types(); } From e3251f0db285e9b60cd4ff943fe8506a48f15722 Mon Sep 17 00:00:00 2001 From: Richard Leitner Date: Thu, 12 Jan 2023 08:32:29 +0100 Subject: [PATCH 3/3] tonic-build: prost: add message_attribute configuration Signed-off-by: Richard Leitner --- tonic-build/src/prost.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tonic-build/src/prost.rs b/tonic-build/src/prost.rs index 3843e3a79..623705b72 100644 --- a/tonic-build/src/prost.rs +++ b/tonic-build/src/prost.rs @@ -23,6 +23,7 @@ pub fn configure() -> Builder { out_dir: None, extern_path: Vec::new(), field_attributes: Vec::new(), + message_attributes: Vec::new(), enum_attributes: Vec::new(), type_attributes: Vec::new(), server_attributes: Attributes::default(), @@ -226,6 +227,7 @@ pub struct Builder { pub(crate) extern_path: Vec<(String, String)>, pub(crate) field_attributes: Vec<(String, String)>, pub(crate) type_attributes: Vec<(String, String)>, + pub(crate) message_attributes: Vec<(String, String)>, pub(crate) enum_attributes: Vec<(String, String)>, pub(crate) server_attributes: Attributes, pub(crate) client_attributes: Attributes, @@ -308,6 +310,19 @@ impl Builder { self } + /// Add additional attribute to matched messages. + /// + /// Passed directly to `prost_build::Config.message_attribute`. + pub fn message_attribute, A: AsRef>( + mut self, + path: P, + attribute: A, + ) -> Self { + self.message_attributes + .push((path.as_ref().to_string(), attribute.as_ref().to_string())); + self + } + /// Add additional attribute to matched enums. /// /// Passed directly to `prost_build::Config.enum_attribute`. @@ -458,6 +473,9 @@ impl Builder { for (prost_path, attr) in self.type_attributes.iter() { config.type_attribute(prost_path, attr); } + for (prost_path, attr) in self.message_attributes.iter() { + config.message_attribute(prost_path, attr); + } for (prost_path, attr) in self.enum_attributes.iter() { config.enum_attribute(prost_path, attr); }