diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-09 17:35:32 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-09 17:35:32 +0100 |
| commit | d5f78a4c2e7b626a492643efd62ddeb394276722 (patch) | |
| tree | cdf38c3d64f6bf417975ce396572fc425d6f8910 /src/main.cc | |
| parent | 802e97ee695de1bc8657c5cbca653bb2f13b90a8 (diff) | |
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 <noreply@anthropic.com>
Diffstat (limited to 'src/main.cc')
| -rw-r--r-- | src/main.cc | 24 |
1 files changed, 24 insertions, 0 deletions
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 <vector> #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 @@ -167,6 +172,16 @@ int main(int argc, char** argv) { 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) { printf("Running WAV dump simulation...\n"); @@ -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; |
