Permalink
Browse files

platform selection via SH script

  • Loading branch information...
1 parent e436bf0 commit a9d26538d503526eea86b5ce349d5e163fd9dc09 @cadorn cadorn committed Sep 29, 2011
Showing with 28 additions and 13 deletions.
  1. +2 −0 docs/Demos.md
  2. +7 −3 lib/pinf-loader-js/loader.js
  3. +19 −10 pinf-loader.sh
View
@@ -9,6 +9,8 @@ These demos work on the following platforms:
* NodeJS (default): `node` (**Tested**)
* Narwhal: `narwhal` (**Not tested lately**)
* RingoJS: `ringo` (**Not tested yet**)
+ * RingoJS: `gpsee` (**Not tested yet**)
+ * RingoJS: `v8cgi` (**Not tested yet**)
To use a specific platform specify `--platform <alias>`. `node` is used by default.
@@ -3,7 +3,7 @@
var boot = exports.boot = function(options)
{
- const VERSION = "0.2.9";
+ const VERSION = "0.2.10";
var timers = {
start: new Date().getTime(),
loadAdditional: 0
@@ -207,6 +207,9 @@ var boot = exports.boot = function(options)
var knownCliPlatforms = [
"node",
+ "gsr",
+ "v8cgi",
+ "ringo",
"narwhal"
];
@@ -253,8 +256,9 @@ var boot = exports.boot = function(options)
else
if (typeof cliOptions.platform != "undefined" && cliOptions.platform != API.ENV.platform)
{
- spawnForPlatform(cliOptions.platform);
- return;
+ // Do nothing! `./pinf-loader.sh` already directed arguments to correct binary.
+// spawnForPlatform(cliOptions.platform);
+// return;
}
function run()
View
@@ -1,15 +1,24 @@
#!/bin/bash
-# TODO: Check --platform to invoke correct platform binary.
-# For now we let the loader check and have node spawn a process if needed.
-# Need to check for `node`, `gsr` (gpsee) and `ringo` to realize: https://github.com/pinf/test-programs-js
-
BASE_PATH=$(dirname $(readlink $0))
-NODE_PATH=$(which "node")
+# TODO: Only match until first non-option argument is found. i.e. argument not prefixed by '-'
+PLATFORM_ALIAS=$(echo "$@" | perl -lpe '($_) = /\s*--platform\s*(\S*)\s*/')
+PLATFORM_BIN_NAME=$PLATFORM_ALIAS
+
+if [ "$PLATFORM_ALIAS" = "gpsee" ]; then
+ PLATFORM_BIN_NAME="gsr"
+fi
-if [ "$NODE_PATH" ]; then
- exec "$NODE_PATH" "$BASE_PATH/pinf-loader.js" "$@"
-else
- echo "ERROR: Need NodeJS installed. 'node' must be on the PATH."
- exit 1
+if [ -z $PLATFORM_BIN_NAME ]; then
+ PLATFORM_ALIAS="node"
+ PLATFORM_BIN_NAME="node"
fi
+
+PLATFORM_BIN_PATH=$(which "$PLATFORM_BIN_NAME")
+
+if [ -z $PLATFORM_BIN_PATH ]; then
+ echo "Fatal Error: No binary '$PLATFORM_BIN_NAME' found for '--platform $PLATFORM_ALIAS' on PATH '$PATH'!"
+ exit 1;
+fi
+
+exec "$PLATFORM_BIN_PATH" "$BASE_PATH/pinf-loader.js" "$@"

0 comments on commit a9d2653

Please sign in to comment.