diff options
Diffstat (limited to 'lib/sellershut-core/build.rs')
-rw-r--r-- | lib/sellershut-core/build.rs | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/sellershut-core/build.rs b/lib/sellershut-core/build.rs index 8ff48f1..110bc22 100644 --- a/lib/sellershut-core/build.rs +++ b/lib/sellershut-core/build.rs @@ -1,10 +1,12 @@ -#[cfg(feature = "auth")] +#[cfg(any(feature = "auth", feature = "profile"))] enum Entity { #[cfg(feature = "auth")] Auth, + #[cfg(feature = "profile")] + Profile, } -#[cfg(feature = "auth")] +#[cfg(any(feature = "auth", feature = "profile"))] impl Entity { fn protos(&self) -> Vec<&'static str> { let mut res: Vec<&'static str> = vec![]; @@ -13,6 +15,10 @@ impl Entity { #[cfg(feature = "auth")] Entity::Auth => { res.extend(vec!["proto/auth/auth.proto"]); + }, + #[cfg(feature = "profile")] + Entity::Profile => { + res.extend(vec!["proto/profile/profile.proto"]); } } res @@ -25,10 +31,13 @@ fn main() -> Result<(), Box<dyn std::error::Error>> { #[cfg(feature = "auth")] build_proto("auth", Entity::Auth); + #[cfg(feature = "profile")] + build_proto("profile", Entity::Profile); + Ok(()) } -#[cfg(feature = "auth")] +#[cfg(any(feature = "auth", feature = "profile"))] fn build_proto(package: &str, entity: Entity) { let out_dir = std::path::PathBuf::from(std::env::var("OUT_DIR").unwrap()); @@ -72,7 +81,7 @@ fn build_proto(package: &str, entity: Entity) { .compile_protos(&entity.protos(), include_paths).unwrap(); } -#[cfg(all(feature = "serde", feature = "auth",))] +#[cfg(all(feature = "serde", any(feature = "auth",feature = "profile")))] fn add_serde(config: tonic_build::Builder) -> tonic_build::Builder { config.type_attribute( ".", |