Skip to content

Commit

Permalink
OSX: Bundle everything inside the .app, except examples/, README, Cha…
Browse files Browse the repository at this point in the history
…ngeLog.txt, etc.

This is the standard way to bundle an .app on OSX, and it fixes the library
references in sclang and scsynth binaries, which now links to the libraries
and frameworks bundled with the .app. Note that since sclang links to the
bundled Qt frameworks, it can not be installed system-wide. But you can install
simple wrapper-scripts into a folder in your PATH.

We also remove the hack in SC_StandAloneInfo_Darwin.cpp to detect standalones
and instead simply pass a SC_STANDALONE definition from cmake.

A MOVED_STUFF.txt file was added in case people wonder where everything has gone,
and README.txt and README_OS_X.txt was updated.
  • Loading branch information
lijon committed Jan 26, 2012
1 parent da8a3c9 commit 068875b
Show file tree
Hide file tree
Showing 11 changed files with 113 additions and 318 deletions.
26 changes: 15 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,8 @@ if(APPLE)
set(auxresourcesdir ${scappauxresourcesdir})

# Some aux files which go in the app's folder
install(FILES README.txt ChangeLog
DESTINATION ${auxresourcesdir}
)
install(FILES COPYING AUTHORS
DESTINATION ${auxresourcesdir}
install(FILES README.txt ChangeLog COPYING AUTHORS platform/mac/MOVED_STUFF.txt
DESTINATION ${scappbundlename}
)
elseif (WIN32)
set(auxresourcesdir "SuperCollider")
Expand Down Expand Up @@ -357,6 +354,18 @@ install(DIRECTORY sounds
DESTINATION ${auxresourcesdir}
)

if(APPLE AND ("${standalone}" STREQUAL ""))
set(exampledir "${scappbundlename}")
else()
set(exampledir "${auxresourcesdir}")
endif()

install(DIRECTORY examples
DESTINATION ${exampledir}
PATTERN "*~" EXCLUDE
PATTERN "*#" EXCLUDE
)

if(INSTALL_OLD_HELP)
install(DIRECTORY Help
DESTINATION ${auxresourcesdir}
Expand All @@ -369,11 +378,6 @@ if(INSTALL_HELP)
if(EXISTS "${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/HelpSource")
message(FATAL_ERROR "Symlinking will fail ! HelpSource folder already exists, please delete it first." )
endif()
install(DIRECTORY examples
DESTINATION ${auxresourcesdir}
PATTERN "*~" EXCLUDE
PATTERN "*#" EXCLUDE
)
install( CODE
"EXECUTE_PROCESS(COMMAND ln -shF ${CMAKE_CURRENT_SOURCE_DIR}/HelpSource ${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/HelpSource )" )
else()
Expand All @@ -386,7 +390,7 @@ if(INSTALL_HELP)
endif()
endif()
endif()
install(DIRECTORY examples HelpSource
install(DIRECTORY HelpSource
DESTINATION ${auxresourcesdir}
PATTERN "*~" EXCLUDE
PATTERN "*#" EXCLUDE
Expand Down
6 changes: 3 additions & 3 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The exact details of using the SuperCollider environment will depend on your pla

1) SuperCollider is really two applications: a sound synthesiser (the Server), and a programming language (the Lang) with its own developer environment. You can use both of these or one or the other. When using SC (SuperCollider) from within the developer environment SC Lang, the SC Server is used automatically for sound synthesis as long as it's turned on! This is accomplished by pressing the 'Boot' button on a Server graphic or running the code s.boot. Further details are in the help tutorials; but we're just warning you now in case you're impatient and can't understand why you're not immediately getting sounds.

2) The Main Help page in SuperCollider (Help/Help.html) gives some immediate key commands and should be enough to help you start navigating the help system. Please also check the different menu options available with the application on your system.
2) The Main Help page in SuperCollider gives some immediate key commands and should be enough to help you start navigating the help system. Please also check the different menu options available with the application on your system.

Platform specific comments:

Expand All @@ -26,13 +26,13 @@ And be careful you're not using TextEdit or a web browser instead of the SuperCo
[Windows] The windows version of SuperCollider is called PsyCollider. Key commands differ from the Mac, but almost all code should work the same. The SwingOSC Java based GUI library is used here, however, for GUIs. You must use JMouseX/JMouseY in particular; PsyCollider does not support MouseX/MouseY UGens.


[Linux] Most people use SuperCollider from emacs; there are some alternative editors available. For GUI building, the SwingOSC Java framework is a standard option. For more information on Linux specific issues, check the "platform/README LINUX" file included in the source package, and the README in the folder editors/scel for information on the emacs editor.
[Linux] Most people use SuperCollider from emacs or gedit; there are some alternative editors available. For more information on Linux specific issues, check the "README_LINUX.txt" file included in the source package, and the README in the folder editors/scel for information on the emacs editor.


Building the Source Code
========================

Platform specific build and install instructions can be found in the README_${PLATOFORM}.txt files
Platform specific build and install instructions can be found in the README_${PLATFORM}.txt files

We hope you enjoy SuperCollider; please get involved in the active community!

Expand Down
32 changes: 19 additions & 13 deletions README_OS_X.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ Then to run the build process run:

make install

This will build the software, then "install" it to a folder "build/SuperCollider"
with the finished products in. You might like to move the "build/SuperCollider"
folder into your /Applications folder.
This will build the software, then "install" it to a folder "SuperCollider" under
CMAKE_INSTALL_PREFIX, which defaults to "<build-directory>/Install",
with the finished products in. You might like to move the "SuperCollider"
folder into your /Applications folder or install it there directly by
passing "-D /Applications" to cmake.

The build process can be configured using the cmake program, cmake
frontends like "ccmake" or "cmake-gui", or by simply editing the
Expand All @@ -60,20 +62,20 @@ For example, by default cmake will create a "release" build, but if you want a

cmake -DCMAKE_BUILD_TYPE=Debug ..

By default cmake will copy SCClassLibrary to the Application directory. There is a cmake option to create
a symlink of the SCClassLibrary instead so that changes to code in the class library are reflected in git.
By default the SCClassLibrary is copied into place. There is a cmake option to create
symlinks of the SCClassLibrary instead so that changes to code in the class library are reflected in git.
To turn on the symlinking do:

cmake -DSC_SYMLINK_CLASSLIB=ON ..

For a 32bit build on a 64bit machine (i.e. recent Mac systems), you need to
configure cmake like this:

cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS:STRING=-m32 -DCMAKE_C_FLAGS:STRING=-m32 ..
cmake -DCMAKE_OSX_ARCHITECTURES='i386' ..

For the BIG universal binary (on 10.6), use:

cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES='ppc;i386;x86_64' ..
cmake -DCMAKE_OSX_ARCHITECTURES='i386;x86_64' ..


Qt GUI:
Expand All @@ -92,17 +94,17 @@ Standalones:
To create a "standalone" app using cmake, you need to use the "standalone" flag.
For example, to create a standalone whose name is MyFabApp:

cmake -D standalone:string=MyFabApp ..
cmake -D standalone="MyFabApp" ..

This builds like normal but names the finished program "MyFabApp" and puts all
resources into the app bundle, including any special resources you might have
created in the folder "platform/mac/MyFabApp Resources" (or, if that doesn't
exist, it just uses "platform/mac/Standalone Resources").
This builds like normal but names the finished program "MyFabApp" and includes
any special resources you might have created in the folder
"platform/mac/MyFabApp Resources" (or, if that doesn't exist, it just uses
"platform/mac/Standalone Resources").

If you've built a standalone and want to go back to normal build mode, just
set that value as an empty string:

cmake -D standalone:string= ..
cmake -D standalone="" ..


------------------------------------------------------------------------
Expand All @@ -122,6 +124,8 @@ universal binary. This UB contains ppc, i386 and x86_64 archs.
Building - 10.6 and 64-bit scsynth and plugins
------------------------------------------------------------------------

*** THIS IS OUTDATED, cmake on 10.6 will build 64-bit by default ***

You will need to do the following to build a 64-bit scsynth and plugins.
* Open the XCode projects for Synth AND Plugins
* Double-click each target, and change the
Expand Down Expand Up @@ -152,6 +156,8 @@ have installed the optional 10.5 SDK, installed with the Apple Developer Tools.
Building SuperCollider THE OLD WAY (no cmake - just xcode required)
------------------------------------------------------------------------

*** THIS IS OUTDATED, instructions below will not work, use cmake instead ***

Requirements:
* Mac OS X 10.4.9 or greater
* Xcode Tools 2.4.1 or greater.
Expand Down
7 changes: 1 addition & 6 deletions cmake_modules/MacAppFolder.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@ if(APPLE)
message(STATUS "Building sc in STANDALONE mode. App name: " ${standalone})
endif()

# For standalone, many things go into the bundle rather than beside it
if ("${standalone}" STREQUAL "")
set(scappauxresourcesdir "${scappbundlename}")
else()
set(scappauxresourcesdir "${scappbundlename}/${scappbundlename}.app/Contents/Resources")
endif()
set(scappauxresourcesdir "${scappbundlename}/${scappbundlename}.app/Contents/Resources")

###### Allow user to select a FHS-style install
# TODO not yet used
Expand Down
83 changes: 29 additions & 54 deletions common/SC_StandAloneInfo_Darwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,84 +3,60 @@
#include <sys/param.h>
#include <stdexcept>
#include <cstring> // for strncpy
#include <mach-o/dyld.h> // for _NSGetExecutablePath
#include <libgen.h>

#include <CoreFoundation/CFString.h>
#include <CoreFoundation/CFBundle.h>
//#include <CoreServices/CoreServices.h>

#include "SC_StandAloneInfo_Darwin.h"

bool SC_StandAloneInfo::sIsStandAlone;
bool SC_StandAloneInfo::haveCheckedBundleStatus;
char SC_StandAloneInfo::dirPath[PATH_MAX];

void SC_StandAloneInfo::SC_StandAloneInfoInit() {
char relDir[PATH_MAX];
CFStringEncoding encoding = kCFStringEncodingASCII;

if ( !haveCheckedBundleStatus )
{
if(!haveCheckedBundleStatus) {
haveCheckedBundleStatus = true;
CFStringRef stringToFind = CFSTR("SCClassLibrary");
CFURLRef enablerURL = CFBundleCopyResourceURL (
CFBundleGetMainBundle(),
stringToFind,
CFSTR("SCClassLibrary"),
NULL,
NULL
);
if ( enablerURL )
{
CFStringRef string2ToFind = CFSTR(".app/");
CFRange findResult = CFStringFind(CFURLGetString(enablerURL), string2ToFind, kCFCompareCaseInsensitive);
if(findResult.length != 0)
{
// You'd think we could get an absolute path to the Resources directory. But
// we can't, we can only get a relative path, or an absolute path to a
// specific resource. Since we don't know the application name, we get the
// latter, and then hack off the resource name.

sIsStandAlone = true;
CFStringRef rawPath = CFURLCopyFileSystemPath(enablerURL, kCFURLPOSIXPathStyle);

CFRange discardRange = CFStringFind (
CFURLCopyFileSystemPath(enablerURL, kCFURLPOSIXPathStyle),
stringToFind,
0
);

CFRange validRange;
validRange.location = 0;
validRange.length = discardRange.location - 1;

CFStringRef dirPathCFString = CFStringCreateWithSubstring (
kCFAllocatorDefault,
rawPath,
validRange
);

CFStringGetCString (
dirPathCFString,
dirPath,
PATH_MAX,
encoding
);
}else
{
if ( enablerURL ) {
// If sclang or SuperCollider binary is run within the .app bundle,
// this is how we find the Resources path.
CFStringRef rawPath = CFURLCopyFileSystemPath(enablerURL, kCFURLPOSIXPathStyle);
rawPath = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@/.."), rawPath);
CFStringGetCString(rawPath, relDir, PATH_MAX, encoding);
} else {
// when sclang is run from a symlink, the resource URL above will not be found,
// so we need to find the path of the executable.
uint32_t *bufsize;
*bufsize = PATH_MAX;
if(_NSGetExecutablePath(relDir, bufsize)==0) {
realpath(relDir, dirPath); // resolve symlink
char *dir = dirname(dirPath);
strcpy(dirPath, dir);
return;
} else {
// in case it failed, fall back to current directory
getcwd(dirPath, PATH_MAX);
}
}
else
{
getcwd(dirPath, PATH_MAX);
}
realpath(relDir, dirPath);
}
}

bool SC_StandAloneInfo::IsStandAlone() {
if ( !haveCheckedBundleStatus )
{
SC_StandAloneInfoInit();
}
return sIsStandAlone;
#ifdef SC_STANDALONE
return true;
#else
return false;
#endif
}

void SC_StandAloneInfo::GetResourceDir(char* pathBuf, int length)
Expand All @@ -90,7 +66,6 @@ void SC_StandAloneInfo::GetResourceDir(char* pathBuf, int length)
SC_StandAloneInfoInit();
}
strncpy(pathBuf, dirPath, length);

}

#endif
8 changes: 1 addition & 7 deletions external_libraries/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,7 @@ endif()


if(APPLE)
# determines the app name and app install location (scappbundlename, scappdir):
include (${CMAKE_SOURCE_DIR}/cmake_modules/MacAppFolder.cmake)

install(TARGETS supercollider_boost_thread
DESTINATION "${scappauxresourcesdir}"
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
COMPONENT app)
# on osx, install_qt4_executable copies the needed libs from the build dir into the installed .app
elseif(WIN32)
install(TARGETS supercollider_boost_thread
DESTINATION "SuperCollider"
Expand Down
19 changes: 5 additions & 14 deletions platform/mac/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ endif()
# determines the app name and app install location (scappbundlename, scappdir):
include (${CMAKE_SOURCE_DIR}/cmake_modules/MacAppFolder.cmake)

# On OSX, everything is installed in a folder named after ${scappauxresourcesdir},
# On OSX, everything is installed in a folder named after ${scappbundlename},
# which defaults to "SuperCollider". The folder is installed under ${CMAKE_INSTALL_PREFIX},
# which defaults to <build directory>/Install/
# This means the app will go in <build dir>/Install/SuperCollider/SuperCollider.app
# and class lib in <build dir>/Install/SuperCollider/SCClassLibrary, etc..
# Class lib and similar goes into .app/Contents/Resources, as well as the external sclang and scsynth binaries.
# The contents of the install prefix folder will be packaged to a DMG with "make package"

if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
Expand Down Expand Up @@ -199,20 +199,11 @@ add_definitions(-DYYSTACK_USE_ALLOCA -DHAVE_SPEECH)

# set how it shows up in the Info.plist file
SET(MACOSX_BUNDLE_ICON_FILE SCcube.icns)
# set where in the bundle to put the icns file
SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_SOURCE_DIR}/Resources/SCcube.icns
PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
# include the icns file in the target
SET(scapp_resources ${CMAKE_CURRENT_SOURCE_DIR}/Resources/SCcube.icns)

file(COPY Resources
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${scappbundlename}.app/Contents
PATTERN Info.plist EXCLUDE
)

install(DIRECTORY Resources/ DESTINATION ${scappauxresourcesdir})

add_executable(${scappbundlename} MACOSX_BUNDLE
${scapp_sources} ${scapp_parser_source}
${scapp_resources}
)

if (SCLANG_SERVER)
Expand Down Expand Up @@ -272,6 +263,7 @@ if (NOT ("${standalone}" STREQUAL ""))
endif()
message(STATUS "Including standalone resources from folder named: " ${standaloneresourcesfrom})
install(DIRECTORY ${standaloneresourcesfrom}/ DESTINATION ${scappauxresourcesdir})
add_definitions(-DSC_STANDALONE)
endif()

set(MACOSX_BUNDLE_BUNDLE_NAME "${scappbundlename}")
Expand All @@ -280,4 +272,3 @@ include(InstallRequiredSystemLibraries)

include(DeployQt4)
install_qt4_executable("${scappbundlename}/${scappbundlename}.app" "" "" "${CMAKE_BINARY_DIR}/server/scsynth;${CMAKE_BINARY_DIR}/external_libraries")

37 changes: 37 additions & 0 deletions platform/mac/MOVED_STUFF.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
SuperCollider class library, help files, sclang and scsynth
HAS BEEN MOVED into SuperCollider.app/Contents/Resources.

In previous versions of SuperCollider, these resources lived in the
top folder next to SuperCollider.app. To make a standard self-contained
app bundle with correct library linking, these have now been moved into
the app bundle.

If you need to access them from the Finder, ctrl-click SuperCollider.app
and choose "Show package contents" from the context menu.

To access them in the Terminal, simply:

$ cd path/to/SuperCollider.app/Contents/Resources

To have sclang and scsynth available system-wide, you can put wrapper-
scripts into a folder in your PATH, like /usr/local/bin
For sclang:

#!/bin/sh
cd /full/path/to/SuperCollider.app/Contents/Resources
exec ./sclang $*

And for scsynth:

#!/bin/sh
cd /full/path/to/SuperCollider.app/Contents/Resources
exec ./scsynth $*

NOTE: Why not symlinking them instead? Because:
- If you have Qt installed system-wide, sclang will complain that
Qt frameworks are loaded twice.
- scsynth will not find the included "plugins", unless given explicitly
with the -U commandline flag.

Happy supercolliding!

Loading

0 comments on commit 068875b

Please sign in to comment.