Skip to content

Commit

Permalink
make kernel bindings mutually exclusive
Browse files Browse the repository at this point in the history
When the crate is built with --all-features we have a bunch of errors
because we are not excluding the 4.14 and 4.20 bindings. Whenever
all features is specified now, the 4.20 bindings are going to be
used. This change is required for switching to rust-vmm-ci where
the tests are run using --all-features flag.

Signed-off-by: Andreea Florescu <[email protected]>
  • Loading branch information
andreeaflorescu authored and Samuel Ortiz committed Jan 7, 2020
1 parent 7b1ddde commit 190dbaa
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 36 deletions.
25 changes: 13 additions & 12 deletions src/arm/mod.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
// Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

#[cfg(feature = "kvm-v4_14_0")]
// Export 4.14 bindings when the feature kvm-v4_20_0 is not specified.
#[cfg(all(feature = "kvm-v4_14_0", not(feature = "kvm-v4_20_0")))]
mod bindings_v4_14_0;
#[cfg(feature = "kvm-v4_20_0")]
mod bindings_v4_20_0;

// Major hack to have a default version in case no feature is specified:
// If no version is specified by using the features, just use the latest one
// which currently is 4.20.
#[cfg(all(not(feature = "kvm-v4_14_0"), not(feature = "kvm-v4_20_0")))]
// Export 4.20 bindings when kvm-v4_20_0 is specified or no kernel version
// related features are specified.
#[cfg(any(
feature = "kvm-v4_20_0",
all(not(feature = "kvm-v4_14_0"), not(feature = "kvm-v4_20_0"))
))]
mod bindings_v4_20_0;

pub mod bindings {
#[cfg(feature = "kvm-v4_14_0")]
#[cfg(all(feature = "kvm-v4_14_0", not(feature = "kvm-v4_20_0")))]
pub use super::bindings_v4_14_0::*;

#[cfg(feature = "kvm-v4_20_0")]
pub use super::bindings_v4_20_0::*;

#[cfg(all(not(feature = "kvm-v4_14_0"), not(feature = "kvm-v4_20_0")))]
#[cfg(any(
feature = "kvm-v4_20_0",
all(not(feature = "kvm-v4_14_0"), not(feature = "kvm-v4_20_0"))
))]
pub use super::bindings_v4_20_0::*;
}
25 changes: 13 additions & 12 deletions src/arm64/mod.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
// Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

#[cfg(feature = "kvm-v4_14_0")]
// Export 4.14 bindings when the feature kvm-v4_20_0 is not specified.
#[cfg(all(feature = "kvm-v4_14_0", not(feature = "kvm-v4_20_0")))]
mod bindings_v4_14_0;
#[cfg(feature = "kvm-v4_20_0")]
mod bindings_v4_20_0;

// Major hack to have a default version in case no feature is specified:
// If no version is specified by using the features, just use the latest one
// which currently is 4.20.
#[cfg(all(not(feature = "kvm-v4_14_0"), not(feature = "kvm-v4_20_0")))]
// Export 4.20 bindings when kvm-v4_20_0 is specified or no kernel version
// related features are specified.
#[cfg(any(
feature = "kvm-v4_20_0",
all(not(feature = "kvm-v4_14_0"), not(feature = "kvm-v4_20_0"))
))]
mod bindings_v4_20_0;

pub mod bindings {
#[cfg(feature = "kvm-v4_14_0")]
#[cfg(all(feature = "kvm-v4_14_0", not(feature = "kvm-v4_20_0")))]
pub use super::bindings_v4_14_0::*;

#[cfg(feature = "kvm-v4_20_0")]
pub use super::bindings_v4_20_0::*;

#[cfg(all(not(feature = "kvm-v4_14_0"), not(feature = "kvm-v4_20_0")))]
#[cfg(any(
feature = "kvm-v4_20_0",
all(not(feature = "kvm-v4_14_0"), not(feature = "kvm-v4_20_0"))
))]
pub use super::bindings_v4_20_0::*;
}
25 changes: 13 additions & 12 deletions src/x86/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,26 @@
#[cfg(feature = "fam-wrappers")]
mod fam_wrappers;

#[cfg(feature = "kvm-v4_14_0")]
// Export 4.14 bindings when the feature kvm-v4_20_0 is not specified.
#[cfg(all(feature = "kvm-v4_14_0", not(feature = "kvm-v4_20_0")))]
mod bindings_v4_14_0;
#[cfg(feature = "kvm-v4_20_0")]
mod bindings_v4_20_0;

// Major hack to have a default version in case no feature is specified:
// If no version is specified by using the features, just use the latest one
// which currently is 4.20.
#[cfg(all(not(feature = "kvm-v4_14_0"), not(feature = "kvm-v4_20_0")))]
// Export 4.20 bindings when kvm-v4_20_0 is specified or no kernel version
// related features are specified.
#[cfg(any(
feature = "kvm-v4_20_0",
all(not(feature = "kvm-v4_14_0"), not(feature = "kvm-v4_20_0"))
))]
mod bindings_v4_20_0;

pub mod bindings {
#[cfg(feature = "kvm-v4_14_0")]
#[cfg(all(feature = "kvm-v4_14_0", not(feature = "kvm-v4_20_0")))]
pub use super::bindings_v4_14_0::*;

#[cfg(feature = "kvm-v4_20_0")]
pub use super::bindings_v4_20_0::*;

#[cfg(all(not(feature = "kvm-v4_14_0"), not(feature = "kvm-v4_20_0")))]
#[cfg(any(
feature = "kvm-v4_20_0",
all(not(feature = "kvm-v4_14_0"), not(feature = "kvm-v4_20_0"))
))]
pub use super::bindings_v4_20_0::*;

#[cfg(feature = "fam-wrappers")]
Expand Down

0 comments on commit 190dbaa

Please sign in to comment.