mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
Auto merge of #7810 - giraffate:support_out_dir_in_build_section, r=alexcrichton
Support out-dir in build section of Cargo configuration file Fixed #7555.
This commit is contained in:
commit
c326fcb37e
@ -63,7 +63,12 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
|
|||||||
ProfileChecking::Checked,
|
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() {
|
if compile_opts.export_dir.is_some() {
|
||||||
config
|
config
|
||||||
.cli_unstable()
|
.cli_unstable()
|
||||||
|
@ -1643,6 +1643,7 @@ pub struct CargoBuildConfig {
|
|||||||
pub rustc_wrapper: Option<PathBuf>,
|
pub rustc_wrapper: Option<PathBuf>,
|
||||||
pub rustc: Option<PathBuf>,
|
pub rustc: Option<PathBuf>,
|
||||||
pub rustdoc: Option<PathBuf>,
|
pub rustdoc: Option<PathBuf>,
|
||||||
|
pub out_dir: Option<ConfigRelativePath>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A type to deserialize a list of strings from a toml file.
|
/// 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
|
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
|
### doctest-xcompile
|
||||||
* Tracking Issue: [#7040](https://github.com/rust-lang/cargo/issues/7040)
|
* Tracking Issue: [#7040](https://github.com/rust-lang/cargo/issues/7040)
|
||||||
* Tracking Rustc Issue: [#64245](https://github.com/rust-lang/rust/issues/64245)
|
* 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(
|
fn check_dir_contents(
|
||||||
out_dir: &Path,
|
out_dir: &Path,
|
||||||
expected_linux: &[&str],
|
expected_linux: &[&str],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user