b/os: only set creation_flags on windows

This commit is contained in:
Tyler Wilding 2023-03-05 16:28:43 -05:00
parent f84a7c6403
commit 362597e604
No known key found for this signature in database
GPG key ID: 77CB07796494137E

View file

@ -1,6 +1,7 @@
#[cfg(target_os = "windows")]
use std::os::windows::process::CommandExt;
use std::{ use std::{
collections::HashMap, collections::HashMap,
os::windows::process::CommandExt,
path::{Path, PathBuf}, path::{Path, PathBuf},
process::Command, process::Command,
}; };
@ -8,7 +9,6 @@ use std::{
use log::{info, warn}; use log::{info, warn};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use serde_json::Value; use serde_json::Value;
use tauri::Manager;
use crate::{ use crate::{
config::LauncherConfig, config::LauncherConfig,
@ -283,13 +283,17 @@ pub async fn extract_and_validate_iso(
// This is the first install step, reset the file // This is the first install step, reset the file
let log_file = create_log_file(&app_handle, "extractor.log", false)?; let log_file = create_log_file(&app_handle, "extractor.log", false)?;
let output = Command::new(exec_info.executable_path) let mut command = Command::new(exec_info.executable_path);
.creation_flags(0x08000000) command
.args(args) .args(args)
.current_dir(exec_info.executable_dir) .current_dir(exec_info.executable_dir)
.stdout(log_file.try_clone().unwrap()) .stdout(log_file.try_clone()?)
.stderr(log_file.try_clone().unwrap()) .stderr(log_file.try_clone()?);
.output()?; #[cfg(windows)]
{
command.creation_flags(0x08000000);
}
let output = command.output()?;
match output.status.code() { match output.status.code() {
Some(code) => { Some(code) => {
if code == 0 { if code == 0 {
@ -339,18 +343,22 @@ pub async fn run_decompiler(
} }
let log_file = create_log_file(&app_handle, "extractor.log", !truncate_logs)?; let log_file = create_log_file(&app_handle, "extractor.log", !truncate_logs)?;
let output = Command::new(&exec_info.executable_path) let mut command = Command::new(exec_info.executable_path);
.creation_flags(0x08000000) command
.args([ .args([
source_path, source_path,
"--decompile".to_string(), "--decompile".to_string(),
"--proj-path".to_string(), "--proj-path".to_string(),
data_folder.to_string_lossy().into_owned(), data_folder.to_string_lossy().into_owned(),
]) ])
.stdout(log_file.try_clone().unwrap()) .stdout(log_file.try_clone()?)
.stderr(log_file) .stderr(log_file)
.current_dir(exec_info.executable_dir) .current_dir(exec_info.executable_dir);
.output()?; #[cfg(windows)]
{
command.creation_flags(0x08000000);
}
let output = command.output()?;
match output.status.code() { match output.status.code() {
Some(code) => { Some(code) => {
if code == 0 { if code == 0 {
@ -400,8 +408,8 @@ pub async fn run_compiler(
} }
let log_file = create_log_file(&app_handle, "extractor.log", !truncate_logs)?; let log_file = create_log_file(&app_handle, "extractor.log", !truncate_logs)?;
let output = Command::new(&exec_info.executable_path) let mut command = Command::new(exec_info.executable_path);
.creation_flags(0x08000000) command
.args([ .args([
source_path, source_path,
"--compile".to_string(), "--compile".to_string(),
@ -410,8 +418,12 @@ pub async fn run_compiler(
]) ])
.stdout(log_file.try_clone().unwrap()) .stdout(log_file.try_clone().unwrap())
.stderr(log_file) .stderr(log_file)
.current_dir(exec_info.executable_dir) .current_dir(exec_info.executable_dir);
.output()?; #[cfg(windows)]
{
command.creation_flags(0x08000000);
}
let output = command.output()?;
match output.status.code() { match output.status.code() {
Some(code) => { Some(code) => {
if code == 0 { if code == 0 {
@ -451,8 +463,8 @@ pub async fn open_repl(
let data_folder = get_data_dir(&config_info, &game_name, false)?; let data_folder = get_data_dir(&config_info, &game_name, false)?;
let exec_info = get_exec_location(&config_info, "goalc")?; let exec_info = get_exec_location(&config_info, "goalc")?;
let output = Command::new("cmd") let mut command = Command::new("cmd");
.creation_flags(0x08000000) command
.args([ .args([
"/K", "/K",
"start", "start",
@ -460,8 +472,12 @@ pub async fn open_repl(
"--proj-path", "--proj-path",
&data_folder.to_string_lossy().into_owned(), &data_folder.to_string_lossy().into_owned(),
]) ])
.current_dir(exec_info.executable_dir) .current_dir(exec_info.executable_dir);
.spawn()?; #[cfg(windows)]
{
command.creation_flags(0x08000000);
}
command.spawn()?;
Ok(()) Ok(())
} }
@ -486,12 +502,16 @@ pub async fn launch_game(
args.push("-proj-path".to_string()); args.push("-proj-path".to_string());
args.push(data_folder.to_string_lossy().into_owned()); args.push(data_folder.to_string_lossy().into_owned());
let log_file = create_log_file(&app_handle, "game.log", false)?; let log_file = create_log_file(&app_handle, "game.log", false)?;
let output = Command::new(exec_info.executable_path) let mut command = Command::new(exec_info.executable_path);
.creation_flags(0x08000000) command
.args(args) .args(args)
.stdout(log_file.try_clone().unwrap()) .stdout(log_file.try_clone().unwrap())
.stderr(log_file) .stderr(log_file)
.current_dir(exec_info.executable_dir) .current_dir(exec_info.executable_dir);
.spawn()?; #[cfg(windows)]
{
command.creation_flags(0x08000000);
}
command.spawn()?;
Ok(()) Ok(())
} }