/* * 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 //=========================================================== const env = process.env; //=========================================================== // 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"; /* The list of directories containing Objective-J source that should be compiled by jake. The main framework directory is always checked for Objective-J source, you only need to edit this if you have source in subdirectories. Do NOT include a leading ortrailing slash in the directory name. Example: var sourceDirs = [ "Core", "Modules", "Modules/Foo", "Modules/Bar" ]; */ var sourceDirs = [ ]; //=========================================================== // AUTOMATICALLY GENERATED // // Do not edit! (unless you know what you are doing) //=========================================================== const path = require("path"); const fs = require("fs"); const stream = ObjectiveJ.term.stream; const jake = JAKE; const CLEAN = JAKE.CLEAN_AND_CLOBBER.CLEAN; const CLOBBER = JAKE.CLEAN_AND_CLOBBER.CLOBBER; const FileList = jake.FileList; const filedir = jake.filedir; const task = jake.task; const framework = CAPPUCCINO.Jake.frameworktask.framework; //const browserEnvironment = require("@objj/cappuccino/Jake/environment.js"); const configuration = env["CONFIG"] || env["CONFIGURATION"] || env["c"] || "Debug"; const productName = "__project.nameasidentifier__"; const buildPath = path.join(buildDir, productName + ".build"); const debugBuildPath = path.join("Build", "Debug"); /* 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")), buildPath = FILE.join(SYS.prefix, "packages", "cappuccino", "Frameworks"), debugPackagePath = FILE.join(buildPath, "Debug", productName); releasePackagePath = FILE.join(buildPath, productName); */ var frameworkTask = framework (productName, function(frameworkTask) { frameworkTask.setBuildIntermediatesPath(path.join(buildPath, configuration)); frameworkTask.setBuildPath(path.join(debugBuildPath, configuration)); frameworkTask.setProductName(productName); frameworkTask.setIdentifier("__project.identifier__"); frameworkTask.setVersion("1.0"); frameworkTask.setAuthor("__organization.name__"); frameworkTask.setEmail("__organization.email__"); frameworkTask.setSummary("__project.name__"); var includes = sourceDirs.map(function(dir) { return dir + "/*.j"; }); var fileList = new FileList(); includes.unshift("*.j"); fileList.include(includes); frameworkTask.setSources(fileList); 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 -S --inline-msg-send"); } else { frameworkTask.setCompilerFlags("-O2"); } }); 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 = path.join(buildDir, configuration, "CommonJS", "cappuccino", "Frameworks", productName); filedir (frameworkCJS, [productName], function() { if (fs.existsSync(frameworkCJS)) fs.rmSync(frameworkCJS, { recursive: true }); // TODO //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 " + path.join(buildDir, "Debug", productName)); describeTask(app, "release", "Builds a release version at " + path.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 " + buildPath); describeTask(app, "install-symlinks", "Builds a debug and release version, then symlinks the built versions into " + buildPath); 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(path.join(buildDir, "Debug", productName)) .include(path.join(buildDir, "Release", productName)) .include(debugBuildPath) .include(buildPath); var install = function(action) { ["Release", "Debug"].forEach(function(aConfig) { colorPrint((action === "symlink" ? "Symlinking " : "Copying ") + aConfig + "...", "cyan"); if (aConfig === "Debug") buildPath = path.join(buildPath, aConfig); if (fs.existsSync(buildPath) && !fs.lstatSync(buildPath).isDirectory()) sudo(["mkdir", "-p", buildPath]); var buildPath = path.resolve(path.join(buildDir, aConfig, productName)), targetPath = path.join(buildPath, 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); };