Skip to content

Commit 7708522

Browse files
committed
Use cross compile style target/host isolation for all builds.
1 parent 197e657 commit 7708522

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+2272
-1014
lines changed

crates/cargo-test-support/src/lib.rs

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -256,12 +256,22 @@ impl Project {
256256
self.root.clone()
257257
}
258258

259-
/// Project's target dir, ex: `/path/to/cargo/target/cit/t0/foo/target`
259+
/// Project's target dir, ex: `/path/to/cargo/target/cit/t0/foo/target/target-triple`
260260
pub fn build_dir(&self) -> PathBuf {
261-
self.root().join("target")
261+
self.root().join("target").join(rustc_host())
262262
}
263263

264-
/// Project's debug dir, ex: `/path/to/cargo/target/cit/t0/foo/target/debug`
264+
/// Project's target dir, ex: `/path/to/cargo/target/cit/t0/foo/target/host/host-triple`
265+
pub fn host_dir(&self) -> PathBuf {
266+
self.root().join("target/host").join(rustc_host())
267+
}
268+
269+
/// Project's debug dir, ex: `/path/to/cargo/target/cit/t0/foo/target/host/host-triple/debug`
270+
pub fn host_debug_dir(&self) -> PathBuf {
271+
self.host_dir().join("debug")
272+
}
273+
274+
/// Project's debug dir, ex: `/path/to/cargo/target/cit/t0/foo/target/target-triple/debug`
265275
pub fn target_debug_dir(&self) -> PathBuf {
266276
self.build_dir().join("debug")
267277
}
@@ -280,16 +290,25 @@ impl Project {
280290
.join(paths::get_lib_filename(name, kind))
281291
}
282292

293+
/// Path to an example built as a library.
294+
/// `kind` should be one of: "lib", "rlib", "staticlib", "dylib", "proc-macro"
295+
/// ex: `/path/to/cargo/target/cit/t0/foo/target/host/host-triple/debug/examples/libex.rlib`
296+
pub fn host_example_lib(&self, name: &str, kind: &str) -> PathBuf {
297+
self.host_debug_dir()
298+
.join("examples")
299+
.join(paths::get_lib_filename(name, kind))
300+
}
301+
283302
/// Path to a debug binary.
284-
/// ex: `/path/to/cargo/target/cit/t0/foo/target/debug/foo`
303+
/// ex: `/path/to/cargo/target/target-triple/cit/t0/foo/target/target-triple/debug/foo`
285304
pub fn bin(&self, b: &str) -> PathBuf {
286305
self.build_dir()
287306
.join("debug")
288307
.join(&format!("{}{}", b, env::consts::EXE_SUFFIX))
289308
}
290309

