From fda6650409cba8d57b2cfe18d911afe2feef2224 Mon Sep 17 00:00:00 2001 From: Alex Van Gils Date: Thu, 8 Oct 2026 21:15:19 -0400 Subject: [PATCH 1/3] supply WebView2 on Windows if we need it --- App.cmake | 7 ++++++- CMakeLists.txt | 4 ++++ CUSTOM_UI.md | 2 +- Plugin.cmake | 7 ++++++- README.md | 6 ++++++ WebView2.cmake | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 71 insertions(+), 3 deletions(-) create mode 100644 WebView2.cmake diff --git a/App.cmake b/App.cmake index 4104b2a..fa9e9c8 100644 --- a/App.cmake +++ b/App.cmake @@ -9,7 +9,8 @@ # `docs/CMake API.md` in the JUCE repo for the full list. if(RNBO_EDITOR_MODE STREQUAL "WEBVIEW") - set(_needs_web_browser NEEDS_WEB_BROWSER TRUE) + # NEEDS_WEBVIEW2 links the WebView2 SDK on Windows (see WebView2.cmake); ignored elsewhere + set(_needs_web_browser NEEDS_WEB_BROWSER TRUE NEEDS_WEBVIEW2 TRUE) endif() juce_add_gui_app(RNBOApp @@ -54,6 +55,10 @@ if(RNBO_EDITOR_MODE STREQUAL "NATIVE") include(${NATIVE_EDITOR_DIR}/CMakeLists.txt) elseif(RNBO_EDITOR_MODE STREQUAL "WEBVIEW") include(${WEB_EDITOR_DIR}/CMakeLists.txt) + if(WIN32) + # Enables the WebView2 backend, which WebBrowserComponent needs on Windows for withResourceProvider + target_compile_definitions(RNBOApp PUBLIC JUCE_USE_WIN_WEBVIEW2_WITH_STATIC_LINKING=1) + endif() endif() if (EXISTS ${RNBO_BINARY_DATA_FILE}) diff --git a/CMakeLists.txt b/CMakeLists.txt index b542203..b7f7437 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,6 +64,10 @@ add_subdirectory( # Compile web UI files into the binary — only needed for the WEBVIEW editor. if(RNBO_EDITOR_MODE STREQUAL "WEBVIEW") add_subdirectory(${WEB_EDITOR_DIR}) + # Windows also needs the WebView2 SDK, fetched here if it isn't already installed + if(WIN32) + include(${CMAKE_CURRENT_LIST_DIR}/WebView2.cmake) + endif() endif() # Create the correct UI header depending on UI style diff --git a/CUSTOM_UI.md b/CUSTOM_UI.md index 0f2e00c..f1c1d62 100644 --- a/CUSTOM_UI.md +++ b/CUSTOM_UI.md @@ -10,7 +10,7 @@ For most people, we recommend starting with the web-based approach. ## Prerequisites -If you haven't yet followed the setup steps in [README.md](./README.md), you should do so before you follow this tutorial. If you want to follow the guide for building a web-based interface, you will also need to install [Node.js](https://nodejs.org/). +If you haven't yet followed the setup steps in [README.md](./README.md), you should do so before you follow this tutorial. If you want to follow the guide for building a web-based interface, you will also need to install [Node.js](https://nodejs.org/). On Windows, CMake will also download the Microsoft WebView2 SDK the first time you configure the web UI build; see [Choosing a UI system](./README.md#choosing-a-ui-system) for details. ## Switching UI diff --git a/Plugin.cmake b/Plugin.cmake index 8dc0195..227f9d1 100644 --- a/Plugin.cmake +++ b/Plugin.cmake @@ -17,7 +17,8 @@ endif() # Check the readme at `docs/CMake API.md` in the JUCE repo for the full list. if(RNBO_EDITOR_MODE STREQUAL "WEBVIEW") - set(_needs_web_browser NEEDS_WEB_BROWSER TRUE) + # NEEDS_WEBVIEW2 links the WebView2 SDK on Windows (see WebView2.cmake); ignored elsewhere + set(_needs_web_browser NEEDS_WEB_BROWSER TRUE NEEDS_WEBVIEW2 TRUE) endif() juce_add_plugin(RNBOAudioPlugin @@ -65,6 +66,10 @@ if(RNBO_EDITOR_MODE STREQUAL "NATIVE") include(${NATIVE_EDITOR_DIR}/CMakeLists.txt) elseif(RNBO_EDITOR_MODE STREQUAL "WEBVIEW") include(${WEB_EDITOR_DIR}/CMakeLists.txt) + if(WIN32) + # Enables the WebView2 backend, which WebBrowserComponent needs on Windows for withResourceProvider + target_compile_definitions(RNBOAudioPlugin PUBLIC JUCE_USE_WIN_WEBVIEW2_WITH_STATIC_LINKING=1) + endif() endif() if (EXISTS ${RNBO_BINARY_DATA_FILE}) diff --git a/README.md b/README.md index a1fada3..2f378db 100644 --- a/README.md +++ b/README.md @@ -141,6 +141,12 @@ The second uses a WebBrowserComponent to build a UI using HTML/CSS/JS. cmake -DRNBO_EDITOR_MODE=WEBVIEW .. ``` +**Windows:** the WEBVIEW editor uses Microsoft's WebView2, which needs the WebView2 SDK at build time. If the SDK isn't already installed through NuGet, CMake downloads it (about 9 MB) into `build/_deps/webview2` the first time you configure. To use a copy you already have, for example when building offline, point CMake at the directory containing the `Microsoft.Web.WebView2.*` package folder: + +```sh +cmake -DRNBO_EDITOR_MODE=WEBVIEW -DJUCE_WEBVIEW2_PACKAGE_LOCATION=C:/path/to/packages .. +``` + By default, `NATIVE` sources its C++ files from `src/nativeui` and `WEBVIEW` sources its files from `src/webui`. If you want to supply your own implementation — for example, to keep your custom UI in a separate directory or a separate repository — you can override either path at configure time: ```sh diff --git a/WebView2.cmake b/WebView2.cmake new file mode 100644 index 0000000..0b5f597 --- /dev/null +++ b/WebView2.cmake @@ -0,0 +1,48 @@ +# On Windows, the WEBVIEW editor needs the Microsoft WebView2 SDK. JUCE looks for it in the local +# NuGet package folder, or in JUCE_WEBVIEW2_PACKAGE_LOCATION if that is set. If neither has it, we +# download the NuGet package into the build tree and point JUCE at it. +# +# To use your own copy (e.g. for offline builds), configure with +# cmake -DJUCE_WEBVIEW2_PACKAGE_LOCATION= .. + +set(WEBVIEW2_VERSION "1.0.3485.44") +set(WEBVIEW2_SHA256 "bc09150b179246ac90189649b13be8e6b11b3ac200e817e18df106e1f3cf489e") + +file(GLOB _webview2_nuget_packages "$ENV{USERPROFILE}/AppData/Local/PackageManagement/NuGet/Packages/*Microsoft.Web.WebView2*") + +if(JUCE_WEBVIEW2_PACKAGE_LOCATION) + message(STATUS "Using WebView2 SDK from ${JUCE_WEBVIEW2_PACKAGE_LOCATION}") +elseif(_webview2_nuget_packages) + message(STATUS "Using WebView2 SDK from the local NuGet package folder") +else() + set(_webview2_root "${CMAKE_BINARY_DIR}/_deps/webview2") + set(_webview2_dir "${_webview2_root}/Microsoft.Web.WebView2.${WEBVIEW2_VERSION}") + + if(NOT EXISTS "${_webview2_dir}/build/native/include/WebView2.h") + set(_webview2_nupkg "${_webview2_root}/Microsoft.Web.WebView2.${WEBVIEW2_VERSION}.nupkg") + message(STATUS "Downloading WebView2 SDK ${WEBVIEW2_VERSION}") + + file(DOWNLOAD + "https://www.nuget.org/api/v2/package/Microsoft.Web.WebView2/${WEBVIEW2_VERSION}" + "${_webview2_nupkg}" + EXPECTED_HASH SHA256=${WEBVIEW2_SHA256} + STATUS _webview2_status) + + list(GET _webview2_status 0 _webview2_status_code) + if(NOT _webview2_status_code EQUAL 0) + list(GET _webview2_status 1 _webview2_status_message) + message(FATAL_ERROR + "Failed to download the WebView2 SDK: ${_webview2_status_message}\n" + "Install it manually from a PowerShell prompt:\n" + "> Register-PackageSource -provider NuGet -name nugetRepository -location https://www.nuget.org/api/v2\n" + "> Install-Package Microsoft.Web.WebView2 -Scope CurrentUser -RequiredVersion ${WEBVIEW2_VERSION} -Source nugetRepository\n" + "or pass -DJUCE_WEBVIEW2_PACKAGE_LOCATION= pointing at an existing copy.") + endif() + + file(ARCHIVE_EXTRACT INPUT "${_webview2_nupkg}" DESTINATION "${_webview2_dir}") + file(REMOVE "${_webview2_nupkg}") + endif() + + set(JUCE_WEBVIEW2_PACKAGE_LOCATION "${_webview2_root}") + message(STATUS "Using WebView2 SDK from ${_webview2_dir}") +endif() From 715b10b0fa40e46bdf3cb1a33a57c96e09d1da94 Mon Sep 17 00:00:00 2001 From: Alex Van Gils Date: Thu, 8 Oct 2026 21:31:15 -0400 Subject: [PATCH 2/3] helpful note to PowerShell users --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 2f378db..3a294ae 100644 --- a/README.md +++ b/README.md @@ -125,6 +125,8 @@ By default, the build script looks for a RNBO export in the `export` folder name cmake -DRNBO_CLASS_FILE_NAME=slime_sound.cpp -G Ninja .. ``` +**Windows PowerShell:** PowerShell splits unquoted arguments like this one at the period, so CMake only sees `slime_sound`. Wrap the whole argument in quotes: `"-DRNBO_CLASS_FILE_NAME=slime_sound.cpp"`. + #### Choosing a UI system RNBO provides a default interface for audio plugins, which simply creates a slider for each parameter in your RNBO patch. If you want to create a custom interface, you can configure CMake to use a different interface system. From cd8c4d363cc4931775b6260951e3a4c5809a306b Mon Sep 17 00:00:00 2001 From: Alex Van Gils Date: Thu, 8 Oct 2026 21:31:43 -0400 Subject: [PATCH 3/3] fail early when the RNBO class file you want is missing --- CMakeLists.txt | 8 ++++++++ CUSTOM_UI.md | 2 ++ 2 files changed, 10 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index b7f7437..f29ce5a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,14 @@ mark_as_advanced(RNBO_CLASS_FILE_NAME) set(RNBO_CLASS_NAME "rnbomatic") set(RNBO_CLASS_FILE "${RNBO_EXPORT_DIR}/${RNBO_CLASS_FILE_NAME}") +if(NOT EXISTS "${RNBO_CLASS_FILE}") + message(FATAL_ERROR + "RNBO class file not found: ${RNBO_CLASS_FILE}\n" + "Export your RNBO patch to ${RNBO_EXPORT_DIR}, and make sure RNBO_CLASS_FILE_NAME " + "matches the exported .cpp file name (currently \"${RNBO_CLASS_FILE_NAME}\").\n" + "In Windows PowerShell, quote the whole argument so the name isn't split at the period, " + "e.g. \"-DRNBO_CLASS_FILE_NAME=my_patch.cpp\"") +endif() set(RNBO_DESCRIPTION_FILE "${RNBO_EXPORT_DIR}/description.json") set(RNBO_PRESETS_FILE "${RNBO_EXPORT_DIR}/presets.json") set(RNBO_BINARY_DATA_FILE "${RNBO_EXPORT_DIR}/${RNBO_CLASS_NAME}_binary.cpp") diff --git a/CUSTOM_UI.md b/CUSTOM_UI.md index f1c1d62..13cc369 100644 --- a/CUSTOM_UI.md +++ b/CUSTOM_UI.md @@ -67,6 +67,8 @@ cd build cmake .. -DRNBO_CLASS_FILE_NAME=three-param-kink.cpp -DRNBO_EDITOR_MODE=WEBVIEW ``` +> In Windows PowerShell, quote the class file argument (`"-DRNBO_CLASS_FILE_NAME=three-param-kink.cpp"`), otherwise PowerShell splits it at the period. See [Renaming your export source](./README.md#renaming-your-export-source). + If you look in `src/CustomAudioProcessor.cpp`, you'll see code like this: ```cpp