scons: Install multiple scripts
Each script acts as an ocarina sub-command, and each write through the ocarina-write-pipe script. Note that these scripts cannot be run directly, and need to run through a processor in the Sconstruct file to set the correct paths. Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
152e7009d8
commit
dce461656f
27
Sconstruct
27
Sconstruct
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/python
|
||||
import sys
|
||||
import os, sys
|
||||
|
||||
MAJOR = 5
|
||||
MINOR = 6
|
||||
|
@ -53,19 +53,34 @@ ocarina=env.Program('ocarina.bin', list_dirs('libsaria') + list_dirs('ocarina'))
|
|||
Default(ocarina)
|
||||
|
||||
# Install Ocarina
|
||||
scripts = os.listdir("scripts/")
|
||||
lib = DESTDIR + PREFIX + "/lib/ocarina" + POSTFIX
|
||||
bin = DESTDIR + PREFIX + "/bin/ocarina" + POSTFIX
|
||||
bin = DESTDIR + PREFIX + "/bin/"
|
||||
images = lib + "/images"
|
||||
env.Install(lib, ocarina)
|
||||
env.Alias("install", [lib, images, bin])
|
||||
env.Command(images, "./images/", [Copy(images, "./images")])
|
||||
def ocarina_sh(target, source, env):
|
||||
f = open("ocarina.sh", "w")
|
||||
for line in open("scripts/ocarina.sh"):
|
||||
|
||||
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%%", lib + "/ocarina.bin")
|
||||
line = line.replace("%%OCARINA%%", ocarina)
|
||||
line = line.replace("%%SARIA%%", saria)
|
||||
f.write(line)
|
||||
f.close()
|
||||
env.Command(bin, None, [ocarina_sh, Move(bin, "ocarina.sh"), Chmod(bin, 0755)])
|
||||
|
||||
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(ocarina, ["include/version.h"])
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
#!/bin/bash
|
||||
|
||||
cmd=`which %%OCARINA%%-$1 2>/dev/null`
|
||||
args="${@: +2}"
|
||||
if [ "$cmd" ]; then
|
||||
$cmd "$args"
|
||||
else
|
||||
%%BIN%% "$*"
|
||||
fi
|
|
@ -0,0 +1,2 @@
|
|||
#!/bin/bash
|
||||
%%OCARINA%%-write-pipe "next"
|
|
@ -0,0 +1,2 @@
|
|||
#!/bin/bash
|
||||
%%OCARINA%%-write-pipe "pause"
|
|
@ -0,0 +1,2 @@
|
|||
#!/bin/bash
|
||||
%%OCARINA%%-write-pipe "play"
|
|
@ -0,0 +1,2 @@
|
|||
#!/bin/bash
|
||||
echo "$*" > ~/.config/%%SARIA%%/ocarina.pipe
|
|
@ -1,2 +0,0 @@
|
|||
#!/bin/bash
|
||||
%%BIN%% "$*"
|
Loading…
Reference in New Issue