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
2 changes: 1 addition & 1 deletion Cargo.lock

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

4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion vdev/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "vdev"
version = "0.3.4"
version = "0.3.5"
edition = "2024"
authors = ["Vector Contributors <vector@datadoghq.com>"]
license = "MPL-2.0"
Expand Down
13 changes: 9 additions & 4 deletions vdev/src/commands/build/vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ pub struct Cli {
#[arg(short, long)]
release: bool,

/// The feature to activate (multiple allowed)
#[arg(short = 'F', long)]
feature: Vec<String>,
/// Features to activate (comma-separated, or set FEATURES env var)
#[arg(short = 'F', long, value_delimiter = ',', env = "FEATURES")]
features: Vec<String>,
}

impl Cli {
Expand All @@ -31,7 +31,12 @@ impl Cli {
command.arg("--release");
}

command.features(&self.feature);
let features: Vec<String> = 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]);
Expand Down
26 changes: 18 additions & 8 deletions vdev/src/commands/check/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ',')]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Honor FEATURES in check rust

For direct cargo vdev check rust invocations, setting FEATURES=... is still ignored because this new --features field is the only one in the changed commands without env = "FEATURES" (checked check rust --help: it prints -F, --features <FEATURES> with no env marker, while build/test/crate-versions show [env: FEATURES=]). In that scenario FEATURES=component-validation-tests cargo vdev check rust falls through to the --all-features path instead of linting the requested feature set, so the advertised env-var support for check/clippy only works when callers happen to go through the Makefile.

Useful? React with 👍 / 👎.

features: Vec<String>,

#[arg(long)]
no_default_features: bool,

#[arg(long)]
fix: bool,
}
Expand All @@ -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"]
Expand Down
13 changes: 9 additions & 4 deletions vdev/src/commands/crate_versions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,
/// Features to activate (comma-separated, or set FEATURES env var)
#[arg(short = 'F', long, value_delimiter = ',', env = "FEATURES")]
features: Vec<String>,
}

impl Cli {
pub fn exec(self) -> Result<()> {
let re_crate = Regex::new(r" (\S+) v([0-9.]+)").unwrap();
let mut versions: HashMap<String, HashSet<String>> = HashMap::default();
let features: Vec<String> = 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()
{
Expand Down
26 changes: 23 additions & 3 deletions vdev/src/commands/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ pub struct Cli {
/// Environment variables in the form KEY[=VALUE]
#[arg(short, long)]
env: Option<Vec<String>>,

/// Features to activate (comma-separated, or set FEATURES env var)
#[arg(short = 'F', long, value_delimiter = ',', env = "FEATURES")]
features: Vec<String>,

#[arg(long)]
no_default_features: bool,
}

fn parse_env(env: Vec<String>) -> BTreeMap<String, Option<String>> {
Expand All @@ -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<String> = 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(),
]);
Comment thread
pront marked this conversation as resolved.
}

LocalTestRunner.test(
Expand Down
Loading