diff --git a/.gitignore b/.gitignore index ce94e4bc..960e5c22 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,5 @@ Cargo.lock /rust-toolchain.toml .idea -.vscode \ No newline at end of file +.vscode +.pregenerated diff --git a/src/v0.rs b/src/v0.rs index 9b998fa8..bd85faa3 100644 --- a/src/v0.rs +++ b/src/v0.rs @@ -26,4 +26,18 @@ impl FromStr for NvmeAnaState { } } +// Include Rust sources generated by protobuf. +#[cfg(target_os = "linux")] include!(concat!(env!("OUT_DIR"), "/mayastor.rs")); + +// In order to IDE to work properly with protobuf definitions on non-Linux platform, +// one can copy generated bindings (mayastor.rs) from a Linux target and put them +// to .pregenerated directory. +// This has to be done every time Mayastor API V0 is changed. +#[cfg(not(target_os = "linux"))] +mod v0_generated { + include!("../.pregenerated/mayastor.rs"); +} + +#[cfg(not(target_os = "linux"))] +pub use v0_generated::*; diff --git a/src/v1.rs b/src/v1.rs index 05515845..b0517315 100644 --- a/src/v1.rs +++ b/src/v1.rs @@ -1,10 +1,20 @@ //! Module to access v1 version of grpc APIs use std::str::FromStr; + // dont export the raw pb generated code mod pb { + // Include Rust sources generated by protobuf. #![allow(unknown_lints)] #![allow(clippy::derive_partial_eq_without_eq)] + #[cfg(target_os = "linux")] include!(concat!(env!("OUT_DIR"), "/mayastor.v1.rs")); + + // In order to IDE to work properly with protobuf definitions on non-Linux platform, + // one can copy generated bindings (mayastor.v1.rs) from a Linux target and put them + // to .pregenerated directory. + // This has to be done every time Mayastor API V1 is changed. + #[cfg(not(target_os = "linux"))] + include!("../.pregenerated/mayastor.v1.rs"); } pub mod common {