Improve build scripts

The build system hadn't been touched in a while, so it needed some
cleaning up.  I moved ocarina-specific files into the ocarina/ directory
and use the ocarina/Sconscript to set up build commands.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
Bryan Schumaker 2012-09-13 19:58:28 -04:00
parent 11b421dfbb
commit 4bf66921df
13 changed files with 39 additions and 78 deletions

View File

@ -7,13 +7,10 @@ if config.DEBUG == True:
FLAGS = ["-Wall", "-Werror", "-g", "-DDEBUG"]
POSTFIX = "-debug"
env = Environment(CCFLAGS = FLAGS)
config.env = Environment(CCFLAGS = FLAGS)
if ARGUMENTS.get('VERBOSE') != "1":
env.Append(CXXCOMSTR = "C++ $TARGET")
env.Append(LINKCOMSTR = "Linking $TARGET")
env.Append(CPPPATH = "include")
config.env = env
config.env.Append(CXXCOMSTR = "C++ $TARGET")
config.env.Append(LINKCOMSTR = "Linking $TARGET")
# Make sure these directories exist before doing anything
if not os.path.exists("bin"):
@ -21,30 +18,11 @@ if not os.path.exists("bin"):
if not os.path.exists("lib"):
os.mkdir("lib")
def directory(dirs):
objs = []
for dir in dirs:
files = SConscript("%s/Sconscript" % dir)
if files:
objs.append(files)
return objs
config.include = SConscript("include/Sconscript")
config.libsaria = SConscript("libsaria/Sconscript")
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_other = app_directory("ocarina", ["scripts", "images", "xml"])
Default([ocarina, oc_link, oc_other])
env.Alias("ocarina", [ocarina, oc_link, oc_other])
ocarina = SConscript("ocarina/Sconscript")
Default(ocarina)
# Install bin/ and lib/
def install_dirs(dirs):
@ -53,13 +31,13 @@ def install_dirs(dirs):
target = os.path.join(config.PREFIX, dir)
for file in os.listdir(dir):
source = os.path.join(dir, file)
env.Install(target, source)
config.env.Install(target, source)
res += [target]
return res
dirs = install_dirs(["bin/", "lib/"])
env.Alias("install", dirs)
env.Command("uninstall", None, Delete(FindInstalledFiles()))
config.env.Alias("install", dirs)
config.env.Command("uninstall", None, Delete(FindInstalledFiles()))
# Clean up the build directory
clean = Clean(ocarina, ["include/version.h", "bin/", "lib/"])
@ -87,4 +65,4 @@ def prepare_release(target, source, env):
f.write(line)
f.close()
env.Command("release", None, [prepare_release])
config.env.Command("release", None, [prepare_release])

View File

@ -1,5 +1,5 @@
#!/usr/bin/python
import os
import os, shutil
MAJOR = 5
MINOR = 11
@ -21,8 +21,15 @@ PREFIX = "/usr"
env = None
application = "libsaria"
include = []
libsaria = []
def get_cpp_files():
dirs = [x[0] for x in os.walk(".")]
return [env.Glob(dir + "/*.cpp") for dir in dirs]
def copy(target, source, env):
shutil.copy(str(source[0]), str(target[0]))
def symlink(target, source, env):
os.symlink(str(source[0]), str(target[0]))

View File

@ -1,21 +0,0 @@
#!/usr/bin/python
import shutil
from config import *
lib = "../lib/" + application + "/%s"
def copy_image(target, source, env):
dst = str(target[0].rfile())
src = str(source[0].rfile())
shutil.copy(src, dst)
images = []
if application == "ocarina":
images = ["ocarina.png", "ocarina512.png"]
files = []
for image in images:
dst = lib % image
files.append(env.Command(dst, image, copy_image))
Return('files')

View File

@ -10,3 +10,5 @@ for line in open("version.tmpl", "r"):
line = line.replace("__VERSION__", str(version))
f.write(line)
f.close()
env.Append(CPPPATH = os.path.join(os.getcwd()))

View File

@ -1,8 +1,20 @@
#!/usr/bin/python
import config
from config import *
config.env.ParseConfig('pkg-config --cflags --libs gtk+-2.0')
config.env.ParseConfig('pkg-config --cflags --libs gmodule-export-2.0')
env.ParseConfig('pkg-config --cflags --libs gtk+-2.0')
env.ParseConfig('pkg-config --cflags --libs gmodule-export-2.0')
files = config.get_cpp_files()
Return('files')
files = get_cpp_files()
extra_files = [
("../bin/ocarina-player", "../ocarina.bin", symlink),
("ocarina.xml", "../lib/ocarina/ocarina.xml", copy),
("images/ocarina.png", "../lib/ocarina/ocarina.png", copy),
]
build = [env.Program("../bin/ocarina-player", libsaria + files)]
for (src, dst, func) in extra_files:
build.append(env.Command(dst, src, func))
env.Alias("ocarina", build)
Return('build')

View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 49 KiB

View File

Before

Width:  |  Height:  |  Size: 988 B

After

Width:  |  Height:  |  Size: 988 B

View File

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -1,17 +0,0 @@
#!/usr/bin/python
import shutil
from config import *
lib = "../lib/" + application + "/%s"
def copy_xml(target, source, env):
dst = str(target[0].rfile())
src = str(source[0].rfile())
shutil.copy(src, dst)
files = []
if application == "ocarina":
dst = lib % "ocarina.xml"
files.append(AlwaysBuild(env.Command(dst, "ocarina.xml", copy_xml)))
Return('files')