mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-25 04:57:03 +00:00
233 lines
7.4 KiB
JavaScript
233 lines
7.4 KiB
JavaScript
/*
|
|
* 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 ENV = process.env;
|
|
|
|
//===========================================================
|
|
// 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)
|
|
//===========================================================
|
|
|
|
const path = require("path");
|
|
const fs = require("fs");
|
|
|
|
var stream = ObjectiveJ.term.stream,
|
|
task = JAKE.task,
|
|
FileList = JAKE.FileList,
|
|
CLEAN = JAKE.CLEAN_AND_CLOBBER.CLEAN,
|
|
CLOBBER = JAKE.CLEAN_AND_CLOBBER.CLOBBER,
|
|
//blend = require("cappuccino/jake").blend,
|
|
configuration = ENV["CONFIG"] || ENV["CONFIGURATION"] || ENV["c"] || "Debug",
|
|
productName = "__project.nameasidentifier__",
|
|
debugBlendKitPath = path.join("Frameworks", "Debug", "BlendKit"),
|
|
releaseBlendKitPath = path.join("Frameworks", "BlendKit"),
|
|
buildPath = path.resolve(path.join(buildDir, productName + ".build"));
|
|
|
|
debugger;
|
|
|
|
var callback;
|
|
|
|
function callbackFunction(blendtask) {
|
|
callback(blendtask);
|
|
}
|
|
|
|
var initilize = function(callback) {
|
|
// This check is only necessary because during the build process blendtask gets created much later.
|
|
var blendTaskPath = path.resolve(fs.realpathSync(process.argv[1]), "..", "..", "lib", "cappuccino", "jake", "blendtask.j");
|
|
|
|
if (fs.existsSync(blendTaskPath))
|
|
{
|
|
var anExports = {};
|
|
function localCallback() {
|
|
callback(anExports);
|
|
}
|
|
process.env["CONFIG"] = "Debug";
|
|
ObjectiveJ.OBJJ_INCLUDE_PATHS.push(path.resolve(fs.realpathSync(process.argv[1]), "..", "..", "Frameworks"));
|
|
//ObjectiveJ.OBJJ_INCLUDE_PATHS.push(path.join(path.join($BUILD_DIR, "Debug"), "CommonJS", "cappuccino", "Frameworks"));
|
|
ObjectiveJ.make_narwhal_factory(blendTaskPath, null, null, localCallback)(require, anExports, module, typeof system !== "undefined" && system, console.log);
|
|
}
|
|
}
|
|
|
|
initilize(callbackFunction);
|
|
|
|
var promise = new Promise((resolve, reject) => {
|
|
callback = function(BLEND_TASK) {
|
|
exports.BlendTask = BLEND_TASK.BlendTask;
|
|
exports.blend = BLEND_TASK.blend;
|
|
defineBlendTask().then(() => {
|
|
resolve();
|
|
delete exports.jakePromise;
|
|
});
|
|
}
|
|
});
|
|
|
|
async function defineBlendTask() {
|
|
await exports.blend (productName + ".blend", function(themeBlendTask)
|
|
{
|
|
themeBlendTask.setBuildIntermediatesPath(path.join(buildPath, configuration))
|
|
themeBlendTask.setBuildPath(path.join(buildDir, configuration));
|
|
|
|
themeBlendTask.setThemeDescriptors(new FileList("ThemeDescriptors.j"));
|
|
themeBlendTask.setIdentifier("__project.identifier__");
|
|
themeBlendTask.setResources(new FileList("Resources/*"));
|
|
});
|
|
task ("build", [productName + ".blend"]);
|
|
}
|
|
|
|
exports.jakePromise = promise;
|
|
|
|
task ("debug", function()
|
|
{
|
|
ENV["CONFIGURATION"] = "Debug";
|
|
JAKE.subjake(["."], "build", ENV);
|
|
|
|
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(buildPath);
|
|
|
|
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.exists(destinationPath))
|
|
return;
|
|
|
|
var blendKitPath = null,
|
|
path = FILE.join(SYS.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);
|
|
}
|
|
|
|
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);
|
|
}
|