#!/usr/bin/env bash # --------------------------------------------------------------------------- # build_windows.sh — cross-compile SerumAlt VST3 for Windows using MinGW-w64 # --------------------------------------------------------------------------- set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" cd "$SCRIPT_DIR" TOOLCHAIN_FILE="$SCRIPT_DIR/mingw64-toolchain.cmake" BUILD_DIR="${BUILD_DIR:-$SCRIPT_DIR/build_windows}" BUILD_TYPE="${BUILD_TYPE:-Release}" OUTPUT_DIR="${OUTPUT_DIR:-$SCRIPT_DIR/SerumAlt_Windows}" PLUGIN_NAME="SerumAlt" export CMAKE_BUILD_PARALLEL_LEVEL="${CMAKE_BUILD_PARALLEL_LEVEL:-2}" if [[ "$(uname -s)" != Linux ]]; then echo "ERROR: build_windows.sh cross-compiles from Linux using MinGW-w64." >&2 exit 1 fi # 1. Check for the host tools and MinGW-w64 cross-compiler. for tool in cmake ninja pkg-config "${CC:-cc}" "${CXX:-c++}" \ x86_64-w64-mingw32-gcc x86_64-w64-mingw32-g++ \ x86_64-w64-mingw32-windres x86_64-w64-mingw32-ar \ x86_64-w64-mingw32-ranlib x86_64-w64-mingw32-strip; do if ! command -v "$tool" >/dev/null 2>&1; then echo "ERROR: $tool not found. See README.md prerequisites." >&2 exit 1 fi done echo "Found: $(command -v x86_64-w64-mingw32-g++)" # 2. Use the checked-in CMake toolchain file without overwriting it. if [[ ! -f "$TOOLCHAIN_FILE" ]]; then echo "ERROR: Toolchain file not found: $TOOLCHAIN_FILE" >&2 exit 1 fi echo "Using toolchain file: $TOOLCHAIN_FILE" # 3. Configure with CMake + Ninja (VST3-only cross build, no test harness). echo "Configuring Windows VST3 in $BUILD_DIR ($BUILD_TYPE)..." cmake -S "$SCRIPT_DIR" -B "$BUILD_DIR" -G Ninja \ -DCMAKE_BUILD_TYPE="$BUILD_TYPE" \ -DCMAKE_TOOLCHAIN_FILE="$TOOLCHAIN_FILE" \ -DSERUMALT_BUILD_PLUGIN=ON \ -DSERUMALT_BUILD_TESTS=OFF # 4. Build the VST3 target. echo "Building Windows VST3..." cmake --build "$BUILD_DIR" --config "$BUILD_TYPE" --target SerumAlt_VST3 # 5. Inject the VST3 moduleinfo.json. # The automatic manifest step is disabled when cross-compiling (see # cmake/Plugin.cmake), because JUCE's manifest helper is a host tool that would # otherwise be built as a Windows executable. The moduleinfo content is # deterministic for this Windows plugin: it depends on the plugin's # name, manufacturer/plugin codes, and version, so we write the same metadata # that the native Windows helper generates. Keep it in sync with the metadata # in CMakeLists.txt and cmake/Plugin.cmake, including the vendored VST3 SDK version. VST3_BUNDLE="$BUILD_DIR/${PLUGIN_NAME}_artefacts/$BUILD_TYPE/VST3/$PLUGIN_NAME.vst3" echo "Writing Windows VST3 manifest..." mkdir -p "$VST3_BUNDLE/Contents/Resources" cat > "$VST3_BUNDLE/Contents/Resources/moduleinfo.json" <<'EOF' { "Name": "SerumAlt", "Version": "1.0.0", "Factory Info": { "Vendor": "SerumAlt Audio", "URL": "", "E-Mail": "", "Flags": { "Unicode": true, "Classes Discardable": false, "Component Non Discardable": false } }, "Classes": [ { "CID": "ABCDEF019182FAEB53616C7453657261", "Category": "Audio Module Class", "Name": "SerumAlt", "Vendor": "SerumAlt Audio", "Version": "1.0.0", "SDKVersion": "VST 3.7.8", "Sub Categories": [ "Instrument", "Synth" ], "Class Flags": 2, "Cardinality": 2147483647, "Snapshots": [] }, { "CID": "ABCDEF011234ABCD53616C7453657261", "Category": "Component Controller Class", "Name": "SerumAlt", "Vendor": "SerumAlt Audio", "Version": "1.0.0", "SDKVersion": "VST 3.7.8", "Sub Categories": [ "Instrument", "Synth" ], "Class Flags": 2, "Cardinality": 2147483647, "Snapshots": [] }, { "CID": "ABCDEF01C0DEF00D53616C7453657261", "Category": "Plugin Compatibility Class", "Name": "SerumAlt", "Vendor": "SerumAlt Audio", "Version": "1.0.0", "SDKVersion": "VST 3.7.8", "Class Flags": 0, "Cardinality": 2147483647, "Snapshots": [] } ] } EOF # 6. Copy the resulting .vst3 bundle to SerumAlt_Windows/ without deleting files. echo "Staging Windows VST3 in $OUTPUT_DIR..." cmake -E copy_directory "$VST3_BUNDLE" "$OUTPUT_DIR/$PLUGIN_NAME.vst3" echo echo "Done. Windows VST3 plugin at: $OUTPUT_DIR/$PLUGIN_NAME.vst3"