Updated all Rakefiles and tools to work with Narwhal

This commit is contained in:
tlrobinson committed 2009-05-10 03:35:31 -07:00
1 parent b31abab595
commit 6e11a66cb0
22 files changed
+305 -362

No files matched your search

Regular → Executable
+11 -12
View File
@@ -5,7 +5,6 @@
@import <AppKit/CPTheme.j>
@import <BlendKit/BlendKit.j>
importClass(java.io.File);
importClass(java.io.FileOutputStream);
importClass(java.io.BufferedWriter);
importClass(java.io.OutputStreamWriter);
@@ -14,7 +13,7 @@ importClass(java.io.OutputStreamWriter);
function main()
{
var index = 0,
count = arguments.length,
count = system.args.length,
outputFilePath = "",
descriptorFiles = [],
@@ -23,22 +22,22 @@ function main()
for (; index < count; ++index)
{
var argument = arguments[index];
var argument = system.args[index];
switch (argument)
{
case "-c":
case "--cib": cibFiles.push(arguments[++index]);
case "--cib": cibFiles.push(system.args[++index]);
break;
case "-d":
case "-descriptor": descriptorFiles.push(arguments[++index]);
case "-descriptor": descriptorFiles.push(system.args[++index]);
break;
case "-o": outputFilePath = arguments[++index];
case "-o": outputFilePath = system.args[++index];
break;
case "-R": resourcesPath = arguments[++index];
case "-R": resourcesPath = system.args[++index];
break;
default: jExtensionIndex = argument.indexOf(".j");
@@ -67,7 +66,7 @@ function main()
var objectTemplates = BKThemeObjectTemplatesForClass(theClass);
data = cibDataFromTopLevelObjects(objectTemplates.concat([themeTemplate])),
temporaryCibFile = File.createTempFile("temp", ".cib"),
temporaryCibFile = Packages.java.io.File.createTempFile("temp", ".cib"),
temporaryCibFilePath = temporaryCibFile.getAbsolutePath(),
writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(temporaryCibFilePath), "UTF-8"));
@@ -116,7 +115,7 @@ function buildBlendFromCibFiles(cibFiles, outputFilePath, resourcesPath)
var resourcesFile = nil;
if (resourcesPath)
resourcesFile = new File(resourcesPath);
resourcesFile = new Packages.java.io.File(resourcesPath);
var count = cibFiles.length,
replacedFiles = [],
@@ -124,7 +123,7 @@ function buildBlendFromCibFiles(cibFiles, outputFilePath, resourcesPath)
while (count--)
{
var theme = themeFromCibFile(new File(cibFiles[count])),
var theme = themeFromCibFile(new Packages.java.io.File(cibFiles[count])),
// Archive our theme.
filePath = [theme name] + ".keyedtheme",
@@ -145,7 +144,7 @@ function buildBlendFromCibFiles(cibFiles, outputFilePath, resourcesPath)
[infoDictionary setObject:replacedFiles forKey:@"CPBundleReplacedFiles"];
[infoDictionary setObject:staticContentName forKey:@"CPBundleExecutable"];
var outputFile = new File(outputFilePath).getCanonicalFile();
var outputFile = new Packages.java.io.File(outputFilePath).getCanonicalFile();
outputFile.mkdirs();
@@ -162,7 +161,7 @@ function buildBlendFromCibFiles(cibFiles, outputFilePath, resourcesPath)
writer.close();
if (resourcesPath)
rsync(new File(resourcesPath), new File(outputFilePath));
rsync(new Packages.java.io.File(resourcesPath), new Packages.java.io.File(outputFilePath));
}
function themeFromCibFile(aFile)
+29
View File
@@ -0,0 +1,29 @@
#!/usr/bin/env ruby
require '../common'
require 'objective-j'
require 'rake'
require 'rake/clean'
require 'fileutils'
$ENVIRONMENT_NARWHAL_PRODUCT = File.join($ENVIRONMENT_DIR, 'narwhal')
$ENVIRONMENT_BROWSERJS_PRODUCT = File.join($ENVIRONMENT_NARWHAL_PRODUCT, 'packages', 'browser')
$ENVIRONMENT_NARWHAL_EXECUTABLE = File.join($ENVIRONMENT_BIN_DIR, 'narwhal')
file_d $ENVIRONMENT_NARWHAL_PRODUCT do
cp_r('narwhal', $ENVIRONMENT_NARWHAL_PRODUCT)
end
file_d $ENVIRONMENT_NARWHAL_EXECUTABLE => [$ENVIRONMENT_NARWHAL_PRODUCT] do
FileUtils.ln_s('../narwhal/bin/narwhal', $ENVIRONMENT_NARWHAL_EXECUTABLE)
end
file_d $ENVIRONMENT_BROWSERJS_PRODUCT => [$ENVIRONMENT_NARWHAL_PRODUCT] do
cp_r('browser.js', $ENVIRONMENT_BROWSERJS_PRODUCT)
end
task :build => [$ENVIRONMENT_NARWHAL_PRODUCT, $ENVIRONMENT_BROWSERJS_PRODUCT, $ENVIRONMENT_NARWHAL_EXECUTABLE]
CLOBBER.include($ENVIRONMENT_NARWHAL_PRODUCT, $ENVIRONMENT_BROWSERJS_PRODUCT, $ENVIRONMENT_NARWHAL_EXECUTABLE)
+27 -5
View File
@@ -1,13 +1,35 @@
#!/usr/bin/env ruby
require 'rake'
require '../../common'
require 'objective-j'
require 'rake'
require 'rake/clean'
$ENVIRONMENT_NARWHAL_PRODUCT = File.join($ENVIRONMENT_DIR, 'narwhal')
$ENVIRONMENT_OBJJ_PRODUCT = File.join($ENVIRONMENT_NARWHAL_PRODUCT, 'packages', 'objj')
subprojects = %w{cplutil objj objjc}
$OBJJC_JS_COMPILER = File.join($ENVIRONMENT_LIB_DIR, 'shrinksafe.jar')
%w(build clean clobber).each do |task_name|
task task_name do
subrake(subprojects, task_name)
$EXECUTABLES = ['objj', 'objjc', 'plutil']
$EXECUTABLES_PRODUCTS = $EXECUTABLES.map {|e| File.join($ENVIRONMENT_BIN_DIR, e) }
file_d $ENVIRONMENT_OBJJ_PRODUCT do
cp_r('objj', $ENVIRONMENT_OBJJ_PRODUCT)
end
$EXECUTABLES.each do |executable|
source = File.join('objj', 'bin', executable)
dest = File.join($ENVIRONMENT_BIN_DIR, executable)
file_d dest => source do
#cp(source, dest)
FileUtils.ln_s("../narwhal/packages/objj/bin/#{executable}", dest)
end
end
file_d $OBJJC_JS_COMPILER => 'shrinksafe.jar' do
cp('shrinksafe.jar', $OBJJC_JS_COMPILER)
end
task :build => [$ENVIRONMENT_OBJJ_PRODUCT, $OBJJC_JS_COMPILER].concat($EXECUTABLES_PRODUCTS)
CLOBBER.include($ENVIRONMENT_OBJJ_PRODUCT, $EXECUTABLES_PRODUCTS, $OBJJC_JS_COMPILER)
-36
View File
@@ -1,36 +0,0 @@
#!/usr/bin/env ruby
require '../../../common'
require 'objective-j'
require 'rake'
require 'rake/clean'
$CPLUTIL_SCRIPT = File.join($BUILD_DIR, 'cplutil.build', $CONFIGURATION, 'main-concat.js')
$CPLUTIL_CLASS = File.join($ENVIRONMENT_LIB_DIR, 'cplutil', 'main.class')
$CPLUTIL_EXECUTABLE = File.join($ENVIRONMENT_BIN_DIR, 'cplutil')
$STANDARD_EXECUTABLE = File.expand_path(File.join('..', 'executable'))
Files = [ File.join($HOME_DIR, 'Tools', 'Utilities', 'bridge.js'), #yuck!
File.join($HOME_DIR, 'Tools', 'Utilities', 'regex-bridge.js'), #double-yuck!
File.join($ENVIRONMENT_FRAMEWORKS_DIR, 'Objective-J', 'rhino.platform', 'Objective-J.js'),
'main.js'];
file_d $CPLUTIL_EXECUTABLE => [$STANDARD_EXECUTABLE] do
cp($STANDARD_EXECUTABLE, $CPLUTIL_EXECUTABLE)
File.chmod 0755, $CPLUTIL_EXECUTABLE
end
file_d $CPLUTIL_SCRIPT => Files do |t|
cat(Files, $CPLUTIL_SCRIPT)
end
file_d $CPLUTIL_CLASS => $CPLUTIL_SCRIPT do |t|
js2java($CPLUTIL_SCRIPT, 'main.class', false)
cp(File.join(File.dirname($CPLUTIL_SCRIPT), 'main.class'), $CPLUTIL_CLASS)
end
task :build => [$CPLUTIL_CLASS, $CPLUTIL_EXECUTABLE]
CLEAN.include(File.join($BUILD_DIR, 'cplutil.build', $CONFIGURATION))
CLOBBER.include(File.join($ENVIRONMENT_LIB_DIR, 'cplutil'), $CPLUTIL_EXECUTABLE)
-39
View File
@@ -1,39 +0,0 @@
#!/bin/bash
# get path of the executable
SELF_PATH=$(cd -P -- "$(dirname -- "$0")" && pwd -P) && SELF_PATH=$SELF_PATH/$(basename -- "$0")
# resolve symlinks
if [ -h $SELF_PATH ]; then
SELF_PATH=`readlink $SELF_PATH`
fi
SELF_DIR=`dirname $SELF_PATH`
OBJJ_HOME=`dirname $SELF_DIR`
OBJJ_LIB="$OBJJ_HOME/lib"
CLASSPATH_TMP="$OBJJ_LIB:$OBJJ_LIB/js.jar:$OBJJ_HOME/lib/$(basename $SELF_PATH)"
#OBJJ="$OBJJ_LIB/objj.js"
RLWRAP=`which rlwrap`
# if there's a "lib" directory, add all the jars from it
if [ -d "lib" ]; then
JARS=`find ./lib -name '*.jar' 2> /dev/null | tr "\n" ":"`
CLASSPATH="$JARS:$CLASSPATH"
fi
# convert paths for Cygwin
if [[ `uname` == CYGWIN* ]]; then
OBJJ_HOME=`cygpath -wp "$OBJJ_HOME"`
#OBJJ=`cygpath -wp "$OBJJ"`
CLASSPATH_TMP=`cygpath -wp "$CLASSPATH_TMP"`
CLASSPATH="$CLASSPATH_TMP;$CLASSPATH"
else
CLASSPATH="$CLASSPATH_TMP:$CLASSPATH"
fi
export OBJJ_HOME
$RLWRAP java -cp $CLASSPATH main $@
#$RLWRAP java -cp $CLASSPATH org.mozilla.javascript.tools.shell.Main $OBJJ $@
-35
View File
@@ -1,35 +0,0 @@
#!/usr/bin/env ruby
require '../../../common'
require 'objective-j'
require 'rake'
require 'rake/clean'
$OBJJ_SCRIPT = File.join($BUILD_DIR, 'objj.build', $CONFIGURATION, 'main-concat.js')
$OBJJ_CLASS = File.join($ENVIRONMENT_LIB_DIR, 'objj', 'main.class')
$OBJJ_EXECUTABLE = File.join($ENVIRONMENT_BIN_DIR, 'objj')
$STANDARD_EXECUTABLE = File.expand_path(File.join('..', 'executable'))
Files = [ File.join($HOME_DIR, 'Tools', 'Utilities', 'bridge.js'), #yuck!
File.join($ENVIRONMENT_FRAMEWORKS_DIR, 'Objective-J', 'rhino.platform', 'Objective-J.js'),
'main.js'];
file_d $OBJJ_EXECUTABLE => [$STANDARD_EXECUTABLE] do
cp($STANDARD_EXECUTABLE, $OBJJ_EXECUTABLE)
File.chmod 0755, $OBJJ_EXECUTABLE
end
file_d $OBJJ_SCRIPT => Files do |t|
cat(Files, $OBJJ_SCRIPT)
end
file_d $OBJJ_CLASS => $OBJJ_SCRIPT do |t|
js2java($OBJJ_SCRIPT, 'main.class', false)
cp(File.join(File.dirname($OBJJ_SCRIPT), 'main.class'), $OBJJ_CLASS)
end
task :build => [$OBJJ_CLASS, $OBJJ_EXECUTABLE]
CLEAN.include(File.join($BUILD_DIR, 'objj.build', $CONFIGURATION))
CLOBBER.include(File.join($ENVIRONMENT_LIB_DIR, 'objj'), $OBJJ_EXECUTABLE)
+3
View File
@@ -0,0 +1,3 @@
#!/usr/bin/env narwhal
require("objj/objj");
+12 -6
View File
@@ -1,3 +1,8 @@
#!/usr/bin/env narwhal
var objjc = require("objj/objjc");
with (objjc)
{
importPackage(java.lang);
@@ -8,7 +13,6 @@ importClass(java.io.BufferedWriter);
importClass(java.io.FileWriter);
OBJJ_PREPROCESSOR_PREPROCESS = 1 << 10;
OBJJ_PREPROCESSOR_COMPRESS = 1 << 11;
OBJJ_PREPROCESSOR_SYNTAX = 1 << 12;
@@ -55,7 +59,7 @@ function compress(/*String*/ aCode, /*Object*/ flags, /*File*/ tmpFile)
writer.close();
return exec(["java", "-jar", OBJJ_HOME + "/lib/objjc/shrinksafe.jar", "-c", tmpFile.getCanonicalPath()]);
return exec(["java", "-jar", OBJJ_HOME + "/lib/shrinksafe.jar", "-c", tmpFile.getCanonicalPath()]);
}
//#define SET_CONTEXT(aFragment, aContext) aFragment.context = aContext
@@ -179,7 +183,7 @@ function main()
outFilePaths = [],
index = 0,
count = arguments.length,
count = system.args.length,
gccArgs = [],
@@ -188,12 +192,12 @@ function main()
for (; index < count; ++index)
{
var argument = String(arguments[index]);
var argument = system.args[index];
if (argument === "-o")
{
if (++index < count)
outFilePaths.push(String(arguments[index]));
outFilePaths.push(system.args[index]);
}
else if (argument.indexOf("-D") === 0)
@@ -222,4 +226,6 @@ function main()
preprocess(filePaths[index], outFilePaths[index], gccArgs, flags);
}
main.apply(main, arguments);
main();
}
+9 -8
View File
@@ -1,3 +1,4 @@
#!/usr/bin/env narwhal
importPackage(java.lang);
@@ -15,7 +16,7 @@ function printUsage()
function main()
{
if (arguments.length < 1)
if (system.args.length < 1)
return printUsage();
var allFiles = NO,
@@ -25,11 +26,11 @@ function main()
outExtension = nil;
index = 0,
count = arguments.length;
count = system.args.length;
for (; index < count; ++index)
{
var argument = arguments[index];
var argument = system.args[index];
if (argument.charAt(0) === '-' && !allFiles)
{
@@ -37,13 +38,13 @@ function main()
return printUsage();
else if (argument === "-convert")
format = arguments[++index];
format = system.args[++index];
else if (argument === "-o")
outPath = arguments[++index];
outPath = system.args[++index];
else if (argument === "-e")
outExtension = arguments[++index];
outExtension = system.args[++index];
else if (argument === "--")
allFiles = YES;
@@ -52,7 +53,7 @@ function main()
return printUsage();
}
else
filePaths.push(arguments[index]);
filePaths.push(system.args[index]);
}
index = 0;
@@ -100,4 +101,4 @@ function main()
}
}
main.apply(main, args);
main();
+75
View File
@@ -0,0 +1,75 @@
var File = require("file");
var window = require("browser/window");
var OBJJ_HOME = system.prefix + "/..";
window.OBJJ_INCLUDE_PATHS = [OBJJ_HOME+"/lib/Frameworks/"];
if (system.env["OBJJ_INCLUDE_PATHS"])
window.OBJJ_INCLUDE_PATHS = system.env["OBJJ_INCLUDE_PATHS"].split(":").concat(window.OBJJ_INCLUDE_PATHS);
//if (system.args.length > 0)
// window.OBJJ_MAIN_FILE = String((new Packages.java.io.File(args.shift())).getAbsolutePath());
window.args = system.args;
with (window)
{
eval(File.read(OBJJ_HOME+"/lib/Frameworks/Objective-J/rhino.platform/Objective-J.js").toString());
if (system.args.length > 0)
{
while (system.args.length && system.args[0].indexOf('-I') === 0)
OBJJ_INCLUDE_PATHS = system.args.shift().substr(2).split(':').concat(OBJJ_INCLUDE_PATHS);
var mainFilePath = String((new Packages.java.io.File(args.shift())).getAbsolutePath());
objj_import(mainFilePath, YES, function() {
if (typeof main === "function")
main.apply(main, args);
});
}
else
{
var br = new Packages.java.io.BufferedReader(new Packages.java.io.InputStreamReader(Packages.java.lang.System["in"], "UTF-8"));
while (true)
{
try {
Packages.java.lang.System.out.print("objj> ");
var input = String(br.readLine()),
fragments = objj_preprocess(input, new objj_bundle(), new objj_file(), OBJJ_PREPROCESSOR_DEBUG_SYMBOLS),
count = fragments.length,
ctx = (new objj_context);
if (count == 1 && (fragments[0].type & FRAGMENT_CODE))
{
var fragment = fragments[0];
var result = eval(fragment.info);
if (result != undefined)
print(result);
}
else if (count > 0)
{
while (count--)
{
var fragment = fragments[count];
if (fragment.type & FRAGMENT_FILE)
objj_request_file(fragment.info, (fragment.type & FRAGMENT_LOCAL), NULL);
ctx.pushFragment(fragment);
}
ctx.schedule();
}
require("browser/timeout").serviceTimeouts();
} catch (e) {
print(e);
}
}
}
require("browser/timeout").serviceTimeouts();
}
+17
View File
@@ -0,0 +1,17 @@
var File = require("file");
var window = require("browser/window");
var exported = ["OBJJ_HOME", "objj_preprocess",
"FRAGMENT_FILE", "FRAGMENT_LOCAL",
"MARKER_CODE", "MARKER_IMPORT_STD", "MARKER_IMPORT_LOCAL",
"OBJJ_PREPROCESSOR_DEBUG_SYMBOLS"];
var OBJJ_HOME = system.prefix + "/..";
with (window)
{
eval(File.read(OBJJ_HOME+"/lib/Frameworks/Objective-J/rhino.platform/Objective-J.js").toString());
for (var i = 0; i < exported.length; i++)
exports[exported[i]] = eval(exported[i]);
}
-112
View File
@@ -1,112 +0,0 @@
debug = false;
args = arguments;
// FIXME: remove these Rhino/Java dependencies
var OBJJ_HOME = Packages.java.lang.System.getenv("OBJJ_HOME"); // chicken/egg problem, getenv is defined in bridge.js
/*
if (!this.window)
{
print("Loading Objective-J bridge.");
load(OBJJ_HOME+'/lib/bridge.js');
}
if (!this.objj_import)
{
print("Loading Objective-J.");
load(OBJJ_HOME+'/lib/Frameworks-Rhino/Objective-J/Objective-J.js');
}
*/
OBJJ_INCLUDE_PATHS = [OBJJ_HOME+"/lib/Frameworks"];
var OBJJ_INCLUDE_PATHS_STRING = getenv("OBJJ_INCLUDE_PATHS");
if (OBJJ_INCLUDE_PATHS_STRING)
OBJJ_INCLUDE_PATHS = OBJJ_INCLUDE_PATHS_STRING.split(":").concat(OBJJ_INCLUDE_PATHS);
try
{
if (args.length > 0)
{
// Convert all arguments to JavaScript-style Strings.
var count = args.length;
while (count--)
args[count] = String(args[count]);
while (args.length && args[0].indexOf('-I') === 0)
OBJJ_INCLUDE_PATHS = args.shift().substr(2).split(':').concat(OBJJ_INCLUDE_PATHS);
}
if (args.length > 0)
{
// Grab the location of the objj file to run.
var mainFilePath = args.shift();
// convert from relative to absolute path
if (this.Packages)
mainFilePath = String((new Packages.java.io.File(mainFilePath)).getAbsolutePath());
if (debug)
print("Loading: " + mainFilePath);
objj_import(mainFilePath, YES, function() { if (typeof main === "function") main.apply(main, args); } );
serviceTimeouts();
if (debug)
print("Done!");
}
else if (typeof objj_console != "undefined")
{
if (debug)
print("Starting Objective-J console.");
objj_console();
}
else
{
print("Error: No file provided or console available.")
}
}
catch (e)
{
print("OBJJ EXCEPTION: " + e);
print(" Name: " + e.name);
print(" Message: " + e.message);
print(" File: " + e.fileName);
print(" Line: " + e.lineNumber);
if (e.javaException)
{
print(" Java Exception: " + e.javaException);
e.javaException.printStackTrace();
}
if (e.rhinoException)
{
print(" Rhino Exception: " + e.rhinoException);
print(" *** Message: " + e.rhinoException.getMessage());
print(" *** Source name: " + e.rhinoException.sourceName());
print(" *** Line number: " + e.rhinoException.lineNumber());
print(" *** Column number: " + e.rhinoException.columnNumber());
print(" *** Line Source: " + e.rhinoException.lineSource());
// print the JavaScript stack trace with line numbers:
print(" *** Filtered stack trace:");
var bos = new Packages.java.io.ByteArrayOutputStream();
e.rhinoException.printStackTrace(new Packages.java.io.PrintStream(bos));
var stack = String(bos.toString()).split("\n").slice(1);
for (var i = 0; i < stack.length; i++) {
var match;
if (match = stack[i].match(/_c[0-9]+\((.+)\)/))
print(match[1]);
}
print(" *** Script stack trace:\n" + e.rhinoException.getScriptStackTrace());
print(" *** Raw stack trace:");
e.rhinoException.printStackTrace();
}
}
+6
View File
@@ -0,0 +1,6 @@
{
"author": "Tom Robinson",
"dependencies": [],
"js": "lib",
"jars": "jars/"
}
-41
View File
@@ -1,41 +0,0 @@
#!/usr/bin/env ruby
require '../../../common'
require 'objective-j'
require 'rake'
require 'rake/clean'
$OBJJC_SCRIPT = File.join($BUILD_DIR, 'objjc.build', $CONFIGURATION, 'main-concat.js')
$OBJJC_CLASS = File.join($ENVIRONMENT_LIB_DIR, 'objjc', 'main.class')
$OBJJC_JS_COMPILER = File.join($ENVIRONMENT_LIB_DIR, 'objjc', 'shrinksafe.jar')
$OBJJC_EXECUTABLE = File.join($ENVIRONMENT_BIN_DIR, 'objjc')
$STANDARD_EXECUTABLE = File.expand_path(File.join('..', 'executable'))
Files = [ File.join($HOME_DIR, 'Tools', 'Utilities', 'bridge.js'), #yuck!
File.join($HOME_DIR, 'Tools', 'Utilities', 'regex-bridge.js'), #double-yuck!
File.join($ENVIRONMENT_FRAMEWORKS_DIR, 'Objective-J', 'rhino.platform', 'Objective-J.js'),
'main.js'];
file_d $OBJJC_EXECUTABLE => [$STANDARD_EXECUTABLE] do
cp($STANDARD_EXECUTABLE, $OBJJC_EXECUTABLE)
File.chmod 0755, $OBJJC_EXECUTABLE
end
file_d $OBJJC_SCRIPT => Files do
cat(Files, $OBJJC_SCRIPT)
end
file_d $OBJJC_CLASS => $OBJJC_SCRIPT do
js2java($OBJJC_SCRIPT, 'main.class', false)
cp(File.join(File.dirname($OBJJC_SCRIPT), 'main.class'), $OBJJC_CLASS)
end
file_d $OBJJC_JS_COMPILER => 'shrinksafe.jar' do
cp('shrinksafe.jar', $OBJJC_JS_COMPILER)
end
task :build => [$OBJJC_CLASS, $OBJJC_EXECUTABLE, $OBJJC_JS_COMPILER]
CLEAN.include(File.join($BUILD_DIR, 'objjc.build', $CONFIGURATION))
CLOBBER.include(File.join($ENVIRONMENT_LIB_DIR, 'objjc'), $OBJJC_EXECUTABLE)
File renamed without changes.
+2 -2
View File
@@ -158,8 +158,8 @@ function fragment_evaluate_code(aFragment)
try
{
#if RHINO
//compiled = eval("function(){"+GET_CODE(aFragment)+"}");
compiled = Packages.org.mozilla.javascript.Context.getCurrentContext().compileFunction(window, "function(){"+GET_CODE(aFragment)+"}", GET_FILE(aFragment).path, 0, null);
compiled = eval("function(){"+GET_CODE(aFragment)+"}");
//compiled = Packages.org.mozilla.javascript.Context.getCurrentContext().compileFunction(window, "function(){"+GET_CODE(aFragment)+"}", GET_FILE(aFragment).path, 0, null);
#else
compiled = new Function(GET_CODE(aFragment));
compiled.displayName = GET_FILE(aFragment).path;
-5
View File
@@ -279,10 +279,6 @@ function CPPropertyListCreateFromXMLData(XMLNodeOrData)
if (XMLNode.string)
{
#if RHINO
XMLNode = DOCUMENT_ELEMENT(_documentBuilder.parse(
new Packages.org.xml.sax.InputSource(new Packages.java.io.StringReader(XMLNode.string))));
#else
if (window.ActiveXObject)
{
XMLNode = new ActiveXObject("Microsoft.XMLDOM");
@@ -290,7 +286,6 @@ function CPPropertyListCreateFromXMLData(XMLNodeOrData)
}
else
XMLNode = DOCUMENT_ELEMENT(new DOMParser().parseFromString(XMLNodeOrData.string, "text/xml"));
#endif
}
// Skip over DOCTYPE and so forth.
+3 -1
View File
@@ -5,7 +5,7 @@ require 'rake'
require 'rake/clean'
subprojects = %w{Objective-J Foundation AppKit Tools}
subprojects = %w{External Objective-J Foundation AppKit Tools External/ojunit}
%w(build clean clobber).each do |task_name|
task task_name do
@@ -82,6 +82,8 @@ task :test => [:build] do
puts "tests failed, aborting the build"
puts build_result
rake abort
else
puts build_result
end
end
+1 -2
View File
@@ -3,8 +3,7 @@
require 'rake'
require '../common'
subprojects = %w{bake capp nib2cib press ojunit}
subprojects = %w{capp bake nib2cib press}
%w(build clean clobber).each do |task_name|
task task_name do
+106 -28
View File
@@ -1,6 +1,3 @@
importClass(java.lang.System);
importClass(java.io.File);
importClass(java.io.FileWriter);
importClass(java.io.FileOutputStream);
importClass(java.io.BufferedWriter);
@@ -10,11 +7,11 @@ importClass(java.io.OutputStreamWriter);
function main()
{
if (arguments.length < 1)
if (system.args.length < 1)
return printUsage();
var index = 0,
count = arguments.length,
count = system.args.length,
shouldSymbolicallyLink = false,
justFrameworks = false,
@@ -24,9 +21,9 @@ function main()
for (; index < count; ++index)
{
var argument = arguments[index];
var argument = system.args[index];
switch (arguments[index])
switch (system.args[index])
{
case "-l": shouldSymbolicallyLink = true;
break;
@@ -36,7 +33,7 @@ function main()
return;
case "-t":
case "--template": template = arguments[++index];
case "--template": template = system.args[++index];
break;
case "-f":
@@ -47,8 +44,8 @@ function main()
}
}
var sourceTemplate = new File(OBJJ_HOME + "/lib/capp/Resources/Templates/" + template),
destinationProject = new File(destination);
var sourceTemplate = new java.io.File(OBJJ_HOME + "/lib/capp/Resources/Templates/" + template),
destinationProject = new java.io.File(destination);
if (!destinationProject.exists())
{
@@ -79,43 +76,43 @@ function main()
function createFrameworksInFile(/*File*/ aFile, /*Boolean*/ shouldSymbolicallyLink)
{
var destinationFrameworks = new File(aFile.getCanonicalPath()+ "/Frameworks"),
destinationDebugFrameworks = new File(aFile.getCanonicalPath() + "/Frameworks/Debug");
var destinationFrameworks = new java.io.File(aFile.getCanonicalPath()+ "/Frameworks"),
destinationDebugFrameworks = new java.io.File(aFile.getCanonicalPath() + "/Frameworks/Debug");
if (!shouldSymbolicallyLink)
{
var sourceFrameworks = new File(OBJJ_HOME + "/lib/Frameworks");
var sourceFrameworks = new java.io.File(OBJJ_HOME + "/lib/Frameworks");
exec(["cp", "-vR", sourceFrameworks.getCanonicalPath(), destinationFrameworks.getCanonicalPath()], true);
return true;
}
var STEAM_BUILD = System.getenv("STEAM_BUILD");
var STEAM_BUILD = system.env("STEAM_BUILD");
// Release Frameworks
new File(destinationFrameworks).mkdir();
new java.io.File(destinationFrameworks).mkdir();
exec(["ln", "-s", new File(STEAM_BUILD + "/Release/Objective-J").getCanonicalPath(),
new File(aFile.getCanonicalPath() + "/Frameworks/Objective-J").getCanonicalPath()], true);
exec(["ln", "-s", new java.io.File(STEAM_BUILD + "/Release/Objective-J").getCanonicalPath(),
new java.io.File(aFile.getCanonicalPath() + "/Frameworks/Objective-J").getCanonicalPath()], true);
exec(["ln", "-s", new File(STEAM_BUILD + "/Release/Foundation").getCanonicalPath(),
new File(aFile.getCanonicalPath() + "/Frameworks/Foundation").getCanonicalPath()], true);
exec(["ln", "-s", new java.io.File(STEAM_BUILD + "/Release/Foundation").getCanonicalPath(),
new java.io.File(aFile.getCanonicalPath() + "/Frameworks/Foundation").getCanonicalPath()], true);
exec(["ln", "-s", new File(STEAM_BUILD + "/Release/AppKit").getCanonicalPath(),
new File(aFile.getCanonicalPath() + "/Frameworks/AppKit").getCanonicalPath()], true);
exec(["ln", "-s", new java.io.File(STEAM_BUILD + "/Release/AppKit").getCanonicalPath(),
new java.io.File(aFile.getCanonicalPath() + "/Frameworks/AppKit").getCanonicalPath()], true);
// Debug Frameworks
new File(destinationDebugFrameworks).mkdir();
new java.io.File(destinationDebugFrameworks).mkdir();
exec(["ln", "-s", new File(STEAM_BUILD + "/Debug/Objective-J").getCanonicalPath(),
new File(aFile.getCanonicalPath() + "/Frameworks/Debug/Objective-J").getCanonicalPath()], true);
exec(["ln", "-s", new java.io.File(STEAM_BUILD + "/Debug/Objective-J").getCanonicalPath(),
new java.io.File(aFile.getCanonicalPath() + "/Frameworks/Debug/Objective-J").getCanonicalPath()], true);
exec(["ln", "-s", new File(STEAM_BUILD + "/Debug/Foundation").getCanonicalPath(),
new File(aFile.getCanonicalPath() + "/Frameworks/Debug/Foundation").getCanonicalPath()], true);
exec(["ln", "-s", new java.io.File(STEAM_BUILD + "/Debug/Foundation").getCanonicalPath(),
new java.io.File(aFile.getCanonicalPath() + "/Frameworks/Debug/Foundation").getCanonicalPath()], true);
exec(["ln", "-s", new File(STEAM_BUILD + "/Debug/AppKit").getCanonicalPath(),
new File(aFile.getCanonicalPath() + "/Frameworks/Debug/AppKit").getCanonicalPath()], true);
exec(["ln", "-s", new java.io.File(STEAM_BUILD + "/Debug/AppKit").getCanonicalPath(),
new java.io.File(aFile.getCanonicalPath() + "/Frameworks/Debug/AppKit").getCanonicalPath()], true);
}
function printUsage()
@@ -136,3 +133,84 @@ function writeContentsToFile(/*String*/ aString, /*File*/ aFile)
writer.close();
}
function exec(/*Array*/ command, /*Boolean*/ showOutput)
{
var line = "",
output = "",
process = Packages.java.lang.Runtime.getRuntime().exec(command),//jsArrayToJavaArray(command));
reader = new Packages.java.io.BufferedReader(new Packages.java.io.InputStreamReader(process.getInputStream()));
while (line = reader.readLine())
{
if (showOutput)
Packages.java.lang.System.out.println(line);
output += line + '\n';
}
reader = new Packages.java.io.BufferedReader(new Packages.java.io.InputStreamReader(process.getErrorStream()));
while (line = reader.readLine())
Packages.java.lang.System.out.println(line);
try
{
if (process.waitFor() != 0)
Packages.java.lang.System.err.println("exit value = " + process.exitValue());
}
catch (anException)
{
Packages.java.lang.System.err.println(anException);
}
return output;
}
function getFiles(/*File*/ sourceDirectory, /*nil|String|Array<String>*/ extensions, /*Array*/ exclusions)
{
var matches = [],
files = sourceDirectory.listFiles(),
hasMultipleExtensions = typeof extensions !== "string";
if (files)
{
var index = 0,
count = files.length;
for (; index < count; ++index)
{
var file = files[index].getCanonicalFile(),
name = String(file.getName()),
isValidExtension = !extensions;
if (exclusions && fileArrayContainsFile(exclusions, file))
continue;
if (!isValidExtension)
if (hasMultipleExtensions)
{
var extensionCount = extensions.length;
while (extensionCount-- && !isValidExtension)
{
var extension = extensions[extensionCount];
if (name.substring(name.length - extension.length - 1) === ("." + extension))
isValidExtension = true;
}
}
else if (name.substring(name.length - extensions.length - 1) === ("." + extensions))
isValidExtension = true;
if (isValidExtension)
matches.push(file);
if (file.isDirectory())
matches = matches.concat(getFiles(file, extensions, exclusions));
}
}
return matches;
}
+1 -1
View File
@@ -36,7 +36,7 @@ CPLogRegister(CPLogPrint);
function exec(command)
{
var p = Packages.java.lang.Runtime.getRuntime().exec(jsArrayToJavaArray(command));
var p = Packages.java.lang.Runtime.getRuntime().exec(command);
var result = p.waitFor();
var reader = new Packages.java.io.BufferedReader(new Packages.java.io.InputStreamReader(p.getInputStream()));
+3 -29
View File
@@ -77,40 +77,14 @@ end
def subrake(directories, task_name)
directories.each do |directory|
if (File.directory?(directory) && File.file?(File.join(directory, "Rakefile")))
system %{cd #{directory} && #{$serialized_env} #{$0} #{task_name}}
ok = system(%{cd #{directory} && #{$serialized_env} #{$0} #{task_name}})
rake abort unless ok
else
puts "warning: subrake missing: " + directory +" (this is not necessarily an error, "+directory+" may be optional)"
end
end
end
# Shared Resrouces in env
$JSJAR_PATH = File.expand_path(File.join($HOME_DIR, 'Tools/Utilities/js.jar'))
$ENVIRONMENT_JS = File.join($ENVIRONMENT_LIB_DIR, 'js.jar')
file_d $ENVIRONMENT_JS do
cp($JSJAR_PATH, $ENVIRONMENT_JS)
end
def js2java(inputfile, className, debug)
debugString = '-nosource -debug' if debug
IO.popen("java -classpath #{$JSJAR_PATH}:. #{debugString} org.mozilla.javascript.tools.jsc.Main -o #{className} #{inputfile}") do |shrinksafe|
puts shrinksafe.read
end
end
def cat(files, outfile)
File.open(outfile, "w") do |concated|
files.each do |file|
concated.write IO.read(file)
end
end
end
def executable_exists?(name)
ENV["PATH"].split(":").any? {|p| File.executable? File.join(p, name) }
end
@@ -122,7 +96,7 @@ def make_objj_executable(path)
File.chmod 0755, path
end
task :build => [$ENVIRONMENT_JS]
task :build
task :default => [:build]
task :release do