Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(build): support for non-Linux IDEs #82

Merged
merged 1 commit into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ Cargo.lock

/rust-toolchain.toml
.idea
.vscode
.vscode
.pregenerated
14 changes: 14 additions & 0 deletions src/v0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
10 changes: 10 additions & 0 deletions src/v1.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
Loading