diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7cc9b2b..e9c9ebc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,10 +8,6 @@ on: branches: - master -env: - JUCE_VERSION: 8.0.1 - ALGLIB_VERSION: 4.00.0 - jobs: set-version: runs-on: ubuntu-latest @@ -27,226 +23,113 @@ jobs: VERSION_NUM="${MAJOR}.${MINOR}.${PATCH}.${BUILD}" echo "VERSION=$VERSION_NUM" >> $GITHUB_OUTPUT - setup-windows: + build-windows: runs-on: windows-latest - steps: - - name: Restore JUCE Cache - uses: actions/cache@v4 - with: - path: JUCE - key: juce-windows-${{ env.JUCE_VERSION }} + needs: + - set-version - - name: Setup and Build JUCE - run: | - if (-not (Test-Path JUCE)) { - Write-Host "JUCE not found in cache, cloning version $env:JUCE_VERSION..." - git clone --branch $env:JUCE_VERSION --depth 1 https://github.com/juce-framework/JUCE.git JUCE - } else { - Write-Host "JUCE found in cache" - } - - - name: Restore AlgLib Cache - uses: actions/cache@v4 - with: - path: AlgLib - key: alglib-windows-${{ env.ALGLIB_VERSION }} + steps: + - uses: actions/checkout@v4 - - name: Setup AlgLib - run: | - if (-not (Test-Path AlgLib)) { - Write-Host "AlgLib not found in cache, downloading..." - New-Item -ItemType Directory -Force -Path third_party - Invoke-WebRequest -Uri https://www.alglib.net/translator/re/alglib-$env:ALGLIB_VERSION.cpp.gpl.zip -OutFile alglib.zip - Expand-Archive alglib.zip -DestinationPath AlgLib - Remove-Item alglib.zip - } else { - Write-Host "AlgLib found in cache" - } - - - name: Restore Inno Setup Cache + - name: Cache dependencies uses: actions/cache@v4 with: - path: inno-setup - key: inno-setup-6 + path: build/_deps + key: deps-windows-juce8.0.4-alglib4.00.0 - - name: Download Inno Setup (if not cached) - shell: pwsh + - name: Configure CMake run: | - if (-not (Test-Path "inno-setup/ISCC.exe")) { - New-Item -ItemType Directory -Force -Path inno-setup - Invoke-WebRequest "https://jrsoftware.org/download.php/is.exe" -OutFile "inno-setup/is.exe" - Start-Process "inno-setup/is.exe" -ArgumentList "/VERYSILENT /SUPPRESSMSGBOXES /DIR=$PWD/inno-setup" -Wait - } + if (!(Test-Path build)) { mkdir build } + cd build + cmake .. -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=Release -DVERSION=${{ needs.set-version.outputs.version }} - setup-linux: - runs-on: ubuntu-latest - needs: setup-windows # Two parallel requests to AlgLib site can cause a timeout error - steps: - - name: Restore JUCE Cache - uses: actions/cache@v4 - with: - path: JUCE - key: juce-linux-${{ env.JUCE_VERSION }} + - name: Build Project + run: cmake --build build --config Release - - name: Clone JUCE - run: | - if [ ! -d "JUCE" ]; then - echo "JUCE not found in cache, cloning version $JUCE_VERSION..." - git clone --branch $JUCE_VERSION --depth 1 https://github.com/juce-framework/JUCE.git JUCE - else - echo "JUCE found in cache" - fi - - - name: Restore AlgLib Cache - uses: actions/cache@v4 + - name: Upload VST3 artifact + uses: actions/upload-artifact@v4 with: - path: AlgLib - key: alglib-linux-${{ env.ALGLIB_VERSION }} - - - name: Download AlgLib - run: | - if [ ! -d "AlgLib" ]; then - echo "AlgLib not found in cache, downloading..." - mkdir -p third_party - curl -L https://www.alglib.net/translator/re/alglib-${ALGLIB_VERSION}.cpp.gpl.zip -o alglib.zip - unzip alglib.zip -d AlgLib - rm alglib.zip - else - echo "AlgLib found in cache" - fi + name: output-vst3-windows + path: ./build/MatchingCompressor_artefacts/Release/VST3/MatchingCompressor.vst3 - build-windows: - runs-on: windows-latest + build-linux: + runs-on: ubuntu-22.04 needs: - - set-version - - setup-windows + - set-version steps: - - uses: actions/checkout@v3 - with: - path: TheProject + - uses: actions/checkout@v4 - - uses: actions/cache@v4 - with: - path: JUCE - key: juce-windows-${{ env.JUCE_VERSION }} - - - uses: actions/cache@v4 + - name: Cache dependencies + uses: actions/cache@v4 with: - path: AlgLib - key: alglib-windows-${{ env.ALGLIB_VERSION }} + path: build/_deps + key: deps-linux-juce8.0.4-alglib4.00.0 - - uses: actions/cache@v4 - with: - path: inno-setup - key: inno-setup-6 + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y libasound2-dev libx11-dev libxrandr-dev libxinerama-dev libxcursor-dev libfreetype6-dev libfontconfig1-dev - name: Configure CMake - shell: pwsh run: | - New-Item -ItemType Directory -Force -Path TheProject/build - cd TheProject/build - cmake .. -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=Release -DVERSION=${{ needs.set-version.outputs.version }} + mkdir -p build + cd build + cmake .. -DCMAKE_BUILD_TYPE=Release -DVERSION=${{ needs.set-version.outputs.version }} - name: Build Project - run: | - cd TheProject/build - cmake --build . --config Release + run: cmake --build build --config Release -- -j$(nproc) - - name: Upload build VST artifact + - name: Upload VST3 artifact uses: actions/upload-artifact@v4 with: - name: output-vst3-windows - path: ./TheProject/build/MatchingCompressor_artefacts/Release/VST3/MatchingCompressor.vst3 - - - name: Set version in Inno Setup script - shell: pwsh - run: | - $version = "${{ needs.set-version.outputs.version }}" - $file = 'TheProject/setup.iss' - (Get-Content $file) -replace '#define MyAppVersion .*', "#define MyAppVersion `"$version`"" | - Set-Content $file -Encoding UTF8 - - # In case of file format error use this version instead of the last command: - #$content = Get-Content $file -Raw - #$newContent = $content -replace '(?m)^#define MyAppVersion .*', "#define MyAppVersion `"$version`"" - #[System.IO.File]::WriteAllText($file, $newContent, [System.Text.Encoding]::UTF8) - - - name: Build Installer - shell: pwsh - run: | - $issPath = "$PWD/TheProject/setup.iss" - $outputDir = "$PWD/TheProject/build/inno" - New-Item -ItemType Directory -Force -Path $outputDir - - $isccPath = "$PWD/inno-setup/ISCC.exe" - & $isccPath /O"$outputDir" $issPath - - - name: Upload installer artifact - uses: actions/upload-artifact@v4 - with: - name: output-ins-windows - path: ./TheProject/build/inno + name: output-vst3-linux + path: ./build/MatchingCompressor_artefacts/Release/VST3/MatchingCompressor.vst3 - build-linux: - runs-on: ubuntu-22.04 - # container: ubuntu:20.04 + build-macos: + runs-on: macos-latest needs: - - set-version - - setup-linux + - set-version steps: - - uses: actions/checkout@v3 - with: - path: TheProject - - - name: Install dependencies - env: # is not necessary unless this works inside a container - DEBIAN_FRONTEND: noninteractive - TZ: Etc/UTC - - # "apt-get" without "sudo" for working inside a container - # "apt-get install -y build-essential cmake" for working inside a container - run: | - sudo apt-get update - sudo apt-get install -y libasound2-dev libx11-dev libxrandr-dev libxinerama-dev libxcursor-dev libfreetype6-dev libfontconfig1-dev - pkg-config --cflags freetype2 - - - uses: actions/cache@v4 - with: - path: JUCE - key: juce-linux-${{ env.JUCE_VERSION }} + - uses: actions/checkout@v4 - - uses: actions/cache@v4 + - name: Cache dependencies + uses: actions/cache@v4 with: - path: AlgLib - key: alglib-linux-${{ env.ALGLIB_VERSION }} + path: build/_deps + key: deps-macos-juce8.0.4-alglib4.00.0 - name: Configure CMake run: | - export CFLAGS="-I/usr/include/freetype2" - export CXXFLAGS="-I/usr/include/freetype2" mkdir -p build cd build - cmake ../TheProject -DCMAKE_BUILD_TYPE=Release -DVERSION=${{ needs.set-version.outputs.version }} + cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" -DVERSION=${{ needs.set-version.outputs.version }} - name: Build Project run: | cd build - cmake --build . --config Release -- -j$(nproc) + cmake --build . --config Release -- -j$(sysctl -n hw.ncpu) - - name: Upload build artifacts + - name: Upload VST3 artifact uses: actions/upload-artifact@v4 with: - name: output-vst3-linux + name: output-vst3-macos path: ./build/MatchingCompressor_artefacts/Release/VST3/MatchingCompressor.vst3 + - name: Upload AU artifact + uses: actions/upload-artifact@v4 + with: + name: output-au-macos + path: ./build/MatchingCompressor_artefacts/Release/AU/MatchingCompressor.component + release-windows: needs: - set-version - build-windows + if: github.event_name == 'push' - runs-on: windows-latest + runs-on: windows-latest permissions: contents: write @@ -267,31 +150,18 @@ jobs: - name: Create VST3 GitHub Release uses: softprops/action-gh-release@v2 with: - tag_name: Win-VST3-no_ins-v${{ needs.set-version.outputs.version }}-alpha - name: Windows VST3 (no installer) v${{ needs.set-version.outputs.version }}-alpha + tag_name: Win-VST3-v${{ needs.set-version.outputs.version }}-alpha + name: Windows VST3 v${{ needs.set-version.outputs.version }}-alpha prerelease: true files: MatchingCompressor-vst3-windows-${{ needs.set-version.outputs.version }}-alpha.zip - - name: Download installator artifact - uses: actions/download-artifact@v4 - with: - name: output-ins-windows - path: MatchingCompressor-installer - - - name: Create installator GitHub Release - uses: softprops/action-gh-release@v2 - with: - tag_name: Win-VST3-install-v${{ needs.set-version.outputs.version }}-alpha - name: Windows VST3 (with installer) v${{ needs.set-version.outputs.version }}-alpha - prerelease: true - files: MatchingCompressor-installer/MatchingCompressor.exe - release-linux: needs: - set-version - build-linux + if: github.event_name == 'push' - runs-on: ubuntu-latest + runs-on: ubuntu-latest permissions: contents: write diff --git a/.gitignore b/.gitignore index bff6234..64215db 100644 --- a/.gitignore +++ b/.gitignore @@ -366,4 +366,5 @@ post_build_plugin.cmake Output/ Builds/ CmakeBuild/ -JuceLibraryCode/ \ No newline at end of file +JuceLibraryCode/ +build/ \ No newline at end of file diff --git a/BUILDING.md b/BUILDING.md new file mode 100644 index 0000000..6e1851f --- /dev/null +++ b/BUILDING.md @@ -0,0 +1,204 @@ +# Building MatchingCompressor + +This document describes how to build the MatchingCompressor VST plugin from source. + +## Prerequisites + +### All Platforms +- **CMake** 3.22 or higher +- **C++17** compatible compiler +- **Git** (for fetching JUCE) + +### macOS +- **Xcode Command Line Tools** or full Xcode +- macOS 10.13 or later recommended + +```bash +xcode-select --install +brew install cmake # if not already installed +``` + +### Linux (Ubuntu/Debian) +```bash +sudo apt-get update +sudo apt-get install -y \ + build-essential \ + cmake \ + git \ + libasound2-dev \ + libx11-dev \ + libxrandr-dev \ + libxinerama-dev \ + libxcursor-dev \ + libfreetype6-dev \ + libfontconfig1-dev \ + libgl1-mesa-dev \ + libwebkit2gtk-4.0-dev +``` + +### Linux (Fedora/RHEL) +```bash +sudo dnf install -y \ + gcc-c++ \ + cmake \ + git \ + alsa-lib-devel \ + libX11-devel \ + libXrandr-devel \ + libXinerama-devel \ + libXcursor-devel \ + freetype-devel \ + fontconfig-devel \ + mesa-libGL-devel \ + webkit2gtk3-devel +``` + +### Windows +- **Visual Studio 2019** or later with C++ workload +- **CMake** (can be installed via Visual Studio Installer) + +## Building + +### Quick Start (All Platforms) + +```bash +# Clone the repository +git clone https://github.com/justonem0reuser/MatchingCompressor.git +cd MatchingCompressor + +# Create build directory +mkdir build && cd build + +# Configure (dependencies are fetched automatically) +cmake .. -DCMAKE_BUILD_TYPE=Release + +# Build +cmake --build . --config Release +``` + +### Build Options + +| Option | Default | Description | +|--------|---------|-------------| +| `BUILD_STANDALONE` | `ON` (local), `OFF` (CI) | Build standalone application | +| `VERSION` | `0.1.0` | Plugin version string | +| `CMAKE_BUILD_TYPE` | - | `Debug` or `Release` | + +Example with options: +```bash +cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_STANDALONE=ON -DVERSION=1.0.0 +``` + +### Platform-Specific Notes + +#### macOS +Builds produce: +- `MatchingCompressor.vst3` - VST3 plugin +- `MatchingCompressor.component` - Audio Unit plugin +- `MatchingCompressor.app` - Standalone application (if enabled) + +```bash +# Parallel build using all cores +cmake --build . --config Release -- -j$(sysctl -n hw.ncpu) +``` + +#### Linux +Builds produce: +- `MatchingCompressor.vst3` - VST3 plugin +- `MatchingCompressor` - Standalone application (if enabled) + +```bash +# Parallel build using all cores +cmake --build . --config Release -- -j$(nproc) +``` + +#### Windows +Builds produce: +- `MatchingCompressor.vst3` - VST3 plugin +- `MatchingCompressor.exe` - Standalone application (if enabled) + +```powershell +# Using Visual Studio generator +cmake .. -G "Visual Studio 17 2022" -A x64 +cmake --build . --config Release +``` + +## Build Artifacts + +After a successful build, artifacts are located in: +``` +build/MatchingCompressor_artefacts/Release/ +├── VST3/ +│ └── MatchingCompressor.vst3 +├── AU/ # macOS only +│ └── MatchingCompressor.component +├── Standalone/ +│ └── MatchingCompressor.app # or .exe on Windows +└── ... +``` + +## Installation + +After building, install the plugins to standard system locations: + +```bash +# Modern CMake style +cmake --install build + +# Or traditional Unix style (from build directory) +cd build && make install +``` + +This installs to the standard plugin directories: + +| Platform | Plugin | Location | +|----------|--------|----------| +| macOS | AU | `~/Library/Audio/Plug-Ins/Components/` | +| macOS | VST3 | `~/Library/Audio/Plug-Ins/VST3/` | +| Linux | VST3 | `~/.vst3/` | +| Windows | VST3 | `C:\Program Files\Common Files\VST3\` | + +### Manual Installation + +Alternatively, copy the plugins manually: + +#### macOS +```bash +cp -r build/MatchingCompressor_artefacts/Release/AU/MatchingCompressor.component ~/Library/Audio/Plug-Ins/Components/ +cp -r build/MatchingCompressor_artefacts/Release/VST3/MatchingCompressor.vst3 ~/Library/Audio/Plug-Ins/VST3/ +``` + +#### Linux +```bash +mkdir -p ~/.vst3 +cp -r build/MatchingCompressor_artefacts/Release/VST3/MatchingCompressor.vst3 ~/.vst3/ +``` + +#### Windows +Copy `build/MatchingCompressor_artefacts/Release/VST3/MatchingCompressor.vst3` to `C:\Program Files\Common Files\VST3\` + +## Troubleshooting + +### CMake cannot find dependencies +Dependencies (JUCE, AlgLib) are fetched automatically via CMake's FetchContent. Ensure you have internet access during the first configure step. + +### Linux: Missing development libraries +If you see errors about missing headers, install the development packages listed in Prerequisites. + +### macOS: Code signing issues +For local development, the plugin is ad-hoc signed. For distribution, you'll need an Apple Developer certificate. + +### Build is slow +The first build downloads JUCE (~200MB) and compiles it. Subsequent builds are faster. Use parallel builds: +```bash +cmake --build . --config Release -j8 +``` + +## Dependencies + +The following dependencies are automatically fetched during configuration: + +| Dependency | Version | License | +|------------|---------|---------| +| [JUCE](https://juce.com/) | 8.0.1 | GPLv3 / Commercial | +| [AlgLib](https://www.alglib.net/) | 4.00.0 | GPLv2+ | diff --git a/CMakeLists.txt b/CMakeLists.txt index 43b5377..0cac189 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,12 +1,26 @@ cmake_minimum_required(VERSION 3.22) project("MatchingCompressor") -#Change this if your AlgLib path is different -set(ALGLIB "${CMAKE_SOURCE_DIR}/../AlgLib/alglib-cpp/src") +include(FetchContent) + +# Fetch JUCE +set(JUCE_VERSION "8.0.4") +FetchContent_Declare( + JUCE + GIT_REPOSITORY https://github.com/juce-framework/JUCE.git + GIT_TAG ${JUCE_VERSION} + GIT_SHALLOW TRUE +) +FetchContent_MakeAvailable(JUCE) -#Change this if your JUCE path is different -set(JUCE_PATH "${CMAKE_SOURCE_DIR}/../JUCE") -set(JUCE_INCLUDE_DIR "${JUCE_PATH}/modules") +# Fetch AlgLib +set(ALGLIB_VERSION "4.00.0") +FetchContent_Declare( + AlgLib + URL https://www.alglib.net/translator/re/alglib-${ALGLIB_VERSION}.cpp.gpl.zip +) +FetchContent_MakeAvailable(AlgLib) +set(ALGLIB "${alglib_SOURCE_DIR}/src") set(BUILD_STANDALONE_DEFAULT ON) if(DEFINED ENV{CI}) @@ -15,12 +29,6 @@ endif() option(BUILD_STANDALONE "Build Standalone" ${BUILD_STANDALONE_DEFAULT}) include_directories(${ALGLIB}) -include_directories(${JUCE_INCLUDE_DIR}) - -add_subdirectory(${JUCE_PATH} JUCE_build) - -#find_package(JUCE CONFIG REQUIRED) -#add_subdirectory(juce) set(JUCE_PLUGIN_FORMATS VST3 AU AUv3 AAX) if(BUILD_STANDALONE) @@ -38,8 +46,13 @@ juce_add_plugin(MatchingCompressor COMPANY_NAME "Just1m0reApp" COMPANY_WEBSITE "https://github.com/justonem0reuser" + PLUGIN_MANUFACTURER_CODE Jmor + PLUGIN_CODE Mtcp + FORMATS ${JUCE_PLUGIN_FORMATS} + AU_MAIN_TYPE kAudioUnitType_Effect + VST3_CATEGORIES "Analyzer" "Dynamics" @@ -155,17 +168,36 @@ target_link_libraries(MatchingCompressor juce::juce_recommended_warning_flags ) -# This allows to add additional steps after building: -# for example, to copy the plugin to the common VST3 directory -# and run a DAW app. - -set(POST_BUILD_SCRIPT "${CMAKE_CURRENT_LIST_DIR}/post_build_plugin.cmake") - -if(EXISTS "${POST_BUILD_SCRIPT}") - add_custom_command(TARGET MatchingCompressor_VST3 POST_BUILD - COMMAND ${CMAKE_COMMAND} - -DPLUGIN_PATH="$" - -DPOST_BUILD_SCRIPT="${POST_BUILD_SCRIPT}" - -P "${POST_BUILD_SCRIPT}" - ) +# Installation targets +# Usage: cmake --install build + +if(APPLE) + install(CODE " + file(INSTALL + DESTINATION \"\$ENV{HOME}/Library/Audio/Plug-Ins/Components\" + TYPE DIRECTORY + FILES \"${CMAKE_BINARY_DIR}/MatchingCompressor_artefacts/\$/AU/MatchingCompressor.component\" + ) + file(INSTALL + DESTINATION \"\$ENV{HOME}/Library/Audio/Plug-Ins/VST3\" + TYPE DIRECTORY + FILES \"${CMAKE_BINARY_DIR}/MatchingCompressor_artefacts/\$/VST3/MatchingCompressor.vst3\" + ) + ") +elseif(UNIX) + install(CODE " + file(INSTALL + DESTINATION \"\$ENV{HOME}/.vst3\" + TYPE DIRECTORY + FILES \"${CMAKE_BINARY_DIR}/MatchingCompressor_artefacts/\$/VST3/MatchingCompressor.vst3\" + ) + ") +elseif(WIN32) + install(CODE " + file(INSTALL + DESTINATION \"\$ENV{PROGRAMFILES}/Common Files/VST3\" + TYPE DIRECTORY + FILES \"${CMAKE_BINARY_DIR}/MatchingCompressor_artefacts/\$/VST3/MatchingCompressor.vst3\" + ) + ") endif()