81 lines
2.0 KiB
Python
81 lines
2.0 KiB
Python
#!/usr/bin/python
|
|
import os, sys
|
|
import config
|
|
|
|
POSTFIX = ""
|
|
DESTDIR = ""
|
|
for argv in sys.argv:
|
|
split = argv.split("=")
|
|
if split[0] == "DESTDIR":
|
|
DESTDIR = split[1] + "/"
|
|
|
|
FLAGS = ["-O2"]
|
|
if config.DEBUG == True:
|
|
FLAGS = ["-Wall", "-Werror", "-g", "-DDEBUG"]
|
|
POSTFIX = "-debug"
|
|
|
|
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
|
|
|
|
def directory(dirs):
|
|
objs = []
|
|
for dir in dirs:
|
|
files = SConscript("%s/Sconscript" % dir)
|
|
if files:
|
|
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_other = app_directory("ocarina", ["scripts", "images"])
|
|
Default([ocarina, oc_link, oc_other])
|
|
env.Alias("ocarina", [ocarina, oc_link, oc_other])
|
|
|
|
# Install bin/ and lib/
|
|
def install_dirs(dirs):
|
|
res = []
|
|
for dir in dirs:
|
|
target = os.path.join(config.PREFIX, dir)
|
|
for file in os.listdir(dir):
|
|
source = os.path.join(dir, file)
|
|
env.Install(target, source)
|
|
res += [target]
|
|
return res
|
|
|
|
dirs = install_dirs(["bin/", "lib/"])
|
|
env.Alias("install", dirs)
|
|
env.Command("uninstall", None, Delete(FindInstalledFiles()))
|
|
|
|
# Clean up the build directory
|
|
Clean(ocarina, ["include/version.h", "bin/", "lib/"])
|
|
|
|
# Create a tarball
|
|
def git_archive(target, source, env):
|
|
version = "%s.%s" % (MAJOR, MINOR)
|
|
if BUG != 0:
|
|
version += ".%s" % BUG
|
|
if EXTRA != "":
|
|
version += "-%s" % EXTRA
|
|
if DEBUG == True:
|
|
version += "-debug"
|
|
ocarina="ocarina-%s" % version
|
|
os.popen("git archive --prefix=%s/ -o %s.tar.gz HEAD" % (ocarina, ocarina))
|
|
print "md5sum:", os.popen("md5sum %s.tar.gz" % ocarina).read()
|
|
env.Command("archive", None, [git_archive])
|