mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-14 22:51:28 +00:00
Framework capp template
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* __filename__
|
||||
* __project.name__
|
||||
*
|
||||
* Created by __user.name__ on __project.date__.
|
||||
*
|
||||
* Copyright __project.year__, __organization.name__. All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
@import "__project.nameasidentifier__Class.j"
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* __filename__
|
||||
* __project.name__
|
||||
*
|
||||
* Created by __user.name__ on __project.date__.
|
||||
*
|
||||
* Copyright __project.year__, __organization.name__. All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
@import <Foundation/CPObject.j>
|
||||
|
||||
|
||||
/*!
|
||||
This class is defined to make it easier to find the bundle,
|
||||
for example to get an image from the framework like this:
|
||||
|
||||
@code
|
||||
var path = [[CPBundle bundleForClass:__project.nameasidentifier__] pathForResource:@"email-action.png"];
|
||||
@endcode
|
||||
|
||||
You can also use [__project.nameasidentifier__ version] to get the current version.
|
||||
*/
|
||||
@implementation __project.nameasidentifier__ : CPObject
|
||||
|
||||
+ (CPString)version
|
||||
{
|
||||
var bundle = [CPBundle bundleForClass:[self class]];
|
||||
|
||||
return [bundle objectForInfoDictionaryKey:@"CPBundleVersion"];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CPBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CPBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,217 @@
|
||||
/*
|
||||
* Jakefile
|
||||
* __project.name__
|
||||
*
|
||||
* Created by __user.name__ on __project.date__.
|
||||
*
|
||||
* Copyright __project.year__, __organization.name__. All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
//===========================================================
|
||||
// DO NOT REMOVE
|
||||
//===========================================================
|
||||
|
||||
var SYS = require("system"),
|
||||
ENV = SYS.env,
|
||||
FILE = require("file"),
|
||||
OS = require("os");
|
||||
|
||||
|
||||
//===========================================================
|
||||
// USER CONFIGURABLE VARIABLES
|
||||
//===========================================================
|
||||
|
||||
/*
|
||||
The directory in which the project will be built. By default
|
||||
it is built in $CAPP_BUILD if that is defined, otherwise
|
||||
in a "Build" directory within the project directory.
|
||||
*/
|
||||
var buildDir = ENV["BUILD_PATH"] || ENV["CAPP_BUILD"] || "Build";
|
||||
|
||||
|
||||
//===========================================================
|
||||
// AUTOMATICALLY GENERATED
|
||||
//
|
||||
// Do not edit! (unless you know what you are doing)
|
||||
//===========================================================
|
||||
|
||||
var stream = require("narwhal/term").stream,
|
||||
JAKE = require("jake"),
|
||||
task = JAKE.task,
|
||||
CLEAN = require("jake/clean").CLEAN,
|
||||
CLOBBER = require("jake/clean").CLOBBER,
|
||||
FileList = JAKE.FileList,
|
||||
filedir = JAKE.filedir,
|
||||
framework = require("cappuccino/jake").framework,
|
||||
browserEnvironment = require("objective-j/jake/environment").Browser,
|
||||
configuration = ENV["CONFIG"] || ENV["CONFIGURATION"] || ENV["c"] || "Debug",
|
||||
productName = "__project.nameasidentifier__",
|
||||
buildPath = FILE.canonical(FILE.join(buildDir, productName + ".build")),
|
||||
packageFrameworksPath = FILE.join(SYS.prefix, "packages", "cappuccino", "Frameworks"),
|
||||
debugPackagePath = FILE.join(packageFrameworksPath, "Debug", productName);
|
||||
releasePackagePath = FILE.join(packageFrameworksPath, productName);
|
||||
|
||||
var frameworkTask = framework (productName, function(frameworkTask)
|
||||
{
|
||||
frameworkTask.setBuildIntermediatesPath(FILE.join(buildPath, configuration));
|
||||
frameworkTask.setBuildPath(FILE.join(buildDir, configuration));
|
||||
|
||||
frameworkTask.setProductName(productName);
|
||||
frameworkTask.setIdentifier("__project.identifier__");
|
||||
frameworkTask.setVersion("1.0");
|
||||
frameworkTask.setAuthor("__organization.name__");
|
||||
frameworkTask.setEmail("__organization.email__");
|
||||
frameworkTask.setSummary("__project.name__");
|
||||
frameworkTask.setSources(new FileList("*.j"));
|
||||
frameworkTask.setResources(new FileList("Resources/**/*"));
|
||||
frameworkTask.setFlattensSources(true);
|
||||
frameworkTask.setInfoPlistPath("Info.plist");
|
||||
frameworkTask.setLicense(BundleTask.License.LGPL_v2_1);
|
||||
//frameworkTask.setEnvironments([browserEnvironment]);
|
||||
|
||||
if (configuration === "Debug")
|
||||
frameworkTask.setCompilerFlags("-DDEBUG -g");
|
||||
else
|
||||
frameworkTask.setCompilerFlags("-O");
|
||||
});
|
||||
|
||||
task ("debug", function()
|
||||
{
|
||||
ENV["CONFIGURATION"] = "Debug";
|
||||
JAKE.subjake(["."], "build", ENV);
|
||||
});
|
||||
|
||||
task ("release", function()
|
||||
{
|
||||
ENV["CONFIGURATION"] = "Release";
|
||||
JAKE.subjake(["."], "build", ENV);
|
||||
});
|
||||
|
||||
task ("default", ["release"]);
|
||||
|
||||
var frameworkCJS = FILE.join(buildDir, configuration, "CommonJS", "cappuccino", "Frameworks", productName);
|
||||
|
||||
filedir (frameworkCJS, [productName], function()
|
||||
{
|
||||
if (FILE.exists(frameworkCJS))
|
||||
FILE.rmtree(frameworkCJS);
|
||||
|
||||
FILE.copyTree(frameworkTask.buildProductPath(), frameworkCJS);
|
||||
});
|
||||
|
||||
task ("build", [productName, frameworkCJS]);
|
||||
|
||||
task ("all", ["debug", "release"]);
|
||||
|
||||
task ("install", ["debug", "release"], function()
|
||||
{
|
||||
install("copy");
|
||||
});
|
||||
|
||||
task ("install-symlinks", ["debug", "release"], function()
|
||||
{
|
||||
install("symlink");
|
||||
});
|
||||
|
||||
task ("help", function()
|
||||
{
|
||||
var app = JAKE.application().name();
|
||||
|
||||
colorPrint("--------------------------------------------------------------------------", "bold+green");
|
||||
colorPrint("__project.name__ - Framework", "bold+green");
|
||||
colorPrint("--------------------------------------------------------------------------", "bold+green");
|
||||
|
||||
describeTask(app, "debug", "Builds a debug version at " + FILE.join(buildDir, "Debug", productName));
|
||||
describeTask(app, "release", "Builds a release version at " + FILE.join(buildDir, "Release", productName));
|
||||
describeTask(app, "all", "Builds a debug and release version");
|
||||
describeTask(app, "install", "Builds a debug and release version, then installs in " + packageFrameworksPath);
|
||||
describeTask(app, "install-symlinks", "Builds a debug and release version, then symlinks the built versions into " + packageFrameworksPath);
|
||||
describeTask(app, "clean", "Removes the intermediate build files");
|
||||
describeTask(app, "clobber", "Removes the intermediate build files and the installed frameworks");
|
||||
|
||||
colorPrint("--------------------------------------------------------------------------", "bold+green");
|
||||
});
|
||||
|
||||
CLEAN.include(buildPath);
|
||||
CLOBBER.include(FILE.join(buildDir, "Debug", productName))
|
||||
.include(FILE.join(buildDir, "Release", productName))
|
||||
.include(debugPackagePath)
|
||||
.include(releasePackagePath);
|
||||
|
||||
var install = function(action)
|
||||
{
|
||||
var packageFrameworksPath = FILE.join(SYS.prefix, "packages", "cappuccino", "Frameworks");
|
||||
|
||||
["Release", "Debug"].forEach(function(aConfig)
|
||||
{
|
||||
colorPrint((action === "symlink" ? "Symlinking " : "Copying ") + aConfig + "...", "cyan");
|
||||
|
||||
if (aConfig === "Debug")
|
||||
packageFrameworksPath = FILE.join(packageFrameworksPath, aConfig);
|
||||
|
||||
if (!FILE.isDirectory(packageFrameworksPath))
|
||||
sudo(["mkdir", "-p", packageFrameworksPath]);
|
||||
|
||||
var buildPath = FILE.absolute(FILE.join(buildDir, aConfig, productName)),
|
||||
targetPath = FILE.join(packageFrameworksPath, productName);
|
||||
|
||||
if (action === "symlink")
|
||||
directoryOp(["ln", "-sf", buildPath, targetPath]);
|
||||
else
|
||||
directoryOp(["cp", "-rf", buildPath, targetPath]);
|
||||
});
|
||||
};
|
||||
|
||||
var directoryOp = function(cmd)
|
||||
{
|
||||
var targetPath = cmd[cmd.length - 1];
|
||||
|
||||
if (FILE.isDirectory(targetPath))
|
||||
sudo(["rm", "-rf", targetPath])
|
||||
|
||||
sudo(cmd);
|
||||
};
|
||||
|
||||
var sudo = function(cmd)
|
||||
{
|
||||
if (OS.system(cmd))
|
||||
OS.system(["sudo"].concat(cmd));
|
||||
};
|
||||
|
||||
var describeTask = function(application, task, description)
|
||||
{
|
||||
colorPrint("\n" + application + " " + task, "violet");
|
||||
description.split("\n").forEach(function(line)
|
||||
{
|
||||
stream.print(" " + line);
|
||||
});
|
||||
}
|
||||
|
||||
var colorPrint = function(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);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
mv "$1"/Framework.j "$1/__project.name__.j"
|
||||
mv "$1"/FrameworkClass.j "$1/__project.name__Class.j"
|
||||
sed -e 's/__filename__/__project.name__.j/' -i '' "$1/__project.name__.j"
|
||||
sed -e 's/__filename__/__project.name__Class.j/' -i '' "$1/__project.name__Class.j"
|
||||
Reference in New Issue
Block a user