Skip to content

Commit

Permalink
Merge pull request #35 from Birch-san/update-deps
Browse files Browse the repository at this point in the history
Upgrade to JUCE 6.1.5 + fluidsynth 2.2.5 + make Docker cross-compile parallel & ARM-native
  • Loading branch information
Birch-san authored Feb 13, 2022
2 parents 7fb8dfb + 23e5bf9 commit 9329281
Show file tree
Hide file tree
Showing 23 changed files with 395 additions and 74 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
/build/
.DS_Store
/VST2_SDK/*
!/VST2_SDK/README.md
!/VST2_SDK/README.md
/llvm-mingw-*/
/llvm-mingw-*.tar.xz
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,9 @@ target_link_libraries(JuicySFPlugin
juce::juce_recommended_lto_flags
juce::juce_recommended_warning_flags)

if (NOT BUILD_SHARED_LIBS)
# Apple clang doesn't support -static-libgcc flag, but seems to make a portable binary regardless
if (NOT BUILD_SHARED_LIBS AND CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ ${CMAKE_EXE_LINKER_FLAGS}")
# the VST2 and VST3 distributions are "modules", so they don't listen to the EXE_LINKER flags
set(CMAKE_MODULE_LINKER_FLAGS "-static-libgcc -static-libstdc++ ${CMAKE_MODULE_LINKER_FLAGS}")
endif (NOT BUILD_SHARED_LIBS)
endif (NOT BUILD_SHARED_LIBS AND CMAKE_SYSTEM_NAME STREQUAL "Windows")
8 changes: 0 additions & 8 deletions Source/PluginProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@
#if JUCE_MAC || JUCE_IOS
#include <Foundation/NSString.h>
#include <Foundation/NSArray.h>
class X {
public:
void y() {
char z;
NSString s;
NSArray a;
}
}
#endif
#include "../JuceLibraryCode/JuceHeader.h"
#include "FluidSynthModel.h"
Expand Down
File renamed without changes.
6 changes: 6 additions & 0 deletions building.win32.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
```bash
DOCKER_BUILDKIT=0 docker build . -f win32.Dockerfile --tag=llvm-mingw
# ues this if you need to investigate any problems:
# docker run -it --rm --name llvm-mingw llvm-mingw
./distribute/bundle_win32.sh 3.0.1
```
2 changes: 1 addition & 1 deletion cmake/Modules/FindPkgConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ function(_pkg_find_libs _prefix _no_cmake_path _no_cmake_environment_path _stati
${_find_opts})

mark_as_advanced(${lib_var_name})
if(lib_var_name)
if(${lib_var_name})
list(APPEND _libs "${${lib_var_name}}")
else()
list(APPEND _libs ${_pkg_search})
Expand Down
2 changes: 1 addition & 1 deletion distribute/README.x64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ VST2\libjuicysfplugin.dll -> "C:\Program Files\Common Files\VST2\libjuicysfplugi
VST3\juicysfplugin.vst3 -> "C:\Program Files\Common Files\VST3\juicysfplugin.vst3"
Standalone\juicysfplugin.exe -> "C:\Program Files\Birchlabs\juicysfplugin.exe"

### Upgrading from a previous version of juicysfplugin
### Upgrading from juicysfplugin 2.x or older

Run the uninstaller that came with juicysfplugin, or delete the files that are described in these release notes:
https://github.com/Birch-san/juicysfplugin/releases/tag/2.3.3
Expand Down
2 changes: 1 addition & 1 deletion distribute/README.x86.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ VST2\libjuicysfplugin.dll -> "C:\Program Files (x86)\Common Files\VST2\libjuicys
VST3\juicysfplugin.vst3 -> "C:\Program Files (x86)\Common Files\VST3\juicysfplugin.vst3"
Standalone\juicysfplugin.exe -> "C:\Program Files (x86)\Birchlabs\juicysfplugin.exe"

### Upgrading from a previous version of juicysfplugin
### Upgrading from juicysfplugin 2.x or older

Run the uninstaller that came with juicysfplugin, or delete the files that are described in these release notes:
https://github.com/Birch-san/juicysfplugin/releases/tag/2.3.3
Expand Down
13 changes: 8 additions & 5 deletions distribute/bundle_win32.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
# ./bundle_win32.sh 3.0.0
# ./bundle_win32.sh 3.1.0

set -eo pipefail
DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
Expand All @@ -9,7 +9,10 @@ mkdir -p "$OUT"

VERSION="$1"

declare -a ARCHS=("x64" "x86")
# x86 build fails in JUCE 6.1.5; problem compiling UUIDGetter
# https://gist.github.com/Birch-san/a36b10155e51bd814ecc7109501e1e64
# declare -a ARCHS=("x64" "x86")
declare -a ARCHS=("x64")

# macOS bundled GNU bash doesn't support associative arrays
arch_long_ix() {
Expand Down Expand Up @@ -50,9 +53,9 @@ for ARCH in ${ARCHS[@]}; do
VST3="$ARCH_OUT/VST3"
mkdir -p "$VST3"

docker cp "$CONTAINER_NAME":"/build/juicysfplugin/build_$ARCH/JuicySFPlugin_artefacts/$FLAVOUR/Standalone/juicysfplugin.exe" "$STANDALONE/juicysfplugin.exe"
docker cp "$CONTAINER_NAME":"/build/juicysfplugin/build_$ARCH/JuicySFPlugin_artefacts/$FLAVOUR/VST/libjuicysfplugin.dll" "$VST2/libjuicysfplugin.dll"
docker cp "$CONTAINER_NAME":"/build/juicysfplugin/build_$ARCH/JuicySFPlugin_artefacts/$FLAVOUR/VST3/juicysfplugin.vst3/Contents/$ARCH_LONG/juicysfplugin.vst3" "$VST3/juicysfplugin.vst3"
docker cp "$CONTAINER_NAME":"$ARCH/$FLAVOUR/Standalone/juicysfplugin.exe" "$STANDALONE/juicysfplugin.exe"
docker cp "$CONTAINER_NAME":"$ARCH/$FLAVOUR/VST/libjuicysfplugin.dll" "$VST2/libjuicysfplugin.dll"
docker cp "$CONTAINER_NAME":"$ARCH/$FLAVOUR/VST3/juicysfplugin.vst3/Contents/$ARCH_LONG/juicysfplugin.vst3" "$VST3/juicysfplugin.vst3"

cp -r "$DIR/../licenses_of_dependencies" "$ARCH_OUT"
cp "$DIR/../LICENSE.txt" "$ARCH_OUT"
Expand Down
130 changes: 109 additions & 21 deletions win32.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,28 +1,104 @@
# DOCKER_BUILDKIT=0 docker build . -f win32.Dockerfile --tag=llvm-mingw
# docker build . -f win32.Dockerfile --tag=llvm-mingw
# docker run -it --rm --name llvm-mingw llvm-mingw
# docker cp get_fluidsynth_deps.sh llvm-mingw:/build/get_fluidsynth_deps.sh && docker exec llvm-mingw /build/get_fluidsynth_deps.sh
ARG UBUNTU_VER=22.04

FROM mstorsjo/llvm-mingw
RUN dpkg --add-architecture i386 && \
apt-get update -qq && \
FROM ubuntu:$UBUNTU_VER AS wgetter
RUN apt-get update -qq && \
apt-get install -qqy --no-install-recommends \
zstd libx11-dev libxrandr-dev libxinerama-dev libxcursor-dev libfreetype6-dev wine-stable wine32 && \
wget ca-certificates && \
apt-get clean -y && \
rm -rf /var/lib/apt/lists/*
COPY win32_cross_compile/clone_fluidsynth.sh clone_fluidsynth.sh
RUN /build/clone_fluidsynth.sh
COPY win32_cross_compile/install.sh install.sh
COPY win32_cross_compile/get_fluidsynth_deps.sh get_fluidsynth_deps.sh
RUN /build/get_fluidsynth_deps.sh
COPY win32_cross_compile/x86_64_toolchain.cmake x86_64_toolchain.cmake
COPY win32_cross_compile/i686_toolchain.cmake i686_toolchain.cmake
COPY win32_cross_compile/aarch64_toolchain.cmake aarch64_toolchain.cmake
COPY win32_cross_compile/make_minimal_fluidsynth.sh make_minimal_fluidsynth.sh
RUN /build/make_minimal_fluidsynth.sh

FROM wgetter AS get_llvm_mingw
COPY win32_cross_compile/download_llvm_mingw.sh download_llvm_mingw.sh
ARG LLVM_MINGW_VER=20220209
RUN LLVM_MINGW_VER=$LLVM_MINGW_VER ./download_llvm_mingw.sh download_llvm_mingw.sh

FROM ubuntu:$UBUNTU_VER AS gitter
RUN apt-get update -qq && \
apt-get install -qqy --no-install-recommends \
git ca-certificates && \
apt-get clean -y && \
rm -rf /var/lib/apt/lists/*

FROM gitter AS get_juce
COPY win32_cross_compile/clone_juce.sh clone_juce.sh
RUN /build/clone_juce.sh
RUN ./clone_juce.sh

FROM gitter AS get_fluidsynth
COPY win32_cross_compile/clone_fluidsynth.sh clone_fluidsynth.sh
RUN ./clone_fluidsynth.sh

FROM ubuntu:$UBUNTU_VER AS toolchain
RUN apt-get update -qq && \
apt-get install -qqy --no-install-recommends \
xz-utils cmake build-essential pkg-config && \
apt-get clean -y && \
rm -rf /var/lib/apt/lists/*
COPY --from=get_llvm_mingw llvm-mingw.tar.xz llvm-mingw.tar.xz
# here's how to merge it into existing /bin, but that could have unintended clashes
# RUN tar -xvf llvm-mingw.tar.xz --strip-components=1 -k && rm llvm-mingw.tar.xz
RUN mkdir -p /opt/llvm-mingw && tar -xvf llvm-mingw.tar.xz --strip-components=1 -C /opt/llvm-mingw && rm llvm-mingw.tar.xz
ENV PATH="/opt/llvm-mingw/bin:$PATH"
COPY win32_cross_compile/x86_64_toolchain.cmake /x86_64_toolchain.cmake
COPY win32_cross_compile/i686_toolchain.cmake /i686_toolchain.cmake
COPY win32_cross_compile/aarch64_toolchain.cmake /aarch64_toolchain.cmake

FROM ubuntu:$UBUNTU_VER AS make_juce
RUN apt-get update -qq && \
apt-get install -qqy --no-install-recommends \
cmake build-essential pkg-config libx11-dev libxrandr-dev libxinerama-dev libxcursor-dev libfreetype6-dev && \
apt-get clean -y && \
rm -rf /var/lib/apt/lists/*
COPY --from=get_juce JUCE JUCE
COPY win32_cross_compile/make_juce.sh make_juce.sh
RUN /build/make_juce.sh
RUN ./make_juce.sh

FROM wgetter AS msys2_deps
RUN apt-get update -qq && \
apt-get install -qqy --no-install-recommends \
zstd && \
apt-get clean -y && \
rm -rf /var/lib/apt/lists/*
COPY win32_cross_compile/get_fluidsynth_deps.sh get_fluidsynth_deps.sh
RUN ./get_fluidsynth_deps.sh

FROM toolchain AS make_fluidsynth_x86
COPY --from=msys2_deps clang32 clang32
COPY --from=get_fluidsynth fluidsynth fluidsynth
COPY win32_cross_compile/configure_fluidsynth.sh configure_fluidsynth.sh
RUN ./configure_fluidsynth.sh x86
COPY win32_cross_compile/build_fluidsynth.sh build_fluidsynth.sh
RUN ./build_fluidsynth.sh x86

FROM toolchain AS make_fluidsynth_x64
COPY --from=msys2_deps clang64 clang64
COPY --from=get_fluidsynth fluidsynth fluidsynth
COPY win32_cross_compile/configure_fluidsynth.sh configure_fluidsynth.sh
RUN ./configure_fluidsynth.sh x64
COPY win32_cross_compile/build_fluidsynth.sh build_fluidsynth.sh
RUN ./build_fluidsynth.sh x64

FROM toolchain AS juicysfplugin_common
RUN apt-get update -qq && \
apt-get install -qqy --no-install-recommends \
libfreetype6-dev && \
apt-get clean -y && \
rm -rf /var/lib/apt/lists/*
COPY --from=make_juce /linux_native/ /linux_native/
COPY --from=msys2_deps /clang32/ /clang32/
COPY --from=msys2_deps /clang64/ /clang64/
COPY --from=make_fluidsynth_x64 /clang64/include/fluidsynth.h /clang64/include/fluidsynth.h
COPY --from=make_fluidsynth_x64 /clang64/include/fluidsynth/ /clang64/include/fluidsynth/
COPY --from=make_fluidsynth_x64 /clang64/lib/pkgconfig/fluidsynth.pc /clang64/lib/pkgconfig/fluidsynth.pc
COPY --from=make_fluidsynth_x64 /clang64/lib/libfluidsynth.a /clang64/lib/libfluidsynth.a
COPY --from=make_fluidsynth_x86 /clang32/include/fluidsynth.h /clang32/include/fluidsynth.h
COPY --from=make_fluidsynth_x86 /clang32/include/fluidsynth/ /clang32/include/fluidsynth/
COPY --from=make_fluidsynth_x86 /clang32/lib/pkgconfig/fluidsynth.pc /clang32/lib/pkgconfig/fluidsynth.pc
COPY --from=make_fluidsynth_x86 /clang32/lib/libfluidsynth.a /clang32/lib/libfluidsynth.a
COPY win32_cross_compile/fix_mingw_headers.sh fix_mingw_headers.sh
RUN ./fix_mingw_headers.sh
COPY win32_cross_compile/attrib_noop.sh /usr/local/bin/attrib
WORKDIR juicysfplugin
COPY VST2_SDK/ /VST2_SDK/
COPY resources/Logo512.png resources/Logo512.png
Expand All @@ -31,7 +107,19 @@ COPY Source/ Source/
COPY JuceLibraryCode/JuceHeader.h JuceLibraryCode/JuceHeader.h
COPY CMakeLists.txt CMakeLists.txt
COPY win32_cross_compile/configure_juicysfplugin.sh configure_juicysfplugin.sh
RUN /build/juicysfplugin/configure_juicysfplugin.sh
COPY win32_cross_compile/attrib.sh /usr/local/bin/attrib

FROM juicysfplugin_common AS juicysfplugin_x86
RUN /juicysfplugin/configure_juicysfplugin.sh x86
COPY win32_cross_compile/make_juicysfplugin.sh make_juicysfplugin.sh
RUN /juicysfplugin/make_juicysfplugin.sh x86

FROM juicysfplugin_common AS juicysfplugin_x64
RUN /juicysfplugin/configure_juicysfplugin.sh x64
COPY win32_cross_compile/make_juicysfplugin.sh make_juicysfplugin.sh
RUN /build/juicysfplugin/make_juicysfplugin.sh
RUN /juicysfplugin/make_juicysfplugin.sh x64

FROM ubuntu:$UBUNTU_VER AS distribute
# x86 build fails in JUCE 6.1.5; problem compiling UUIDGetter
# https://gist.github.com/Birch-san/a36b10155e51bd814ecc7109501e1e64
# COPY --from=juicysfplugin_x86 /juicysfplugin/build_x86/JuicySFPlugin_artefacts/ /x86/
COPY --from=juicysfplugin_x64 /juicysfplugin/build_x64/JuicySFPlugin_artefacts/ /x64/
2 changes: 0 additions & 2 deletions win32_cross_compile/attrib.sh

This file was deleted.

9 changes: 9 additions & 0 deletions win32_cross_compile/attrib_noop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash
# attrib is a win32 executable used for modifying file attributes.
# the JUCE build uses it to apply a folder icon to the VST3 folder.
# we can run attrib.exe in Wine, but for aarch64 Ubuntu that entails
# building Wine from source.
# alternatively we could use the Unix utility fattr.
# but we would need to do this on a FAT or NTFS filesystem.
# this is quite high-effort just for the sake of putting an icon on a folder.
>&2 echo "Skipping execution of attrib, with args $@"
33 changes: 33 additions & 0 deletions win32_cross_compile/build_fluidsynth.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash
set -eo pipefail
shopt -s nullglob

cd fluidsynth

if test -n "$1"; then
declare -a ARCHS=("$1")
else
# declare -a ARCHS=("x64" "x86" "arm64")
declare -a ARCHS=("x64" "x86")
fi

declare -A TOOLCHAINS=( [x64]=x86_64 [x86]=i686 [arm64]=aarch64 )
declare -A REPOS=( [x64]=clang64 [x86]=clang32 [arm64]=clangarm64 )

for ARCH in ${ARCHS[@]}; do
echo "arch: $ARCH"

REPO="${REPOS[$ARCH]}"
echo "repo: $REPO"

BUILD="build_$ARCH"

cmake --build "$BUILD" --target libfluidsynth
# manual installation; not sure how to ask it to "only install libfluidsynth".
cp "$BUILD"/fluidsynth.pc "/$REPO/lib/pkgconfig/"
cp "$BUILD"/src/libfluidsynth*.a "/$REPO/lib/libfluidsynth.a"
mkdir -p /$REPO/include/fluidsynth
cp include/fluidsynth/*.h "/$REPO/include/fluidsynth/"
cp "$BUILD"/include/fluidsynth.h "/$REPO/include/fluidsynth.h"
cp "$BUILD"/include/fluidsynth/*.h "/$REPO/include/fluidsynth/"
done
2 changes: 1 addition & 1 deletion win32_cross_compile/clone_fluidsynth.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env bash
exec git clone --branch v2.2.4 --depth 1 https://github.com/FluidSynth/fluidsynth.git
exec git clone --branch v2.2.5 --depth 1 https://github.com/FluidSynth/fluidsynth.git
2 changes: 1 addition & 1 deletion win32_cross_compile/clone_juce.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env bash
exec git clone --branch 6.1.2-build-VST3-on-mingw --depth 1 https://github.com/Birch-san/JUCE.git
exec git clone --branch 6.1.5 --depth 1 https://github.com/juce-framework/JUCE.git
2 changes: 0 additions & 2 deletions win32_cross_compile/clone_juicysfplugin.sh

This file was deleted.

67 changes: 67 additions & 0 deletions win32_cross_compile/configure_fluidsynth.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/env bash
set -eo pipefail
shopt -s nullglob

cd fluidsynth

if test -n "$1"; then
declare -a ARCHS=("$1")
else
# declare -a ARCHS=("x64" "x86" "arm64")
declare -a ARCHS=("x64" "x86")
fi

declare -A TOOLCHAINS=( [x64]=x86_64 [x86]=i686 [arm64]=aarch64 )
declare -A REPOS=( [x64]=clang64 [x86]=clang32 [arm64]=clangarm64 )

for ARCH in ${ARCHS[@]}; do
echo "arch: $ARCH"

REPO="${REPOS[$ARCH]}"
echo "repo: $REPO"

TOOLCHAIN="${TOOLCHAINS[$ARCH]}"
echo "toolchain: $TOOLCHAIN"
TOOLCHAIN_FILE="/${TOOLCHAIN}_toolchain.cmake"
echo "toolchain file: $TOOLCHAIN_FILE"

BUILD="build_$ARCH"

# OpenMP doesn't support static libraries on Windows:
# https://github.com/llvm/llvm-project/blob/main/openmp/README.rst#options-for-libomp
# Yet, our priority is "statically-link everything" (in order to build a single-file binary,
# which can be installed by drag-and-drop).
PKG_CONFIG_PATH="/$REPO/lib/pkgconfig" cmake -B"$BUILD" -DCMAKE_INSTALL_PREFIX="/$REPO" \
-DBUILD_SHARED_LIBS=off \
-Denable-portaudio=off \
-Denable-dbus=off \
-Denable-aufile=off \
-Denable-ipv6=off \
-Denable-jack=off \
-Denable-ladspa=off \
-Denable-libinstpatch=off \
-Denable-libsndfile=on \
-Denable-midishare=off \
-Denable-opensles=off \
-Denable-oboe=off \
-Denable-network=off \
-Denable-oss=off \
-Denable-dsound=off \
-Denable-wasapi=off \
-Denable-waveout=off \
-Denable-winmidi=off \
-Denable-sdl2=off \
-Denable-pkgconfig=on \
-Denable-pulseaudio=off \
-Denable-readline=off \
-Denable-threads=on \
-Denable-openmp=off \
-Denable-coreaudio=off \
-Denable-coremidi=off \
-Denable-framework=off \
-Denable-lash=off \
-Denable-alsa=off \
-Denable-systemd=off \
-DCMAKE_TOOLCHAIN_FILE="$TOOLCHAIN_FILE" \
-DCMAKE_BUILD_TYPE=Release
done
Loading

0 comments on commit 9329281

Please sign in to comment.