291310
/// Path to a release binary.
292-
/// ex: `/path/to/cargo/target/cit/t0/foo/target/release/foo`
311+
/// ex: `/path/to/cargo/target/target-triple/cit/t0/foo/target/target-triple/release/foo`
293312
pub fn release_bin(&self, b: &str) -> PathBuf {
294313
self.build_dir()
295314
.join("release")
@@ -299,11 +318,11 @@ impl Project {
299318
/// Path to a debug binary for a specific target triple.
300319
/// ex: `/path/to/cargo/target/cit/t0/foo/target/i686-apple-darwin/debug/foo`
301320
pub fn target_bin(&self, target: &str, b: &str) -> PathBuf {
302-
self.build_dir().join(target).join("debug").join(&format!(
303-
"{}{}",
304-
b,
305-
env::consts::EXE_SUFFIX
306-
))
321+
self.root()
322+
.join("target")
323+
.join(target)
324+
.join("debug")
325+
.join(&format!("{}{}", b, env::consts::EXE_SUFFIX))
307326
}
308327

309328
/// Returns an iterator of paths matching the glob pattern, which is

src/bin/cargo/commands/bench.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,10 @@ pub fn cli() -> App {
5151

5252
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
5353
let ws = args.workspace(config)?;
54+
let rustc = config.load_global_rustc(Some(&ws));
5455
let mut compile_opts = args.compile_options(
5556
config,
57+
rustc,
5658
CompileMode::Bench,
5759
Some(&ws),
5860
ProfileChecking::Checked,

src/bin/cargo/commands/build.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@ pub fn cli() -> App {
4949

5050
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
5151
let ws = args.workspace(config)?;
52+
let rustc = config.load_global_rustc(Some(&ws));
5253
let mut compile_opts = args.compile_options(
5354
config,
55+
rustc,
5456
CompileMode::Build,
5557
Some(&ws),
5658
ProfileChecking::Checked,

src/bin/cargo/commands/check.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
5454
}
5555
};
5656
let mode = CompileMode::Check { test };
57-
let compile_opts = args.compile_options(config, mode, Some(&ws), ProfileChecking::Unchecked)?;
57+
let rustc = config.load_global_rustc(Some(&ws));
58+
let compile_opts =
59+
args.compile_options(config, rustc, mode, Some(&ws), ProfileChecking::Unchecked)?;
5860

5961
ops::compile(&ws, &compile_opts)?;
6062
Ok(())

src/bin/cargo/commands/doc.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
4040
let mode = CompileMode::Doc {
4141
deps: !args.is_present("no-deps"),
4242
};
43+
let rustc = config.load_global_rustc(Some(&ws));
4344
let mut compile_opts =
44-
args.compile_options(config, mode, Some(&ws), ProfileChecking::Checked)?;
45+
args.compile_options(config, rustc, mode, Some(&ws), ProfileChecking::Checked)?;
4546
compile_opts.rustdoc_document_private_items = args.is_present("document-private-items");
4647

4748
let doc_opts = DocOptions {

src/bin/cargo/commands/fix.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
8383

8484
// Unlike other commands default `cargo fix` to all targets to fix as much
8585
// code as we can.
86-
let mut opts = args.compile_options(config, mode, Some(&ws), ProfileChecking::Unchecked)?;
86+
let rustc = config.load_global_rustc(Some(&ws));
87+
let mut opts =
88+
args.compile_options(config, rustc, mode, Some(&ws), ProfileChecking::Unchecked)?;
8789

8890
if let CompileFilter::Default { .. } = opts.filter {
8991
opts.filter = CompileFilter::Only {

src/bin/cargo/commands/install.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,15 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
127127
None
128128
};
129129

130+
let ws = args.workspace(config);
131+
let rustc = if ws.is_ok() {
132+
config.load_global_rustc(Some(&ws?))
133+
} else {
134+
config.load_global_rustc(None)
135+
};
130136
let mut compile_opts = args.compile_options(
131137
config,
138+
rustc,
132139
CompileMode::Build,
133140
workspace.as_ref(),
134141
ProfileChecking::Checked,

src/bin/cargo/commands/run.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ pub fn cli() -> App {
3333
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
3434
let ws = args.workspace(config)?;
3535

36+
let rustc = config.load_global_rustc(Some(&ws));
3637
let mut compile_opts = args.compile_options(
3738
config,
39+
rustc,
3840
CompileMode::Build,
3941
Some(&ws),
4042
ProfileChecking::Checked,

src/bin/cargo/commands/rustc.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,10 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
6060
return Err(CliError::new(err, 101));
6161
}
6262
};
63+
let rustc = config.load_global_rustc(Some(&ws));
6364
let mut compile_opts = args.compile_options_for_single_package(
6465
config,
66+
rustc,
6567
mode,
6668
Some(&ws),
6769
ProfileChecking::Unchecked,

src/bin/cargo/commands/rustdoc.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@ pub fn cli() -> App {
4040

4141
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
4242
let ws = args.workspace(config)?;
43+
let rustc = config.load_global_rustc(Some(&ws));
4344
let mut compile_opts = args.compile_options_for_single_package(
4445
config,
46+
rustc,
4547
CompileMode::Doc { deps: false },
4648
Some(&ws),
4749
ProfileChecking::Checked,

0 commit comments

Comments
 (0)