add release flag to x task

This commit is contained in:
Niels Geens 2025-08-05 17:16:15 +02:00
parent 872f933506
commit 09e861eb73
3 changed files with 36 additions and 16 deletions

View File

@ -10,7 +10,10 @@ pub struct Args {
#[derive(Subcommand)] #[derive(Subcommand)]
pub enum Command { pub enum Command {
Run, Run {
#[arg(short, long)]
release: bool,
},
Collect, Collect,
Mapper, Mapper,
} }

View File

@ -15,8 +15,11 @@ async fn main() {
.expect("Failed to change to workspace directory"); .expect("Failed to change to workspace directory");
match args.command { match args.command {
Some(args::Command::Run) | None => { Some(args::Command::Run { release }) => {
run::run().await; run::run(release).await;
}
None => {
run::run(false).await;
} }
Some(args::Command::Collect) => { Some(args::Command::Collect) => {
collect::collect().await; collect::collect().await;

View File

@ -5,7 +5,7 @@ use tokio_util::sync::CancellationToken;
type ProcessHandle = Arc<Mutex<Option<Child>>>; type ProcessHandle = Arc<Mutex<Option<Child>>>;
pub async fn run() { pub async fn run(release: bool) {
let qjackctl_handle: ProcessHandle = Arc::new(Mutex::new(None)); let qjackctl_handle: ProcessHandle = Arc::new(Mutex::new(None));
let audio_engine_handle: ProcessHandle = Arc::new(Mutex::new(None)); let audio_engine_handle: ProcessHandle = Arc::new(Mutex::new(None));
let gui_handle: ProcessHandle = Arc::new(Mutex::new(None)); let gui_handle: ProcessHandle = Arc::new(Mutex::new(None));
@ -35,9 +35,9 @@ pub async fn run() {
// Start processes // Start processes
let qjackctl = spawn_qjackctl().await; let qjackctl = spawn_qjackctl().await;
tokio::time::sleep(tokio::time::Duration::from_secs(2)).await; tokio::time::sleep(tokio::time::Duration::from_secs(2)).await;
let audio_engine = spawn_audio_engine().await; let audio_engine = spawn_audio_engine(release).await;
let gui = spawn_gui().await; let gui = spawn_gui(release).await;
let simulator = spawn_simulator().await; let simulator = spawn_simulator(release).await;
// Store handles for cleanup // Store handles for cleanup
*qjackctl_handle.lock().await = Some(qjackctl); *qjackctl_handle.lock().await = Some(qjackctl);
@ -130,11 +130,12 @@ async fn spawn_qjackctl() -> Child {
.expect("Could not start qjackctl") .expect("Could not start qjackctl")
} }
async fn spawn_audio_engine() -> Child { async fn spawn_audio_engine(release: bool) -> Child {
Command::new("cargo") Command::new("cargo")
.args([ .args([
"run", "run",
"--release", "--profile",
if release { "release" } else { "debug" },
"--bin", "--bin",
"audio_engine", "audio_engine",
"--", "--",
@ -145,19 +146,32 @@ async fn spawn_audio_engine() -> Child {
.expect("Could not start audio engine") .expect("Could not start audio engine")
} }
async fn spawn_gui() -> Child { async fn spawn_gui(release: bool) -> Child {
Command::new("cargo") Command::new("cargo")
.args(["run", "--release", "--bin", "gui"]) .args([
"run",
"--profile",
if release { "release" } else { "debug" },
"--bin",
"gui"
])
.spawn() .spawn()
.expect("Could not start gui") .expect("Could not start gui")
} }
async fn spawn_simulator() -> Child { async fn spawn_simulator(release: bool) -> Child {
if release {
Command::new("sleep")
.args(["infinity"])
.spawn()
.expect("Could not start simulator")
} else {
Command::new("cargo") Command::new("cargo")
.args(["run", "--release", "--bin", "simulator"]) .args(["run", "--release", "--bin", "simulator"])
.spawn() .spawn()
.expect("Could not start simulator") .expect("Could not start simulator")
} }
}
async fn kill_process(child: &mut Child, name: &str) { async fn kill_process(child: &mut Child, name: &str) {
match child.kill().await { match child.kill().await {