diff --git a/Cargo.lock b/Cargo.lock index fb525def3b832..c381fca288209 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -12791,7 +12791,7 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "vdev" -version = "0.3.4" +version = "0.3.5" dependencies = [ "anyhow", "cfg-if", diff --git a/Makefile b/Makefile index bbe578ea375df..8631d5c2f6013 100644 --- a/Makefile +++ b/Makefile @@ -380,7 +380,7 @@ check-component-features: ## Check that all component features are setup properl .PHONY: check-clippy check-clippy: ## Check code with Clippy - $(VDEV) check rust + $(VDEV) check rust $(if $(filter-out default default-msvc,$(FEATURES)),--features "$(FEATURES)") .PHONY: check-docs check-docs: generate-vrl-docs ## Check that all /docs file are valid - vrl docs due to remap.functions.* references @@ -557,7 +557,7 @@ ci-generate-publish-metadata: ## Generates the necessary metadata required for b .PHONY: clippy-fix clippy-fix: - $(VDEV) check rust --fix + $(VDEV) check rust --fix $(if $(filter-out default default-msvc,$(FEATURES)),--features "$(FEATURES)") .PHONY: fmt fmt: diff --git a/vdev/Cargo.toml b/vdev/Cargo.toml index e8b4d3b2254dc..a78a640f58e42 100644 --- a/vdev/Cargo.toml +++ b/vdev/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "vdev" -version = "0.3.4" +version = "0.3.5" edition = "2024" authors = ["Vector Contributors "] license = "MPL-2.0" diff --git a/vdev/src/commands/build/vector.rs b/vdev/src/commands/build/vector.rs index d06a8206f1b48..4f00864e38ae6 100644 --- a/vdev/src/commands/build/vector.rs +++ b/vdev/src/commands/build/vector.rs @@ -16,9 +16,9 @@ pub struct Cli { #[arg(short, long)] release: bool, - /// The feature to activate (multiple allowed) - #[arg(short = 'F', long)] - feature: Vec, + /// Features to activate (comma-separated, or set FEATURES env var) + #[arg(short = 'F', long, value_delimiter = ',', env = "FEATURES")] + features: Vec, } impl Cli { @@ -31,7 +31,12 @@ impl Cli { command.arg("--release"); } - command.features(&self.feature); + let features: Vec = self + .features + .into_iter() + .filter(|f| !f.is_empty()) + .collect(); + command.features(&features); let target = self.target.unwrap_or_else(platform::default_target); command.args(["--target", &target]); diff --git a/vdev/src/commands/check/rust.rs b/vdev/src/commands/check/rust.rs index 3656ff96d62c4..a8e64d6c1f273 100644 --- a/vdev/src/commands/check/rust.rs +++ b/vdev/src/commands/check/rust.rs @@ -13,9 +13,12 @@ pub struct Cli { #[arg(long, default_value_t = true)] clippy: bool, - #[arg(value_name = "FEATURE")] + #[arg(short = 'F', long, value_delimiter = ',')] features: Vec, + #[arg(long)] + no_default_features: bool, + #[arg(long)] fix: bool, } @@ -36,14 +39,21 @@ impl Cli { Vec::default() }; - let feature_args = if self.features.is_empty() { - vec!["--all-features".to_string()] + let features: Vec<&str> = self + .features + .iter() + .map(String::as_str) + .filter(|f| !f.is_empty()) + .collect(); + let feature_args = if self.no_default_features || !features.is_empty() { + let mut args = vec!["--no-default-features".to_string()]; + if !features.is_empty() { + args.push("--features".to_string()); + args.push(features.join(",")); + } + args } else { - vec![ - "--no-default-features".to_string(), - "--features".to_string(), - self.features.join(",").clone(), - ] + vec!["--all-features".to_string()] }; [tool.as_ref(), "--workspace", "--all-targets"] diff --git a/vdev/src/commands/crate_versions.rs b/vdev/src/commands/crate_versions.rs index 9b9fa3f6fea04..10d6445a02fc7 100644 --- a/vdev/src/commands/crate_versions.rs +++ b/vdev/src/commands/crate_versions.rs @@ -18,19 +18,24 @@ pub struct Cli { #[arg(long)] all: bool, - /// The feature to active (multiple allowed). If none are specified, the default is used. - #[arg(short = 'F', long)] - feature: Vec, + /// Features to activate (comma-separated, or set FEATURES env var) + #[arg(short = 'F', long, value_delimiter = ',', env = "FEATURES")] + features: Vec, } impl Cli { pub fn exec(self) -> Result<()> { let re_crate = Regex::new(r" (\S+) v([0-9.]+)").unwrap(); let mut versions: HashMap> = HashMap::default(); + let features: Vec = self + .features + .into_iter() + .filter(|f| !f.is_empty()) + .collect(); for line in Command::new("cargo") .arg("tree") - .features(&self.feature) + .features(&features) .check_output()? .lines() { diff --git a/vdev/src/commands/test.rs b/vdev/src/commands/test.rs index 72719e14d74dc..f677136370782 100644 --- a/vdev/src/commands/test.rs +++ b/vdev/src/commands/test.rs @@ -17,6 +17,13 @@ pub struct Cli { /// Environment variables in the form KEY[=VALUE] #[arg(short, long)] env: Option>, + + /// Features to activate (comma-separated, or set FEATURES env var) + #[arg(short = 'F', long, value_delimiter = ',', env = "FEATURES")] + features: Vec, + + #[arg(long)] + no_default_features: bool, } fn parse_env(env: Vec) -> BTreeMap> { @@ -39,9 +46,22 @@ impl Cli { args.append(&mut extra_args); } - if !args.contains(&"--features".to_string()) { - let features = platform::default_features(); - args.extend(["--features".to_string(), features.to_string()]); + let features: Vec = self + .features + .into_iter() + .filter(|f| !f.is_empty()) + .collect(); + + if self.no_default_features || !features.is_empty() { + args.push("--no-default-features".to_string()); + if !features.is_empty() { + args.extend(["--features".to_string(), features.join(",")]); + } + } else if !args.contains(&"--features".to_string()) { + args.extend([ + "--features".to_string(), + platform::default_features().to_string(), + ]); } LocalTestRunner.test(