From 5934590ecbaade854a2dac830528e64f0c060830 Mon Sep 17 00:00:00 2001 From: Paul Walker Date: Sat, 12 Jan 2019 19:51:56 -0500 Subject: [PATCH] More mac build and installer These diffs fix the fact that resources didn't overwrite bu 1. Not doing the analyze to get update correct 2. Fixing the postinstall script to rsync --delete Additionally it adds packaging options to build-osx to make these features easier to use. Finally the README was a little long in the tooth now that we have mac more streamlined, so update it. Former-commit-id: 3891c2eb3e9e6b969e668fa7e959b04e2a318c69 [formerly 91d3623bf77337860da4c43d6dd1ca7dd9384afc] Former-commit-id: c97fda9404ec8f57c540f49b9c2b179dbe8d0304 Former-commit-id: 89834ee523ff489c45426ee3e8bef71130fd7629 --- README.md | 118 ++++++++---------- build-osx.sh | 31 +++++ .../ResourcesPackageScript/postinstall | 2 +- installer_mac/make_installer.sh | 4 +- 4 files changed, 85 insertions(+), 70 deletions(-) diff --git a/README.md b/README.md index 443e9f65ed8..ff50646f28f 100644 --- a/README.md +++ b/README.md @@ -64,119 +64,105 @@ Then proceed as above. # macOS -## Building a Surge.component (Audio Unit) with macOS +## Build Pre-requisites This process expects that you have both `Xcode` and `Xcode Command Line Utilities` installed. -Install `premake5` by downloading it from https://premake.github.io. Unzip the package. - -Launch the Terminal in the folder where `premake5` has been unzipped into and copy it to `/usr/local/bin`. +Install `premake5` by downloading it from https://premake.github.io. Unzip the package. Install it +in /usr/local/bin or elsewhere in your path. ``` cp premake5 /usr/local/bin ``` - -Clone the Surge repo to a path of your choice. -``` -git clone https://github.com/kurasu/surge.git -``` - -Enter the Surge folder and use the following command to grab all the submodules referenced by Surge. +Clone the Surge repo to a path of your choice, and init submodules ``` +git clone https://github.com/kurasu/surge.git +cd surge git submodule update --init --recursive ``` -Execute the Surge build script. -``` -./build-osx.sh -``` - -If you see any issues with `Xcode-Select`, or you get told that you are missing the `Command Line Utilities`, grab them. The error itself should list the commands required. - -After the build runs, be it successful or not, you can now launch Xcode and open the `Surge` folder. Let Xcode do it's own indexing / processing, which will take a while. -All of the three projects (`surge-vst3`, `surge-vst2`, `surge-au`) will recommend you to `Validate Project Settings`, meaning, more precisely, to `Update to recommended settings`. By clicking on `Update to recommended settings`, a dialog will open and you'll be prompted to `Perform Changes`. Perform the changes. - -At this point you can build an Audio Unit, and it will link and pass validation. +## Building with build-osx.sh -To try the Audio Unit you will need to install and validate it. If you don't know how to disable and revalidate audio units, be -a bit cautious here. You can slightly mess things up. To make it easy there's a build-osx option which will do it for you. +`build-osx.sh` has all the commands you need to build, test, locally install, validate, and package Surge on mac. +It's what the primary mac developers use day to day. The simplest approach is to build everything ``` -./build-osx.sh --build-validate-au -``` - -This will update the build date, run a build, and if the build works, remove the version of surge in `/Library/Audio/Plug-ins`, replacing it with the latest AudioUnit. -After that, the script will run `auvaltool` to make sure that the Audio Unit is properly installed. -You should be able to see the build date and time on `stderr` in the `auval` output. - -Tips on how to develop and debug using this are in [this issue](https://github.com/kurasu/surge/issues/58). - -You have successfully built and installed the AU if you see: - -``` --------------------------------------------------- -AU VALIDATION SUCCEEDED. --------------------------------------------------- +./build-osx.sh ``` -To use the AU in Logic, Mainstage, GarageBand, and so on, you need to do one more one-time step which is to invalidate your AU cache so that you force Logic to rescan. The easiest way to do this is to move the AudioUnitCache away from it's location by typing in: +this command will build, but not install, the VST3 and AU components. It has a variety of options which +are documented in the `./build-osx.sh --help` screen but a few key ones are: -``` -mv ~/Library/Caches/AudioUnitCache ~/Desktop -``` +* `./build-osx.sh --build-validate-au` will build the audio unit, correctly install it locally in `~/Library` +and run au-val on it. Running any of the installing options of `./build-osx` will install assets on your +system. If you are not comfortable removing an audio unit by hand and the like, please exercise caution. -After this, launch Logic. If everything works and starts up again, you can delete the cache from your desktop. If this doesn't succeed, you can always put it back again. +* `./build-osx.sh --build-and-install` will build all assets and install them locally -## Building a Surge.vst (VST2) with macOS +* `./build-osx.sh --clean-all` will clean your work area of all assets -If you want to build VST2 versions of the plug-in, set the environment variable VST2SDK_DIR to the location of the SDK prior to building. +* `./build-osx.sh --clean-and-package` will do a complete clean, thena complete build, then build +a mac installer package which will be deposited in products. -An example of setting the environment variable `VST2SDK_DIR` would be: +`./build-osx.sh` is also impacted by a couple of environment variables. -```export VST2SDK_DIR=~/programming/VST_SDK_2.4``` +* `VST2SDK_DIR` points to a vst2sdk. If this is set vst2 will build. If you set it after having +done a run without vst2, you will need to `./build-osx.sh --clean-all` to pick up vst2 consistently -***NOTE***: This environment variable needs to be set _before_ running `premake5 xcode4` - which generates projects / and is part of the `build-osx.sh` script. +* `BREWBUILD=TRUE` will use homebrew clang. If XCode refuses to build immediately with `error: invalid value 'c++17' in '-std=c++17'` +and you do not want to upgrade XCode to a more recent version, use [homebrew](https://brew.sh/) to install llvm and set this variable. + -## Building a Surge.vst3 (VST3) with macOS +## Using xcode -Surge VST3 builds cleanly from the xcode project and results in a `Surge.vst3` asset deposited in the `product` directory. +`premake xcode4` builds xcode assets so if you would rather just use xcode, you can open the solutions created after running premake yourself +or having `./build-osx.sh` run it. -## Building with an XCode that doesn't support C++17 +After the build runs, be it successful or not, you can now launch Xcode and open the `Surge` folder. Let Xcode do it's own indexing / processing, which will take a while. -If XCode refuses to build immediately with `error: invalid value 'c++17' in '-std=c++17'` then you can install Homebrew llvm to solve the problem. +All of the three projects (`surge-vst3`, `surge-vst2`, `surge-au`) will recommend you to `Validate Project Settings`, meaning, more precisely, to `Update to recommended settings`. By clicking on `Update to recommended settings`, a dialog will open and you'll be prompted to `Perform Changes`. Perform the changes. -Use [homebrew](https://brew.sh/) to install llvm +XCode will result in built assets in `products/` but will not install them and will not install the ancilliary assets. To do that you can either `./build-osx.sh --install-local` or +`./build-osx.sh --package` and run the resulting pkg file to install in `/Library`. -```brew install llvm``` +## Using the built assets -and set environment variable `BREWBUILD` to "true", eg: +Once you have underaken the install options above, the AU and VSTs should just work. Launch your favorite host, get it to load the plugin, and have fun! -```export BREWBUILD="true"``` +To use the AU in Logic, Mainstage, GarageBand, and so on, you need to do one more one-time step which is to invalidate your AU cache so that you force +Logic to rescan. The easiest way to do this is to move the AudioUnitCache away from it's location by typing in: -***NOTE***: This environment variable needs to be set _before_ running `premake5 xcode4` - which generates projects / and is part of the `build-osx.sh` script. +``` +mv ~/Library/Caches/AudioUnitCache ~/Desktop +``` -## Building macOS installer package +then restart Logic and rescan. If the rescan succeeds you can remove the cache from `~/Desktop`. -After successfully building one or more plugins, from the command line: +Finally, the mac devs can't recomment [hosting au](http://ju-x.com/hostingau.html) highly enough for development. Open it once, open surge, and save that +configuration to your desktop. You will quickly find that ``` -cd installer_osx -./make_installer.sh +./build-osx.sh --build-validate-au && /Applications/Hosting\ AU.app/Contents/MacOS/Hosting\ AU ~/Desktop/Surge.hosting ``` -`` can be something like `1.0.0` or `1.0.6b4`. The installer package will include whichever plugins are available, the resulting `.pkg` will be at `installer_osx/installer/Install Surge .pkg` +is a super fast way to do a build and pop up Surge with stdout and stderr attached to your terminal. + + +## Packaging an installer -If you wish to also create a `.dmg` of the installer bundle, add `--dmg` to the the `make_installer.sh` command, eg: +`./build-osx.sh --package` will create a `.pkg` file with a reasonable name. If you would like to use an alternate version number, though, the packaging script is in `installer_mac`. ``` -./make_installer.sh 1.0.7 --dmg +cd installer_mac +./make_installer.sh myPeculiarVersion +mv installer/Surge-myPeculiar-Version-Setup.pkg wherever-youwant ``` -the resulting `Install_Surge_.dmg` can be found in `installer_osx`. +is an available option. # Linux diff --git a/build-osx.sh b/build-osx.sh index e21745685db..6e0b1edbe9c 100755 --- a/build-osx.sh +++ b/build-osx.sh @@ -37,6 +37,10 @@ Commands are: --build-and-install Build and install the assets --build-validate-au Build and install the audio unit then validate it + --package Creates a .pkg file from current built state in products + --clean-and-package Cleans everything; runs all the builds; makes an installer; drops it in products + Equivalent of running --clean-all then --build then --package + --clean Clean all the builds --clean-all Clean all the builds and remove the xcode files and target directories @@ -231,6 +235,25 @@ run_uninstall_surge() sudo rm -rf ~/Library/Application\ Support/Surge } +run_package() +{ + pkgver=`cat VERSION`beta-`(date +%Y-%m-%d-%H%M)` + echo "Building with version [${pkgver}]" + cd installer_mac/ + ./make_installer.sh ${pkgver} + cd .. + + mv installer_mac/installer/*${pkgver}*.pkg products/ + + echo + echo "Package completed and in products/ directory" + echo + ls -l products/*${pkgver}*.pkg + echo + echo "Have a lovely day!" + echo +} + # This is the main section of the script command="$1" @@ -272,6 +295,14 @@ case $command in --clean-all) run_clean_all ;; + --clean-and-package) + run_clean_all + run_all_builds + run_package + ;; + --package) + run_package + ;; --uninstall-surge) run_uninstall_surge ;; diff --git a/installer_mac/ResourcesPackageScript/postinstall b/installer_mac/ResourcesPackageScript/postinstall index 6a0e087fe60..ed25d311e20 100755 --- a/installer_mac/ResourcesPackageScript/postinstall +++ b/installer_mac/ResourcesPackageScript/postinstall @@ -1,4 +1,4 @@ #!/bin/bash -cp -R "$DSTVOLUME/tmp/Surge" /Library/Application\ Support/ +rsync -r --delete "$DSTVOLUME/tmp/Surge" /Library/Application\ Support/ chown -R $USER:staff /Library/Application\ Support/Surge rm -rf "$DSTVOLUME/tmp/Surge" diff --git a/installer_mac/make_installer.sh b/installer_mac/make_installer.sh index da326fb26b7..d7b9457fa4e 100755 --- a/installer_mac/make_installer.sh +++ b/installer_mac/make_installer.sh @@ -90,9 +90,7 @@ echo "Commit: $(git rev-parse HEAD)" >> "$RSRCS/BuildInfo.txt" # build resources package -pkgbuild --analyze --root "$RSRCS" Surge_Resources.plist -pkgbuild --root "$RSRCS" --component-plist Surge_Resources.plist --identifier "com.vemberaudio.resources.pkg" --version $VERSION --scripts ResourcesPackageScript --install-location "/tmp/Surge" Surge_Resources.pkg -rm Surge_Resources.plist +pkgbuild --root "$RSRCS" --identifier "com.vemberaudio.resources.pkg" --version $VERSION --scripts ResourcesPackageScript --install-location "/tmp/Surge" Surge_Resources.pkg # remove build info from resource folder