From: R. Steve McKown Date: Thu, 3 Dec 2009 20:45:13 +0000 (-0700) Subject: Add tinyos.sh, a utility for changing the active tree (TOSROOT). X-Git-Tag: release/2.1.0-3~1 X-Git-Url: https://oss.titaniummirror.com/gitweb/?p=tinyos-2.x.git;a=commitdiff_plain;h=cb67b07e45b82cc600d70b3eff793e8c4120a08a Add tinyos.sh, a utility for changing the active tree (TOSROOT). --- diff --git a/tinyos.sh b/tinyos.sh new file mode 100644 index 00000000..20814c4e --- /dev/null +++ b/tinyos.sh @@ -0,0 +1,43 @@ +#! /usr/bin/env bash +# Here we setup the environment +# variables needed by the tinyos +# make system + +TOSBASE=/opt/tinyos + +# $1 is a directory or tos version number +# returns a fully rooted and valid TOSROOT +getdir() +{ + if [ -d "$1" -a -d "$1/tos" ]; then + echo "$1" + elif [ -d "$TOSBASE/$1" -a -d "$TOSBASE/$1/tos" ]; then + echo "$TOSBASE/$1" + fi +} + +# Clear TOS environment +if [ -n "$TOSROOT" ]; then + CLASSPATH=$(echo $CLASSPATH | sed -e "s|:$TOSROOT/support/sdk/java||") +fi +unset TOSDIR MAKERULES + +# Set TOS environment +TOSROOT=$(getdir "$1") +if [ -z "$TOSROOT" ]; then + TOSROOT=$(cat ~/.tosrc 2>/dev/null) +fi + +if [ -z "$TOSROOT" ]; then + echo "No TinyOS source directory found. Usage:" >&2 + echo "source /opt/tinyos/tinyos.sh [ | ]" >&2 + export TOSROOT TOSDIR MAKERULES +else + echo "Setting up for TinyOS source in $TOSROOT" + echo "$TOSROOT" > ~/.tosrc + TOSDIR="$TOSROOT/tos" + CLASSPATH=$CLASSPATH:$TOSROOT/support/sdk/java + MAKERULES="$TOSROOT/support/make/Makerules" + export TOSROOT TOSDIR CLASSPATH MAKERULES +fi +unset TOSBASE tmp