mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
Support out-dir in build section of Cargo configuration file
Fixed #7555.
This commit is contained in:
parent
4e0d2f1a16
commit
4a1ba1c8e5
@ -63,7 +63,12 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
|
||||
ProfileChecking::Checked,
|
||||
)?;
|
||||
|
||||
compile_opts.export_dir = args.value_of_path("out-dir", config);
|
||||
if let Some(out_dir) = args.value_of_path("out-dir", config) {
|
||||
compile_opts.export_dir = Some(out_dir);
|
||||
} else if let Some(out_dir) = config.build_config()?.out_dir.as_ref() {
|
||||
let out_dir = out_dir.resolve_path(config);
|
||||
compile_opts.export_dir = Some(out_dir);
|
||||
}
|
||||
if compile_opts.export_dir.is_some() {
|
||||
config
|
||||
.cli_unstable()
|
||||
|
@ -1643,6 +1643,7 @@ pub struct CargoBuildConfig {
|
||||
pub rustc_wrapper: Option<PathBuf>,
|
||||
pub rustc: Option<PathBuf>,
|
||||
pub rustdoc: Option<PathBuf>,
|
||||
pub out_dir: Option<ConfigRelativePath>,
|
||||
}
|
||||
|
||||
/// A type to deserialize a list of strings from a toml file.
|
||||
|
@ -76,6 +76,13 @@ directory. Example:
|
||||
cargo +nightly build --out-dir=out -Z unstable-options
|
||||
```
|
||||
|
||||
This can also be specified in `.cargo/config` files.
|
||||
|
||||
```toml
|
||||
[build]
|
||||
out-dir = "out"
|
||||
```
|
||||
|
||||
### doctest-xcompile
|
||||
* Tracking Issue: [#7040](https://github.com/rust-lang/cargo/issues/7040)
|
||||
* Tracking Rustc Issue: [#64245](https://github.com/rust-lang/rust/issues/64245)
|
||||
|
@ -246,6 +246,30 @@ fn avoid_build_scripts() {
|
||||
);
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn cargo_build_out_dir() {
|
||||
let p = project()
|
||||
.file("src/main.rs", r#"fn main() { println!("Hello, World!") }"#)
|
||||
.file(
|
||||
".cargo/config",
|
||||
r#"
|
||||
[build]
|
||||
out-dir = "out"
|
||||
"#,
|
||||
)
|
||||
.build();
|
||||
|
||||
p.cargo("build -Z unstable-options")
|
||||
.masquerade_as_nightly_cargo()
|
||||
.run();
|
||||
check_dir_contents(
|
||||
&p.root().join("out"),
|
||||
&["foo"],
|
||||
&["foo", "foo.dSYM"],
|
||||
&["foo.exe", "foo.pdb"],
|
||||
);
|
||||
}
|
||||
|
||||
fn check_dir_contents(
|
||||
out_dir: &Path,
|
||||
expected_linux: &[&str],
|
||||
|
Loading…
x
Reference in New Issue
Block a user