Skip to content

Commit 165fb43

Browse files
committed
Support dependencies during cross compilation
1 parent da426fa commit 165fb43

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

tests/compiletest.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ fn run_tests(mode: Mode, path: &str, target: Option<String>) -> Result<()> {
6565
dependency_builder: Some((
6666
std::env::current_dir()?.join("miri"),
6767
vec!["cargo".to_string()],
68+
vec![("MIRI_SYSROOT".to_string(), std::env::var("MIRI_SYSROOT").unwrap())],
6869
)),
6970
};
7071
ui_test::run_tests(config)

ui_test/src/dependencies.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use color_eyre::eyre::{ensure, Result};
1+
use color_eyre::eyre::{bail, Result};
22
use std::{
33
path::{Path, PathBuf},
44
process::Command,
@@ -12,13 +12,14 @@ pub fn build_dependencies(config: &Config) -> Result<Vec<(String, PathBuf)>> {
1212
Some(path) => path,
1313
None => return Ok(vec![]),
1414
};
15-
let (program, args): (&Path, &[_]) = match &config.dependency_builder {
16-
Some((path, args)) => (path, args),
17-
None => (Path::new("cargo"), &[]),
15+
let (program, args, envs): (&Path, &[_], &[_]) = match &config.dependency_builder {
16+
Some((path, args, envs)) => (path, args, envs),
17+
None => (Path::new("cargo"), &[], &[]),
1818
};
1919
let mut build = Command::new(program);
2020
build.env_clear();
2121
build.env("PATH", std::env::var_os("PATH").unwrap());
22+
build.envs(envs.iter().map(|(k, v)| (k, v)));
2223
build.args(args);
2324
build.arg("run");
2425
if let Some(target) = &config.target {
@@ -32,7 +33,12 @@ pub fn build_dependencies(config: &Config) -> Result<Vec<(String, PathBuf)>> {
3233

3334
let output = build.output()?;
3435

35-
ensure!(output.status.success(), "{output:#?}");
36+
if !output.status.success() {
37+
let stdout = String::from_utf8(output.stdout)?;
38+
let stderr = String::from_utf8(output.stderr)?;
39+
bail!("failed to compile dependencies:\nstderr:\n{stderr}\n\nstdout:{stdout}");
40+
}
41+
3642
let output = output.stdout;
3743
let output = String::from_utf8(output)?;
3844
Ok(output

ui_test/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub struct Config {
4444
pub manifest_path: Option<PathBuf>,
4545
/// Can be used to override what command to run instead of `cargo` to build the
4646
/// dependencies in `manifest_path`
47-
pub dependency_builder: Option<(PathBuf, Vec<String>)>,
47+
pub dependency_builder: Option<(PathBuf, Vec<String>, Vec<(String, String)>)>,
4848
}
4949

5050
#[derive(Debug)]

0 commit comments

Comments
 (0)