scripts: Create an %APP-play for sending play commands
I'm currently using the "ocarina" script as a functions file, but this will change eventually. Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
62c3ef2684
commit
d6dff5290f
29
Sconstruct
29
Sconstruct
|
@ -26,13 +26,14 @@ if ARGUMENTS.get('VERBOSE') != "1":
|
||||||
env.Append(LINKCOMSTR = "Linking $TARGET")
|
env.Append(LINKCOMSTR = "Linking $TARGET")
|
||||||
env.Append(CPPPATH = "include")
|
env.Append(CPPPATH = "include")
|
||||||
|
|
||||||
Export("env", "MAJOR", "MINOR", "BUG", "EXTRA")
|
Export("env", "MAJOR", "MINOR", "BUG", "EXTRA", "DEBUG")
|
||||||
|
|
||||||
def directory(dirs):
|
def directory(dirs):
|
||||||
objs = []
|
objs = []
|
||||||
for dir in dirs:
|
for dir in dirs:
|
||||||
files = SConscript("%s/Sconscript" % dir)
|
files = SConscript("%s/Sconscript" % dir)
|
||||||
objs.append(files)
|
if files:
|
||||||
|
objs.append(files)
|
||||||
return objs
|
return objs
|
||||||
|
|
||||||
def symlink(target, source, env):
|
def symlink(target, source, env):
|
||||||
|
@ -42,7 +43,8 @@ def symlink(target, source, env):
|
||||||
SConscript(['include/Sconscript'])
|
SConscript(['include/Sconscript'])
|
||||||
ocarina = env.Program('bin/ocarina-player', directory(["libsaria", "ocarina"]))
|
ocarina = env.Program('bin/ocarina-player', directory(["libsaria", "ocarina"]))
|
||||||
oc_link = env.Command("ocarina.bin", "bin/ocarina-player", symlink)
|
oc_link = env.Command("ocarina.bin", "bin/ocarina-player", symlink)
|
||||||
Default([ocarina, oc_link])
|
oc_scripts = directory(["scripts"])
|
||||||
|
Default([ocarina, oc_link, oc_scripts])
|
||||||
|
|
||||||
# Install Ocarina
|
# Install Ocarina
|
||||||
scripts = os.listdir("scripts/")
|
scripts = os.listdir("scripts/")
|
||||||
|
@ -54,27 +56,6 @@ env.Install(lib, ocarina)
|
||||||
env.Alias("install", [lib, images, bin])
|
env.Alias("install", [lib, images, bin])
|
||||||
env.Command(images, "./images/", [Copy(images, "./images")])
|
env.Command(images, "./images/", [Copy(images, "./images")])
|
||||||
|
|
||||||
def process_script(target, source, env):
|
|
||||||
f = open(target[0].rfile().abspath, "w")
|
|
||||||
ocarina="ocarina"
|
|
||||||
saria="saria"
|
|
||||||
if DEBUG == True:
|
|
||||||
ocarina = ocarina + "-debug"
|
|
||||||
saria = saria + "-debug"
|
|
||||||
for line in open(source[0].rfile().abspath):
|
|
||||||
line = line.replace("%%BIN%%", baselib + "/ocarina.bin")
|
|
||||||
line = line.replace("%%OCARINA%%", ocarina)
|
|
||||||
line = line.replace("%%SARIA%%", saria)
|
|
||||||
f.write(line)
|
|
||||||
f.close()
|
|
||||||
|
|
||||||
for script in scripts:
|
|
||||||
if script[0] == ".":
|
|
||||||
continue
|
|
||||||
src = "scripts/" + script
|
|
||||||
dst = bin + script.replace("ocarina", "ocarina" + POSTFIX)
|
|
||||||
env.Command(dst, src, [process_script, Chmod(dst, 0755)])
|
|
||||||
|
|
||||||
# Clean up the build directory
|
# Clean up the build directory
|
||||||
Clean(ocarina, ["include/version.h"])
|
Clean(ocarina, ["include/version.h"])
|
||||||
|
|
||||||
|
|
3
scripts/%APP-play
Normal file
3
scripts/%APP-play
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/bash
|
||||||
|
. `dirname $0`/ocarina
|
||||||
|
write_to_pipe "play"
|
33
scripts/Sconscript
Normal file
33
scripts/Sconscript
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
|
||||||
|
Import( "env", "DEBUG" )
|
||||||
|
bin = os.path.abspath("../bin/%s")
|
||||||
|
|
||||||
|
def create_script(target, source, env):
|
||||||
|
dst = str(target[0].rfile())
|
||||||
|
src = str(source[0].rfile())
|
||||||
|
|
||||||
|
f = open(dst, "w");
|
||||||
|
for line in open(src):
|
||||||
|
line = line.replace("%APP", "ocarina")
|
||||||
|
line = line.replace("%DEBUG", str(DEBUG))
|
||||||
|
f.write(line)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
os.chmod(dst, 0755)
|
||||||
|
|
||||||
|
files = []
|
||||||
|
for file in os.listdir("."):
|
||||||
|
# SConscript swap files and stuff
|
||||||
|
if re.search("Sconscript", file):
|
||||||
|
continue
|
||||||
|
elif file[0] == ".":
|
||||||
|
continue
|
||||||
|
|
||||||
|
dst = (bin % file).replace("%APP", "ocarina")
|
||||||
|
print dst
|
||||||
|
files.append(env.Command(dst, file, create_script))
|
||||||
|
|
||||||
|
Return('files')
|
|
@ -1,9 +1,33 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
cmd=`which %%OCARINA%%-$1 2>/dev/null`
|
DEBUG=%DEBUG
|
||||||
args="${@: +2}"
|
|
||||||
if [ "$cmd" ]; then
|
function get_app_dir
|
||||||
$cmd "$args"
|
{
|
||||||
else
|
dir="$HOME/.%APP"
|
||||||
%%BIN%% "$*"
|
if [ "$DEBUG" == "True" ]; then
|
||||||
fi
|
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
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
%%OCARINA%%-write-pipe "play"
|
|
Loading…
Reference in New Issue
Block a user