Further jake work.

Reviewed by me.
This commit is contained in:
Francisco Ryan Tolmasky I committed 2009-09-24 01:11:46 -07:00
1 parent 64a8e4c5c0
commit ffd99e3ed7
7 files changed
+169 -23

No files matched your search

+97
View File
@@ -0,0 +1,97 @@
#!/usr/bin/env ruby
var FILE = require("file");
require(FILE.absolute("../common.jake"));
$BUILD_PATH = FILE.join($BUILD_DIR, $CONFIGURATION, 'AppKit');
$ENVIRONMENT_PRODUCT = FILE.join($ENVIRONMENT_FRAMEWORKS_DIR, 'AppKit');
$THEME_PRODUCT = FILE.join($BUILD_PATH, 'Resources', 'Aristo.blend');
$ENVIRONMENT_THEME_PRODUCT = FILE.join($ENVIRONMENT_PRODUCT, 'Resources', 'Aristo.blend');
//AppKitFiles = FileList['**/*.j'].exclude('CoreGraphics/CGContextCanvas.j', 'CoreGraphics/CGContextVML.j', 'Themes/**', 'Tools/**')
framework ("AppKit", function(AppKitTask)
{
AppKitTask.setBuildIntermediatesPath(FILE.join($BUILD_DIR, "AppKit.build", $CONFIGURATION))
AppKitTask.setBuildPath(FILE.join($BUILD_DIR, $CONFIGURATION));
AppKitTask.setIdentifier("com.280n.AppKit");
AppKitTask.setLicense(BundleTask.License.LGPL_v2_1);
AppKitTask.setSources(FILE.glob("**/*.j").concat(FILE.glob("*.j")));//terrible!
AppKitTask.setResources(FILE.glob("Resources/*"));
AppKitTask.setPlatforms([BundleTask.Platform.Browser, BundleTask.Platform.CommonJS]);
AppKitTask.setFlattensSources(true);
if ($CONFIGURATION === "Release")
AppKitTask.setCompilerFlags("-O");
else
AppKitTask.setCompilerFlags("-DDEBUG -g");
});
/*
ObjectiveJ::BundleTask.new(:AppKit) do |t|
t.name = 'AppKit'
t.identifier = 'com.280n.AppKit'
t.version = '0.7.1'
t.author = '280 North, Inc.'
t.email = 'feedback @nospam@ 280north.com'
t.summary = 'AppKit classes for Cappuccino'
t.sources = AppKitFiles
t.resources = FileList['Resources/*']
t.license = ObjectiveJ::License::LGPL_v2_1
t.build_path = $BUILD_PATH
t.flag = '-DDEBUG -g' if $CONFIGURATION == 'Debug'
t.flag = '-O' if $CONFIGURATION == 'Release'
t.platforms = [ObjectiveJ::Platform::Browser, ObjectiveJ::Platform::Rhino]
t.type = ObjectiveJ::Bundle::Type::Framework
end*/
//# It would be nice to just have ENVIRONMENT_PRODUCT depend on THEME_PRODUCT,
//# but this would be a circular dependency because THEME_PRODUCT needs
//# ENVIRONMENT_PRODUCT up-to-date since it runs an objj application that uses
//# AppKit.
//file_d $ENVIRONMENT_PRODUCT => [:AppKit] do
// cp_r(File.join($BUILD_PATH, '.'), $ENVIRONMENT_PRODUCT)
//end
//file_d $ENVIRONMENT_THEME_PRODUCT => $THEME_PRODUCT do
// cp_r(File.join($THEME_PRODUCT, '.'), $ENVIRONMENT_THEME_PRODUCT)
//end
//ThemeFiles = FileList['Themes/Aristo/*']
//file_d $THEME_PRODUCT => ThemeFiles << $ENVIRONMENT_PRODUCT do
// File.popen("blend -d Themes/Aristo/ThemeDescriptors.j -o #{$THEME_PRODUCT} -R Themes/Aristo/Resources") do |blend|
// blend.sync = true
//
// while str = blend.gets
// puts str
// end
// end
// rake abort if ($? != 0)
//end
task ("build", ["AppKit"]);//, $ENVIRONMENT_PRODUCT, $THEME_PRODUCT, $ENVIRONMENT_THEME_PRODUCT]
subprojects = ["Tools"];
function subtasks(subprojects, taskNames)
{
taskNames.forEach(function(aTaskName)
{
var subtaskName = taskNames + "_subprojects";
task (aTaskName, [subtaskName]);
task (subtaskName, function()
{
subjake(subprojects, aTaskName);
});
});
}
subtasks (subprojects, ["build", "clean", "clobber"]);
//CLOBBER.include($ENVIRONMENT_PRODUCT)
+1
View File
@@ -18,6 +18,7 @@ framework ("Foundation", function(FoundationTask)
FoundationTask.setLicense(BundleTask.License.LGPL_v2_1);
FoundationTask.setSources(FILE.glob("**/*.j").concat(FILE.glob("*.j")));//terrible!
FoundationTask.setResources(FILE.glob("Resources/*"));
FoundationTask.setFlattensSources(true);
if ($CONFIGURATION === "Release")
FoundationTask.setCompilerFlags("-O");
@@ -13,7 +13,7 @@ if (window.isRhino) {
window.OBJJ_HOME = exports.OBJJ_HOME = file.resolve(module.path, "..");
var frameworksPath = file.resolve(window.OBJJ_HOME, "lib/", "Frameworks/"),
objectivejPath = file.resolve(frameworksPath, "Objective-J/", "rhino.platform/", "Objective-J.js");
objectivejPath = file.resolve(frameworksPath, "Objective-J/", "CommonJS.platform/", "Objective-J.js");
window.OBJJ_INCLUDE_PATHS = [frameworksPath];
if (system.env["OBJJ_INCLUDE_PATHS"])
@@ -0,0 +1,23 @@
BundleTask = require("objective-j/jake/bundletask").BundleTask;
function ApplicationTask(aName)
{
ApplicationTask.apply(this, arguments);
}
ApplicationTask.__proto__ = BundleTask;
ApplicationTask.prototype.__proto__ = BundleTask.prototype;
ApplicationTask.prototype.packageTask = function()
{
return "APPL";
}
exports.ApplicationTask = ApplicationTask;
exports.application = function(aName, aFunction)
{
// No .apply necessary because the parameters aren't variable.
return ApplicationTask.defineTask(aName, aFunction);
}
@@ -25,13 +25,17 @@ function BundleTask(aName, anApplication)
this._resources = null;
this._identifier = null;
this._version = 0.1;
this._compilerFlags = null;
this._flattensSources = false;
this._productName = this.name();
this._buildIntermediatesPath = null;
this._buildPath = FILE.cwd();
this._replacedFiles = new objj_dictionary();
// this._nib2cibFlags = [];
// this.shouldnib
}
@@ -110,12 +114,6 @@ BundleTask.Platform = {
"Browser" : "Browser"
};
BundleTask.PLATFORM_DIRECTORIES = {
"ObjJ" : "objj.platform",
"CommonJS" : "commonjs.platform",
"Browser" : "browser.platform"
};
BundleTask.PLATFORM_DEFAULT_FLAGS = {
"ObjJ" : [],
"CommonJS" : ['-DPLATFORM_RHINO -DPLATFORM_COMMONJS'],
@@ -221,6 +219,16 @@ BundleTask.prototype.compilerFlags = function()
return this._compilerFlags;
}
BundleTask.prototype.flattensSources = function()
{
return this._flattensSources;
}
BundleTask.prototype.setFlattensSources = function(/*Boolean*/ shouldFlattenSources)
{
this._flattensSources = shouldFlattenSources;
}
BundleTask.prototype.setLicense = function(aLicense)
{
this._license = aLicense;
@@ -263,7 +271,7 @@ BundleTask.prototype.buildIntermediatesProductPath = function()
BundleTask.prototype.buildProductStaticPathForPlatform = function(aPlatform)
{
return FILE.join(this.buildProductPath(), BundleTask.PLATFORM_DIRECTORIES[aPlatform], this.productName() + ".sj");
return FILE.join(this.buildProductPath(), aPlatform + ".platform", this.productName() + ".sj");
}
BundleTask.prototype.defineTasks = function()
@@ -290,13 +298,12 @@ BundleTask.prototype.infoPlist = function()
infoPlist.setValue("CPBundleIdentifier", this.identifier());
infoPlist.setValue("CPBundleVersion", this.version());
infoPlist.setValue("CPBundlePackageType", this.packageType());
infoPlist.setValue("CPBundleReplacedFiles", this._replacedFiles);
infoPlist.setValue("CPBundlePlatforms", this.platforms());
infoPlist.setValue("CPBundleExecutable", this.productName() + ".sj");
return infoPlist;
/*
info_plist_path = File.join(build_path, 'Info.plist')
new_info_plist = { 'CPBundleName' => name, 'CPBundleIdentifier' => identifier, 'CPBundleInfoDictionaryVersion' => 6.0, 'CPBundleVersion' => version, 'CPBundlePackageType' => Bundle::Type.code_string(type) }
new_info_plist['CPBundlePlatforms'] = platforms;
if info_plist
existing_info_plist = Plist::parse_xml(info_plist)
@@ -474,20 +481,32 @@ BundleTask.prototype.defineStaticTask = function()
{
this.platforms().forEach(function(/*String*/ aPlatform)
{
var staticPath = this.buildProductStaticPathForPlatform(aPlatform);
var sourcesPath = FILE.join(this.buildIntermediatesProductPath(), aPlatform + ".platform", ""),
staticPath = this.buildProductStaticPathForPlatform(aPlatform),
flattensSources = this.flattensSources();
filedir (staticPath, function(aTask)
{
print("Creating static file...");
print("Creating static file... " + staticPath);
FILE.write(staticPath, "@STATIC;1.0;", { charset:"UTF-8" });
var fileStream = FILE.open(staticPath, "w+", { charset:"UTF-8" });
fileStream.write("@STATIC;1.0;");
aTask.prerequisites().forEach(function(aFilename)
{
// Our prerequisites will contain directories due to filedir.
if (FILE.isFile(aFilename))
OS.system("cat " + aFilename + " >> " + staticPath);
{
var relativePath = flattensSources ? FILE.basename(aFilename) : FILE.relative(sourcesPath, aFilename);
// FIXME: We need to do this for now due to file.read adding newlines. Revert when fixed.
fileStream.write("p;" + relativePath.length + ";" + relativePath);
fileStream.write(FILE.read(aFilename, { mode:"b" }).decodeToString("UTF-8"));
}
}, this);
fileStream.close();
});
this.enhance([staticPath]);
@@ -501,7 +520,8 @@ BundleTask.prototype.defineSourceTasks = function()
if (!sources)
return;
var compilerFlags = this.compilerFlags();
var compilerFlags = this.compilerFlags(),
flattensSources = this.flattensSources();
if (!compilerFlags)
compilerFlags = "";
@@ -512,20 +532,22 @@ BundleTask.prototype.defineSourceTasks = function()
this.platforms().forEach(function(/*String*/ aPlatform)
{
var platformSources = sources,
platformBuildIntermediatesPath = FILE.join(this.buildIntermediatesProductPath(), BundleTask.PLATFORM_DIRECTORIES[aPlatform]),
sourcesPath = FILE.join(this.buildIntermediatesProductPath(), aPlatform + ".platform", ""),
staticPath = this.buildProductStaticPathForPlatform(aPlatform),
flags = BundleTask.PLATFORM_DEFAULT_FLAGS[aPlatform].join(" ");
if (!Array.isArray(platformSources))
platformSources = platformSources[aPlatform];
var replacedFiles = [];
platformSources.forEach(function(/*String*/ aFilename)
{
// if this file doesn't exist or isn't a .j file, don't preprocess it.
if (!FILE.exists(aFilename) || FILE.extension(aFilename) !== '.j')
return;
var compiledPlatformSource = FILE.join(platformBuildIntermediatesPath, FILE.basename(aFilename));
var compiledPlatformSource = FILE.join(sourcesPath, FILE.basename(aFilename));
filedir (compiledPlatformSource, [aFilename], function()
{
@@ -535,7 +557,10 @@ BundleTask.prototype.defineSourceTasks = function()
filedir (staticPath, [compiledPlatformSource]);
replacedFiles.push(flattensSources ? FILE.basename(aFilename) : FILE.relative(sourcesPath, aFilename));
}, this);
this._replacedFiles.setValue(aPlatform, replacedFiles);
}, this);
/*
list.each do |fileName|
+3 -3
View File
@@ -14,7 +14,7 @@ $LICENSE_PRODUCT = FILE.join($PRODUCT, 'LICENSE')
$LICENSE_FILE = FILE.join($HOME_DIR, 'Tools', 'Rake', 'lib', 'licenses', 'LGPL-v2.1')
$BROWSER_FILE = FILE.join($PRODUCT, 'Objective-J.js')
$RHINO_FILE = FILE.join($PRODUCT, 'rhino.platform', 'Objective-J.js')
$RHINO_FILE = FILE.join($PRODUCT, 'CommonJS.platform', 'Objective-J.js')
Files = ["Runtime/constants.js", "Runtime/utilities.js", "Runtime/json2.js", "Runtime/runtime.js", "Runtime/dictionary.js", "Runtime/plist.js", "Runtime/file.js", "Runtime/exception.js", "Runtime/preprocess.js", "Runtime/evaluate.js", "Runtime/bootstrap.js"];
//Files = new FileList("constants.js", "utilities.js", "json2.js", "runtime.js", "dictionary.js", "plist.js", "file.js", "exception.js", "preprocess.js", "evaluate.js", "bootstrap.js");
@@ -26,12 +26,12 @@ task ("build", [$BROWSER_FILE, $RHINO_FILE, $LICENSE_PRODUCT, $COMMONJS_PRODUCT,
filedir ($BROWSER_FILE, Files, function(aTask)
{
build_product(aTask.name(), platform_flags('browser', 'objj'));//ObjectiveJ::Platform::Browser, ObjectiveJ::Platform::ObjJ))
build_product(aTask.name(), platform_flags('Browser', 'ObjJ'));
});
filedir ($RHINO_FILE, Files, function(aTask)
{
flags = platform_flags('rhino', 'objj');//ObjectiveJ::Platform::Rhino, ObjectiveJ::Platform::ObjJ)
flags = platform_flags('CommonJS', 'ObjJ');
flags += ' -DRHINO'
build_product(aTask.name(), flags)
+1 -1
View File
@@ -394,7 +394,7 @@ objj_search.prototype.didReceiveBundleResponse = function(aResponse)
// FIXME: Is this the right approach?
// Request the compiled file regardless of whether our current inquiry
var directory = DIRECTORY(aResponse.filePath),
replacedFiles = dictionary_getValue(bundle.info, "CPBundleReplacedFiles"),
replacedFiles = dictionary_getValue(dictionary_getValue(bundle.info, "CPBundleReplacedFiles"), platform),
index = 0,
count = replacedFiles.length;