Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing qt4 capability from faust2{faustvst,jaqt,lv2} #349

Open
wants to merge 14 commits into
base: master-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 62 additions & 60 deletions tools/faust2appls/faust2faustvst
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#! /bin/bash
#!/usr/bin/env bash

#set -x

. faustpath
. faustoptflags

set -eou > /dev/null

# Check for some common locations of the VST SDK files. This falls back to
# /usr/local/src/vstsdk if none of these are found. In that case, or if make
# picks the wrong location, you can also set the SDK variable explicitly.
Expand All @@ -15,21 +16,20 @@
# the preferred path comes *last*.
sdkpaths="/usr/src/VST* /usr/src/vst* /usr/include/VST* /usr/include/vst* /opt/local/src/VST* /opt/local/src/vst* /opt/local/include/VST* /opt/local/include/vst* /usr/local/src/VST* /usr/local/src/vst* /usr/local/include/VST* /usr/local/include/vst* $VSTSDK"
# This should hopefully work on *BSD, Linux and Mac OSX.
[ -z "$SDK" ] && SDK=$(echo $sdkpaths | xargs ls -f -d 2>/dev/null | tail -n 1)
[ -z "$SDK" ] && SDK=/usr/local/src/vstsdk
[ -z "${SDK:-}" ] && SDK=$(echo "$sdkpaths" | xargs ls -f -d 2>/dev/null | tail -n 1)
[ -z "${SDK:-}" ] && SDK=/usr/local/src/vstsdk

# SDKSRC should point to the SDK source files (vstplugmain.cpp et al).
# Usually these are either directly under $SDK or in the
# public.sdk/source/vst2.x subdirectory.
[ -z "$SDKSRC" -a -f "$SDK/vstplugmain.cpp" ] && SDKSRC="$SDK"
[ -z "$SDKSRC" -a -f "$SDK/public.sdk/source/vst2.x/vstplugmain.cpp" ] && SDKSRC="$SDK/public.sdk/source/vst2.x"
[ -z "$SDKSRC" ] && SDKSRC="$SDK/public.sdk/source/vst2.x"
[ -z "${SDKSRC:-}" ] && [ -f "$SDK/vstplugmain.cpp" ] && SDKSRC="$SDK"
[ -z "${SDKSRC:-}" ] && [ -f "$SDK/public.sdk/source/vst2.x/vstplugmain.cpp" ] && SDKSRC="$SDK/public.sdk/source/vst2.x"
[ -z "${SDKSRC:-}" ] && SDKSRC="$SDK/public.sdk/source/vst2.x"

# Default qmake setup (for GUI compilation). This requires Qt4 or Qt5 (Qt5 is
# preferred). We try to locate the qmake executable in some common locations
# here. If this doesn't work out then you can also set the QMAKE environment
# variable explicitly, or use one of the -qt4 and -qt5 options below.
[ -z "$QMAKE" ] && QMAKE=$(which qmake-qt5 || which /opt/local/libexec/qt5/bin/qmake || which qmake-qt4 || which /opt/local/libexec/qt4/bin/qmake || echo qmake)
# Default qmake setup (for GUI compilation). This requires Qt5. If qmake-qt5 or
# qmake can not be found in PATH, you can set the QMAKE environment variable
# explicitly, or use the -qt5 option below.
[ -z "${QMAKE:-}" ] && QMAKE=$(command -v qmake-qt5 || command -v qmake)

# Where the Faust includes live. We assume that this is under the prefix of
# whatever Faust binary 'which' locates. You can also specify this explicitly
Expand Down Expand Up @@ -60,14 +60,17 @@ NVOICES=-1
KEEP="no"
STYLE=""

PROCARCH="-fPIC"
FILES=()
OPTIONS=()

PROCARCH=("-fPIC")
dllext=".so"
CXXFLAGS="-O3 -std=c++11 -march=native -mfpmath=sse -msse -msse2 -msse3 -ffast-math -ftree-vectorize"
CXXFLAGS=("-O3" "-std=c++11" "-march=native" "-mfpmath=sse" "-msse" "-msse2" "-msse3" "-ffast-math" "-ftree-vectorize")

