Skip to content

Commit 493919c

Browse files
committed
drop CompileMode::Install; override target in exec
1 parent 7460592 commit 493919c

File tree

4 files changed

+11
-18
lines changed

4 files changed

+11
-18
lines changed

src/bin/cargo/commands/install.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,12 @@ continuous integration systems.",
7474
}
7575

7676
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
77-
let mut compile_opts = args.compile_options(config, CompileMode::Install)?;
77+
let mut compile_opts = args.compile_options(config, CompileMode::Build)?;
78+
79+
// for `cargo-install` we want to use what the user specified via `--target` and ignore what's
80+
// in `.cargo/config` and what the environment says
81+
compile_opts.build_config.requested_target = args.target();
82+
7883
compile_opts.build_config.release = !args.is_present("debug");
7984

8085
let krates = args.values_of("crate")

src/cargo/core/compiler/build_config.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,8 @@ impl BuildConfig {
6060
bail!("target was empty")
6161
}
6262
}
63-
let target = if mode == CompileMode::Install {
64-
// ignore `.cargo/config` when compiling for `cargo install`
65-
requested_target
66-
} else {
67-
let cfg_target = config.get_string("build.target")?.map(|s| s.val);
68-
requested_target.clone().or(cfg_target)
69-
};
63+
let cfg_target = config.get_string("build.target")?.map(|s| s.val);
64+
let target = requested_target.clone().or(cfg_target);
7065

7166
if jobs == Some(0) {
7267
bail!("jobs must be at least 1")
@@ -136,8 +131,6 @@ pub enum CompileMode {
136131
Doc { deps: bool },
137132
/// A target that will be tested with `rustdoc`.
138133
Doctest,
139-
// Like `Build` but we are compiling something that will be installed
140-
Install,
141134
/// A marker for Units that represent the execution of a `build.rs`
142135
/// script.
143136
RunCustomBuild,
@@ -182,7 +175,7 @@ impl CompileMode {
182175
/// List of all modes (currently used by `cargo clean -p` for computing
183176
/// all possible outputs).
184177
pub fn all_modes() -> &'static [CompileMode] {
185-
static ALL: [CompileMode; 10] = [
178+
static ALL: [CompileMode; 9] = [
186179
CompileMode::Test,
187180
CompileMode::Build,
188181
CompileMode::Check { test: true },
@@ -191,7 +184,6 @@ impl CompileMode {
191184
CompileMode::Doc { deps: true },
192185
CompileMode::Doc { deps: false },
193186
CompileMode::Doctest,
194-
CompileMode::Install,
195187
CompileMode::RunCustomBuild,
196188
];
197189
&ALL

src/cargo/core/profiles.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ impl Profiles {
8484
CompileMode::Build
8585
| CompileMode::Check { .. }
8686
| CompileMode::Doctest
87-
| CompileMode::Install
8887
| CompileMode::RunCustomBuild => {
8988
// Note: RunCustomBuild doesn't normally use this code path.
9089
// `build_unit_profiles` normally ensures that it selects the

src/cargo/ops/cargo_compile.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -386,10 +386,7 @@ impl CompileFilter {
386386
pub fn need_dev_deps(&self, mode: CompileMode) -> bool {
387387
match mode {
388388
CompileMode::Test | CompileMode::Doctest | CompileMode::Bench => true,
389-
CompileMode::Build
390-
| CompileMode::Doc { .. }
391-
| CompileMode::Check { .. }
392-
| CompileMode::Install => match *self
389+
CompileMode::Build | CompileMode::Doc { .. } | CompileMode::Check { .. } => match *self
393390
{
394391
CompileFilter::Default { .. } => false,
395392
CompileFilter::Only {
@@ -710,7 +707,7 @@ fn filter_default_targets(targets: &[Target], mode: CompileMode) -> Vec<&Target>
710707
.iter()
711708
.filter(|t| t.tested() || t.is_example())
712709
.collect(),
713-
CompileMode::Build | CompileMode::Check { .. } | CompileMode::Install => targets
710+
CompileMode::Build | CompileMode::Check { .. } => targets
714711
.iter()
715712
.filter(|t| t.is_bin() || t.is_lib())
716713
.collect(),

0 commit comments

Comments
 (0)