Improvements to the ThemeDescriptor capp template:

- New/improved jake tasks: debug, release, all, clean, clobber, test, test-release, help.
- help task shows comprehensive, formatted documentation for the available tasks.
- BlendKit is automatically symlinked into the Frameworks directory if necessary as part of the build process, so that the showcase will always work.
- User can easily change the build directory by changing one line.
- Fixed incorrect placeholders in main.j.
This commit is contained in:
Aparajita Fishman
2011-05-07 13:12:12 -04:00
parent 5c10615c9f
commit 2d96fcf87f
5 changed files with 165 additions and 23 deletions
@@ -3,28 +3,172 @@
* __project.name__
*
* Created by __user.name__ on __project.date__.
* Copyright __project.year__, __organization.name__ All rights reserved.
* Copyright __project.year__, __organization.name__. All rights reserved.
*/
//===========================================================
// DO NOT REMOVE
//===========================================================
var ENV = require("system").env,
FILE = require("file"),
task = require("jake").task,
FileList = require("jake").FileList,
OS = require("os");
//===========================================================
// USER CONFIGURABLE VARIABLES
//===========================================================
/*
The directory in which the project will be built. By default
it is built in a "Build" directory within the project directory.
To use your $CAPP_BUILD directory, change the declaration to:
var buildDir = ENV["CAPP_BUILD"];
*/
var buildDir = "Build";
//===========================================================
// AUTOMATICALLY GENERATED
//
// Do not edit! (unless you know what you are doing)
//===========================================================
var productName = "__project.nameasidentifier__"
stream = require("narwhal/term").stream,
JAKE = require("jake"),
task = JAKE.task,
CLEAN = require("jake/clean").CLEAN,
CLOBBER = require("jake/clean").CLOBBER,
FileList = JAKE.FileList,
blend = require("cappuccino/jake").blend,
configuration = ENV["CONFIG"] || ENV["CONFIGURATION"] || ENV["c"] || "Debug";
configuration = ENV["CONFIG"] || ENV["CONFIGURATION"] || ENV["c"] || "Debug",
productName = "__project.nameasidentifier__",
debugBlendKitPath = FILE.join("Frameworks", "Debug", "BlendKit"),
releaseBlendKitPath = FILE.join("Frameworks", "BlendKit"),
buildPath = FILE.canonical(FILE.join(buildDir, productName + ".build"));
blend ("__project.nameasidentifier__.blend", function(__project.nameasidentifier__Task)
blend (productName + ".blend", function(themeBlendTask)
{
__project.nameasidentifier__Task.setBuildIntermediatesPath(FILE.join("Build", "__project.nameasidentifier__.build", configuration))
__project.nameasidentifier__Task.setBuildPath(FILE.join("Build", configuration));
themeBlendTask.setBuildIntermediatesPath(FILE.join(buildPath, configuration))
themeBlendTask.setBuildPath(FILE.join(buildDir, configuration));
__project.nameasidentifier__Task.setThemeDescriptors(new FileList("ThemeDescriptors.j"));
__project.nameasidentifier__Task.setIdentifier("com.280n.__project.identifier__");
__project.nameasidentifier__Task.setResources(new FileList("Resources/*"));
themeBlendTask.setThemeDescriptors(new FileList("ThemeDescriptors.j"));
themeBlendTask.setIdentifier("__project.identifier__");
themeBlendTask.setResources(new FileList("Resources/*"));
});
task ("default", ["__project.nameasidentifier__.blend"]);
task ("debug", function()
{
ENV["CONFIGURATION"] = "Debug";
JAKE.subjake(["."], "build", ENV);
task ("build", ["default"]);
symlinkBlendKit(debugBlendKitPath);
});
task ("release", function()
{
ENV["CONFIGURATION"] = "Release";
JAKE.subjake(["."], "build", ENV);
symlinkBlendKit(releaseBlendKitPath);
});
task ("default", ["release"]);
task ("build", [productName + ".blend"]);
task ("all", ["debug", "release"]);
task ("test", ["debug"], function()
{
OS.system(["open", "index-debug.html"]);
});
task ("test-release", ["release"], function()
{
OS.system(["open", "index.html"]);
});
CLEAN.include(buildPath);
CLOBBER.include(buildDir);
task ("help", function()
{
var app = JAKE.application().name();
colorPrint("--------------------------------------------------------------------------", "bold+green");
colorPrint("__project.name__ - Theme Blend", "bold+green");
colorPrint("--------------------------------------------------------------------------", "bold+green");
describeTask(app, "debug", "Builds a debug version at " + FILE.join(buildDir, "Debug"));
describeTask(app, "release", "Builds a release version at " + FILE.join(buildDir, "Release"));
describeTask(app, "all", "Builds a debug and release version");
describeTask(app, "test", "Builds a debug version, symlinks to the installed BlendKit framework,\nand opens the theme showcase in the default browser");
describeTask(app, "test-release", "Builds a release version, symlinks to the installed BlendKit framework,\nand opens the theme showcase in the default browser");
describeTask(app, "clean", "Removes the intermediate build files");
describeTask(app, "clobber", "Removes the intermediate build files and the built theme");
colorPrint("--------------------------------------------------------------------------", "bold+green");
});
var describeTask = function(application, task, description)
{
colorPrint("\n" + application + " " + task, "violet");
description.split("\n").forEach(function(line)
{
print(" " + line);
});
}
var symlinkBlendKit = function(destinationPath)
{
if (FILE.isDirectory(destinationPath))
return;
var blendKitPath = null,
path = FILE.join(require("system").prefix, "packages", "cappuccino", "Frameworks", "BlendKit");
if (FILE.isDirectory(path))
blendKitPath = path;
if (!blendKitPath)
{
cappBuild = ENV["CAPP_BUILD"];
if (cappBuild)
{
var buildTypes = ["Release", "Debug"];
for (var i = 0; i < buildTypes.length; ++i)
{
var path = FILE.join(cappBuild, buildTypes[i], "BlendKit");
if (FILE.isDirectory(path))
{
blendKitPath = path;
break;
}
}
}
}
if (blendKitPath)
FILE.symlink(blendKitPath, destinationPath);
}
function colorPrint(message, color)
{
var matches = color.match(/(bold(?: |\+))?(.+)/);
if (!matches)
return;
message = "\0" + matches[2] + "(" + message + "\0)";
if (matches[1])
message = "\0bold(" + message + "\0)";
stream.print(message);
}
@@ -3,15 +3,13 @@
* __project.name__
*
* Created by __user.name__ on __project.date__.
* Copyright __project.year__, __organization.name__ All rights reserved.
* Copyright __project.year__, __organization.name__. All rights reserved.
*/
@import <BlendKit/BKThemeDescriptor.j>
@implementation __project.nameasidentifier__ThemeDescriptor : BKThemeDescriptor
{
}
+ (CPString)themeName
{
@@ -21,7 +19,7 @@
+ (CPButton)themedButton
{
var button = [[CPButton alloc] initWithFrame:CGRectMake(0.0, 0.0, 100.0, 20.0)];
[button setValue:[CPColor blueColor] forThemeAttribute:@"bezel-color"];
[button setValue:[CPColor greenColor] forThemeAttribute:@"bezel-color" inState:CPThemeStateHighlighted];
@@ -29,7 +27,7 @@
[button setValue:[CPColor yellowColor] forThemeAttribute:@"text-color" inState:CPThemeStateHighlighted];
[button setTitle:@"Yikes!"];
return button;
}
@@ -7,7 +7,7 @@
__project.name__
Created by __user.name__ on __project.date__.
Copyright __project.year__, __organization.name__ All rights reserved.
Copyright __project.year__, __organization.name__. All rights reserved.
-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7, chrome=1" />
@@ -7,7 +7,7 @@
__project.name__
Created by __user.name__ on __project.date__.
Copyright __project.year__, __organization.name__ All rights reserved.
Copyright __project.year__, __organization.name__. All rights reserved.
-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7, chrome=1" />
@@ -1,9 +1,9 @@
/*
* main.j
* __Product__
* __project.name__
*
* Created by __Me__ on __Date__.
* Copyright 2008 __MyCompanyName__. All rights reserved.
* Created by __user.name__ on __project.date__.
* Copyright __project.year__, __organization.name__. All rights reserved.
*/
@import <Foundation/Foundation.j>