git.haldean.org droidcopter / master run
master

Tree @master (Download .tar.gz)

run @masterraw · history · blame

#!/bin/bash

if [ -z "${ANDROIDPATH}" ]; then
    if [ `hostname` == "alux" ]; then
	export ANDROID_ROOT='/usr/share/android'
	export LINKOFFLINE="-linkoffline $ANDROID_ROOT/docs/reference $ANDROID_ROOT/docs/reference"
	export WORLDWIND_DOCS='-linkoffline /usr/share/doc/worldwind-doc /usr/share/doc/worldwind-doc'
    else
	export ANDROID_ROOT='/usr/share/bin/android-sdk-linux_86'
	export LINKOFFLINE="-linkoffline http://developer.android.com/reference/ $ANDROID_ROOT/docs/reference"
    fi
fi

export ANDROIDPATH="$ANDROID_ROOT/platforms/android-8/android.jar"
export CLASSPATH=$ANDROIDPATH:$CLASSPATH:./lib/simplegraph/:`ls -1 jars/*.jar jars/worldwind/*.jar | xargs | sed "s/ /:/g"`:/usr/share/java/j3dcore.jar:/usr/share/java/j3dutils.jar:/usr/share/java/vecmath.jar:.:/usr/lib/jvm/java-7-openjdk/jre/lib/ext/j3dcore.jar:/usr/lib/jvm/java-7-openjdk/jre/lib/ext/j3dutils.jar:/usr/lib/jvm/java-7-openjdk/jre/lib/ext/vecmath.jar:
export PORT=7000

if [ 'heartless' == "$1" ] || [ 'heartless' == "$2" ]; then
    export HEARTLESS='heartless'
fi

OSNAME=`uname`

if [ 'Linux' == "$OSNAME" ]; then
    DOCK=
else
    DOCK='-Xdock:icon=img/logo.png -Xdock:name=HorizonServer'
fi


clean() {
    echo "Clean old classfiles and backup files" 1>&2
    rm -f org/haldean/{chopper/server{/nav,},blob}/*.{class,java\~}
}

run() {
    CMD="java -Djava.library.path=/lib/:jars/worldwind/:jars/ -Xmx512m
	-Dsun.java2d.noddraw=true $DOCK org.haldean.chopper.server.ServerCreator
	host=$HOST port=$PORT $DEBUG $HEARTLESS pidlog=pidlog.txt imgdir=video/
        debuglog=debug.txt"
    echo $CMD
    exec $CMD
}

doc() {
    javadoc -author -version -d doc/ $LINKOFFLINE $WORLDWIND_DOCS \
	-classpath $CLASSPATH -sourcepath . -windowtitle "Robocopter Documentation" \
	`ls -d org/haldean/chopper/*/ | sed "s/[\/]*$//" | sed "s/\//./g" | xargs`
}

check() {
    checkstyle -c style-checks.xml -r org/ -o doc/check-results.txt
}

build() {
    javac org/haldean/chopper/server/ServerCreator.java -Xlint:deprecation -encoding ISO-8859-1
}

keyboard() {
    echo "Enabling keyboard. You may be asked to input your password."
    echo "The command about to be run is 'sudo chmod o+r /dev/input/*'"
    echo "This will add read priveleges to all input devices for all users."
    echo "To revert after running, run 'sudo chmod o-r /dev/input/*'."
    sudo chmod o+r /dev/input/*
}

if [ 'clean' == "$1" ]; then
    clean
    exit
fi

if [ 'pack' == "$1" ]; then
    echo "Creating archive" 1>&2
    tar -czf server.tar.gz org unit
elif [ 'enable-keyboard' == "$1" ]; then
    keyboard
elif [ 'doc' == "$1" ]; then
    doc
elif [ 'open-doc' == "$1" ]; then
    doc
    gnome-open doc/index.html &> /dev/null
elif [ 'check' == "$1" ]; then
    clean
    check
elif [ 'nobuild' == "$1" ]; then
    if [ '' == "$2" ]; then 
#	export HOST=droidcopter.cs.columbia.edu
	export HOST=192.168.168.65
    else 
	export HOST=$2
    fi

    run
elif [ 'build' == "$1" ]; then
    clean
    build
else
    clean
    
    if [ '' == "$1" ]; then 
#	export HOST='droidcopter.cs.columbia.edu'
	export HOST='192.168.168.65'
    else 
	export HOST=$1
    fi
  
    build && echo "Compiled" 1>&2 && run
fi