Skip to content

Commit

Permalink
Re-add deprecated out-dir
Browse files Browse the repository at this point in the history
  • Loading branch information
valadaptive committed May 4, 2024
1 parent bae765e commit d4a1c4d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/bin/cargo/commands/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,26 @@ pub fn exec(gctx: &mut GlobalContext, args: &ArgMatches) -> CliResult {
let mut compile_opts =
args.compile_options(gctx, CompileMode::Build, Some(&ws), ProfileChecking::Custom)?;

if let Some(artifact_dir) = args.value_of_path("artifact-dir", gctx) {
let mut artifact_dir_arg = args.value_of_path("artifact-dir", gctx);

if artifact_dir_arg.is_none() {
let out_dir_arg = args.value_of_path("out-dir", gctx);
if out_dir_arg.is_some() {
gctx.shell()
.warn("the --out-dir flag has been changed to --artifact-dir")?;
}
artifact_dir_arg = out_dir_arg
}

if let Some(artifact_dir) = artifact_dir_arg {
compile_opts.build_config.export_dir = Some(artifact_dir);
} else if let Some(out_dir) = gctx.build_config()?.out_dir.as_ref() {
let artifact_dir = out_dir.resolve_path(gctx);
compile_opts.build_config.export_dir = Some(artifact_dir);
}
if compile_opts.build_config.export_dir.is_some() {
gctx.cli_unstable().fail_if_stable_opt("--artifact-dir", 6790)?;
gctx.cli_unstable()
.fail_if_stable_opt("--artifact-dir", 6790)?;
}
ops::compile(&ws, &compile_opts)?;
Ok(())
Expand Down
10 changes: 10 additions & 0 deletions src/cargo/util/command_prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ pub trait CommandExt: Sized {
.action(ArgAction::SetTrue)
.hide(true)
};

self._arg(
opt(
"artifact-dir",
Expand All @@ -412,6 +413,15 @@ 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),
)
}
}

Expand Down

0 comments on commit d4a1c4d

Please sign in to comment.