From 85c68f78dad0e8654b9405a88221b3e6325d5898 Mon Sep 17 00:00:00 2001 From: Tom Robinson Date: Wed, 6 Jan 2010 20:00:37 -0800 Subject: [PATCH] Update for compatibility with latest narwhal. Switch back to 280north/narwhal --- Objective-J/CommonJS/lib/objective-j.js | 8 +++++--- bootstrap.sh | 14 +++++++++----- common.jake | 12 ++++++++---- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/Objective-J/CommonJS/lib/objective-j.js b/Objective-J/CommonJS/lib/objective-j.js index 5927271db..26f848c11 100644 --- a/Objective-J/CommonJS/lib/objective-j.js +++ b/Objective-J/CommonJS/lib/objective-j.js @@ -62,12 +62,14 @@ if (system.env["OBJJ_INCLUDE_PATHS"]) // TODO: somehow make window object the top scope? with (window) { + var objectivejSource = FILE.read(objectivejPath, { charset:"UTF-8" }); + // read and eval Objective-J.js with the module's scope if (system.engine === "rhino") - Packages.org.mozilla.javascript.Context.getCurrentContext().evaluateString(window, FILE.read(objectivejPath, { charset:"UTF-8" }), "Objective-J.js", 0, null); + Packages.org.mozilla.javascript.Context.getCurrentContext().evaluateString(window, objectivejSource, objectivejPath, 0, null); else - eval(FILE.read(objectivejPath, { charset:"UTF-8" })); - + eval(objectivejSource); + // export desired variables. must eval variable name to obtain a reference. [ "objj_preprocess", diff --git a/bootstrap.sh b/bootstrap.sh index 9ffc511ee..124c2dbdc 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -16,7 +16,7 @@ function prompt () { } function which () { - echo "$PATH" | tr ":" "\n" | while read line; do [ -f "$line/$1" ] && echo "$line/$1" && return 0; done + echo "$PATH" | tr ":" "\n" | while read line; do [ -x "$line/$1" ] && echo "$line/$1" && return 0; done } function ask_remove_dir () { @@ -66,7 +66,7 @@ else tusk_install_command="install" fi -github_project="tlrobinson-narwhal" +github_project="280north-narwhal" github_path=$(echo "$github_project" | tr '-' '/') install_directory="/usr/local/narwhal" tmp_zip="/tmp/narwhal.zip" @@ -123,7 +123,7 @@ if ! prompt; then exit 1 fi -echo "Installing necessary dependencies..." +echo "Installing necessary packages..." if ! tusk update; then echo "Error: unable to update tusk catalog. Check that you have sufficient permissions." @@ -138,9 +138,13 @@ if [ `uname` = "Darwin" ]; then echo "This is optional but will make building and running Objective-J much faster." if prompt; then tusk $tusk_install_command narwhal-jsc - (cd "$install_directory/packages/narwhal-jsc" && make webkit) - if ! [ "$NARWHAL_ENGINE" = "jsc" ]; then + if ! (cd "$install_directory/packages/narwhal-jsc" && make webkit); then + echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" + echo "WARNING: building narwhal-jsc failed. Hit enter to continue." + echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" + read + elif ! [ "$NARWHAL_ENGINE" = "jsc" ]; then echo "================================================================================" echo "Rhino is the default Narwhal engine, should we change the default to JavaScriptCore for you?" echo "This can by overridden by setting the NARWHAL_ENGINE environment variable to \"jsc\" or \"rhino\"." diff --git a/common.jake b/common.jake index 2cd240707..237aa161d 100644 --- a/common.jake +++ b/common.jake @@ -7,10 +7,14 @@ function ensurePackageUpToDate(packageName, requiredVersion) print("You are missing package \"" + packageName + "\", version " + requiredVersion + " or later. Please install using \"tusk install "+packageName+"\" and re-run jake"); require("os").exit(1); } - - var version = packageInfo.version; - if (version && require("util").compare(version.split("."), requiredVersion.split(".")) !== -1) + // newer versions of packages provide already split versions + var version = typeof packageInfo.version === "string" ? packageInfo.version.split(".") : packageInfo; + + if (typeof requiredVersion === "string") + requiredVersion = requiredVersion.split("."); + + if (version && require("util").compare(version, requiredVersion) !== -1) return; print("Your copy of " + packageName + " is out of date (version " + version + "). Update? yes or no:"); @@ -28,7 +32,7 @@ function ensurePackageUpToDate(packageName, requiredVersion) // UPDATE THESE TO PICK UP CORRESPONDING CHANGES IN DEPENDENCIES ensurePackageUpToDate("jake", "0.1.1"); -ensurePackageUpToDate("browserjs", "0.1"); +ensurePackageUpToDate("browserjs", "0.1.1"); var Jake = require("jake");