Skip to content
Merged
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
11 changes: 0 additions & 11 deletions src/bin/cargo/commands/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,11 @@ pub fn exec(gctx: &mut GlobalContext, args: &ArgMatches) -> CliResult {
if let Some(artifact_dir) = args.value_of_path("artifact-dir", gctx) {
// If the user specifies `--artifact-dir`, use that
compile_opts.build_config.export_dir = Some(artifact_dir);
} else if let Some(artifact_dir) = args.value_of_path("out-dir", gctx) {
// `--out-dir` is deprecated, but still supported for now
gctx.shell()
.warn("the --out-dir flag has been changed to --artifact-dir")?;
compile_opts.build_config.export_dir = Some(artifact_dir);
} else if let Some(artifact_dir) = gctx.build_config()?.artifact_dir.as_ref() {
// If a CLI option is not specified for choosing the artifact dir, use the `artifact-dir` from the build config, if
// present
let artifact_dir = artifact_dir.resolve_path(gctx);
compile_opts.build_config.export_dir = Some(artifact_dir);
} else if let Some(artifact_dir) = gctx.build_config()?.out_dir.as_ref() {
// As a last priority, check `out-dir` in the build config
gctx.shell()
.warn("the out-dir config option has been changed to artifact-dir")?;
let artifact_dir = artifact_dir.resolve_path(gctx);
compile_opts.build_config.export_dir = Some(artifact_dir);
}

if compile_opts.build_config.export_dir.is_some() {
Expand Down
19 changes: 10 additions & 9 deletions src/cargo/util/command_prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,15 +542,16 @@ pub trait CommandExt: Sized {
.help_heading(heading::COMPILATION_OPTIONS),
)
._arg(unsupported_short_arg)
._arg(
opt(
"out-dir",
"Copy final artifacts to this directory (deprecated; use --artifact-dir instead)",
)
.value_name("PATH")
.conflicts_with("artifact-dir")
.hide(true),
)
._arg({
let value_parser = UnknownArgumentValueParser::suggest_arg("--artifact-dir");
Arg::new("unsupported-out-dir-flag")
.help("")
.long("out-dir")
.value_name("PATH")
.value_parser(value_parser)
.action(ArgAction::SetTrue)
.hide(true)
})
}

fn arg_compile_time_deps(self) -> Self {
Expand Down
2 changes: 0 additions & 2 deletions src/cargo/util/context/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,6 @@ pub struct CargoBuildConfig {
pub rustc_workspace_wrapper: Option<ConfigRelativePath>,
pub rustc: Option<ConfigRelativePath>,
pub rustdoc: Option<ConfigRelativePath>,
// deprecated alias for artifact-dir
pub out_dir: Option<ConfigRelativePath>,
pub artifact_dir: Option<ConfigRelativePath>,
pub warnings: Option<WarningHandling>,
/// Unstable feature `-Zsbom`.
Expand Down
46 changes: 6 additions & 40 deletions tests/testsuite/artifact_dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,60 +326,26 @@ For more information, try '--help'.
}

#[cargo_test]
fn deprecated_out_dir() {
fn removed_out_dir_flag() {
let p = project()
.file("src/main.rs", r#"fn main() { println!("Hello, World!") }"#)
.build();

p.cargo("build -Z unstable-options --out-dir out")
.masquerade_as_nightly_cargo(&["out-dir"])
.with_status(1)
.enable_mac_dsym()
.with_stderr_data(str![[r#"
[WARNING] the --out-dir flag has been changed to --artifact-dir
[COMPILING] foo v0.0.1 ([ROOT]/foo)
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
[ERROR] unexpected argument '--out-dir' found

"#]])
.run();
check_dir_contents(
&p.root().join("out"),
&["foo"],
&["foo", "foo.dSYM"],
&["foo.exe", "foo.pdb"],
&["foo.exe"],
);
}
tip: a similar argument exists: '--artifact-dir'

#[cargo_test]
fn cargo_build_deprecated_out_dir() {
let p = project()
.file("src/main.rs", r#"fn main() { println!("Hello, World!") }"#)
.file(
".cargo/config.toml",
r#"
[build]
out-dir = "out"
"#,
)
.build();
Usage: cargo[EXE] build [OPTIONS]

p.cargo("build -Z unstable-options")
.masquerade_as_nightly_cargo(&["out-dir"])
.enable_mac_dsym()
.with_stderr_data(str![[r#"
[WARNING] the out-dir config option has been changed to artifact-dir
[COMPILING] foo v0.0.1 ([ROOT]/foo)
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
For more information, try '--help'.

"#]])
.run();
check_dir_contents(
&p.root().join("out"),
&["foo"],
&["foo", "foo.dSYM"],
&["foo.exe", "foo.pdb"],
&["foo.exe"],
);
}

#[cargo_test]
Expand Down