mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
parent
aecaef3e23
commit
e620865633
@ -74,7 +74,7 @@ continuous integration systems.",
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
|
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
|
||||||
let mut compile_opts = args.compile_options(config, CompileMode::Build)?;
|
let mut compile_opts = args.compile_options(config, CompileMode::Install)?;
|
||||||
compile_opts.build_config.release = !args.is_present("debug");
|
compile_opts.build_config.release = !args.is_present("debug");
|
||||||
|
|
||||||
let krates = args.values_of("crate")
|
let krates = args.values_of("crate")
|
||||||
|
@ -60,8 +60,13 @@ impl BuildConfig {
|
|||||||
bail!("target was empty")
|
bail!("target was empty")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
let target = if mode == CompileMode::Install {
|
||||||
|
// ignore `.cargo/config` when compiling for `cargo install`
|
||||||
|
requested_target
|
||||||
|
} else {
|
||||||
let cfg_target = config.get_string("build.target")?.map(|s| s.val);
|
let cfg_target = config.get_string("build.target")?.map(|s| s.val);
|
||||||
let target = requested_target.clone().or(cfg_target);
|
requested_target.clone().or(cfg_target)
|
||||||
|
};
|
||||||
|
|
||||||
if jobs == Some(0) {
|
if jobs == Some(0) {
|
||||||
bail!("jobs must be at least 1")
|
bail!("jobs must be at least 1")
|
||||||
@ -131,6 +136,8 @@ pub enum CompileMode {
|
|||||||
Doc { deps: bool },
|
Doc { deps: bool },
|
||||||
/// A target that will be tested with `rustdoc`.
|
/// A target that will be tested with `rustdoc`.
|
||||||
Doctest,
|
Doctest,
|
||||||
|
// Like `Build` but we are compiling something that will be installed
|
||||||
|
Install,
|
||||||
/// A marker for Units that represent the execution of a `build.rs`
|
/// A marker for Units that represent the execution of a `build.rs`
|
||||||
/// script.
|
/// script.
|
||||||
RunCustomBuild,
|
RunCustomBuild,
|
||||||
|
@ -84,6 +84,7 @@ impl Profiles {
|
|||||||
CompileMode::Build
|
CompileMode::Build
|
||||||
| CompileMode::Check { .. }
|
| CompileMode::Check { .. }
|
||||||
| CompileMode::Doctest
|
| CompileMode::Doctest
|
||||||
|
| CompileMode::Install
|
||||||
| CompileMode::RunCustomBuild => {
|
| CompileMode::RunCustomBuild => {
|
||||||
// Note: RunCustomBuild doesn't normally use this code path.
|
// Note: RunCustomBuild doesn't normally use this code path.
|
||||||
// `build_unit_profiles` normally ensures that it selects the
|
// `build_unit_profiles` normally ensures that it selects the
|
||||||
|
@ -386,7 +386,10 @@ impl CompileFilter {
|
|||||||
pub fn need_dev_deps(&self, mode: CompileMode) -> bool {
|
pub fn need_dev_deps(&self, mode: CompileMode) -> bool {
|
||||||
match mode {
|
match mode {
|
||||||
CompileMode::Test | CompileMode::Doctest | CompileMode::Bench => true,
|
CompileMode::Test | CompileMode::Doctest | CompileMode::Bench => true,
|
||||||
CompileMode::Build | CompileMode::Doc { .. } | CompileMode::Check { .. } => match *self
|
CompileMode::Build
|
||||||
|
| CompileMode::Doc { .. }
|
||||||
|
| CompileMode::Check { .. }
|
||||||
|
| CompileMode::Install => match *self
|
||||||
{
|
{
|
||||||
CompileFilter::Default { .. } => false,
|
CompileFilter::Default { .. } => false,
|
||||||
CompileFilter::Only {
|
CompileFilter::Only {
|
||||||
@ -707,7 +710,7 @@ fn filter_default_targets(targets: &[Target], mode: CompileMode) -> Vec<&Target>
|
|||||||
.iter()
|
.iter()
|
||||||
.filter(|t| t.tested() || t.is_example())
|
.filter(|t| t.tested() || t.is_example())
|
||||||
.collect(),
|
.collect(),
|
||||||
CompileMode::Build | CompileMode::Check { .. } => targets
|
CompileMode::Build | CompileMode::Check { .. } | CompileMode::Install => targets
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|t| t.is_bin() || t.is_lib())
|
.filter(|t| t.is_bin() || t.is_lib())
|
||||||
.collect(),
|
.collect(),
|
||||||
|
@ -1237,3 +1237,33 @@ warning: be sure to add `[..]` to your PATH to be able to run the installed bina
|
|||||||
",
|
",
|
||||||
).run();
|
).run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn install_ignores_cargo_config() {
|
||||||
|
pkg("bar", "0.0.1");
|
||||||
|
|
||||||
|
let p = project("foo")
|
||||||
|
.file(
|
||||||
|
"Cargo.toml",
|
||||||
|
r#"
|
||||||
|
[package]
|
||||||
|
name = "foo"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = []
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
.file(
|
||||||
|
".cargo/config",
|
||||||
|
r#"
|
||||||
|
[build]
|
||||||
|
target = "non-existing-target"
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
.file("src/main.rs", "fn main() {}")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
assert_that(
|
||||||
|
cargo_process("install").arg("bar").cwd(p.root()),
|
||||||
|
execs().with_status(0),
|
||||||
|
);
|
||||||
|
assert_that(cargo_home(), has_installed_exe("bar"));
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user