Skip to content

Commit bdefd58

Browse files
committed
Implemented feature flag support.
We now support `--features`, `--all-features` in addition to `--no-default-features`. This closes rust-lang#91.
1 parent 091939b commit bdefd58

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

src/bin/cargo_semver.rs

+17-10
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,6 @@ fn run(config: &cargo::Config, matches: &getopts::Matches) -> Result<()> {
121121
child.args(&["--target", &target]);
122122
}
123123

124-
if !matches.opt_present("no-default-features") {
125-
child.args(&["--cfg", "feature=\"default\""]);
126-
}
127-
128124
let mut child = child
129125
.arg("-")
130126
.stdin(Stdio::piped())
@@ -207,10 +203,6 @@ fn run(config: &cargo::Config, matches: &getopts::Matches) -> Result<()> {
207203
child.args(&["--target", &target]);
208204
}
209205

210-
if !matches.opt_present("no-default-features") {
211-
child.args(&["--cfg", "feature=\"default\""]);
212-
}
213-
214206
let child = child
215207
.arg("-")
216208
.stdin(Stdio::piped())
@@ -284,6 +276,17 @@ mod cli {
284276
"api-guidelines",
285277
"report only changes that are breaking according to the API-guidelines",
286278
);
279+
opts.optopt(
280+
"",
281+
"features",
282+
"Space-separated list of features to activate",
283+
"FEATURES",
284+
);
285+
opts.optflag(
286+
"",
287+
"all-features",
288+
"Activate all available features",
289+
);
287290
opts.optflag(
288291
"",
289292
"no-default-features",
@@ -458,9 +461,13 @@ impl<'a> WorkInfo<'a> {
458461
if let Some(target) = matches.opt_str("target") {
459462
opts.build_config.requested_target = Some(target);
460463
}
461-
opts.no_default_features = matches.opt_present("no-default-features");
462464

463-
// TODO: this is where we could insert feature flag builds (or using the CLI mechanisms)
465+
if let Some(s) = matches.opt_str("features") {
466+
opts.features = s.split(" ").map(str::to_owned).collect();
467+
}
468+
469+
opts.all_features = matches.opt_present("all-features");
470+
opts.no_default_features = matches.opt_present("no-default-features");
464471

465472
env::set_var(
466473
"RUSTFLAGS",

0 commit comments

Comments
 (0)