remove start_porcess helper method

This commit is contained in:
bit-aloo 2025-06-16 23:50:10 +05:30
parent 2e4f2d2f3b
commit b16ba4d3ee
No known key found for this signature in database

View file

@ -5,13 +5,11 @@
use std::ffi::OsStr;
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};
use std::sync::OnceLock;
use std::thread::panicking;
use std::time::{Instant, SystemTime, UNIX_EPOCH};
use std::{env, fs, io, panic, str};
use build_helper::util::fail;
use object::read::archive::ArchiveFile;
use crate::LldMode;
@ -282,33 +280,6 @@ pub fn make(host: &str) -> PathBuf {
}
}
/// Spawn a process and return a closure that will wait for the process
/// to finish and then return its output. This allows the spawned process
/// to do work without immediately blocking bootstrap.
#[track_caller]
pub fn start_process(cmd: &mut Command) -> impl FnOnce() -> String + use<> {
let child = match cmd.stderr(Stdio::inherit()).stdout(Stdio::piped()).spawn() {
Ok(child) => child,
Err(e) => fail(&format!("failed to execute command: {cmd:?}\nERROR: {e}")),
};
let command = format!("{cmd:?}");
move || {
let output = child.wait_with_output().unwrap();
if !output.status.success() {
panic!(
"command did not execute successfully: {}\n\
expected success, got: {}",
command, output.status
);
}
String::from_utf8(output.stdout).unwrap()
}
}
/// Returns the last-modified time for `path`, or zero if it doesn't exist.
pub fn mtime(path: &Path) -> SystemTime {
fs::metadata(path).and_then(|f| f.modified()).unwrap_or(UNIX_EPOCH)