Layout: - scripts/ holds the four build scripts plus the new clean.sh - cmake/ holds mingw64-toolchain.cmake - the scripts default to build/linux, build/macos, build/windows, build/harness - docs/ holds the audit documents, with the round 1 task list archived Cleanup: - scripts/clean.sh removes generated output, with --dry-run, --staging, --legacy and --all, and refuses tracked, protected or outside paths - the Windows VST3 manifest now comes from cmake/moduleinfo.json.in, so its version, vendor and class IDs follow cmake/Plugin.cmake instead of a hand-written heredoc that could drift - deleted the unused Source/GUI/Slider, which no code constructed - fixed the hidden double processBlock overload: three warning lines to zero - unslopped the build scripts, the two .cjs helpers and the CMake comments - .gitignore covers the upstream JUCE Projucer and DemoRunner binaries Verified: five scripts pass bash -n; the harness passes CTest with zero warning lines; the Linux VST3 and Standalone link; the Windows cross-build passes its x86-64, runtime-import and entry-point checks; each configure exposes only its own targets; and a full build leaves Source/ and third_party/JUCE unchanged. The generated manifest is identical to the previous hand-written one.
94 lines
3.6 KiB
Bash
Executable File
94 lines
3.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Cross-compile the Windows x64 VST3 from Linux with MinGW-w64.
|
|
set -euo pipefail
|
|
|
|
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
cd "$REPO_ROOT"
|
|
|
|
TOOLCHAIN_FILE="$REPO_ROOT/cmake/mingw64-toolchain.cmake"
|
|
BUILD_DIR="${BUILD_DIR:-$REPO_ROOT/build/windows}"
|
|
BUILD_TYPE="${BUILD_TYPE:-Release}"
|
|
OUTPUT_DIR="${OUTPUT_DIR:-$REPO_ROOT/SerumAlt_Windows}"
|
|
PLUGIN_NAME="SerumAlt"
|
|
export CMAKE_BUILD_PARALLEL_LEVEL="${CMAKE_BUILD_PARALLEL_LEVEL:-2}"
|
|
|
|
if [[ "$(uname -s)" != Linux ]]; then
|
|
echo "ERROR: scripts/build_windows.sh cross-compiles from Linux with MinGW-w64." >&2
|
|
exit 1
|
|
fi
|
|
|
|
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 \
|
|
x86_64-w64-mingw32-objdump; do
|
|
if ! command -v "$tool" >/dev/null 2>&1; then
|
|
echo "ERROR: $tool not found. See README.md prerequisites." >&2
|
|
exit 1
|
|
fi
|
|
done
|
|
|
|
if [[ ! -f "$TOOLCHAIN_FILE" ]]; then
|
|
echo "ERROR: toolchain file not found: $TOOLCHAIN_FILE" >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "Configuring Windows VST3 in $BUILD_DIR ($BUILD_TYPE)..."
|
|
cmake -S "$REPO_ROOT" -B "$BUILD_DIR" -G Ninja \
|
|
-DCMAKE_BUILD_TYPE="$BUILD_TYPE" \
|
|
-DCMAKE_TOOLCHAIN_FILE="$TOOLCHAIN_FILE" \
|
|
-DSERUMALT_BUILD_PLUGIN=ON \
|
|
-DSERUMALT_BUILD_TESTS=OFF
|
|
|
|
echo "Building Windows VST3..."
|
|
cmake --build "$BUILD_DIR" --config "$BUILD_TYPE" --target SerumAlt_VST3
|
|
|
|
# A stock Windows host has neither the MinGW C++ runtime nor the MinGW threading
|
|
# runtime, so a module that imports one fails to load and the host drops it from
|
|
# its plugin list. cmake/Plugin.cmake links both statically; these checks fail the
|
|
# build when that link option is missing from a cached or a fresh build tree.
|
|
VST3_BUNDLE="$BUILD_DIR/${PLUGIN_NAME}_artefacts/$BUILD_TYPE/VST3/$PLUGIN_NAME.vst3"
|
|
VST3_BINARY="$VST3_BUNDLE/Contents/x86_64-win/$PLUGIN_NAME.vst3"
|
|
if [[ ! -f "$VST3_BINARY" ]]; then
|
|
echo "ERROR: cross-build produced no module at $VST3_BINARY" >&2
|
|
exit 1
|
|
fi
|
|
if ! x86_64-w64-mingw32-objdump -f "$VST3_BINARY" | grep -q 'i386:x86-64'; then
|
|
echo "ERROR: $VST3_BINARY is not an x86-64 module" >&2
|
|
exit 1
|
|
fi
|
|
VST3_DUMP="$(x86_64-w64-mingw32-objdump -p "$VST3_BINARY")"
|
|
for runtime in libgcc_s_seh-1.dll libstdc++-6.dll libwinpthread-1.dll; do
|
|
if grep -qF "DLL Name: $runtime" <<<"$VST3_DUMP"; then
|
|
echo "ERROR: $VST3_BINARY still imports $runtime." >&2
|
|
echo " Restore the static-runtime link options in cmake/Plugin.cmake" >&2
|
|
echo " and rebuild with a fresh BUILD_DIR." >&2
|
|
exit 1
|
|
fi
|
|
done
|
|
# JUCE defines only these entry points on Windows. bundleEntry and bundleExit are
|
|
# macOS-only, and the VST3 SDK loader requires GetPluginFactory while treating
|
|
# InitDll and ExitDll as optional.
|
|
for entry in GetPluginFactory InitDll ExitDll; do
|
|
if ! grep -qE "[[:space:]]${entry}\$" <<<"$VST3_DUMP"; then
|
|
echo "ERROR: $VST3_BINARY does not export $entry" >&2
|
|
exit 1
|
|
fi
|
|
done
|
|
|
|
# JUCE's manifest helper is a host tool, so a cross-build disables it and CMake
|
|
# writes moduleinfo.json from cmake/moduleinfo.json.in instead.
|
|
MANIFEST="$BUILD_DIR/moduleinfo.json"
|
|
if [[ ! -f "$MANIFEST" ]]; then
|
|
echo "ERROR: CMake wrote no manifest at $MANIFEST" >&2
|
|
exit 1
|
|
fi
|
|
mkdir -p "$VST3_BUNDLE/Contents/Resources"
|
|
cmake -E copy "$MANIFEST" "$VST3_BUNDLE/Contents/Resources/moduleinfo.json"
|
|
|
|
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"
|