# Darwin-specific
#ARCH="-arch i386 -arch x86_64"
if [[ $(uname) == Darwin || $CROSSTARGET == Darwin ]]; then
CXXFLAGS="-O3 -std=c++11 $ARCH -mfpmath=sse -msse -msse2 -msse3 -ffast-math -ftree-vectorize -I/opt/local/include"
if [[ $(uname) == Darwin || ${CROSSTARGET:-} == Darwin ]]; then
CXXFLAGS=("-O3" "-std=c++11" "$ARCH" "-mfpmath=sse" "-msse" "-msse2" "-msse3" "-ffast-math" "-ftree-vectorize" "-I/opt/local/include")
dllext=".vst"
fi

Expand All @@ -88,7 +91,7 @@ Options:
-novoicectrls: no extra polyphony/tuning controls on GUI (instruments only)
-nvoices N: number of synth voices (instruments only; arg must be an integer)
-osc: activate OSC control
-qt4, -qt5: select the GUI toolkit (requires Qt4/5; implies -gui)
-qt5: select the GUI toolkit (requires Qt5; implies -gui)
-style S: select the stylesheet (arg must be Default, Blue, Grey or Salmon)

Environment variables:
Expand All @@ -108,7 +111,7 @@ EOF
: ignore
elif [ $p = "-icc" ]; then
CXX=icpc
CXXFLAGS="-O3 -std=c++11 -xHost -ftz -fno-alias -fp-model fast=2"
CXXFLAGS=("-O3" "-std=c++11" "-xHost" "-ftz" "-fno-alias" "-fp-model" "fast=2")
elif [ $p = "-osc" ]; then
OSCDEFS="DEFINES += OSCCTRL"
OSCLIBS="-lOSCFaust"
Expand All @@ -128,39 +131,34 @@ EOF
elif [ $p = "-gui" ]; then
FAUST_UI=1
plugin_gui=yes
elif [ $p = "-qt4" ]; then
FAUST_UI=1
plugin_gui=yes
QMAKE=$(which qmake-qt4 || which /opt/local/libexec/qt4/bin/qmake || echo qmake-qt4)
elif [ $p = "-qt5" ]; then
FAUST_UI=1
plugin_gui=yes
QMAKE=$(which qmake-qt5 || which /opt/local/libexec/qt5/bin/qmake || echo qmake-qt5)
QMAKE=$(command -v qmake-qt5 || command -v qmake)
elif [ $p = "-nvoices" ]; then
(( i++ ))
NVOICES=${!i}
elif [ $p = "-arch32" ]; then
PROCARCH="-m32 -L/usr/lib32"
PROCARCH=("-m32" "-L/usr/lib32")
elif [ $p = "-arch64" ]; then
PROCARCH="-m64 -fPIC"
PROCARCH=("-m64" "-fPIC")
elif [ $p = "-osx" ]; then
CXXFLAGS="-O3 -std=c++11 $ARCH -mfpmath=sse -msse -msse2 -msse3 -ffast-math -ftree-vectorize -I/opt/local/include"
CXXFLAGS=("-O3" "-std=c++11" "$ARCH" "-mfpmath=sse" "-msse" "-msse2" "-msse3" "-ffast-math" "-ftree-vectorize" "-I/opt/local/include")
dllext=".vst"
elif [ $p = "-keep" ]; then
KEEP="yes"
elif [ $p = "-style" ]; then
(( i++ ))
STYLE=${!i}
elif [ ${p:0:1} = "-" ]; then
OPTIONS="$OPTIONS $p"
OPTIONS+=("$p")
elif [[ -f "$p" ]]; then
FILES="$FILES $p"
FILES+=("$p")
else
OPTIONS="$OPTIONS $p"
OPTIONS+=("$p")
fi
done

