From e23ecd4bfbc510051897c886147c06c3852c1582 Mon Sep 17 00:00:00 2001 From: Bryan Schumaker Date: Sat, 2 Jun 2012 09:38:49 -0400 Subject: [PATCH] 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 --- Sconstruct | 9 ++++++++- config.py | 1 + scripts/Sconscript | 8 ++++---- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Sconstruct b/Sconstruct index 3f0298a2..fab302c4 100644 --- a/Sconstruct +++ b/Sconstruct @@ -31,13 +31,20 @@ def directory(dirs): objs.append(files) 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): os.symlink(str(source[0]), str(target[0])) SConscript(['include/Sconscript']) ocarina = env.Program('bin/ocarina-player', directory(["libsaria", "ocarina"])) 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]) # Install Ocarina diff --git a/config.py b/config.py index 00a6582b..7c16db05 100644 --- a/config.py +++ b/config.py @@ -9,6 +9,7 @@ DEBUG = False env = None +application = "libsaria" def get_cpp_files(): dirs = [x[0] for x in os.walk(".")] diff --git a/scripts/Sconscript b/scripts/Sconscript index 8f59fde8..06673a0b 100644 --- a/scripts/Sconscript +++ b/scripts/Sconscript @@ -3,9 +3,9 @@ import os, re from config import * 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): dst = str(target[0].rfile()) @@ -13,7 +13,7 @@ def create_script(target, source, env): f = open(dst, "w"); for line in open(src): - line = line.replace("%APP", "ocarina") + line = line.replace("%APP", application) line = line.replace("%LIB", LIBDIR) line = line.replace("%DEBUG", str(DEBUG)) f.write(line) @@ -32,7 +32,7 @@ for file in os.listdir("."): dir = bin if file == "functions": dir = lib - dst = (dir % file).replace("%APP", "ocarina") + dst = (dir % file).replace("%APP", application) files.append(env.Command(dst, file, create_script)) Return('files')