diff options
author | rtkay123 <dev@kanjala.com> | 2025-08-11 22:02:37 +0200 |
---|---|---|
committer | rtkay123 <dev@kanjala.com> | 2025-08-11 22:02:37 +0200 |
commit | 9c850d6c4d0ed468709c2eb5340d7b64bbb9aa68 (patch) | |
tree | 4aa550323df9372e367932fa6bccf40db9aeac26 /lib/warden-core/build.rs | |
parent | 1ffebf617e651e1008d13bcc8cfbe79c9323c48b (diff) | |
download | warden-9c850d6c4d0ed468709c2eb5340d7b64bbb9aa68.tar.bz2 warden-9c850d6c4d0ed468709c2eb5340d7b64bbb9aa68.zip |
build(config): create crate
Diffstat (limited to 'lib/warden-core/build.rs')
-rw-r--r-- | lib/warden-core/build.rs | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/lib/warden-core/build.rs b/lib/warden-core/build.rs index 37c1c68..9088fd7 100644 --- a/lib/warden-core/build.rs +++ b/lib/warden-core/build.rs @@ -1,12 +1,14 @@ -#[cfg(any(feature = "message", feature = "pseudonyms"))] +#[cfg(any(feature = "message", feature = "pseudonyms", feature = "configuration"))] enum Entity { #[cfg(feature = "message")] ISO2022, #[cfg(feature = "pseudonyms")] Pseudonyms, + #[cfg(feature = "configuration")] + Configuration, } -#[cfg(any(feature = "message", feature = "pseudonyms"))] +#[cfg(any(feature = "message", feature = "pseudonyms", feature = "configuration"))] impl Entity { fn protos(&self) -> Vec<&'static str> { let mut res: Vec<&'static str> = vec![]; @@ -16,6 +18,14 @@ impl Entity { vec!["proto/warden_message.proto"] } + + #[cfg(feature = "configuration")] + fn configuration_protos() -> Vec<&'static str> { + vec![ + "proto/configuration/routing.proto", + ] + } + #[cfg(feature = "pseudonyms")] fn pseudonyms_protos() -> Vec<&'static str> { vec![ @@ -35,6 +45,10 @@ impl Entity { Entity::Pseudonyms => { res.extend(pseudonyms_protos()); } + #[cfg(feature = "configuration")] + Entity::Configuration => { + res.extend(configuration_protos()); + } } res } @@ -43,7 +57,7 @@ impl Entity { fn main() -> Result<(), Box<dyn std::error::Error>> { println!("cargo:rerun-if-changed=../../proto"); - #[cfg(any(feature = "message", feature = "pseudonyms"))] + #[cfg(any(feature = "message", feature = "pseudonyms", feature = "configuration"))] let mut protos: Vec<&'static str> = vec![]; #[cfg(feature = "message")] @@ -52,13 +66,17 @@ fn main() -> Result<(), Box<dyn std::error::Error>> { #[cfg(feature = "pseudonyms")] protos.extend(Entity::Pseudonyms.protos()); - #[cfg(any(feature = "message", feature = "pseudonyms"))] + #[cfg(feature = "configuration")] + protos.extend(Entity::Configuration.protos()); + + #[cfg(any(feature = "message", feature = "pseudonyms", feature = "configuration"))] build_proto(&protos)?; + Ok(()) } -#[cfg(any(feature = "message", feature = "pseudonyms"))] +#[cfg(any(feature = "message", feature = "pseudonyms", feature = "configuration"))] fn build_proto(protos: &[&str]) -> Result<(), Box<dyn std::error::Error>> { let out_dir = std::path::PathBuf::from(std::env::var("OUT_DIR").unwrap()); @@ -82,7 +100,7 @@ fn build_proto(protos: &[&str]) -> Result<(), Box<dyn std::error::Error>> { Ok(()) } -#[cfg(all(feature = "serde", any(feature = "pseudonyms", feature = "message")))] +#[cfg(all(feature = "serde", any(feature = "pseudonyms", feature = "message", feature = "configuration")))] fn add_serde(config: tonic_prost_build::Builder) -> tonic_prost_build::Builder { let config = config.type_attribute( ".", @@ -98,7 +116,7 @@ fn add_serde(config: tonic_prost_build::Builder) -> tonic_prost_build::Builder { config } -#[cfg(all(feature = "openapi", any(feature = "message", feature = "pseudonyms")))] +#[cfg(all(feature = "openapi", any(feature = "message", feature = "pseudonyms", feature = "configuration")))] fn add_openapi(config: tonic_prost_build::Builder) -> tonic_prost_build::Builder { config.type_attribute(".", "#[derive(utoipa::ToSchema)]") } |