Files
cappuccino/Tests/Manual/CPTextFieldEditingStyleTest/Jakefile
T
David Richardson 53784f0e10 Migrate subsidiary test Jakefiles to @objj/jake toolchain
Applies the transformation script across all applications in the Tests/Manual directory to eliminate Narwhal-era dependencies and establish compatibility with the modern Node-based runner.

* Removes explicit `require("jake")` calls in favor of the injected JAKE global.
* Replaces legacy `cappuccino/jake` application instantiation with the `CAPPUCCINO.Jake.applicationtask.app` hook.
* Substitutes archaic `system`, `file`, and `os` API calls with native Node `child_process`, `fs`, and `path` modules.
* Corrects package paths for nativehost deployment targets.
2026-09-08 19:08:43 -06:00

184 lines
6.2 KiB
JavaScript

/*
* Jakefile
* CPTextFieldEditingStyleTest
*
* Created by Alexandre Wilhelm on June 9, 2014.
*/
var ENV = process.env, cp = require("child_process"), fs = require("fs"), path = require("path");,
FILE = require("file"),
JAKE = require("jake"),
task = JAKE.task,
FileList = JAKE.FileList,
app = CAPPUCCINO.Jake.applicationtask.app,
configuration = ENV["CONFIG"] || ENV["CONFIGURATION"] || ENV["c"] || "Debug",
OS = require("os"),
projectName = "CPTextFieldEditingStyleTest";
app (projectName, function(task)
{
ENV["OBJJ_INCLUDE_PATHS"] = "Frameworks";
if (configuration === "Debug")
ENV["OBJJ_INCLUDE_PATHS"] = path.join(ENV["OBJJ_INCLUDE_PATHS"], configuration);
task.setBuildIntermediatesPath(path.join("Build", "CPTextFieldEditingStyleTest.build", configuration));
task.setBuildPath(path.join("Build", configuration));
task.setProductName("CPTextFieldEditingStyleTest");
task.setIdentifier("com.yourcompany.CPTextFieldEditingStyleTest");
task.setVersion("1.0");
task.setAuthor("Your Company");
task.setEmail("feedback @nospam@ yourcompany.com");
task.setSummary("CPTextFieldEditingStyleTest");
task.setSources(new FileList("**/*.j").exclude(path.join("Build", "**")).exclude(path.join("Frameworks", "Source", "**")));
task.setResources(new FileList("Resources/**"));
task.setIndexFilePath("index.html");
task.setInfoPlistPath("Info.plist");
if (configuration === "Debug")
task.setCompilerFlags("-DDEBUG -g");
else
task.setCompilerFlags("-O");
});
task ("default", [projectName], function()
{
printResults(configuration);
});
task ("build", ["default"], function()
{
updateApplicationSize();
});
task ("debug", function()
{
ENV["CONFIGURATION"] = "Debug";
JAKE.subjake(["."], "build", ENV);
});
task ("release", function()
{
ENV["CONFIGURATION"] = "Release";
JAKE.subjake(["."], "build", ENV);
});
task ("run", ["debug"], function()
{
cp.execSync(["open", path.join("Build", "Debug", projectName, "index.html")].join(" "), { stdio: "inherit" });
});
task ("run-release", ["release"], function()
{
cp.execSync(["open", path.join("Build", "Release", projectName, "index.html")].join(" "), { stdio: "inherit" });
});
task ("deploy", ["release"], function()
{
fs.mkdirSync(path.join("Build", "Deployment", projectName), { recursive: true });
cp.execSync(["press", "-f", path.join("Build", "Release", projectName), path.join("Build", "Deployment", projectName)].join(" "), { stdio: "inherit" });
printResults("Deployment")
});
task ("desktop", ["release"], function()
{
fs.mkdirSync(path.join("Build", "Desktop", projectName), { recursive: true });
require("@objj/nativehost").buildNativeHost(path.join("Build", "Release", projectName), path.join("Build", "Desktop", projectName, "CPTextFieldEditingStyleTest.app"));
printResults("Desktop")
});
task ("run-desktop", ["desktop"], function()
{
cp.execSync([path.join("Build", "Desktop", projectName, "CPTextFieldEditingStyleTest.app", "Contents", "MacOS", "NativeHost"), "-i"].join(" "), { stdio: "inherit" });
});
function printResults(configuration)
{
console.log("----------------------------");
console.log(configuration+" app built at path: "+path.join("Build", configuration, projectName));
console.log("----------------------------");
}
function updateApplicationSize()
{
console.log("Calculating application file sizes...");
var contents = FILE.read(path.join("Build", ENV["CONFIGURATION"], projectName, "Info.plist"), { charset:"UTF-8" }),
format = CFPropertyList.sniffedFormatOfString(contents),
plist = CFPropertyList.propertyListFromString(contents),
totalBytes = {executable:0, data:0, mhtml:0};
// Get the size of all framework executables and sprite data
var frameworksDir = "Frameworks";
if (ENV["CONFIGURATION"] === "Debug")
frameworksDir = path.join(frameworksDir, "Debug");
var frameworks = FILE.list(frameworksDir);
frameworks.forEach(function(framework)
{
if (framework !== "Source")
addBundleFileSizes(path.join(frameworksDir, framework), totalBytes);
});
// Read in the default theme name, and attempt to get its size
var themeName = plist.valueForKey("CPDefaultTheme") || "Aristo2",
themePath = nil;
if (themeName === "Aristo" || themeName === "Aristo2")
themePath = path.join(frameworksDir, "AppKit", "Resources", themeName + ".blend");
else
themePath = path.join("Frameworks", "Resources", themeName + ".blend");
if (FILE.isDirectory(themePath))
addBundleFileSizes(themePath, totalBytes);
// Add sizes for the app
addBundleFileSizes(path.join("Build", ENV["CONFIGURATION"], projectName), totalBytes);
console.log("Executables: " + totalBytes.executable + ", sprite data: " + totalBytes.data + ", total: " + (totalBytes.executable + totalBytes.data));
var dict = new CFMutableDictionary();
dict.setValueForKey("executable", totalBytes.executable);
dict.setValueForKey("data", totalBytes.data);
dict.setValueForKey("mhtml", totalBytes.mhtml);
plist.setValueForKey("CPApplicationSize", dict);
FILE.write(path.join("Build", ENV["CONFIGURATION"], projectName, "Info.plist"), CFPropertyList.stringFromPropertyList(plist, format), { charset:"UTF-8" });
}
function addBundleFileSizes(bundlePath, totalBytes)
{
var bundleName = FILE.basename(bundlePath),
environment = bundleName === "Foundation" ? "Objj" : "Browser",
bundlePath = path.join(bundlePath, environment + ".environment");
if (FILE.isDirectory(bundlePath))
{
var filename = bundleName + ".sj",
filePath = new FILE.Path(path.join(bundlePath, filename));
if (filePath.exists())
totalBytes.executable += filePath.size();
filePath = new FILE.Path(path.join(bundlePath, "dataURLs.txt"));
if (filePath.exists())
totalBytes.data += filePath.size();
filePath = new FILE.Path(path.join(bundlePath, "MHTMLData.txt"));
if (filePath.exists())
totalBytes.mhtml += filePath.size();
filePath = new FILE.Path(path.join(bundlePath, "MHTMLPaths.txt"));
if (filePath.exists())
totalBytes.mhtml += filePath.size();
}
}