Skip to content

Instantly share code, notes, and snippets.

@adcxyz
Created April 29, 2016 19:38
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adcxyz/81c6be8cda432b222e4aea3a97406a55 to your computer and use it in GitHub Desktop.
Save adcxyz/81c6be8cda432b222e4aea3a97406a55 to your computer and use it in GitHub Desktop.
Making A Standalone with SC 3.7.0

/****

A full script for creating a standalone app based on the current setup and config of a SuperCollider.app - tested with 3.7.0.

c Alberto de Campo 2016

HOW TO USE this:

  1. have your system ready with all desired quarks installed, and a working startup file. (can be a very simple test setup)

  2. read each section, then try evaluating it at once; in case of problems, evaluate line by line, and tell me where which problems happen

  3. when you get to the wakeup kiss, share and enjoy!

  4. To adapt to your project: a. open String.scDir (Contents/Resources/), b. replace template startup.scd with your startup.scd v. and put your project files in _files/

****/

( // define the name for the new app and its location: ~newAppName = "StehAllein"; newAppLocation = "/Desktop/".standardizePath;

// some helper functions ~readText = { |path| var f = File(path, "r"); var t = f.readAllString; f.close; t; }; ~writeText = { |path, string| File(path, "w").write(string).close; }; ~copyFolder = { |orig, dest| unixCmd("cp -r" + quote(orig) + quote(dest)) };

// make some needed paths and folders ~pathToThisApp = String.scDir.dirname.dirname; ~pathToNewApp = ~newAppLocation +/+ ~newAppName ++ ".app"; ~newAppResDir = ~pathToNewApp +/+ "Contents/Resources"; ~newAppSupportDir = Platform.userConfigDir.replace("SuperCollider", ~newAppName); // name for a dir where quarks etc should be moved to: ~newAppQuarksDir = ~newAppResDir +/+ "SCClassLibrary/Z_AddedQuarks";

// a place to move StehAllein project files to: ~newAppAddendaDir = ~newAppResDir +/+ "StehAllein_files"; )

( // make a copy of this app with the new name: // can take a while on slow harddisks, wait for RESULT = 0

if (File.exists(~pathToNewApp).not) { ~copyFolder.(~pathToThisApp, ~pathToNewApp); File.exists(~pathToNewApp); } { warn("% already exists.".format(~pathToNewApp)) }; // make the app support dir File.mkdir(~newAppSupportDir); )

( // fixups in the new app - 1. fix the Info.plist file: ~infoPlistPath = ~pathToNewApp +/+ "Contents/Info.plist"; // get its string, replace the SC names, write again ~infoString = ~readText.(~infoPlistPath); ~newInfoString = ~infoString.replace("SuperCollider", ~newAppName ); ~writeText.(~infoPlistPath, ~newInfoString); ~readText.(~infoPlistPath); )

( // fixups in the new app - 2. rename the binary inside the app folder unixCmd("mv" + quote(~pathToNewApp +/+ "Contents/MacOS/SuperCollider") + quote(~pathToNewApp +/+ "Contents/MacOS/" ++ ~newAppName).postln); )

( // copy all folders in my current quarks includePaths // to Resources/SCClassLibrary to freeze them: File.mkdir(~newAppQuarksDir); if (File.exists(~newAppQuarksDir)) { "/*** copying Quarks : ***/".postln; LanguageConfig.includePaths.do { |path| unixCmd("cd" + quote(~newAppQuarksDir) ++ ";" "cp -r" + quote(path).postln + "."); }; };

// write an extension file so startupFile is in scDir for standalones. ~writeText.value(~newAppQuarksDir +/+ "extModStartupFile.sc", "+ OSXPlatform { startupFiles { ^[String.scDir +/+ "startup.scd"]; } } " ); /* ~newAppQuarksDir.openOS; */ ) // then make a well-noticeable template startup file: ( ~startupCode = "var b = Window.screenBounds.insetBy(200, 150); var w = Window('!!! YO % !!!', b).front; var u = UserView(w, b.moveTo(0,0)).front.background_(Color.red); u.drawFunc_({ Pen.stringCenteredIn( "Click Me to continue: \n replace startup file with yours,\n replace project folder with yours...", u.bounds, Font('Inconsolata', 48) ); }); u.mouseDownAction_({ String.scDir.openOS });

// // uncomment to open resources folder while building the app, // // comment out when finished: // String.scDir.openOS; ".format(~newAppName, ~newAppName);

~writeText.(~newAppResDir +/+ "startup.scd", ~startupCode); )

/// make a folder for project files: File.mkdir(~newAppAddendaDir);

// now, time for the wakeup kiss : unixCmd("open" + ~pathToNewApp);

// open Resources folder to put things there now? ~newAppAddendaDir.postcs.openOS;

// in case things went wrong, delete these and start over: /* unixCmd("rm -r" + quote(~pathToNewApp)); unixCmd("rm -r" + quote(~newAppSupportDir)); */

/******* NEXT STEPS already with your new app: ********/

// open Resources folder to put things there String.scDir.openOS;

// * put your startup file there in Resources/ // * add your project files folder to Resources/ // * adapt startup file to point to project files folder

// adapt main help file: (String.scDir +/+ "/HelpSource/Help.schelp").openOS;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment