diff --git a/build.rs b/build.rs index 48815471ce..522489af28 100644 --- a/build.rs +++ b/build.rs @@ -118,9 +118,7 @@ fn main() { println!("cargo:rerun-if-changed=build.rs"); println!("cargo:rerun-if-changed=seccomp"); - if env::var("CARGO_CFG_TARGET_FAMILY").unwrap() != "unix" - || env::var("CARGO_FEATURE_CHROMEOS").is_ok() - { + if env::var("CARGO_CFG_TARGET_FAMILY").unwrap() != "unix" { return; } @@ -134,6 +132,13 @@ fn main() { let target = env::var("TARGET").unwrap(); + // Disable embedding of seccomp policy files on ChromeOS builds. + println!("cargo:rerun-if-env-changed=CROSVM_BUILD_VARIANT"); + if env::var("CROSVM_BUILD_VARIANT").unwrap_or(String::new()) == "chromeos" { + fs::write(out_dir.join("bpf_includes.in"), "Default::default()").unwrap(); + return; + } + generate_preprocessed(&minijail_dir, &out_dir); generate_llvm_ir(&minijail_dir, &out_dir, &target); generate_constants_json(&minijail_dir, &out_dir); diff --git a/media/libvda/build.rs b/media/libvda/build.rs index 50d2d01fd2..0a18c1fc46 100644 --- a/media/libvda/build.rs +++ b/media/libvda/build.rs @@ -3,21 +3,12 @@ // found in the LICENSE file. fn main() { - // Skip installing dependencies when generating documents. - if std::env::var("CARGO_DOC").is_ok() { - return; + // libvda is only avalable on chromeos build. + // To enable clippy checks with this feature enabled upstream we will just skip + // linking the library, allowing the crate to be compiled, but not linked. + println!("cargo:rerun-if-env-changed=CROSVM_BUILD_VARIANT"); + if std::env::var("CROSVM_BUILD_VARIANT").unwrap_or(String::new()) == "chromeos" { + pkg_config::probe_library("libvda").unwrap(); + println!("cargo:rustc-link-lib=dylib=vda"); } - - #[allow(clippy::single_match)] - match pkg_config::probe_library("libvda") { - Ok(_) => (), - // Ignore pkg-config failures on non-chromeos platforms to allow cargo-clippy to run even - // if libvda.pc doesn't exist. - #[cfg(not(feature = "chromeos"))] - Err(_) => (), - #[cfg(feature = "chromeos")] - Err(e) => panic!("{}", e), - }; - - println!("cargo:rustc-link-lib=dylib=vda"); } diff --git a/src/crosvm/sys/unix/jail_helpers.rs b/src/crosvm/sys/unix/jail_helpers.rs index 9d067fd904..b0192c1704 100644 --- a/src/crosvm/sys/unix/jail_helpers.rs +++ b/src/crosvm/sys/unix/jail_helpers.rs @@ -17,16 +17,8 @@ use once_cell::sync::Lazy; use crate::crosvm::config::JailConfig; -static EMBEDDED_BPFS: Lazy>> = Lazy::new(|| { - #[cfg(not(feature = "chromeos"))] - { - include!(concat!(env!("OUT_DIR"), "/bpf_includes.in")) - } - #[cfg(feature = "chromeos")] - { - std::collections::HashMap::<&str, Vec>::new() - } -}); +static EMBEDDED_BPFS: Lazy>> = + Lazy::new(|| include!(concat!(env!("OUT_DIR"), "/bpf_includes.in"))); pub(super) struct SandboxConfig<'a> { pub(super) limit_caps: bool,