mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2024-11-24 12:34:31 +00:00
Modify builds via CROSVM_BUILD_VARIANT env var
We currently use cargo features to modify the build process, which makes them non-additive and prevents us from moving towards using --all-features in the future. To change build.rs behavior to integrate with downstream build systems (e.g. use pkg_config only on chromeos) we will use the newly added CROSVM_BUILD_VARIANT env variable. Currently only used by ChromeOS, but not limited to it. For now, CROSVM_BUILD_VARIANT=chromeos will prevent the embedding of seccomp policies. BUG=b:244618505 TEST=Test in combination with https://crrev.com/c/3923813 Change-Id: I2bfe999b5252740d57c73c4a85d73bd343c8259e Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3926325 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Dennis Kempin <denniskempin@google.com>
This commit is contained in:
parent
4c211a4d41
commit
a2ecd1eb50
3 changed files with 17 additions and 29 deletions
11
build.rs
11
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);
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -17,16 +17,8 @@ use once_cell::sync::Lazy;
|
|||
|
||||
use crate::crosvm::config::JailConfig;
|
||||
|
||||
static EMBEDDED_BPFS: Lazy<std::collections::HashMap<&str, Vec<u8>>> = Lazy::new(|| {
|
||||
#[cfg(not(feature = "chromeos"))]
|
||||
{
|
||||
include!(concat!(env!("OUT_DIR"), "/bpf_includes.in"))
|
||||
}
|
||||
#[cfg(feature = "chromeos")]
|
||||
{
|
||||
std::collections::HashMap::<&str, Vec<u8>>::new()
|
||||
}
|
||||
});
|
||||
static EMBEDDED_BPFS: Lazy<std::collections::HashMap<&str, Vec<u8>>> =
|
||||
Lazy::new(|| include!(concat!(env!("OUT_DIR"), "/bpf_includes.in")));
|
||||
|
||||
pub(super) struct SandboxConfig<'a> {
|
||||
pub(super) limit_caps: bool,
|
||||
|
|
Loading…
Reference in a new issue