From d5f78a4c2e7b626a492643efd62ddeb394276722 Mon Sep 17 00:00:00 2001 From: skal Date: Mon, 9 Feb 2026 17:35:32 +0100 Subject: feat: Add debug-only file change detection for rapid iteration Enables --hot-reload flag to watch config files and notify on changes. Detects modifications to assets/sequences/music for rebuild workflow. Completely stripped from release builds (0 bytes overhead). Co-Authored-By: Claude Sonnet 4.5 --- src/main.cc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/main.cc') diff --git a/src/main.cc b/src/main.cc index 59001fb..b4091e7 100644 --- a/src/main.cc +++ b/src/main.cc @@ -11,6 +11,7 @@ #include "audio/tracker.h" #if !defined(STRIP_ALL) #include "audio/backend/wav_dump_backend.h" +#include "util/file_watcher.h" #include #endif #include "generated/assets.h" // Include generated asset header @@ -32,6 +33,7 @@ int main(int argc, char** argv) { bool dump_wav = false; bool tempo_test_enabled = false; const char* wav_output_file = "audio_dump.wav"; + bool hot_reload_enabled = false; #if !defined(STRIP_ALL) for (int i = 1; i < argc; ++i) { @@ -57,6 +59,9 @@ int main(int argc, char** argv) { } } else if (strcmp(argv[i], "--tempo") == 0) { tempo_test_enabled = true; + } else if (strcmp(argv[i], "--hot-reload") == 0) { + hot_reload_enabled = true; + printf("Hot-reload enabled (watching config files)\n"); } } #else @@ -166,6 +171,16 @@ int main(int argc, char** argv) { audio_start(); g_last_audio_time = audio_get_playback_time(); // Initialize after start +#if !defined(STRIP_ALL) + // Hot-reload setup + FileWatcher file_watcher; + if (hot_reload_enabled) { + file_watcher.add_file("assets/final/demo_assets.txt"); + file_watcher.add_file("assets/demo.seq"); + file_watcher.add_file("assets/music.track"); + } +#endif + #if !defined(STRIP_ALL) // In WAV dump mode, run headless simulation and write audio to file if (dump_wav) { @@ -255,6 +270,15 @@ int main(int argc, char** argv) { // context fill_audio_buffer(audio_dt, current_physical_time); +#if !defined(STRIP_ALL) + // Hot-reload: Check for file changes + if (hot_reload_enabled && file_watcher.check_changes()) { + printf("\n[Hot-Reload] Config files changed - rebuild required\n"); + printf("[Hot-Reload] Run: cmake --build build -j4 && ./build/demo64k\n"); + file_watcher.reset(); + } +#endif + // --- Graphics Update --- const float aspect_ratio = platform_state.aspect_ratio; -- cgit v1.2.3