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

Reduce the build time of the tests #3304

Merged
merged 6 commits into from
Mar 11, 2024
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: 0 additions & 3 deletions src/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions src/lib/linux-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,28 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
default = ["rustix"]
std = []
rustix = ["dep:rustix"]
c_bindings = ["dep:shadow-build-common", "dep:cbindgen"]

[dependencies]
bitflags = "2.4.1"
log = { version = "0.4.20", default-features = false }
shadow-pod = { path = "../pod" }
static_assertions = "1.1.0"
vasi = { path = "../vasi" }
num_enum = { version = "0.7.1", default-features=false }
num_enum = { version = "0.7.1", default-features = false }
memoffset = "0.9.0"
bytemuck = "1.14.0"
linux-syscall = "1.0.0"
linux-errno = "1.0.1"
naked-function = "0.1.5"
linux-raw-sys = "0.6.3"
rustix = { optional=true, version = "0.38.28", default-features=false, features = ["process"] }
rustix = { optional = true, version = "0.38.28", default-features = false, features = ["process"] }

[dev-dependencies]
rustix = { version = "0.38.28", default-features=false, features = ["thread", "process", "time"] }

[build-dependencies]
shadow-build-common = { path = "../shadow-build-common" }
cbindgen = { version = "0.26.0", default_features = false }
shadow-build-common = { optional = true, path = "../shadow-build-common", features = ["cbindgen"] }
cbindgen = { optional = true, version = "0.26.0", default_features = false }
11 changes: 8 additions & 3 deletions src/lib/linux-api/build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#[cfg(feature = "c_bindings")]
use shadow_build_common::ShadowBuildCommon;

