build: add CMake and MinGW cross-compilation toolchain
This commit is contained in:
Executable
+134
@@ -0,0 +1,134 @@
|
||||
#!/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="mingw64-toolchain.cmake"
|
||||
BUILD_DIR="build_windows"
|
||||
OUTPUT_DIR="SerumAlt_Windows"
|
||||
PLUGIN_NAME="SerumAlt"
|
||||
|
||||
# 1. Check for the MinGW-w64 cross-compiler and exit if it is not found.
|
||||
if ! command -v x86_64-w64-mingw32-g++ >/dev/null 2>&1; then
|
||||
echo "ERROR: x86_64-w64-mingw32-g++ not found." >&2
|
||||
echo "Please install the MinGW-w64 cross-compiler first, e.g.:" >&2
|
||||
echo " sudo pacman -S mingw-w64-gcc" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Found: $(command -v x86_64-w64-mingw32-g++)"
|
||||
|
||||
# 2. Generate the CMake toolchain file.
|
||||
cat > "$TOOLCHAIN_FILE" <<'EOF'
|
||||
set(CMAKE_SYSTEM_NAME Windows)
|
||||
set(CMAKE_SYSTEM_PROCESSOR x86_64)
|
||||
|
||||
set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
|
||||
set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
|
||||
set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres)
|
||||
set(CMAKE_AR x86_64-w64-mingw32-ar)
|
||||
set(CMAKE_RANLIB x86_64-w64-mingw32-ranlib)
|
||||
set(CMAKE_STRIP x86_64-w64-mingw32-strip)
|
||||
|
||||
set(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||
EOF
|
||||
|
||||
echo "Wrote toolchain file: $TOOLCHAIN_FILE"
|
||||
|
||||
# 3. Configure with CMake + Ninja (VST3-only cross build, no test harness).
|
||||
cmake -S . -B "$BUILD_DIR" -G Ninja \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_TOOLCHAIN_FILE="$TOOLCHAIN_FILE" \
|
||||
-DSERUMALT_BUILD_TESTS=OFF
|
||||
|
||||
# 4. Build the VST3 target.
|
||||
cmake --build "$BUILD_DIR" --target SerumAlt_VST3
|
||||
|
||||
# 5. Inject the VST3 moduleinfo.json.
|
||||
# The automatic manifest step is disabled when cross-compiling (see
|
||||
# CMakeLists.txt), because JUCE's manifest helper is a host tool that would
|
||||
# otherwise be built as a Windows executable. The moduleinfo content is
|
||||
# deterministic and platform-independent: it depends only on the plugin's
|
||||
# name, manufacturer/plugin codes, and version, so we write the identical
|
||||
# file that the native helper generates. Keep it in sync with the metadata
|
||||
# in CMakeLists.txt (PLUGIN_CODE, PLUGIN_MANUFACTURER_CODE, VERSION).
|
||||
VST3_BUNDLE="$BUILD_DIR/${PLUGIN_NAME}_artefacts/Release/VST3/$PLUGIN_NAME.vst3"
|
||||
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/.
|
||||
mkdir -p "$OUTPUT_DIR"
|
||||
rm -rf "$OUTPUT_DIR/$PLUGIN_NAME.vst3"
|
||||
cp -R "$BUILD_DIR/${PLUGIN_NAME}_artefacts/Release/VST3/$PLUGIN_NAME.vst3" "$OUTPUT_DIR/"
|
||||
|
||||
echo
|
||||
echo "Done. Windows VST3 plugin at: $SCRIPT_DIR/$OUTPUT_DIR/$PLUGIN_NAME.vst3"
|
||||
Reference in New Issue
Block a user