Skip to content

Commit a6c388d

Browse files
committed
vhost: add build.rs file to fix docs.rs build
When using `vhost` crate as a dependency, (e.g. in vhost-user-backend), RUSTDOC_disable_feature_compat_errors is not set for the docs.rs build. We must detect it in the build script using DOCS_RS env var. Otherwise, building vhost-user-backend in docs.rs fails with: error: Both `postcopy` and `xen` features can not be enabled at the same time. --> vhost/src/lib.rs:63:1 | 63 | compile_error!("Both `postcopy` and `xen` features can not be enabled at the same time."); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Also add the same build.rs file for vhost-user-backend since it uses the same cfg. Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
1 parent 4770776 commit a6c388d

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

vhost-user-backend/build.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// SPDX-License-Identifier: Apache-2.0 or BSD-3-Clause
2+
3+
fn main() {
4+
println!("cargo::rerun-if-env-changed=DOCS_RS");
5+
if std::env::var("DOCS_RS").is_ok() {
6+
println!("cargo::rustc-cfg=RUSTDOC_disable_feature_compat_errors");
7+
}
8+
}

vhost/build.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// SPDX-License-Identifier: Apache-2.0 or BSD-3-Clause
2+
3+
fn main() {
4+
println!("cargo::rerun-if-env-changed=DOCS_RS");
5+
if std::env::var("DOCS_RS").is_ok() {
6+
println!("cargo::rustc-cfg=RUSTDOC_disable_feature_compat_errors");
7+
}
8+
}

0 commit comments

Comments
 (0)