Skip to content

Commit 6ee972f

Browse files
committed
Properly forward a requested target
1 parent 0b3e046 commit 6ee972f

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/bin/cargo_semver.rs

+14-4
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,10 @@ fn run(config: &cargo::Config, matches: &getopts::Matches, explain: bool) -> Res
120120
(work_info, stable_crate.max_version.clone())
121121
};
122122

123-
let (current_rlib, current_deps_output) = current.rlib_and_dep_output(config, &name, true)?;
124-
let (stable_rlib, stable_deps_output) = stable.rlib_and_dep_output(config, &name, false)?;
123+
let (current_rlib, current_deps_output) =
124+
current.rlib_and_dep_output(config, &name, true, matches)?;
125+
let (stable_rlib, stable_deps_output) =
126+
stable.rlib_and_dep_output(config, &name, false, matches)?;
125127

126128
println!("current_rlib: {:?}", current_rlib);
127129
println!("stable_rlib: {:?}", stable_rlib);
@@ -385,11 +387,17 @@ impl<'a> WorkInfo<'a> {
385387
config: &'a cargo::Config,
386388
name: &str,
387389
current: bool,
390+
matches: &getopts::Matches,
388391
) -> Result<(PathBuf, PathBuf)> {
389392
let mut opts =
390393
cargo::ops::CompileOptions::new(config, cargo::core::compiler::CompileMode::Build)?;
391394
// we need the build plan to find our build artifacts
392395
opts.build_config.build_plan = true;
396+
397+
if let Some(target) = matches.opt_str("target") {
398+
opts.build_config.requested_target = Some(target);
399+
}
400+
393401
// TODO: this is where we could insert feature flag builds (or using the CLI mechanisms)
394402

395403
env::set_var(
@@ -421,8 +429,10 @@ impl<'a> WorkInfo<'a> {
421429
if i.package_name == name {
422430
// FIXME: this is a hack to avoid picking up output artifacts of
423431
// build scrits and build programs (no outputs):
424-
let build_script =
425-
i.outputs.iter().any(|v| v.to_str().unwrap().contains("build_script"));
432+
let build_script = i
433+
.outputs
434+
.iter()
435+
.any(|v| v.to_str().unwrap().contains("build_script"));
426436
let build_program = i.outputs.is_empty();
427437
if build_script || build_program {
428438
continue;

0 commit comments

Comments
 (0)