FILES=( $FILES )
if [ ${#FILES[@]} = 0 ]; then
echo "$0: no filename specified" >&2
exit 1
Expand All @@ -171,27 +169,19 @@ fi

# Check to see whether the required include and library files are where we
# expect them, and bail out with an error message otherwise.
if [ ! -f "$FAUSTINC/faust/gui/QTUI.h" ]; then echo "$0: faust include files not found" >&2; exit 1; fi
if [ ! -f "$FAUSTARCH/faustvstqt.h" ]; then echo "$0: faust-vst library files not found" >&2; exit 1; fi

# Determine the Qt version so that we can pick the needed compilation options.
QTVERSION=$($QMAKE -v 2>/dev/null | tail -1 | sed 's/.*Qt version \([0-9]\).*/\1/')

QTEXTRA=
if [ $QTVERSION = 5 ]; then
QTEXTRA=x11extras
fi
if [ ! -f "${FAUSTINC:-}/faust/gui/QTUI.h" ]; then echo "$0: faust include files not found" >&2; exit 1; fi
if [ ! -f "${FAUSTARCH:-}/faustvstqt.h" ]; then echo "$0: faust-vst library files not found" >&2; exit 1; fi

arch=faustvst.cpp
dspname=${FILES[0]}
SRCDIR=$(dirname "$dspname")
ABSDIR=$(cd $SRCDIR && pwd)
ABSDIR=$(cd "$SRCDIR" && pwd)
CURDIR=$(pwd)

clsname=`basename "$dspname" .dsp`
clsname=$(basename "$dspname" .dsp)
cppname="$clsname.cpp"
soname="$clsname$dllext"
tmpdir=`mktemp -d /tmp/faust2faustvst.XXXXXX`
tmpdir=$(mktemp -d /tmp/faust2faustvst.XXXXXX)

RESOURCES=
STYLE_CXXFLAGS=
Expand All @@ -202,9 +192,9 @@ fi

# now set in faustoptflags
#CXX=g++
CPPFLAGS="-DFAUST_META=$FAUST_META -DFAUST_MIDICC=$FAUST_MIDICC -DFAUST_MTS=$FAUST_MTS -DFAUST_UI=$FAUST_UI -DVOICE_CTRLS=$VOICE_CTRLS -I$SDK -I$SDKSRC -D__cdecl="
CPPFLAGS=("-DFAUST_META=$FAUST_META" "-DFAUST_MIDICC=$FAUST_MIDICC" "-DFAUST_MTS=$FAUST_MTS" "-DFAUST_UI=$FAUST_UI" "-DVOICE_CTRLS=$VOICE_CTRLS" "-I$SDK" "-I$SDKSRC" "-D__cdecl=")
if [ $NVOICES -ge 0 ]; then
CPPFLAGS="$CPPFLAGS -DNVOICES=$NVOICES"
CPPFLAGS+=("-DNVOICES=$NVOICES")
fi

# Extra SDK modules needed to build a working plugin.
Expand All @@ -219,24 +209,28 @@ sdksrc="$SDKSRC/$main $SDKSRC/$afx $SDKSRC/$afxx"
#OPTIONS="$OPTIONS -cn \"$clsname\""

# Create the temp directory.
mkdir -p $tmpdir
mkdir -p "$tmpdir"
#trap "echo $0: compile error, intermediate files left in $tmpdir >&2" EXIT
# Compile the Faust module.
faust -i -a "$FAUSTARCH/$arch" $OPTIONS "$dspname" -o "$tmpdir/$cppname" || exit 1
if [ -n "$plugin_gui" ]; then
if [ "${#OPTIONS[@]}" ]; then
faust -i -a "$FAUSTARCH/$arch" "${OPTIONS[@]}" "$dspname" -o "$tmpdir/$cppname" || exit 1
else
faust -i -a "$FAUSTARCH/$arch" "$dspname" -o "$tmpdir/$cppname" || exit 1
fi
if [ -n "${plugin_gui:-}" ]; then
# We have to use qmake here.
# XXXTODO: OSX support
(
cd "$tmpdir"
$QMAKE -project -t lib -o ${clsname}.pro "CONFIG += gui plugin no_plugin_name_prefix warn_off" "QT += widgets printsupport network $QTEXTRA" "INCLUDEPATH+=$ABSDIR" "INCLUDEPATH+=$CURDIR" "INCLUDEPATH+=$FAUSTARCH" "INCLUDEPATH+=$FAUSTINC" "QMAKE_CXXFLAGS=-std=c++11 $CPPFLAGS" $STYLE_CXXFLAGS "LIBS+=$ARCHLIB $OSCLIBS $HTTPLIBS" "SOURCES+=$SDKSRC/$main $SDKSRC/$afx $SDKSRC/$afxx" "HEADERS+=$FAUSTARCH/faustvstqt.h $FAUSTINC/faust/gui/QTUI.h" $RESOURCES "$OSCDEFS" "$HTTPDEFS" "$QRDEFS"
$QMAKE *.pro
$QMAKE -project -t lib -o "${clsname}.pro" "CONFIG += gui plugin no_plugin_name_prefix warn_off" "QT += widgets printsupport network x11extras" "INCLUDEPATH+=$ABSDIR" "INCLUDEPATH+=$CURDIR" "INCLUDEPATH+=$FAUSTARCH" "INCLUDEPATH+=$FAUSTINC" "QMAKE_CXXFLAGS=-std=c++11 ${CPPFLAGS[*]}" "$STYLE_CXXFLAGS" "LIBS+=$ARCHLIB $OSCLIBS $HTTPLIBS" "SOURCES+=$SDKSRC/$main $SDKSRC/$afx $SDKSRC/$afxx" "HEADERS+=$FAUSTARCH/faustvstqt.h $FAUSTINC/faust/gui/QTUI.h" "$RESOURCES" "$OSCDEFS" "$HTTPDEFS" "$QRDEFS"
$QMAKE ./*.pro
make
) > /dev/null || exit 1
else
if [[ $(uname) == Darwin || $CROSSTARGET == Darwin ]]; then
mkdir -p $tmpdir/$soname/Contents/MacOS
printf '%s' 'BNDL????' > $tmpdir/$soname/Contents/PkgInfo
sed -e "s?@name@?$clsname?g;s?@version@?1.0.0?g" > $tmpdir/$soname/Contents/Info.plist <<EOF
if [[ $(uname) == Darwin || ${CROSSTARGET:-} == Darwin ]]; then
mkdir -p "$tmpdir/$soname/Contents/MacOS"
printf '%s' 'BNDL????' > "$tmpdir/$soname/Contents/PkgInfo"
sed -e "s?@name@?$clsname?g;s?@version@?1.0.0?g" > "$tmpdir/$soname/Contents/Info.plist" <<EOF
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
Expand All @@ -263,23 +257,31 @@ if [[ $(uname) == Darwin || $CROSSTARGET == Darwin ]]; then
</dict>
</plist>
EOF
$CXX -bundle $CXXFLAGS $FAUSTTOOLSFLAGS $PROCARCH -I"$ABSDIR" $CPPFLAGS $sdksrc "$tmpdir/$cppname" -o "$tmpdir/$soname/Contents/MacOS/$clsname" || exit 1
if [ -n "${FAUSTTOOLSFLAGS:-}" ]; then
$CXX -bundle "${CXXFLAGS[@]}" "${FAUSTTOOLSFLAGS:-}" "${PROCARCH[@]}" -I"$ABSDIR" "${CPPFLAGS[@]}" "$sdksrc" "$tmpdir/$cppname" -o "$tmpdir/$soname/Contents/MacOS/$clsname" || exit 1
else
$CXX -bundle "${CXXFLAGS[@]}" "${PROCARCH[@]}" -I"$ABSDIR" "${CPPFLAGS[@]}" "$sdksrc" "$tmpdir/$cppname" -o "$tmpdir/$soname/Contents/MacOS/$clsname" || exit 1
fi
else
$CXX -shared $CXXFLAGS $FAUSTTOOLSFLAGS $PROCARCH -I"$ABSDIR" $CPPFLAGS $sdksrc "$tmpdir/$cppname" -o "$tmpdir/$soname" || exit 1
if [ -n "${FAUSTTOOLSFLAGS:-}" ]; then
$CXX -shared "${CXXFLAGS[@]}" "${FAUSTTOOLSFLAGS:-}" "${PROCARCH[@]}" -I"$ABSDIR" "${CPPFLAGS[@]}" "$sdksrc" "$tmpdir/$cppname" -o "$tmpdir/$soname" || exit 1
else
$CXX -shared "${CXXFLAGS[@]}" "${PROCARCH[@]}" -I"$ABSDIR" "${CPPFLAGS[@]}" "$sdksrc" "$tmpdir/$cppname" -o "$tmpdir/$soname" || exit 1
fi
fi
fi
#trap - EXIT

# copy down the plugin (bundle on OS X)
rm -rf "$SRCDIR/$soname"
rm -rf "${SRCDIR:?}/$soname"
cp -r "$tmpdir/$soname" "$SRCDIR"
if [[ $KEEP == yes ]]; then
# keep the build directory
rm -rf "$SRCDIR/$clsname"
mv $tmpdir "$SRCDIR/$clsname"
rm -rf "${SRCDIR:?}/$clsname"
mv "$tmpdir" "$SRCDIR/$clsname"
else
# Clean up.
rm -rf $tmpdir
rm -rf "$tmpdir"
fi
# Print the name of the generated plugin.
echo "$SRCDIR/$soname;"
Loading