diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c8bdbf9..5b1265e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,6 +14,22 @@ permissions: contents: read jobs: + windows: + name: Windows plugins (MSVC) + runs-on: windows-2025 + timeout-minutes: 30 + steps: + - uses: actions/checkout@v7 + - uses: ilammy/msvc-dev-cmd@v1 + with: + arch: x64 + - name: Configure + run: cmake --preset windows-plugin -DVISONA_BUILD_PLUGIN_CHECKS=ON + - name: Build + run: cmake --build --preset windows-plugin + - name: Test + run: ctest --preset windows-plugin + linux: name: Linux core (${{ matrix.compiler }}) runs-on: ubuntu-24.04 diff --git a/AGENTS.md b/AGENTS.md index dc0dfaa..aa2f481 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -76,4 +76,4 @@ cmake --preset linux-plugin && cmake --build --preset linux-plugin && ctest --pr cmake --preset core-gcc && cmake --build --preset core-gcc && ctest --preset core-gcc ``` -`core-clang`, `core-sanitize` (Clang with ASan and UBSan) and `core-tsan` (Clang with TSan) work the same way. Format C++ with `clang-format`. Pull-request CI in `.github/workflows/ci.yml` runs the `core-gcc`, `core-clang`, `core-sanitize` and `core-tsan` presets. The macOS app, the macOS VST3, AU and CLAP plugins (Visona and Visona Sync, checked with `auval` and `clap-validator`, signed with a Developer ID and notarized as described in `docs/signing.md`), the Windows x64 and Linux x86_64 VST3 and CLAP plugins (checked with `pluginval` and `clap-validator`) and the Pi ARM64 app (with the `pi-ci` preset, a parallel build of `pi`) are built by `.github/workflows/release.yml` when a GitHub release is published. Run by hand, that workflow builds only the artifacts ticked, from the branch chosen, and publishes them to the `dev-builds` prerelease. `.github/workflows/pi-quick.yml`, run by hand, publishes the Pi app the same way but faster, with the `pi-quick` preset: app only, parallel, `ccache`, no tests. Nothing checks that the JUCE targets compile on macOS, Windows or Linux before then, and nothing in CI runs the UI checks or `tests/scripts/test_pi_deploy.py`. +`core-clang`, `core-sanitize` (Clang with ASan and UBSan) and `core-tsan` (Clang with TSan) work the same way. Format C++ with `clang-format`. Pull-request CI in `.github/workflows/ci.yml` runs the `core-gcc`, `core-clang`, `core-sanitize` and `core-tsan` presets, plus the `windows-plugin` preset with MSVC and offline processor checks. The macOS app, the macOS VST3, AU and CLAP plugins (Visona and Visona Sync, checked with `auval` and `clap-validator`, signed with a Developer ID and notarized as described in `docs/signing.md`), the Windows x64 and Linux x86_64 VST3 and CLAP plugins (checked with `pluginval` and `clap-validator`) and the Pi ARM64 app (with the `pi-ci` preset, a parallel build of `pi`) are built by `.github/workflows/release.yml` when a GitHub release is published. Run by hand, that workflow builds only the artifacts ticked, from the branch chosen, and publishes them to the `dev-builds` prerelease. `.github/workflows/pi-quick.yml`, run by hand, publishes the Pi app the same way but faster, with the `pi-quick` preset: app only, parallel, `ccache`, no tests. Nothing checks that the JUCE targets compile on macOS or Linux before then, and nothing in CI runs the UI checks or `tests/scripts/test_pi_deploy.py`. diff --git a/cmake/LspMsvc.cmake b/cmake/LspMsvc.cmake new file mode 100644 index 0000000..bb65a46 --- /dev/null +++ b/cmake/LspMsvc.cmake @@ -0,0 +1,34 @@ +# Adapt only the platform header used by the pinned LSP measurement subset. +# Keep fetched sources pristine and put the generated header ahead of upstream. +function(visona_lsp_msvc_headers output_dir) + set(source "${lsp_common_SOURCE_DIR}/include/lsp-plug.in/common/types.h") + file(READ "${source}" contents) + + # Fail on pin drift instead of silently producing an incomplete adaptation. + foreach(needle IN ITEMS "#include " + "#if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)" + "#if defined(__WORDSIZE) && (__WORDSIZE == 128)") + string(FIND "${contents}" "${needle}" position) + if(position EQUAL -1) + message(FATAL_ERROR "Review the LSP MSVC adaptation: missing ${needle}") + endif() + endforeach() + + # MSVC has no POSIX unistd.h or ssize_t. ptrdiff_t is signed and pointer-sized. + string(REPLACE "#include " "typedef ptrdiff_t ssize_t;" + contents "${contents}") + # The supported Windows target is little-endian x64. Do not depend on + # undefined GCC preprocessor macros comparing equal to zero in MSVC. + string(REPLACE "#if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)" + "#if defined(_WIN32)\n #define ARCH_LE\n#elif (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)" + contents "${contents}") + string(REPLACE "#if defined(__WORDSIZE) && (__WORDSIZE == 128)" + "#if defined(_WIN64)\n #define ARCH_64BIT\n #elif defined(_WIN32)\n #define ARCH_32BIT\n #elif defined(__WORDSIZE) && (__WORDSIZE == 128)" + contents "${contents}") + + set(header "${output_dir}/lsp-plug.in/common/types.h") + file(MAKE_DIRECTORY "${output_dir}/lsp-plug.in/common") + # configure_file avoids changing the header timestamp on every configure. + file(WRITE "${header}.in" "${contents}") + configure_file("${header}.in" "${header}" COPYONLY) +endfunction() diff --git a/cmake/LspStereo.cmake b/cmake/LspStereo.cmake index afec0ff..e6b8231 100644 --- a/cmake/LspStereo.cmake +++ b/cmake/LspStereo.cmake @@ -24,3 +24,10 @@ target_include_directories(visona_lsp_stereo SYSTEM PUBLIC "${lsp_common_SOURCE_DIR}/include") target_compile_definitions(visona_lsp_stereo PUBLIC LSP_DSP_UNITS_BUILTIN LSP_DSP_LIB_BUILTIN LSP_COMMON_LIB_BUILTIN) + +if(MSVC) + include("${CMAKE_CURRENT_LIST_DIR}/LspMsvc.cmake") + set(lsp_msvc_include "${CMAKE_CURRENT_BINARY_DIR}/lsp-msvc/include") + visona_lsp_msvc_headers("${lsp_msvc_include}") + target_include_directories(visona_lsp_stereo SYSTEM BEFORE PUBLIC "${lsp_msvc_include}") +endif() diff --git a/tests/BandAnalyzerTests.cpp b/tests/BandAnalyzerTests.cpp index 1ce8591..562c206 100644 --- a/tests/BandAnalyzerTests.cpp +++ b/tests/BandAnalyzerTests.cpp @@ -58,7 +58,7 @@ TEST_CASE("Band stereo energy does not cancel opposite phase", "[bands]") const auto stereo = read(analyzer); REQUIRE(stereo.db[17] == Catch::Approx(-6.0206).margin(0.2)); analyzer.reset(48000); - std::fill(opposite.begin(), opposite.end(), 0); + std::fill(opposite.begin(), opposite.end(), 0.0f); analyzer.process(tone, opposite, 0); REQUIRE(read(analyzer).db[17] == Catch::Approx(stereo.db[17] - 3.0103f).margin(0.01)); } diff --git a/third_party/lsp/README.md b/third_party/lsp/README.md index a93ed31..3565868 100644 --- a/third_party/lsp/README.md +++ b/third_party/lsp/README.md @@ -31,7 +31,20 @@ upstream headers: review it and rerun the oracle tests when updating pins. Do no link a second/full LSP implementation into the same binary without reconciling the symbols. -No upstream source patches are carried. `StereoAnalyzer` works around the pinned +On MSVC, `cmake/LspMsvc.cmake` generates an overlay for the pinned common +`types.h`: it replaces the unused POSIX `unistd.h` include with a pointer-sized +signed `ssize_t` and detects Windows word size and endianness explicitly. The +fetched sources remain pristine; only this target and consumers of its headers +see the overlay. `StereoDsp.cpp` includes common types before the DSP declarations +so `ssize_t` is available there too. The meter algorithms and generic DSP sources +remain unmodified. Unused upstream GNU attribute and assembly macros are not +expanded by this subset; this is not general MSVC support for the full LSP API. + +When changing pins, review the overlay and include order, build the Windows +plugins with MSVC, and run the core oracle and offline processor tests. PR CI +runs that Windows build in addition to the Linux core and sanitizer jobs. + +`StereoAnalyzer` works around the pinned Panometer's incomplete `clear()` by forcing a period change, and starts both meters fresh for every published window. See [stereo analysis](../../docs/stereo.md) for the measurements, validity policy and integration tests. diff --git a/third_party/lsp/StereoDsp.cpp b/third_party/lsp/StereoDsp.cpp index e86e20d..0cc44b6 100644 --- a/third_party/lsp/StereoDsp.cpp +++ b/third_party/lsp/StereoDsp.cpp @@ -1,6 +1,8 @@ // Bind the six DSP entry points used by LSP's Correlometer and Panometer to // unmodified, portable upstream implementations. This is not the full LSP API. // Constant initialization avoids process-global runtime dispatch and its locks. +// Common types supplies ssize_t before the DSP API declarations on MSVC. +#include #include #include @@ -10,6 +12,9 @@ #include #include +static_assert(sizeof(lsp::umword_t) == sizeof(void*)); +static_assert(sizeof(ssize_t) == sizeof(size_t)); + namespace lsp::dsp { constinit decltype(copy) copy = generic::copy;