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..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") @@ -64,6 +72,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..13cc369 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 @@ -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 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..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. @@ -141,6 +143,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=