scripts: Create functions file in lib/ocarina/

Makes it easier to install and keeps functions separate from the ocarina
commands.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
Bryan Schumaker 2012-05-28 10:43:13 -04:00
parent de5cdc1cbc
commit bba2989866
5 changed files with 40 additions and 34 deletions

1
.gitignore vendored
View File

@ -3,4 +3,5 @@
*.tar.gz
.sconsign.dblite
bin/
lib/
include/version.h

View File

@ -1,3 +1,3 @@
#!/bin/bash
. `dirname $0`/ocarina
. `dirname $0`/../lib/ocarina/functions
write_to_pipe "play"

View File

@ -2,7 +2,8 @@
import os, re
Import( "env", "DEBUG" )
bin = os.path.abspath("../bin/%s")
bin = "../bin/%s"
lib = "../lib/ocarina/%s"
def create_script(target, source, env):
dst = str(target[0].rfile())
@ -25,7 +26,10 @@ for file in os.listdir("."):
elif file[0] == ".":
continue
dst = (bin % file).replace("%APP", "ocarina")
dir = bin
if file == "functions":
dir = lib
dst = (dir % file).replace("%APP", "ocarina")
files.append(env.Command(dst, file, create_script))
Return('files')

25
scripts/functions Normal file
View File

@ -0,0 +1,25 @@
#!/bin/bash
DEBUG=%DEBUG
function get_app_dir
{
dir="$HOME/.%APP"
if [ "$DEBUG" == "True" ]; then
dir="$dir-debug"
fi
echo $dir
}
function write_to_pipe
{
pipe=`get_app_dir`/pipe
if [ ! -p $pipe ]; then
exit 0
fi
file=`mktemp`
echo "$*" > $file
echo $file > $pipe
rm -f $file
}

View File

@ -1,33 +1,9 @@
#!/bin/bash
DEBUG=%DEBUG
function get_app_dir
{
dir="$HOME/.%APP"
if [ "$DEBUG" == "True" ]; then
dir="$dir-debug"
fi
echo $dir
}
function write_to_pipe
{
pipe=`get_app_dir`/pipe
if [ ! -p $pipe ]; then
exit 0
fi
file=`mktemp`
echo "$*" > $file
echo $file > $pipe
rm -f $file
}
#cmd=`which %%OCARINA%%-$1 2>/dev/null`
#args="${@: +2}"
#if [ "$cmd" ]; then
# $cmd "$args"
#else
# %%BIN%% "$*"
#fi
cmd=`which %%OCARINA%%-$1 2>/dev/null`
args="${@: +2}"
if [ "$cmd" ]; then
$cmd "$args"
else
%%BIN%% "$*"
fi