@@ -50,18 +50,44 @@ pub fn exec(gctx: &mut GlobalContext, args: &ArgMatches) -> CliResult {
50
50
let mut compile_opts =
51
51
args. compile_options ( gctx, CompileMode :: Build , Some ( & ws) , ProfileChecking :: Custom ) ?;
52
52
53
- let mut artifact_dir_arg = args. value_of_path ( "artifact-dir" , gctx) ;
53
+ // If the user specifies `--artifact-dir`, use that
54
+ let mut artifact_dir = args. value_of_path ( "artifact-dir" , gctx) ;
54
55
55
- if artifact_dir_arg. is_none ( ) {
56
+ // `--out-dir` is deprecated, but still supported for now
57
+ if artifact_dir. is_none ( ) {
56
58
let out_dir_arg = args. value_of_path ( "out-dir" , gctx) ;
57
59
if out_dir_arg. is_some ( ) {
58
60
gctx. shell ( )
59
61
. warn ( "the --out-dir flag has been changed to --artifact-dir" ) ?;
60
62
}
61
- artifact_dir_arg = out_dir_arg
63
+ artifact_dir = out_dir_arg
62
64
}
63
65
64
- if let Some ( artifact_dir) = artifact_dir_arg {
66
+ // If a CLI option is not specified for choosing the artifact dir, use the `artifact-dir` from the build config, if
67
+ // present
68
+ if artifact_dir. is_none ( ) {
69
+ artifact_dir = gctx
70
+ . build_config ( ) ?
71
+ . artifact_dir
72
+ . as_ref ( )
73
+ . map ( |path| path. resolve_path ( gctx) ) ;
74
+ }
75
+
76
+ // As a last priority, check `out-dir` in the build config
77
+ if artifact_dir. is_none ( ) {
78
+ let out_dir = gctx
79
+ . build_config ( ) ?
80
+ . out_dir
81
+ . as_ref ( )
82
+ . map ( |path| path. resolve_path ( gctx) ) ;
83
+ if out_dir. is_some ( ) {
84
+ gctx. shell ( )
85
+ . warn ( "the out-dir config option has been changed to artifact-dir" ) ?;
86
+ }
87
+ artifact_dir = out_dir;
88
+ }
89
+
90
+ if let Some ( artifact_dir) = artifact_dir {
65
91
compile_opts. build_config . export_dir = Some ( artifact_dir) ;
66
92
} else if let Some ( out_dir) = gctx. build_config ( ) ?. out_dir . as_ref ( ) {
67
93
let artifact_dir = out_dir. resolve_path ( gctx) ;
0 commit comments