Build: make a directory using application name

The app_directory() function sets the config.application variable, then
calls the Sconscript file in that directory.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
Bryan Schumaker 2012-06-02 09:38:49 -04:00
parent 0ffd1ad4d6
commit e23ecd4bfb
3 changed files with 13 additions and 5 deletions

View File

@ -31,13 +31,20 @@ def directory(dirs):
objs.append(files) objs.append(files)
return objs return objs
def app_directory(app, dirs):
name = config.application
config.application = app
ret = directory(dirs)
config.application = name
return ret
def symlink(target, source, env): def symlink(target, source, env):
os.symlink(str(source[0]), str(target[0])) os.symlink(str(source[0]), str(target[0]))
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)
oc_scripts = directory(["scripts"]) oc_scripts = app_directory("ocarina", ["scripts"])
Default([ocarina, oc_link, oc_scripts]) Default([ocarina, oc_link, oc_scripts])
# Install Ocarina # Install Ocarina

View File

@ -9,6 +9,7 @@ DEBUG = False
env = None env = None
application = "libsaria"
def get_cpp_files(): def get_cpp_files():
dirs = [x[0] for x in os.walk(".")] dirs = [x[0] for x in os.walk(".")]

View File

@ -3,9 +3,9 @@ import os, re
from config import * from config import *
bin = "../bin/%s" bin = "../bin/%s"
lib = "../lib/ocarina/%s" lib = "../lib/" + application + "/%s"
LIBDIR="`dirname $0`/../lib/ocarina/" LIBDIR="`dirname $0`/../lib/" + application
def create_script(target, source, env): def create_script(target, source, env):
dst = str(target[0].rfile()) dst = str(target[0].rfile())
@ -13,7 +13,7 @@ def create_script(target, source, env):
f = open(dst, "w"); f = open(dst, "w");
for line in open(src): for line in open(src):
line = line.replace("%APP", "ocarina") line = line.replace("%APP", application)
line = line.replace("%LIB", LIBDIR) line = line.replace("%LIB", LIBDIR)
line = line.replace("%DEBUG", str(DEBUG)) line = line.replace("%DEBUG", str(DEBUG))
f.write(line) f.write(line)
@ -32,7 +32,7 @@ for file in os.listdir("."):
dir = bin dir = bin
if file == "functions": if file == "functions":
dir = lib dir = lib
dst = (dir % file).replace("%APP", "ocarina") dst = (dir % file).replace("%APP", application)
files.append(env.Command(dst, file, create_script)) files.append(env.Command(dst, file, create_script))
Return('files') Return('files')