Skip to content

Commit

Permalink
Move macOS entirely to CMAKE (surge-synthesizer#1715)
Browse files Browse the repository at this point in the history
As of this commit, macOS does not use premake but instead uses CMAKE
for the builds. Will do linux and windows soon thereafter.

Addresses surge-synthesizer#1206
  • Loading branch information
baconpaul authored Apr 13, 2020
1 parent 03cd58e commit 89ca75d
Show file tree
Hide file tree
Showing 10 changed files with 585 additions and 255 deletions.
690 changes: 535 additions & 155 deletions CMakeLists.txt

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ tailored at Surge dev.

# Building Surge

*PLEASE BE AWARE WE ARE RIGHT NOW (like April 13 2020) IN THE MIDDLE OF MOVING TO CMAKE AND THESE DIRECTIONS
ARE NOT YET UPDATED. If you are on MACOS you should use build-osx.sh like normal but don't need PREMAKE.
Check https://github.com/surge-synthesizer/surge/issues/1206 for details*

To build surge, you need [Git](https://git-scm.com/downloads) and [Premake 5](https://premake.github.io/download.html#v5)
installed with the appropriate version for your system. We are migrating towards [CMake](https://cmake.org) so for
some OSes you need to install CMake also.
Expand Down
8 changes: 0 additions & 8 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,7 @@ jobs:
displayName: all - submodule init
- bash: |
pushd $AGENT_TEMPDIRECTORY
export PREMAKE_MAC=https://github.com/premake/premake-core/releases/download/v5.0.0-alpha13/premake-5.0.0-alpha13-macosx.tar.gz
curl -L $PREMAKE_MAC --output premake5.tar.gz
tar zxvf premake5.tar.gz
popd
export PATH=$AGENT_TEMPDIRECTORY:$PATH
./build-osx.sh --build --verbose
ls -alFh target
ls -alFh products
condition: variables.isMac
displayName: macOS - build all assets
Expand Down
123 changes: 38 additions & 85 deletions build-osx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ Other usages take the form of
Commands are:
--help Show this message
--premake Run premake only
--build Run the builds without cleans
--install-local Once assets are built, install them locally
Expand Down Expand Up @@ -94,16 +93,6 @@ prerequisite_check()
exit 1
fi

# TODO: Check premake is installed
if [ ! $(which premake5) ]; then
echo
echo ${RED}ERROR: You do not have premake5 on your path${NC}
echo
echo Please download and install premake from https://premake.github.io per the Surge README.md
echo
exit 1
fi

if [ ! $(which cmake) ]; then
echo
echo ${RED}ERROR: You do not have cmake on your path${NC}
Expand All @@ -124,58 +113,13 @@ prerequisite_check()
fi
}

run_premake()
{
rm -rf surge-au.xcodeproj
rm -rf surge-vst2.xcodeproj
rm -rf surge-vst3.xcodeproj

if [[ -z $SURGE_PREMAKE ]]; then
premake5 xcode4

# We need this until premake pushes my #1336 to a binary
perl scripts/macOS/whack-xcode.pl < surge-au.xcodeproj/project.pbxproj > txc
mv txc surge-au.xcodeproj/project.pbxproj

perl scripts/macOS/whack-xcode.pl < surge-vst3.xcodeproj/project.pbxproj > txc
mv txc surge-vst3.xcodeproj/project.pbxproj

if [[ -d surge-vst2.xcodeproj/ ]]; then
perl scripts/macOS/whack-xcode.pl < surge-vst2.xcodeproj/project.pbxproj > txc
mv txc surge-vst2.xcodeproj/project.pbxproj
fi
else
echo
echo ${RED}Using custom premake binary${NC}
echo $SURGE_PREMAKE
echo
$SURGE_PREMAKE xcode4
fi
touch Surge.xcworkspace/premake-stamp
}

run_premake_if()
{
if [[ premake5.lua -nt Surge.xcworkspace/premake-stamp ]]; then
run_premake
fi
}

run_clean()
{
flavor=$1
echo
echo "Cleaning build - $flavor"
xcodebuild clean -configuration Release -project surge-${flavor}.xcodeproj
}

run_clean_headless()
{
if [ -d "build/Surge.xcodeproj" ]; then
echo
echo "Cleaning build - headless"
xcodebuild clean -configuration Release -project build/Surge.xcodeproj
fi
xcodebuild clean -configuration Release -project build/Surge.xcodeproj/ -target $flavor
}

run_build()
Expand Down Expand Up @@ -210,6 +154,29 @@ run_build()
fi
}

run_cmake_build()
{
target=$1

echo Building ${target} with cmake

# Don't let TEE eat my return status
mkdir -p build
cmake -GXcode -Bbuild
xcodebuild build -configuration Release -project build/Surge.xcodeproj -target ${target}

build_suc=$?

if [[ $build_suc = 0 ]]; then
echo ${GREEN}Build of $target succeeded${NC}
else
echo
echo ${RED}** Build of $target failed**${NC}

exit 2
fi
}

run_build_headless()
{
mkdir -p build_logs
Expand Down Expand Up @@ -250,28 +217,28 @@ run_build_headless()

default_action()
{
run_premake
if [ -d "surge-vst2.xcodeproj" ]; then
run_clean "vst2"
run_build "vst2"
run_cmake_build "Surge.vst2"
fi

run_clean "vst3"
run_build "vst3"
# FIXME
# run_clean "vst3"
run_cmake_build "Surge.vst3"

run_clean "au"
run_build "au"
# FIXME
# run_clean "au"
run_cmake_build "Surge.component"
}

run_all_builds()
{
run_premake_if
if [ -d "surge-vst2.xcodeproj" ]; then
run_build "vst2"
fi

run_build "vst3"
run_build "au"
run_cmake_build "Surge.vst3"
run_cmake_build "Surge.component"
run_build_headless
}

Expand All @@ -289,8 +256,7 @@ run_install_local()

run_build_validate_au()
{
run_premake_if
run_build "au"
run_cmake_build "Surge.component"

rsync -r --delete "resources/data/" "$HOME/Library/Application Support/Surge/"
rsync -r --delete "products/Surge.component/" ~/Library/Audio/Plug-Ins/Components/Surge.component/
Expand Down Expand Up @@ -336,38 +302,28 @@ run_reaper_vst3()

run_build_install_vst2()
{
run_premake_if
run_build "vst2"
run_cmake_build "Surge.vst2"

rsync -r --delete "resources/data/" "$HOME/Library/Application Support/Surge/"
rsync -r --delete "products/Surge.vst/" ~/Library/Audio/Plug-Ins/VST/Surge.vst/
}

run_build_install_vst3()
{
run_premake_if
run_build "vst3"
run_cmake_build "Surge.vst3"

rsync -r --delete "resources/data/" "$HOME/Library/Application Support/Surge/"
rsync -r --delete "products/Surge.vst3/" ~/Library/Audio/Plug-Ins/VST3/Surge.vst3/
}

run_clean_builds()
{
if [ ! -d "Surge.xcworkspace" ]; then
if [ ! -d "build/Surge.xcodeproj" ]; then
echo "No surge workspace; no builds to clean"
return 0
else
echo "Clean build on all flavors"
xcodebuild clean -project build/Surge.xcodeproj
fi

if [ -d "surge-vst2.xcodeproj" ]; then
run_clean "vst2"
fi

run_clean "vst3"
run_clean "au"
run_clean_headless
}

run_clean_all()
Expand Down Expand Up @@ -442,9 +398,6 @@ prerequisite_check
# if you add a Key here then you need to implement it as a function and add it to the help above
# to get the PR swept. Thanks!
case $command in
--premake)
run_premake
;;
--build)
run_all_builds
;;
Expand Down
3 changes: 2 additions & 1 deletion scripts/macOS/package-au.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ FONT_SRC_LOCATION="$RES_SRC_LOCATION/fonts"
SVG_SRC_LOCATION="assets/${SURGE_USE_VECTOR_SKIN}/SVG/exported"

BUNDLE_RES_SRC_LOCATION="$RES_SRC_LOCATION/osx-resources"
EXEC_LOCATION="target/au/Release/Surge.dylib"
#EXEC_LOCATION="target/au/Release/Surge.dylib"
EXEC_LOCATION="build/Release/libsurge-au.dylib"
#EXEC_LOCATION="target/au/Debug/Surge-Debug.dylib"

# output configs
Expand Down
2 changes: 1 addition & 1 deletion scripts/macOS/package-vst.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ SVG_SRC_LOCATION="assets/${SURGE_USE_VECTOR_SKIN}/SVG/exported"
FONT_SRC_LOCATION="$RES_SRC_LOCATION/fonts"

BUNDLE_RES_SRC_LOCATION="$RES_SRC_LOCATION/osx-resources"
EXEC_LOCATION="target/vst2/Release/Surge.dylib"
EXEC_LOCATION="build/Release/libsurge-vst2.dylib"
#EXEC_LOCATION="target/vst2/Debug/Surge-Debug.dylib"

# output configs
Expand Down
3 changes: 2 additions & 1 deletion scripts/macOS/package-vst3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ FONT_SRC_LOCATION="$RES_SRC_LOCATION/fonts"
SVG_SRC_LOCATION="assets/${SURGE_USE_VECTOR_SKIN}/SVG/exported"

BUNDLE_RES_SRC_LOCATION="$RES_SRC_LOCATION/osx-resources"
EXEC_LOCATION="target/vst3/Release/Surge.dylib"
EXEC_LOCATION="build/Release/libsurge-vst3.dylib"
#EXEC_LOCATION="target/vst3/Release/Surge.dylib"
#EXEC_LOCATION="target/vst3/Debug/Surge-Debug.dylib"

# output configs
Expand Down
3 changes: 1 addition & 2 deletions src/common/SurgeSynthesizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -819,8 +819,7 @@ void SurgeSynthesizer::programChange(char channel, int value)

void SurgeSynthesizer::updateDisplay()
{
#if PLUGGUI
#else
#if ! TARGET_AUDIOUNIT
getParent()->updateDisplay();
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion src/common/gui/SurgeGUIEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ typedef VSTGUI::PluginGUIEditor EditorType;
#include "SurgeBitmaps.h"
#include "PopupEditorSpawner.h"

#include <vstcontrols.h>
#include "vstcontrols.h"
#include "SurgeSynthesizer.h"

#include "SkinSupport.h"
Expand Down
2 changes: 1 addition & 1 deletion src/common/gui/vstcontrols.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma once

#include "vstgui/vstgui.h"
#include <CCursorHidingControl.h>
#include "CCursorHidingControl.h"

0 comments on commit 89ca75d

Please sign in to comment.