diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c7b6d94..830df4e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,6 +12,12 @@ jobs: build: name: Build on ${{ matrix.os }} runs-on: ${{ matrix.os }} + env: + CMAKE_BUILD_PARALLEL_LEVEL: '4' + PRISM_JUCE_VERSION: 8.0.4 + PRISM_WEBVIEW2_VERSION: 1.0.1901.177 + SCCACHE_GHA_ENABLED: 'true' + SCCACHE_IGNORE_SERVER_IO_ERROR: '1' strategy: fail-fast: false matrix: @@ -43,7 +49,31 @@ jobs: ~/.cache/electron-builder key: ${{ runner.os }}-electron-cache + - name: Setup sccache + if: runner.os != 'Linux' + uses: mozilla-actions/sccache-action@v0.0.10 + + - name: Cache JUCE + if: runner.os != 'Linux' + uses: actions/cache@v4 + with: + path: .ci-cache/juce/JUCE-${{ env.PRISM_JUCE_VERSION }} + key: ${{ runner.os }}-juce-${{ env.PRISM_JUCE_VERSION }}-v1 + + - name: Prepare JUCE checkout + if: runner.os != 'Linux' + shell: bash + run: | + juce_dir=".ci-cache/juce/JUCE-${PRISM_JUCE_VERSION}" + if [ ! -f "$juce_dir/CMakeLists.txt" ]; then + rm -rf "$juce_dir" + mkdir -p "$(dirname "$juce_dir")" + git clone --depth 1 --branch "$PRISM_JUCE_VERSION" https://github.com/juce-framework/JUCE.git "$juce_dir" + fi + - name: Install dependencies + env: + PRISM_SKIP_NATIVE_POSTINSTALL: '1' run: npm ci - name: Install Linux native build dependencies @@ -73,27 +103,62 @@ jobs: - name: Configure JUCE plugins (macOS) if: runner.os == 'macOS' - run: cmake -B plugin/build -S plugin -DCMAKE_BUILD_TYPE=Release + run: | + cmake -B plugin/build -S plugin -G Ninja \ + -DCMAKE_BUILD_TYPE=Release \ + -DJUCE_PATH="$GITHUB_WORKSPACE/.ci-cache/juce/JUCE-${PRISM_JUCE_VERSION}" \ + -DPRISM_PLUGIN_FORMATS="AU;VST3" \ + -DPRISM_COPY_PLUGIN_AFTER_BUILD=OFF \ + -DCMAKE_C_COMPILER_LAUNCHER=sccache \ + -DCMAKE_CXX_COMPILER_LAUNCHER=sccache # JUCE's NEEDS_WEBVIEW2 expects the Microsoft.Web.WebView2 NuGet package # to already be installed locally; it doesn't fetch it itself. Install it # and point CMake at the resulting folder via JUCE_WEBVIEW2_PACKAGE_LOCATION. + - name: Cache WebView2 SDK (Windows) + if: runner.os == 'Windows' + uses: actions/cache@v4 + with: + path: ${{ runner.temp }}/webview2 + key: ${{ runner.os }}-webview2-${{ env.PRISM_WEBVIEW2_VERSION }}-v1 + - name: Install WebView2 SDK (Windows) if: runner.os == 'Windows' shell: pwsh run: | $sdkRoot = "$env:RUNNER_TEMP\webview2" - New-Item -ItemType Directory -Force -Path $sdkRoot | Out-Null - nuget install Microsoft.Web.WebView2 -Version 1.0.1901.177 -OutputDirectory $sdkRoot -ExcludeVersion + $packageRoot = Join-Path $sdkRoot "Microsoft.Web.WebView2" + $webViewHeader = Join-Path $packageRoot "build\native\include\WebView2.h" + if (-not (Test-Path $webViewHeader)) { + Remove-Item -Recurse -Force $sdkRoot -ErrorAction SilentlyContinue + New-Item -ItemType Directory -Force -Path $sdkRoot | Out-Null + nuget install Microsoft.Web.WebView2 -Version $env:PRISM_WEBVIEW2_VERSION -OutputDirectory $sdkRoot -ExcludeVersion + } "JUCE_WEBVIEW2_PACKAGE_LOCATION=$sdkRoot" >> $env:GITHUB_ENV - name: Configure JUCE plugins (Windows) if: runner.os == 'Windows' - run: cmake -B plugin/build -S plugin -G "Visual Studio 17 2022" -A x64 -DJUCE_WEBVIEW2_PACKAGE_LOCATION="$env:JUCE_WEBVIEW2_PACKAGE_LOCATION" + shell: cmd + run: | + for /f "usebackq tokens=*" %%i in (`vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do set VSINSTALL=%%i + call "%VSINSTALL%\VC\Auxiliary\Build\vcvars64.bat" + cmake -B plugin/build -S plugin -G Ninja -DCMAKE_BUILD_TYPE=Release -DJUCE_PATH="%GITHUB_WORKSPACE%\.ci-cache\juce\JUCE-%PRISM_JUCE_VERSION%" -DPRISM_PLUGIN_FORMATS=VST3 -DPRISM_COPY_PLUGIN_AFTER_BUILD=OFF -DJUCE_WEBVIEW2_PACKAGE_LOCATION="%JUCE_WEBVIEW2_PACKAGE_LOCATION%" -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache - - name: Build JUCE plugins + - name: Build JUCE plugins (macOS) + if: runner.os == 'macOS' + run: cmake --build plugin/build --target PrismInstallerPlugins --parallel 4 + + - name: Build JUCE plugins (Windows) + if: runner.os == 'Windows' + shell: cmd + run: | + for /f "usebackq tokens=*" %%i in (`vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do set VSINSTALL=%%i + call "%VSINSTALL%\VC\Auxiliary\Build\vcvars64.bat" + cmake --build plugin/build --target PrismInstallerPlugins --config Release --parallel 4 + + - name: Show sccache stats if: runner.os != 'Linux' - run: cmake --build plugin/build --config Release + run: sccache --show-stats - name: Stage plugins for installer shell: bash @@ -115,10 +180,20 @@ jobs: fi done echo "--- staged VST3 ---" - ls -la plugin/dist-installer/VST3 || true + ls -la plugin/dist-installer/VST3 + vst3_count="$(find plugin/dist-installer/VST3 -maxdepth 1 -name "*.vst3" | wc -l | tr -d ' ')" + if [ "$vst3_count" -ne 7 ]; then + echo "ERROR: expected 7 VST3 plugins, found $vst3_count" + exit 1 + fi if [ "$RUNNER_OS" = "macOS" ]; then echo "--- staged AU ---" - ls -la plugin/dist-installer/AU || true + ls -la plugin/dist-installer/AU + au_count="$(find plugin/dist-installer/AU -maxdepth 1 -name "*.component" | wc -l | tr -d ' ')" + if [ "$au_count" -ne 7 ]; then + echo "ERROR: expected 7 AU plugins, found $au_count" + exit 1 + fi fi - name: Build distributable diff --git a/package.json b/package.json index 88fdf9a..e689b62 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "plugin-ui:build": "vite build --config vite.plugin-ui.config.ts", "build:native": "cd native && node-gyp rebuild", "rebuild:native": "node -e \"const e=require('electron/package.json').version;const a=process.arch;const{execSync}=require('child_process');execSync('node-gyp rebuild --target='+e+' --arch='+a+' --dist-url=https://electronjs.org/headers',{stdio:'inherit',cwd:'native'})\"", - "postinstall": "npm run rebuild:native || echo 'Native build failed, will use JS fallback'", + "postinstall": "node scripts/build/postinstall-native.cjs", "dist": "npm run build && electron-builder --publish never", "dist:mac": "npm run build && electron-builder --mac --publish never", "dist:win": "npm run build && electron-builder --win --publish never", diff --git a/plugin/CMakeLists.txt b/plugin/CMakeLists.txt index ea7ac37..a4ee81c 100644 --- a/plugin/CMakeLists.txt +++ b/plugin/CMakeLists.txt @@ -33,6 +33,11 @@ set(PRISM_NATIVE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../native/src) # UI delivery: bundled (self-contained, default) vs Vite dev server (hot reload). option(PRISM_DEV_SERVER "Load the webview UI from the Vite dev server instead of the embedded bundle" OFF) +# Build controls. Defaults preserve the full local build; CI narrows these to +# the formats that are actually packaged. +set(PRISM_PLUGIN_FORMATS "AU;VST3;Standalone" CACHE STRING "JUCE plugin formats to build") +option(PRISM_COPY_PLUGIN_AFTER_BUILD "Copy built plugins into user plugin folders after build" ON) + # Embed the built webview bundle once; every scope plugin shares it (the C++ tells # the UI which scope to mount via initialisation data). if(NOT PRISM_DEV_SERVER) @@ -53,13 +58,13 @@ function(add_prism_scope TARGET PRODUCT PLUGIN_CODE SCOPE_DEFINE) BUNDLE_ID com.astra.prism.${TARGET} PLUGIN_MANUFACTURER_CODE Prsm PLUGIN_CODE ${PLUGIN_CODE} - FORMATS AU VST3 Standalone + FORMATS ${PRISM_PLUGIN_FORMATS} IS_SYNTH FALSE NEEDS_MIDI_INPUT FALSE NEEDS_MIDI_OUTPUT FALSE IS_MIDI_EFFECT FALSE NEEDS_WEBVIEW2 TRUE # Windows: links Microsoft Edge WebView2. No-op elsewhere. - COPY_PLUGIN_AFTER_BUILD TRUE) + COPY_PLUGIN_AFTER_BUILD ${PRISM_COPY_PLUGIN_AFTER_BUILD}) target_sources(${TARGET} PRIVATE Source/PluginProcessor.cpp @@ -123,3 +128,23 @@ add_prism_scope(PrismLUFSMeter "Prism Loudness Meter" Pluf "PRISM_SCOPE_LUFSM add_prism_scope(PrismVectorscope "Prism Vectorscope" Pvct "PRISM_SCOPE_VECTORSCOPE=1") add_prism_scope(PrismSpectrogram "Prism Spectrogram" Pspg "PRISM_SCOPE_SPECTROGRAM=1") add_prism_scope(PrismWaveform "Prism Waveform" Pwav "PRISM_SCOPE_WAVEFORM=1") + +set(PRISM_SCOPE_TARGETS + PrismSpectrum + PrismOscilloscope + PrismVUMeter + PrismLUFSMeter + PrismVectorscope + PrismSpectrogram + PrismWaveform) + +add_custom_target(PrismInstallerPlugins) +foreach(PRISM_SCOPE_TARGET IN LISTS PRISM_SCOPE_TARGETS) + if("VST3" IN_LIST PRISM_PLUGIN_FORMATS) + add_dependencies(PrismInstallerPlugins ${PRISM_SCOPE_TARGET}_VST3) + endif() + + if(APPLE AND "AU" IN_LIST PRISM_PLUGIN_FORMATS) + add_dependencies(PrismInstallerPlugins ${PRISM_SCOPE_TARGET}_AU) + endif() +endforeach() diff --git a/scripts/build/postinstall-native.cjs b/scripts/build/postinstall-native.cjs new file mode 100644 index 0000000..51bdb79 --- /dev/null +++ b/scripts/build/postinstall-native.cjs @@ -0,0 +1,18 @@ +const { spawnSync } = require('node:child_process') + +const skipNativePostinstall = /^(1|true|yes)$/i.test(process.env.PRISM_SKIP_NATIVE_POSTINSTALL || '') + +if (skipNativePostinstall) { + console.log('Skipping native postinstall because PRISM_SKIP_NATIVE_POSTINSTALL is set.') + process.exit(0) +} + +const npmCommand = process.platform === 'win32' ? 'npm.cmd' : 'npm' +const result = spawnSync(npmCommand, ['run', 'rebuild:native'], { stdio: 'inherit' }) + +if (result.status === 0) { + process.exit(0) +} + +console.warn('Native build failed, will use JS fallback') +process.exit(0)