Skip to content
Open
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
10 changes: 1 addition & 9 deletions Cargo.lock

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

2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ members = [
"common/test_random_derive",
"common/validator_dir",
"common/warp_utils",
"common/workspace_members",
"consensus/fixed_bytes",
"consensus/fork_choice",
"consensus/int_to_bytes",
Expand Down Expand Up @@ -273,7 +272,6 @@ validator_store = { path = "validator_client/validator_store" }
validator_test_rig = { path = "testing/validator_test_rig" }
warp = { version = "0.3.7", default-features = false, features = ["tls"] }
warp_utils = { path = "common/warp_utils" }
workspace_members = { path = "common/workspace_members" }
xdelta3 = { git = "https://github.com/sigp/xdelta3-rs", rev = "4db64086bb02e9febb584ba93b9d16bb2ae3825a" }
zeroize = { version = "1", features = ["zeroize_derive", "serde"] }
zip = { version = "6.0", default-features = false, features = ["deflate"] }
Expand Down
4 changes: 3 additions & 1 deletion common/logging/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ tracing-appender = { workspace = true }
tracing-core = { workspace = true }
tracing-log = { workspace = true }
tracing-subscriber = { workspace = true }
workspace_members = { workspace = true }

[build-dependencies]
cargo_metadata = { workspace = true }
46 changes: 46 additions & 0 deletions common/logging/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//! This build script should only rerun when:
//! 1. This build.rs file is changed.
//! 2. The workspace Cargo.toml changes.
//! 3. Build dependencies change.
use cargo_metadata::MetadataCommand;
use std::{env, fs, path::Path};

fn main() {
println!("cargo:rerun-if-changed=build.rs");

let metadata = MetadataCommand::new()
.no_deps()
.exec()
.expect("Failed to get cargo metadata");

let workspace_cargo_toml = metadata.workspace_root.join("Cargo.toml");
println!("cargo:rerun-if-changed={}", workspace_cargo_toml);

let workspace_crates = get_workspace_crates(&metadata);

// A bit of a hacky way to generate the list of workspace crates and
// save to a file in OUT_DIR.
let mut code = String::from("&[\n");
for crate_name in &workspace_crates {
code.push_str(&format!(" \"{}\",\n", crate_name));
}
code.push_str("]\n");

let out_dir = env::var("OUT_DIR").unwrap();
let dest_path = Path::new(&out_dir).join("workspace_crates.rs");
fs::write(&dest_path, code).expect("Failed to write workspace_crates.rs");
}

fn get_workspace_crates(metadata: &cargo_metadata::Metadata) -> Vec<String> {
metadata
.workspace_members
.iter()
.filter_map(|member_id| {
metadata
.packages
.iter()
.find(|package| &package.id == member_id)
.map(|package| package.name.clone())
})
.collect()
}
3 changes: 1 addition & 2 deletions common/logging/src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use std::collections::HashSet;
use tracing_subscriber::filter::FilterFn;
use workspace_members::workspace_crates;

const WORKSPACE_CRATES: &[&str] = workspace_crates!();
const WORKSPACE_CRATES: &[&str] = include!(concat!(env!("OUT_DIR"), "/workspace_crates.rs"));

/// Constructs a filter which only permits logging from crates which are members of the workspace.
pub fn build_workspace_filter()
Expand Down
11 changes: 0 additions & 11 deletions common/workspace_members/Cargo.toml

This file was deleted.

39 changes: 0 additions & 39 deletions common/workspace_members/src/lib.rs

This file was deleted.