fix(launcher): defer hardware probes and hide Windows consoles

Collect performance-report hardware after the first frame and preserve logs, input and CLI pipes while suppressing background terminal windows.

Co-Authored-By: OpenAI Codex (GPT-6.1 Sol) <noreply@openai.com>
This commit is contained in:
RobertTGreat
2026-10-24 18:34:08 +01:00
parent 7fca3c2f97
commit 1be8a4caea
27 changed files with 570 additions and 50 deletions
+18 -4
View File
@@ -1,6 +1,7 @@
//! The JDK that compiles and runs the vanilla exporters. They call Mojang's own code, so they
//! stay Java; everything around them is here.
use std::ffi::OsStr;
use std::fs;
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};
@@ -13,6 +14,19 @@ pub struct Jdk {
const TIMEOUT: Duration = Duration::from_secs(3600);
/// Exporters and JDK probes write to pipes or log files, never to a new terminal.
fn command(program: impl AsRef<OsStr>) -> Command {
let mut command = Command::new(program);
command.stdin(Stdio::null());
#[cfg(windows)]
{
use std::os::windows::process::CommandExt;
const CREATE_NO_WINDOW: u32 = 0x0800_0000;
command.creation_flags(CREATE_NO_WINDOW);
}
command
}
fn executable(dir: &Path, name: &str) -> PathBuf {
dir.join(if cfg!(windows) {
format!("{name}.exe")
@@ -29,7 +43,7 @@ fn on_path(name: &str) -> Option<PathBuf> {
/// The major version `javac -version` reports ("javac 25.0.1" → 25; "javac 1.8.0" → 8).
fn javac_major(javac: &Path) -> Result<u32, String> {
let output = Command::new(javac)
let output = command(javac)
.arg("-version")
.stdin(Stdio::null())
.output()
@@ -183,7 +197,7 @@ pub fn find(major: i64, more: &[PathBuf]) -> Result<Jdk, String> {
candidates.push((javac, java, "PATH"));
}
if cfg!(target_os = "macos") {
if let Ok(out) = Command::new("/usr/libexec/java_home")
if let Ok(out) = command("/usr/libexec/java_home")
.args(["-v", &major.to_string()])
.stderr(Stdio::null())
.output()
@@ -260,7 +274,7 @@ impl Jdk {
/// `javac --release <major> -proc:none` with Python's `subprocess.run(..., check=True,
/// stdout=log, stderr=STDOUT, timeout=3600)`.
pub fn javac(&self, major: i64, args: &[String], log: &fs::File) -> Result<(), String> {
let mut command = Command::new(&self.javac);
let mut command = command(&self.javac);
command
.args(["--release", &major.to_string(), "-proc:none"])
.args(args);
@@ -268,7 +282,7 @@ impl Jdk {
}
pub fn java(&self, args: &[String], cwd: Option<&Path>, log: &fs::File) -> Result<(), String> {
let mut command = Command::new(&self.java);
let mut command = command(&self.java);
command.args(args);
if let Some(dir) = cwd {
command.current_dir(dir);