From e034a2bb14a4a2fd01fcee6883ae03d445d0957f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kav=C3=ADk?= Date: Sat, 1 Jun 2024 23:06:27 +0200 Subject: [PATCH] new tasks, frontend crate platform features --- Makefile.toml | 36 +++++++++++++++++++++++++++++++----- frontend/src/platform.rs | 3 +++ src-tauri/tauri.conf.json | 4 ++-- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/Makefile.toml b/Makefile.toml index 2c28aed..8a3f03b 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -29,6 +29,15 @@ run_task = { fork = true, parallel = true, name = [ "watch_tauri_glue", ]} +[tasks.start_web] +description = "Run without Tauri in the browser & watch Typescript and Rust in the debug mode" +dependencies = ["store_current_process_id"] +run_task = { fork = true, parallel = true, name = [ + "tauri_dev_with_cleanup", + "watch_pixi_canvas", + "watch_tauri_glue", +]} + [tasks.bundle] description = "Compile in the release mode and create installation packages" dependencies = ["tauri_build", "show_release_paths"] @@ -46,10 +55,13 @@ description = "Run locally installed tauri" command = "tauri/bin/cargo-tauri" args = ["${@}"] +[tasks.mzoon_for_tauri] +description = "Run locally installed mzoon with enabled `frontend` feature `platform_tauri" +extend = "mzoon_with_disabled_frontend_features" + [tasks.mzoon] -description = "Run locally installed mzoon" -command = "mzoon/bin/mzoon" -args = ["${@}"] +description = "Run locally installed mzoon with enabled `frontend` feature `platform_browser" +extend = "mzoon_with_disabled_frontend_features" # [tasks.mzoon] # description = "Run mzoon from a cloned MoonZoon repo" @@ -58,6 +70,11 @@ args = ["${@}"] ###### HELPER TASKS ###### +[tasks.mzoon_with_disabled_frontend_features] +description = "Run locally installed mzoo" +command = "mzoon/bin/mzoon" +args = ["${@}"] + [tasks.store_current_process_id] description = "" script_runner = "@duckscript" @@ -72,11 +89,20 @@ description = "Run `tauri dev`" extend = "tauri" args = ["dev"] +[tasks.mzoon_start] +description = "Run `mzoon start`" +extend = "mzoon" +args = ["start"] + [tasks.tauri_dev_with_cleanup] description = "Run forked `tauri dev` with cleanup" -run_task = { fork = true, cleanup_task = "cleanup_after_tauri_dev", name = ["tauri_dev"] } +run_task = { fork = true, cleanup_task = "kill_watchers", name = ["tauri_dev"] } -[tasks.cleanup_after_tauri_dev] +[tasks.mzoon_start_with_cleanup] +description = "Run forked `mzoon start` with cleanup" +run_task = { fork = true, cleanup_task = "kill_watchers", name = ["mzoon_start"] } + +[tasks.kill_watchers] description = "Kill the cargo-make/makers process and all its children / forked processes" script_runner = "@duckscript" script = ''' diff --git a/frontend/src/platform.rs b/frontend/src/platform.rs index 465c9f9..9e3104d 100644 --- a/frontend/src/platform.rs +++ b/frontend/src/platform.rs @@ -8,6 +8,9 @@ mod browser; #[cfg(feature = "platform_browser")] use browser as platform; +#[cfg(all(feature = "platform_tauri", feature = "platform_browser"))] +compile_error!("feature \"foo\" and feature \"bar\" cannot be enabled at the same time"); + pub async fn show_window() { platform::show_window().await } diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index cd35803..bd2346e 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -5,8 +5,8 @@ "build": { "frontendDist": "../frontend_dist", "devUrl": "http://localhost:8080", - "beforeDevCommand": "makers mzoon start", - "beforeBuildCommand": "makers mzoon build -r -f" + "beforeDevCommand": "makers mzoon_for_tauri start", + "beforeBuildCommand": "makers mzoon_for_tauri build -r -f" }, "app": { "macOSPrivateApi": true,