mirror of
https://github.com/allankoechke/rust.git
synced 2026-11-30 11:05:36 +00:00
Fixes the builds of rustc and library/std for the L4Re target OS. A major change was done in linking binaries: The need for the L4Bender tool was removed and linking parameters are now fully configured in the rustc target config.
50 lines
1.4 KiB
Rust
50 lines
1.4 KiB
Rust
fn main() {
|
|
// No `Command` on Miri, emscripten or L4Re
|
|
#[cfg(all(
|
|
not(miri),
|
|
any(unix, windows),
|
|
not(any(target_os = "emscripten", target_os = "l4re"))
|
|
))]
|
|
{
|
|
use std::io::{Read, pipe};
|
|
use std::{env, process};
|
|
|
|
if env::var("I_AM_THE_CHILD").is_ok() {
|
|
child();
|
|
} else {
|
|
parent();
|
|
}
|
|
|
|
fn parent() {
|
|
let me = env::current_exe().unwrap();
|
|
// If a custom `runner` is set up for the current target, we'll be
|
|
// executing `./runner ./test`, not just `./test`. For such a case,
|
|
// use the same arguments for child to avoid executing `runner`
|
|
// without an actual executable.
|
|
let args = env::args();
|
|
|
|
let (rx, tx) = pipe().unwrap();
|
|
assert!(
|
|
process::Command::new(me)
|
|
.args(args)
|
|
.env("I_AM_THE_CHILD", "1")
|
|
.stdout(tx)
|
|
.status()
|
|
.unwrap()
|
|
.success()
|
|
);
|
|
|
|
let mut s = String::new();
|
|
(&rx).read_to_string(&mut s).unwrap();
|
|
drop(rx);
|
|
assert_eq!(s, "Heloo,\n");
|
|
|
|
println!("Test pipe_subprocess.rs success");
|
|
}
|
|
|
|
fn child() {
|
|
println!("Heloo,");
|
|
}
|
|
}
|
|
}
|