#[cfg(feature = "c_bindings")]
fn run_cbindgen(build_common: &ShadowBuildCommon) {
let base_config = build_common.cbindgen_base_config();
let crate_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();
Expand Down Expand Up @@ -29,7 +31,10 @@ fn run_cbindgen(build_common: &ShadowBuildCommon) {
}

fn main() {
let build_common =
shadow_build_common::ShadowBuildCommon::new(std::path::Path::new("../../.."), None);
run_cbindgen(&build_common);
#[cfg(feature = "c_bindings")]
{
let build_common =
shadow_build_common::ShadowBuildCommon::new(std::path::Path::new("../../.."), None);
run_cbindgen(&build_common);
}
}
2 changes: 1 addition & 1 deletion src/lib/log-c2rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ va_list = { version = "0.1.4", default-features = false }

[build-dependencies]
cc = { version = "1.0", features = ["parallel"] }
shadow-build-common = { path = "../shadow-build-common" }
shadow-build-common = { path = "../shadow-build-common", features = ["cbindgen"] }
cbindgen = { version = "0.26.0", default_features = false }
4 changes: 2 additions & 2 deletions src/lib/logger/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ cc = { version = "1.0", features = ["parallel"] }
bindgen = { version = "0.69.1" }
# Needs to be a build-dependency as well for its generated header files
# to be present, which our C build needs.
linux-api = { path = "../linux-api" }
shadow-build-common = { path = "../shadow-build-common" }
linux-api = { path = "../linux-api", features = ["c_bindings"] }
shadow-build-common = { path = "../shadow-build-common", features = ["bindgen"] }

[lib]
path = "src/lib.rs"
Expand Down
8 changes: 6 additions & 2 deletions src/lib/shadow-build-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
bindgen = ["dep:bindgen"]
cbindgen = ["dep:cbindgen"]

[dependencies]
bindgen = { version = "0.69.1" }
cbindgen = { version = "0.26.0", default_features = false }
bindgen = { optional = true, version = "0.69.1" }
cbindgen = { optional = true, version = "0.26.0", default_features = false }
cc = { version = "1.0", features = ["parallel"] }
system-deps = "6.2"

Expand Down
4 changes: 4 additions & 0 deletions src/lib/shadow-build-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ impl ShadowBuildCommon {
b
}

#[cfg(feature = "bindgen")]
pub fn bindgen_builder(&self) -> bindgen::Builder {
let mut builder = bindgen::Builder::default()
// Tell cargo to invalidate the built crate whenever any of the
Expand All @@ -94,6 +95,7 @@ impl ShadowBuildCommon {
builder
}

#[cfg(feature = "cbindgen")]
pub fn cbindgen_base_config(&self) -> cbindgen::Config {
let header = "
/*
Expand Down Expand Up @@ -143,6 +145,7 @@ impl ShadowBuildCommon {
}
}

#[cfg(feature = "cbindgen")]
pub trait CBindgenExt {
fn get_mut(&mut self) -> &mut cbindgen::Config;

Expand All @@ -169,6 +172,7 @@ pub trait CBindgenExt {
}
}

#[cfg(feature = "cbindgen")]
impl CBindgenExt for cbindgen::Config {
fn get_mut(&mut self) -> &mut cbindgen::Config {
self
Expand Down
2 changes: 1 addition & 1 deletion src/lib/shadow-shim-helper-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ bytemuck = "1.14.0"

[build-dependencies]
cc = { version = "1.0", features = ["parallel"] }
shadow-build-common = { path = "../shadow-build-common" }
shadow-build-common = { path = "../shadow-build-common", features = ["cbindgen"] }
system-deps = "6.2"
cbindgen = { version = "0.26.0", default_features = false }

Expand Down
4 changes: 2 additions & 2 deletions src/lib/shim/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ perf_timers = []
[dependencies]
formatting-nostd = { path = "../formatting-nostd" }
libc = { version = "0.2", default-features = false }
linux-api = { path = "../linux-api"}
linux-api = { path = "../linux-api", features = ["rustix"] }
num_enum = { version = "0.7.1", default-features=false }
shadow-shim-helper-rs = { path = "../shadow-shim-helper-rs" }
shadow_shmem = { path = "../shmem" }
Expand All @@ -37,7 +37,7 @@ test-log = "0.2.14"
bindgen = { version = "0.69.1" }
cbindgen = { version = "0.26.0", default_features = false }
cc = { version = "1.0", features = ["parallel"] }
shadow-build-common = { path = "../shadow-build-common" }
shadow-build-common = { path = "../shadow-build-common", features = ["bindgen", "cbindgen"] }
# Building the C code from this crate's build script requires
# that these bindings have been generated.
shadow-shim-helper-rs = { path = "../shadow-shim-helper-rs" }
Expand Down
2 changes: 1 addition & 1 deletion src/lib/tsc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ logger = { path = "../logger" }
[build-dependencies]
bindgen = { version = "0.69.1" }
cc = { version = "1.0", features = ["parallel"] }
shadow-build-common = { path = "../shadow-build-common" }
shadow-build-common = { path = "../shadow-build-common", features = ["bindgen", "cbindgen"] }
system-deps = "6.2"
cbindgen = { version = "0.26.0", default_features = false }

Expand Down
10 changes: 5 additions & 5 deletions src/lib/vasi-sync/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
num_enum = { version = "0.7.1", default-features=false }
rustix = { version = "0.38.28", default-features = false, features=["fs", "thread", "process"] }
num_enum = { version = "0.7.1", default-features = false }
rustix = { version = "0.38.28", default-features = false, features = ["fs", "thread", "process"] }
static_assertions = "1.1.0"
vasi = { path = "../vasi" }
rustc-hash = { version = "1.1.0", default-features=false }
rustc-hash = { version = "1.1.0", default-features = false }

[dev-dependencies]
criterion = "0.5.1"
rand = "0.8.5"
rustix = { version = "0.38.28", default-features = false, features=["process"] }
rustix = { version = "0.38.28", default-features = false, features = ["process"] }
libc = "0.2"
nix = "0.27.1"
nix = "0.27.1"

[target.'cfg(loom)'.dependencies]
loom = { version = "0.7", features = ["checkpoint"] }
Expand Down
6 changes: 3 additions & 3 deletions src/main/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ path = "lib.rs"
crate-type = ["rlib", "staticlib"]

[dependencies]
anyhow = { version = "1.0.78", features = ["backtrace"] }
anyhow = "1.0.78"
atomic_refcell = "0.1"
backtrace = "0.3.69"
bitflags = "2.4"
Expand All @@ -22,7 +22,7 @@ clap = { version = "4.5.0", features = ["derive", "wrap_help"] }
crossbeam = "0.8.3"
gml-parser = { path = "../lib/gml-parser" }
libc = "0.2"
linux-api = { path = "../lib/linux-api", features = ["std"] }
linux-api = { path = "../lib/linux-api", features = ["c_bindings", "std"] }
# don't log debug or trace levels in release mode
log = { version = "0.4", features = ["release_max_level_debug"] }
log-c2rust = { path = "../lib/log-c2rust" }
Expand Down Expand Up @@ -71,7 +71,7 @@ bytemuck = "1.14.0"
perf_timers = []

[build-dependencies]
shadow-build-common = { path = "../lib/shadow-build-common" }
shadow-build-common = { path = "../lib/shadow-build-common", features = ["bindgen", "cbindgen"] }
bindgen = { version = "0.69.1" }
cbindgen = { version = "0.26.0", default_features = false }
cc = { version = "1.0", features = ["parallel"] }
Expand Down
8 changes: 4 additions & 4 deletions src/test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,14 @@ name = "test_prctl"
path = "prctl/test_prctl.rs"

[dependencies]
anyhow = { version = "1.0.78", features = ["backtrace"] }
anyhow = "1.0.78"
formatting-nostd = { path = "../lib/formatting-nostd" }
libc = "0.2"
linux-api = { path = "../lib/linux-api", features = ["std"] }
linux-api = { path = "../lib/linux-api", features = ["rustix", "std"] }
neli = "0.6.4"
nix = { version = "0.26.4", features = ["event", "feature", "fs", "poll", "process", "sched", "signal", "socket", "uio"] }
rand = { version="0.8.5", features=["small_rng"] }
rustix = { version = "0.38.28", default-features=false, features=["fs", "mm", "pipe", "time", "thread"]}
rand = { version = "0.8.5", features = ["small_rng"] }
rustix = { version = "0.38.28", default-features = false, features = ["fs", "mm", "pipe", "time", "thread"] }
signal-hook = "0.3.17"
once_cell = "1.19.0"
vasi-sync = { path = "../lib/vasi-sync" }
Expand Down
Loading