summaryrefslogtreecommitdiff
path: root/scripts
AgeCommit message (Collapse)Author
12 hoursfeat(build): Add FINAL_STRIP mode for maximum size optimizationskal
Implemented systematic fatal error checking infrastructure that can be stripped for final builds. This addresses the need to remove all error checking (abort() calls) from the production binary while maintaining safety during development. ## New Infrastructure ### 1. CMake Option: DEMO_FINAL_STRIP - New build mode for absolute minimum binary size - Implies DEMO_STRIP_ALL (stricter superset) - NOT included in DEMO_ALL_OPTIONS (manual opt-in only) - Message printed during configuration ### 2. Header: src/util/fatal_error.h - Systematic macro-based error checking - Zero cost when FINAL_STRIP enabled (compiles to ((void)0)) - Full error messages with file:line info when enabled - Five macros for different use cases: - FATAL_CHECK(cond, msg, ...): Conditional checks (most common) - FATAL_ERROR(msg, ...): Unconditional errors - FATAL_UNREACHABLE(): Unreachable code markers - FATAL_ASSERT(cond): Assertion-style invariants - FATAL_CODE_BEGIN/END: Complex validation blocks ### 3. CMake Target: make final - Convenience target for triggering final build - Reconfigures with FINAL_STRIP and rebuilds demo64k - Only available when NOT in FINAL_STRIP mode (prevents recursion) ### 4. Script: scripts/build_final.sh - Automated final build workflow - Creates build_final/ directory - Shows size comparison with STRIP_ALL build (if available) - Comprehensive warnings about stripped error checking ## Build Mode Hierarchy | Mode | Error Checks | Debug Features | Size Opt | |-------------|--------------|----------------|----------| | Debug | ✅ | ✅ | ❌ | | STRIP_ALL | ✅ | ❌ | ✅ | | FINAL_STRIP | ❌ | ❌ | ✅✅ | ## Design Decisions (All Agreed Upon) 1. **FILE:LINE Info**: ✅ Include (worth 200 bytes for debugging) 2. **ALL_OPTIONS**: ❌ Manual opt-in only (too dangerous for testing) 3. **FATAL_ASSERT**: ✅ Add macro (semantic clarity for invariants) 4. **Strip Hierarchy**: ✅ STRIP_ALL keeps checks, FINAL_STRIP removes all 5. **Naming**: ✅ FATAL_* prefix (clear intent, conventional) ## Size Impact Current: 10 abort() calls in production code - ring_buffer.cc: 7 checks (~350 bytes) - miniaudio_backend.cc: 3 checks (~240 bytes) Estimated savings with FINAL_STRIP: ~500-600 bytes ## Documentation Updated: - doc/HOWTO.md: Added FINAL_STRIP build instructions - doc/CONTRIBUTING.md: Added fatal error checking guidelines - src/util/fatal_error.h: Comprehensive usage documentation ## Next Steps (Not in This Commit) Phase 2: Convert ring_buffer.cc abort() calls to FATAL_CHECK() Phase 3: Convert miniaudio_backend.cc abort() calls to FATAL_CHECK() Phase 4: Systematic scan for remaining abort() calls Phase 5: Verify size reduction with actual measurements ## Usage # Convenience methods make final # From normal build directory ./scripts/build_final.sh # Creates build_final/ # Manual cmake -S . -B build_final -DDEMO_FINAL_STRIP=ON cmake --build build_final ⚠️ WARNING: FINAL_STRIP builds have NO error checking. Use ONLY for final release, never for development/testing. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
13 hoursfix(coverage): Explicitly disable STRIP_ALL during coverage runsskal
Added -DDEMO_STRIP_ALL=OFF to cmake configuration in gen_coverage_report.sh to ensure all test code is included in coverage analysis. Previously the script relied on the default value of STRIP_ALL, which could potentially exclude test infrastructure code from coverage reports. The remaining warnings in coverage output are benign lcov/genhtml warnings about unknown categories and data inconsistencies, normal for coverage analysis. Coverage: 57.8% lines, 76.0% functions (77 source files) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
13 hoursfix(coverage): Handle moved files and clean stale coverage dataskal
Problem: Coverage script failed with error: lcov: ERROR: (source) unable to open /Users/skal/demo/src/platform.cc Root Cause: - Old .gcno/.gcda coverage files referenced old src/platform.cc path - File was moved to src/platform/platform.cc in earlier refactor - Stale coverage data persisted between runs Solution: 1. Added 'source' to LCOV_OPTS ignore list - Handles missing source files gracefully - Common when files are moved/renamed between coverage runs 2. Enable automatic cleanup of build_coverage/ directory - Removes stale coverage data before each run - Prevents conflicts from moved/renamed files - Changed from commented-out to active cleanup Result: - Coverage report generates successfully - 57.8% line coverage, 76.0% function coverage - No errors about missing src/platform.cc - Clean builds prevent stale data accumulation The script now handles project reorganizations gracefully.
13 hoursfix(ci): Update verification script to catch tool compilation failuresskal
Problem: The spectool.cc include path bug was not caught by the test suite because check_all.sh only built tests, not tools. Root Cause Analysis: - check_all.sh used -DDEMO_BUILD_TESTS=ON only - Tools (spectool, specview, specplay) are built with -DDEMO_BUILD_TOOLS=ON - CTest runs tests but doesn't verify tool compilation - Result: Tool compilation failures went undetected Solution: Updated scripts/check_all.sh to: 1. Enable both -DDEMO_BUILD_TESTS=ON and -DDEMO_BUILD_TOOLS=ON 2. Explicitly verify all tools compile (spectool, specview, specplay) 3. Add clear output messages for each verification stage 4. Document what the script verifies in header comments Updated doc/CONTRIBUTING.md: - Added "Automated Verification (Recommended)" section - Documented that check_all.sh verifies tests AND tools - Provided manual verification steps as alternative - Clear command examples with expected behavior Verification: - Tested by intentionally breaking spectool.cc include - Script correctly caught the compilation error - Reverted break and verified all tools build successfully This ensures all future tool changes are verified before commit. Prevents regression: Similar include path issues will now be caught by pre-commit verification.
29 hoursfeat(audio): Add RMS normalization to spectool for consistent sample loudnessskal
IMPLEMENTATION: - Added --normalize flag to spectool analyze command - Default target RMS: 0.15 (customizable via --normalize [rms]) - Two-pass processing: load all PCM → calculate RMS/peak → normalize → DCT - Peak-limiting safety: prevents clipping by limiting scale factor if peak > 1.0 - Updated gen_spectrograms.sh to use --normalize by default ALGORITHM: 1. Calculate original RMS and peak of input audio 2. Compute scale factor to reach target RMS (default 0.15) 3. Check if scaled peak would exceed 1.0 (after windowing + IDCT) 4. If yes, reduce scale factor to keep peak ≤ 1.0 (prevents clipping) 5. Apply scale factor to all PCM samples before windowing/DCT RESULTS: Before normalization: - RMS range: 0.054 - 0.248 (4.6x variation, ~13 dB) - Some peaks > 1.0 (clipping) After normalization: - RMS range: 0.049 - 0.097 (2.0x variation, ~6 dB) ✅ 2.3x improvement - All peaks < 1.0 (no clipping) ✅ SAMPLES REGENERATED: - All 14 .spec files regenerated with normalization - High dynamic range samples (SNARE_808, CRASH_DMX, HIHAT_CLOSED_DMX) were peak-limited to prevent clipping - Consistent loudness across all drum and bass samples GITIGNORE CHANGE: - Removed *.spec from .gitignore to track normalized spectrograms - This ensures reproducibility and prevents drift from source files handoff(Claude): RMS normalization implemented and working. All samples now have consistent loudness with no clipping.
3 daysasset location cleanupskal
4 daysfeat(tooling): Add directory filtering to coverage report script (Task #46)skal
Updated gen_coverage_report.sh to accept an optional argument for targeting specific directories using lcov --extract.
4 daysfeat(tooling): Implement code coverage reporting (Task #44)skal
Added CMake support for coverage builds and a script to generate HTML reports using lcov on macOS. Also cleaned up .gitignore.
4 daysrefactor: Task #20 - Platform & Code Hygieneskal
- Consolidated all WebGPU shims and platform-specific logic into src/platform.h. - Refactored platform_init to return PlatformState by value and platform_poll to automatically refresh time and aspect_ratio. - Removed STL dependencies (std::map, std::vector, std::string) from AssetManager and Procedural subsystems. - Fixed Windows cross-compilation by adjusting include paths and linker flags in CMakeLists.txt and updating build_win.sh. - Removed redundant direct inclusions of GLFW/glfw3.h and WebGPU headers across the project. - Applied clang-format and updated documentation. handoff(Gemini): Completed Task #20 and 20.1. Platform abstraction is now unified, and core paths are STL-free. Windows build is stable.
4 daysbuild: Enable parallel compilation in build scriptsskal
Add -j8 flag to all cmake --build commands to use 8 threads for faster parallel compilation across gen_assets.sh, crunch_demo.sh, and build_win.sh scripts. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
5 daysfeat(assets): Add new drum samples and improve conversion scriptskal
Created a new script, scripts/gen_spectrograms.sh, to robustly convert all audio files in assets/originals to .spec format. The new script is more portable and provides better feedback. Added the newly generated drum and bass samples to the asset list, organizing them by type for clarity. This completes the requested sub-task.
5 daysfix(shader): Correct WGSL loop syntax in calc_shadowskal
- Replaced invalid 'i++' with 'i = i + 1' in the shader's calc_shadow function loop. - This resolves the shader parsing error and allows the 3D renderer test to run successfully on all platforms.
5 daysadd new tasksskal
5 daysfeat(build): Add check_all script and optimize spectoolskal
- Task #4b: Added scripts/check_all.sh to build and test all platform targets (native and Windows cross-compile) to ensure pre-commit stability. - Task #10: Modified spectool to trim both leading and trailing silent frames from generated .spec files, reducing asset size.
7 daysrefactor: move generated asset files to src/generated/skal
- Updated CMakeLists.txt to generate assets.h and assets_data.cc in src/generated/. - Updated scripts/gen_assets.sh to reflect the new output location. - Modified asset_packer.cc to generate correct include paths in assets_data.cc. - Updated source files (main.cc, asset_manager.cc, test_assets.cc) to include headers from the 'generated/' subdirectory. - Ensured all targets have correct include paths to find generated headers. - Removed stale generated files from src/.
7 daysfix: Cross-compilation and style complianceskal
Fixes seq_compiler build for Windows cross-compilation. Moves common WebGPU compatibility shims to gpu.h. Applies project-wide coding style via clang-format. Verified on both macOS (native) and Windows (cross-compile).
7 daysupdate session with mix fixesskal
7 daysupdate state in .md filesskal
7 daysFinalize Windows port with size analysis reporting and updated docsskal
7 daysAdd Windows cross-compilation support (MinGW) and emulation (Wine)skal
8 daysChore: Remove trailing whitespaces across the codebaseskal
10 dayschore(scripts): Update gen_assets.sh to include test asset generationskal
Ensures that test assets are also generated when the production pipeline is run.
11 daysfix(assets): Update gen_assets.sh pathsskal
Synchronizes scripts/gen_assets.sh with the current project structure: uses 'demo_assets.txt' and outputs to the 'src/' directory.
11 daysfix(crunch): Use strip/gzexe on macOS instead of UPXskal
UPX is unreliable on macOS. Switched to using standard 'strip -u -r' and 'gzexe' for binary compression on Darwin systems. Achieved a compressed binary size of ~48KB (dynamically linked). Updated FETCH_DEPS.md to reflect that UPX is now only required for Linux/Windows.
11 daysfeat(crunch): Add UPX-based binary packer scriptskal
Adds 'scripts/crunch_demo.sh' to automate building a stripped binary and compressing it with UPX. Updates 'FETCH_DEPS.md' with UPX installation instructions and 'HOWTO.md' with usage guide. This addresses Task 3 (add binary crunchers).
11 daysrefactor(gpu): Integrate WebGPU via system wgpu-native and glfw3webgpuskal
Replaces the complex wgpu-native submodule and manual platform-specific surface creation with a system-wide wgpu-native install (via Homebrew) and the glfw3webgpu helper library. - Updates scripts/project_init.sh to fetch glfw3webgpu and ensure wgpu-native is installed. - Refactors CMakeLists.txt to link against the system wgpu-native library. - Simplifies src/platform.cc to use glfwCreateWindowWGPUSurface. - Simplifies src/gpu/gpu.cc to use standard WebGPU headers. - Updates FETCH_DEPS.md with new installation instructions. - Updates PROJECT_CONTEXT.md with the new integration strategy.
11 daysfeat: Implement fullscreen, keyboard controls, and pulsating heptagonskal
This commit fulfills tasks 1 and 2, and adds a synchronized visual effect. - **Fullscreen Mode**: Added '--fullscreen' command-line argument and dynamic toggling via 'F' key. - **Keyboard Controls**: Implemented 'Esc' to exit and 'F' to toggle fullscreen in 'src/platform.cc'. - **Synchronized Visuals**: Added a pulsating heptagon effect in 'src/gpu/gpu.cc' and 'src/gpu/shader.wgsl' that scales and changes color based on the real-time audio peak from the synth. - **Refactor**: Abstracted platform-specific WebGPU surface creation into 'src/platform.cc' to keep 'src/gpu/gpu.cc' cross-platform. - **Build System**: Corrected 'CMakeLists.txt' to properly link 'wgpu-native' and platform frameworks, and updated 'project_init.sh' to build the submodule. - **Documentation**: Updated 'HOWTO.md' and 'PROJECT_CONTEXT.md' with new features and decisions.
11 daysinitial commitskal