Created
September 13, 2015 10:10
-
-
Save zwetan/97cf1838f4d3d72bbc93 to your computer and use it in GitHub Desktop.
redshell bash script to place in the redtamarin-sdk bin folder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function follow_links() { | |
file="$1" | |
while [ -h "$file" ]; do | |
# On Mac OS, readlink -f doesn't work. | |
file="$(readlink "$file")" | |
done | |
echo "$file" | |
} | |
# Unlike $0, $BASH_SOURCE points to the absolute path of this file. | |
PROG_NAME="$(follow_links "$BASH_SOURCE")" | |
# Handle the case where dart-sdk/bin has been symlinked to. | |
CUR_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)" | |
UNAME="$(uname)" | |
BITS="32" | |
EXT="" | |
# REDTAMARIN_SDK env var not found | |
if [ -z "$REDTAMARIN_SDK" ]; then | |
REDTAMARIN_SDK="$(dirname "$CUR_DIR")"; | |
fi | |
if [ $UNAME == "Darwin" ]; then | |
OS="macintosh"; | |
elif [ $UNAME == "Linux" ]; then | |
OS="linux" | |
elif [ "$(uname -o)" == "Cygwin" ]; then | |
#elif [ "$(uname -s)" == CYGWIN* ]; then | |
OS="windows" | |
EXT=".exe" | |
fi | |
if [ "$(uname -m)" == "x86_64" ]; then | |
BITS="64" | |
fi | |
# runtimes/redshell/macintosh/64/redshell | |
BIN="$REDTAMARIN_SDK/runtimes/redshell/$OS/$BITS/redshell$EXT" | |
# Usage: | |
# $ redshell -h [avmplus options] | |
# $ redshell filename[.as/.abc/.swf] [optional arguments] | |
FILE_NAME=$1 | |
shift | |
# You can configure the redshell per script with a config file | |
# named like the filename and adding the extension .config | |
# ex: | |
# $ redshell test.as | |
# test.as.config | |
CONFIG_NAME="${FILE_NAME}.config" | |
# You can also dynamically configure by defining | |
# the env var REDSHELL_CONFIG | |
# ex: | |
# $ export REDSHELL_CONFIG="-swfversion 14"; redshell test.as | |
# By default we use the redshell without any config | |
CONFIG="" | |
#echo "PROG_NAME=$PROG_NAME"; | |
#echo "CUR_DIR=$CUR_DIR"; | |
#echo "REDTAMARIN_SDK=$REDTAMARIN_SDK"; | |
#echo "OS=$OS"; | |
#echo "BITS=$BITS" | |
#echo "BIN=$BIN"; | |
#echo "FILE_NAME=$FILE_NAME" | |
#echo "CONFIG_NAME=$CONFIG_NAME"; | |
#echo "REDSHELL_CONFIG=$REDSHELL_CONFIG" | |
if [ -z "$FILE_NAME" ]; then | |
echo "You need to provide a filename, eg. 'redshell filename.as'" | |
exit 1 | |
elif [ "$FILE_NAME" == "-h" ]; then | |
exec "$BIN" $@; | |
exit 1 | |
fi | |
if [ -e "$CONFIG_NAME" ]; then | |
CONFIG="$(<$CONFIG_NAME)" | |
elif [ -z "$REDSHELL_CONFIG}" ]; then | |
# config env var not found | |
: | |
else | |
CONFIG="${REDSHELL_CONFIG}" | |
fi | |
#echo "CONFIG=$CONFIG" | |
if [ -z "$CONFIG" ]; then | |
exec "$BIN" ${FILE_NAME} -- $@; | |
else | |
exec "$BIN" $CONFIG ${FILE_NAME} -- $@; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment