From 9aad67ae0437a5e7c0005eb403c549dbb04a8a84 Mon Sep 17 00:00:00 2001 From: Francisco Ryan Tolmasky I Date: Mon, 2 Feb 2009 01:59:50 -0800 Subject: [PATCH] Added create-frameworks to steam, and began adding Templating system. Reviewed by me. --- .../Templates/Application/AppController.j | 39 +++++++++++ Tools/steam/Templates/Application/Info.plist | 12 ++++ .../Templates/Application/index-debug.html | 36 ++++++++++ Tools/steam/Templates/Application/index.html | 37 ++++++++++ Tools/steam/Templates/Application/main.j | 18 +++++ Tools/steam/create-frameworks.js | 64 +++++++++++++++++- Tools/steam/create.js | 67 +++++-------------- Tools/steam/steam | 3 +- 8 files changed, 222 insertions(+), 54 deletions(-) create mode 100644 Tools/steam/Templates/Application/AppController.j create mode 100644 Tools/steam/Templates/Application/Info.plist create mode 100644 Tools/steam/Templates/Application/index-debug.html create mode 100644 Tools/steam/Templates/Application/index.html create mode 100755 Tools/steam/Templates/Application/main.j diff --git a/Tools/steam/Templates/Application/AppController.j b/Tools/steam/Templates/Application/AppController.j new file mode 100644 index 000000000..21ede646e --- /dev/null +++ b/Tools/steam/Templates/Application/AppController.j @@ -0,0 +1,39 @@ +/* + * AppController.j + * __Product__ + * + * Created by __Me__ on __Date__. + * Copyright 2008 __MyCompanyName__. All rights reserved. + */ + +@import + + +@implementation AppController : CPObject +{ +} + +- (void)applicationDidFinishLaunching:(CPNotification)aNotification +{ + var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask], + contentView = [theWindow contentView]; + + var label = [[CPTextField alloc] initWithFrame:CGRectMakeZero()]; + + [label setStringValue:@"Hello World!"]; + [label setFont:[CPFont boldSystemFontOfSize:24.0]]; + + [label sizeToFit]; + + [label setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin | CPViewMinYMargin | CPViewMaxYMargin]; + [label setFrameOrigin:CGPointMake((CGRectGetWidth([contentView bounds]) - CGRectGetWidth([label frame])) / 2.0, (CGRectGetHeight([contentView bounds]) - CGRectGetHeight([label frame])) / 2.0)]; + + [contentView addSubview:label]; + + [theWindow orderFront:self]; + + // Uncomment the following line to turn on the standard menu bar. + //[CPMenu setMenuBarVisible:YES]; +} + +@end diff --git a/Tools/steam/Templates/Application/Info.plist b/Tools/steam/Templates/Application/Info.plist new file mode 100644 index 000000000..a81852dcd --- /dev/null +++ b/Tools/steam/Templates/Application/Info.plist @@ -0,0 +1,12 @@ + + + + + CPApplicationDelegateClass + AppController + CPBundleName + __Product__ + CPPrincipalClass + CPApplication + + diff --git a/Tools/steam/Templates/Application/index-debug.html b/Tools/steam/Templates/Application/index-debug.html new file mode 100644 index 000000000..d941b006a --- /dev/null +++ b/Tools/steam/Templates/Application/index-debug.html @@ -0,0 +1,36 @@ + + + + + + + Hello World + + + + + + + + +
+
+ +
+
+ + + diff --git a/Tools/steam/Templates/Application/index.html b/Tools/steam/Templates/Application/index.html new file mode 100644 index 000000000..bea6f5f36 --- /dev/null +++ b/Tools/steam/Templates/Application/index.html @@ -0,0 +1,37 @@ + + + + + + + Hello World + + + + + + + + + +
+
+ +
+
+ + + + diff --git a/Tools/steam/Templates/Application/main.j b/Tools/steam/Templates/Application/main.j new file mode 100755 index 000000000..d4cec69f3 --- /dev/null +++ b/Tools/steam/Templates/Application/main.j @@ -0,0 +1,18 @@ +/* + * main.j + * __Product__ + * + * Created by __Me__ on __Date__. + * Copyright 2008 __MyCompanyName__. All rights reserved. + */ + +@import +@import + +@import "AppController.j" + + +function main(args, namedArgs) +{ + CPApplicationMain(args, namedArgs); +} diff --git a/Tools/steam/create-frameworks.js b/Tools/steam/create-frameworks.js index 3d91f1b04..89b355ea9 100644 --- a/Tools/steam/create-frameworks.js +++ b/Tools/steam/create-frameworks.js @@ -1,4 +1,66 @@ function createFrameworks() { - return create(Array.concat.apply(arguments, ["-f"])); + var shouldSymbolicallyLink = false, + index = 0, + count = arguments.length, + + destination = ""; + + for (; index < count; ++index) + { + var argument = arguments[index]; + + switch (arguments[index]) + { + case "-l": shouldSymbolicallyLink = true; + break; + + default: destination = argument; + } + } + + createFrameworksInFile(new File(destination), shouldSymbolicallyLink); +} + +function createFrameworksInFile(/*File*/ aFile, /*Boolean*/ shouldSymbolicallyLink) +{ + var destinationFrameworks = new File(aFile.getCanonicalPath()+ "/Frameworks"), + destinationDebugFrameworks = new File(aFile.getCanonicalPath() + "/Frameworks/Debug"); + + if (!shouldSymbolicallyLink) + { + var sourceFrameworks = new File(OBJJ_HOME + "/lib/Frameworks"), + sourceDebugFrameworks = new File(OBJJ_HOME + "/lib/Frameworks-Debug"); + + exec(["cp", "-vR", sourceFrameworks.getCanonicalPath(), destinationFrameworks.getCanonicalPath()], true); + exec(["cp", "-vR", sourceDebugFrameworks.getCanonicalPath(), destinationDebugFrameworks.getCanonicalPath()], true); + + return true; + } + + var STEAM_BUILD = System.getenv("STEAM_BUILD"); + + // Release Frameworks + new File(destinationFrameworks).mkdir(); + + exec(["ln", "-s", new File(STEAM_BUILD + "/Release/Objective-J").getCanonicalPath(), + new File(aFile.getCanonicalPath() + "/Frameworks/Objective-J").getCanonicalPath()], true); + + exec(["ln", "-s", new File(STEAM_BUILD + "/Release/Foundation").getCanonicalPath(), + new File(aFile.getCanonicalPath() + "/Frameworks/Foundation").getCanonicalPath()], true); + + exec(["ln", "-s", new File(STEAM_BUILD + "/Release/AppKit").getCanonicalPath(), + new File(aFile.getCanonicalPath() + "/Frameworks/AppKit").getCanonicalPath()], true); + + // Debug Frameworks + new File(destinationDebugFrameworks).mkdir(); + + exec(["ln", "-s", new File(STEAM_BUILD + "/Debug/Objective-J").getCanonicalPath(), + new File(aFile.getCanonicalPath() + "/Frameworks/Debug/Objective-J").getCanonicalPath()], true); + + exec(["ln", "-s", new File(STEAM_BUILD + "/Debug/Foundation").getCanonicalPath(), + new File(aFile.getCanonicalPath() + "/Frameworks/Debug/Foundation").getCanonicalPath()], true); + + exec(["ln", "-s", new File(STEAM_BUILD + "/Debug/AppKit").getCanonicalPath(), + new File(aFile.getCanonicalPath() + "/Frameworks/Debug/AppKit").getCanonicalPath()], true); } \ No newline at end of file diff --git a/Tools/steam/create.js b/Tools/steam/create.js index d95fc069a..3b8d653c3 100644 --- a/Tools/steam/create.js +++ b/Tools/steam/create.js @@ -3,12 +3,12 @@ function create() if (arguments.length < 1) printUsage("create"); - var link = false, + var shouldSymbolicallyLink = false, index = 0, count = arguments.length, - destination = NULL, - justFrameworks = false; + template = "Application", + destination = ""; for (; index < count; ++index) { @@ -16,61 +16,24 @@ function create() switch (arguments[index]) { - case "-l": link = true; - break; - case "-f": justFrameworks = true; - break; - default: destination = argument; + case "-l": shouldSymbolicallyLink = true; + break; + + case "--template": template = arguments[++index]; + break; + + default: destination = argument; } } - var sourceNewApplication = new File(OBJJ_HOME + "/lib/NewApplication"), - destinationNewApplication = new File(destination), - sourceFrameworks = new File(OBJJ_HOME + "/lib/Frameworks"), - sourceDebugFrameworks = new File(OBJJ_HOME + "/lib/Frameworks-Debug"), - destinationFrameworks = new File(destination + "/Frameworks"), - destinationDebugFrameworks = new File(destination + "/Frameworks/Debug"); + var sourceTemplate = new File(OBJJ_HOME + "/lib/steam/Templates/" + template), + destinationProject = new File(destination); - System.out.println(sourceNewApplication.getCanonicalPath() + "," + destinationNewApplication.getCanonicalPath() + "," + sourceFrameworks.getCanonicalPath() + "," + destinationFrameworks.getCanonicalPath()); - - if (justFrameworks || !destinationNewApplication.exists()) + if (!destinationProject.exists()) { - if (!justFrameworks) - exec(["cp", "-vR", sourceNewApplication.getCanonicalPath(), destinationNewApplication.getCanonicalPath()], true); + exec(["cp", "-vR", sourceTemplate.getCanonicalPath(), destinationProject.getCanonicalPath()], true); - if (!link) - { - exec(["cp", "-vR", sourceFrameworks.getCanonicalPath(), destinationFrameworks.getCanonicalPath()], true); - exec(["cp", "-vR", sourceDebugFrameworks.getCanonicalPath(), destinationDebugFrameworks.getCanonicalPath()], true); - } - else - { - var STEAM_BUILD = System.getenv("STEAM_BUILD"); - - // Release Frameworks - new File(destinationFrameworks).mkdir(); - - exec(["ln", "-s", new File(STEAM_BUILD + "/Release/Objective-J").getCanonicalPath(), - new File(destination + "/Frameworks/Objective-J").getCanonicalPath()], true); - - exec(["ln", "-s", new File(STEAM_BUILD + "/Release/Foundation").getCanonicalPath(), - new File(destination + "/Frameworks/Foundation").getCanonicalPath()], true); - - exec(["ln", "-s", new File(STEAM_BUILD + "/Release/AppKit").getCanonicalPath(), - new File(destination + "/Frameworks/AppKit").getCanonicalPath()], true); - - // Debug Frameworks - new File(destinationDebugFrameworks).mkdir(); - - exec(["ln", "-s", new File(STEAM_BUILD + "/Debug/Objective-J").getCanonicalPath(), - new File(destination + "/Frameworks/Debug/Objective-J").getCanonicalPath()], true); - - exec(["ln", "-s", new File(STEAM_BUILD + "/Debug/Foundation").getCanonicalPath(), - new File(destination + "/Frameworks/Debug/Foundation").getCanonicalPath()], true); - - exec(["ln", "-s", new File(STEAM_BUILD + "/Debug/AppKit").getCanonicalPath(), - new File(destination + "/Frameworks/Debug/AppKit").getCanonicalPath()], true); - } + createFrameworksInFile(destinationProject, shouldSymbolicallyLink); } else System.out.println("Directory already exists"); diff --git a/Tools/steam/steam b/Tools/steam/steam index d5f64ee3a..e66147478 100644 --- a/Tools/steam/steam +++ b/Tools/steam/steam @@ -24,7 +24,8 @@ if [ -z $OBJJ_HOME ]; then fi OBJJ_LIB="$OBJJ_HOME/lib" -CLASSPATH="$OBJJ_LIB:$OBJJ_LIB/js.jar" +STEAM="$OBJJ_LIB/steam" +CLASSPATH="$STEAM:$OBJJ_LIB:$OBJJ_LIB/js.jar" # convert paths for Cygwin if [[ `uname` == CYGWIN* ]]; then