diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 9369e6c..887db97 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -48,8 +48,6 @@ jobs: apt install -y sudo cmake curl tree - uses: actions/checkout@v4 - with: - submodules: true - name: Setup Environment Variables shell: bash @@ -58,12 +56,11 @@ jobs: echo "VERSION=$VERSION" >> $GITHUB_ENV echo "APP_DIR=${{ env.BUILD_DIR }}/${{ env.BINARY_NAME }}_artefacts/${{ env.BUILD_TYPE }}" >> $GITHUB_ENV echo "ZIP_FILE_NAME=${{ env.BINARY_NAME }}_${{ matrix.name }}.zip" >> $GITHUB_ENV - echo "JUCE_SHA1=$(git rev-parse HEAD:modules/juce)" >> $GITHUB_ENV - echo "PLUGIN_BUILD_DIR=modules/juce/Builds" >> $GITHUB_ENV - + # This needs to be absolute to make action/cache happy + # JUCE examples are built from within the CPM-fetched JUCE source directory WORKING_DIR=$(pwd) - echo "PLUGIN_CACHE_PATH=$WORKING_DIR/modules/juce/Builds/examples/Plugins" >> $GITHUB_ENV + echo "PLUGIN_CACHE_PATH=$WORKING_DIR/${{ env.BUILD_DIR }}/_deps/juce-src/Builds/examples/Plugins" >> $GITHUB_ENV - name: Install dependencies (Linux) if: ${{ matrix.name == 'Linux' }} @@ -90,7 +87,7 @@ jobs: - name: ccache uses: hendrikmuhs/ccache-action@v1.2 with: - key: v2-${{ matrix.name }}-${{ env.BUILD_TYPE }} + key: v3-${{ matrix.name }}-${{ env.BUILD_TYPE }} - name: Configure shell: bash @@ -114,11 +111,11 @@ jobs: with: path: ${{ env.PLUGIN_CACHE_PATH }} # Increment the version in the key below to manually break plugin cache - key: v7-${{ runner.os }}-${{ env.JUCE_SHA1 }} + key: v9-${{ runner.os }} - name: Build JUCE example plugins if: steps.cache-plugins.outputs.cache-hit != 'true' - working-directory: modules/juce + working-directory: ${{ env.BUILD_DIR }}/_deps/juce-src shell: bash run: | cmake -B Builds -DJUCE_BUILD_EXAMPLES=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache . @@ -170,6 +167,33 @@ jobs: name: ${{ env.ZIP_FILE_NAME }} path: ${{ env.APP_DIR }}/${{ env.ZIP_FILE_NAME }} + # Test pluginval as a dependency in another JUCE project + as_dependency: + name: Pluginval as Dependency + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-15, windows-latest] + juce: ["8.0.3", "8.0.11"] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + + - name: Install dependencies (Linux) + if: runner.os == 'Linux' + run: | + sudo apt-get update + sudo apt-get install -y libasound2-dev libfreetype6-dev libx11-dev libxcomposite-dev libxcursor-dev libxinerama-dev libxrandr-dev mesa-common-dev libwebkit2gtk-4.1-dev ladspa-sdk + + - name: Configure + run: cmake -B build -S tests/pluginval_as_dependency -DJUCE_VERSION="${{ matrix.juce }}" + + - name: Build + run: cmake --build build --target pluginval --parallel 4 + + - name: Verify + run: cmake --build build --target verify_pluginval + # Create release for tagged refs deploy: if: contains(github.ref, 'tags/v') diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index b03a59d..0000000 --- a/.gitmodules +++ /dev/null @@ -1,4 +0,0 @@ -[submodule "modules/juce"] - path = modules/juce - url = https://github.com/juce-framework/JUCE - branch = develop diff --git a/CMakeLists.txt b/CMakeLists.txt index a2073e3..323a98b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,16 +3,24 @@ cmake_minimum_required(VERSION 3.15) file(STRINGS VERSION CURRENT_VERSION LIMIT_COUNT 1) project(pluginval VERSION ${CURRENT_VERSION}) -if (APPLE) - # Target OS versions down to 10.11 - set (CMAKE_OSX_DEPLOYMENT_TARGET "10.11" CACHE INTERNAL "") - - # Uncomment to produce a universal binary - # set(CMAKE_OSX_ARCHITECTURES arm64 x86_64) - set(PLUGINVAL_ENABLE_RTCHECK ON) -elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux") - # Disable rtcheck on Linux for now until further testing on real Linux systems has been done - # set(PLUGINVAL_ENABLE_RTCHECK ON) +# Just compliing pluginval +if (pluginval_IS_TOP_LEVEL) + if (APPLE) + # Target OS versions down to 10.11 + set (CMAKE_OSX_DEPLOYMENT_TARGET "10.11" CACHE INTERNAL "") + + # Uncomment to produce a universal binary + # set(CMAKE_OSX_ARCHITECTURES arm64 x86_64) + set(PLUGINVAL_ENABLE_RTCHECK ON) + elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux") + # Disable rtcheck on Linux for now until further testing on real Linux systems has been done + # set(PLUGINVAL_ENABLE_RTCHECK ON) + endif() +else() + # compiling as a "dependency" of another JUCE CMake project + if (NOT COMMAND juce_add_module) + message(FATAL_ERROR "JUCE must be added to your project before pluginval!") + endif () endif() # sanitizer options, from https://github.com/sudara/cmake-includes/blob/main/Sanitizers.cmake @@ -52,11 +60,9 @@ if(PLUGINVAL_ENABLE_RTCHECK) CPMAddPackage("gh:Tracktion/rtcheck#main") endif() - -option(PLUGINVAL_FETCH_JUCE "Fetch JUCE along with pluginval" ON) - -if(PLUGINVAL_FETCH_JUCE) - add_subdirectory(modules/juce) +# Only fetch JUCE when top-level (when used as dependency, JUCE is already available) +if (pluginval_IS_TOP_LEVEL) + CPMAddPackage("gh:juce-framework/juce#8.0.3") endif() if (DEFINED ENV{VST2_SDK_DIR}) @@ -151,11 +157,34 @@ if (PLUGINVAL_ENABLE_RTCHECK) endif () endif() -set (cmdline_docs_out "${CMAKE_CURRENT_LIST_DIR}/docs/Command line options.md") - -add_custom_command (OUTPUT "${cmdline_docs_out}" - COMMAND pluginval --help > "${cmdline_docs_out}" - COMMENT "Regenerating Command line options.md..." - USES_TERMINAL) +if (pluginval_IS_TOP_LEVEL) + set (cmdline_docs_out "${CMAKE_CURRENT_LIST_DIR}/docs/Command line options.md") -add_custom_target (PluginvalDocs DEPENDS "${cmdline_docs_out}") + add_custom_command (OUTPUT "${cmdline_docs_out}" + COMMAND pluginval --help > "${cmdline_docs_out}" + COMMENT "Regenerating Command line options.md..." + USES_TERMINAL) + add_custom_target (PluginvalDocs DEPENDS "${cmdline_docs_out}") +else() + # Custom pluginval CLI target + set(PLUGINVAL_STRICTNESS_LEVEL 10 CACHE STRING "Pluginval --strictness argument (1-10)") + set_property(CACHE PLUGINVAL_STRICTNESS_LEVEL PROPERTY STRINGS 1 2 3 4 5 6 7 8 9 10) + + # Set the target based on the platform + # Makes the assumption both are being built + if(APPLE) + set(PLUGINVAL_TARGET "${CMAKE_PROJECT_NAME}_AU") + else() + set(PLUGINVAL_TARGET "${CMAKE_PROJECT_NAME}_VST3") + endif() + + get_target_property(artefact ${PLUGINVAL_TARGET} JUCE_PLUGIN_ARTEFACT_FILE) + + # TODO: This doesn't populate the executable in clion + add_custom_target(${CMAKE_PROJECT_NAME}_pluginval_cli + COMMAND $ + --validate ${artefact} + --strictness-level 10 + DEPENDS pluginval ${PLUGINVAL_TARGET} + COMMENT "Run pluginval CLI with strict validation") +endif() diff --git a/README.md b/README.md index ae280f5..4ad3a92 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,25 @@ cmake -B Builds/Debug -DCMAKE_BUILD_TYPE=Debug . # configure cmake --build Builds/Debug --config Debug # build ``` +### Including within an existing JUCE project + +Instead of running as a separate app, you can add pluginval as a CMake target to your existing JUCE plugin project. This not only makes for a convenient debugging workflow, it gives you better stack traces. + +For example, if you add pluginval as a git submodule like so: +``` +git submodule add -b develop git@github.com:Tracktion/pluginval.git modules/pluginval +``` + +or added with CPM like so: + +``` +CPMAddPackage("gh:tracktion/pluginval#develop") +``` + +Then all you need to do is call `add_subdirectory ("modules/pluginval")` in your `CMakeLists.txt`. This should be done **after** your call to `juce_add_plugin`. + +Note that only JUCE 8 is currently supported/tested for this method. + ### Third-party Installation ###### _Chocolatey (Windows):_ ```shell diff --git a/Source/CommandLine.cpp b/Source/CommandLine.cpp index 1082c47..426c45c 100644 --- a/Source/CommandLine.cpp +++ b/Source/CommandLine.cpp @@ -241,7 +241,11 @@ namespace bool isPluginArgument (juce::String arg) { juce::AudioPluginFormatManager formatManager; + #if JUCE_VERSION >= 0x08000B juce::addDefaultFormatsToManager (formatManager); + #else + formatManager.addDefaultFormats(); + #endif for (auto format : formatManager.getFormats()) if (format->fileMightContainThisPluginType (arg)) diff --git a/Source/MainComponent.cpp b/Source/MainComponent.cpp index 28658ff..1547ac8 100644 --- a/Source/MainComponent.cpp +++ b/Source/MainComponent.cpp @@ -331,7 +331,11 @@ namespace MainComponent::MainComponent (Validator& v) : validator (v) { + #if JUCE_VERSION >= 0x08000B juce::addDefaultFormatsToManager (formatManager); + #else + formatManager.addDefaultFormats(); + #endif menuBar.setModel (this); addAndMakeVisible (menuBar); diff --git a/Source/PluginTests.cpp b/Source/PluginTests.cpp index a434d54..e685dad 100644 --- a/Source/PluginTests.cpp +++ b/Source/PluginTests.cpp @@ -69,7 +69,11 @@ PluginTests::PluginTests (const juce::String& fileOrIdentifier, Options opts) { jassert (fileOrIdentifier.isNotEmpty()); jassert (juce::isPositiveAndNotGreaterThan (options.strictnessLevel, 10)); + #if JUCE_VERSION >= 0x08000B juce::addDefaultFormatsToManager (formatManager); + #else + formatManager.addDefaultFormats(); + #endif } PluginTests::PluginTests (const juce::PluginDescription& desc, Options opts) diff --git a/modules/juce b/modules/juce deleted file mode 160000 index a2a9c54..0000000 --- a/modules/juce +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a2a9c54e31d090e5d1f9c2e23f160fff2556f9ec diff --git a/tests/pluginval_as_dependency/CMakeLists.txt b/tests/pluginval_as_dependency/CMakeLists.txt new file mode 100644 index 0000000..0ea3743 --- /dev/null +++ b/tests/pluginval_as_dependency/CMakeLists.txt @@ -0,0 +1,31 @@ +cmake_minimum_required(VERSION 3.22) +project(PluginvalAsDependency VERSION 1.0.0) + +set(JUCE_VERSION "8.0.3" CACHE STRING "JUCE version to test against") + +include(${CMAKE_CURRENT_LIST_DIR}/../../cmake/CPM.cmake) + +CPMAddPackage("gh:juce-framework/JUCE#${JUCE_VERSION}") + +# Minimal plugin to test pluginval as a dependency +# Plugin name must match CMAKE_PROJECT_NAME for pluginval's CLI target to work +# Must be defined BEFORE adding pluginval +juce_add_plugin(${CMAKE_PROJECT_NAME} + PLUGIN_MANUFACTURER_CODE Test + PLUGIN_CODE Test + FORMATS VST3 AU + PRODUCT_NAME "TestPlugin") + +target_sources(${CMAKE_PROJECT_NAME} PRIVATE TestPlugin.cpp) +target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE juce::juce_audio_processors) + +CPMAddPackage( + NAME pluginval + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../.. +) + +# Verify pluginval runs and reports the expected JUCE version +add_custom_target(verify_pluginval + COMMAND $ --help | grep "JUCE v${JUCE_VERSION}" + DEPENDS pluginval + COMMENT "Verify pluginval built with JUCE ${JUCE_VERSION}") diff --git a/tests/pluginval_as_dependency/TestPlugin.cpp b/tests/pluginval_as_dependency/TestPlugin.cpp new file mode 100644 index 0000000..39b98a0 --- /dev/null +++ b/tests/pluginval_as_dependency/TestPlugin.cpp @@ -0,0 +1,39 @@ +// Minimal JUCE plugin to test pluginval builds as a dependency +#include + +class TestProcessor : public juce::AudioProcessor +{ +public: + TestProcessor() + : AudioProcessor (BusesProperties() + .withInput ("Input", juce::AudioChannelSet::stereo(), true) + .withOutput ("Output", juce::AudioChannelSet::stereo(), true)) + { + } + + const juce::String getName() const override { return "TestPlugin"; } + bool acceptsMidi() const override { return false; } + bool producesMidi() const override { return false; } + double getTailLengthSeconds() const override { return 0.0; } + + int getNumPrograms() override { return 1; } + int getCurrentProgram() override { return 0; } + void setCurrentProgram (int) override {} + const juce::String getProgramName (int) override { return {}; } + void changeProgramName (int, const juce::String&) override {} + + void prepareToPlay (double, int) override {} + void releaseResources() override {} + void processBlock (juce::AudioBuffer&, juce::MidiBuffer&) override {} + + bool hasEditor() const override { return false; } + juce::AudioProcessorEditor* createEditor() override { return nullptr; } + + void getStateInformation (juce::MemoryBlock&) override {} + void setStateInformation (const void*, int) override {} +}; + +juce::AudioProcessor* JUCE_CALLTYPE createPluginFilter() +{ + return new TestProcessor(); +}