From 84700cf61b18b84af2834e3363b2f6feeb739fd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kav=C3=ADk?= Date: Sat, 1 Jun 2024 23:46:12 +0200 Subject: [PATCH] enable both FASTWAVE_PLATFORM values in Rust Analyzer --- .gitignore | 1 + Makefile.toml | 3 +++ frontend/build.rs | 3 ++- frontend/src/platform.rs | 2 ++ 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index cf67cae..2ecdede 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ frontend_dist/_api frontend_dist/index.html mzoon tauri +!.vscode diff --git a/Makefile.toml b/Makefile.toml index 006f4ea..9d9b9cc 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -42,6 +42,9 @@ run_task = { fork = true, parallel = true, name = [ description = "Compile in the release mode and create installation packages" dependencies = ["tauri_build", "show_release_paths"] +# @TODO Write task `bundle_browser` once we know whether we need only the frontend +# or also the backend side (Moon server) + # @TODO: Format also Typescript and CSS [tasks.format] description = "Format code" diff --git a/frontend/build.rs b/frontend/build.rs index 39935d2..95b14e2 100644 --- a/frontend/build.rs +++ b/frontend/build.rs @@ -16,7 +16,8 @@ macro_rules! instruction { // } fn main() { - let default_platform = "BROWSER"; + let default_platform = "TAURI"; let platform = env::var("FASTWAVE_PLATFORM").unwrap_or_else(|_| default_platform.to_owned()); instruction!("cargo:rustc-cfg=FASTWAVE_PLATFORM=\"{platform}\""); + instruction!("cargo:rerun-if-env-changed=FASTWAVE_PLATFORM"); } diff --git a/frontend/src/platform.rs b/frontend/src/platform.rs index 84e0465..ddee1c1 100644 --- a/frontend/src/platform.rs +++ b/frontend/src/platform.rs @@ -1,6 +1,8 @@ // @TODO maybe rewrite `FASTWAVE_PLATFORM` to features once it's possible to set them through env vars: // https://github.com/rust-lang/cargo/issues/4829 +// NOTE: `FASTWAVE_PLATFORM` is set in `Makefile.toml` tasks and then in `build.rs` + #[cfg(FASTWAVE_PLATFORM = "TAURI")] mod tauri; #[cfg(FASTWAVE_PLATFORM = "TAURI")]