2011-11-07 23:42:59 -05:00
|
|
|
#!/usr/bin/python
|
2012-02-07 22:07:48 -05:00
|
|
|
import os, sys
|
2011-11-07 23:42:59 -05:00
|
|
|
|
2011-08-28 11:10:58 -04:00
|
|
|
MAJOR = 5
|
2012-02-18 10:03:28 -05:00
|
|
|
MINOR = 7
|
|
|
|
BUG = 0
|
2012-02-17 08:27:12 -05:00
|
|
|
EXTRA = ""
|
2012-02-18 10:03:28 -05:00
|
|
|
DEBUG = True
|
2011-08-28 11:10:58 -04:00
|
|
|
|
2011-11-10 17:31:27 -05:00
|
|
|
PREFIX = "/usr"
|
2012-02-07 21:07:27 -05:00
|
|
|
POSTFIX = ""
|
2011-11-10 17:31:27 -05:00
|
|
|
DESTDIR = ""
|
|
|
|
for argv in sys.argv:
|
|
|
|
split = argv.split("=")
|
|
|
|
if split[0] == "DESTDIR":
|
|
|
|
DESTDIR = split[1] + "/"
|
2011-11-07 23:42:59 -05:00
|
|
|
|
2011-08-28 11:10:58 -04:00
|
|
|
FLAGS = ["-O2"]
|
2011-10-28 14:17:59 -04:00
|
|
|
if DEBUG == True:
|
|
|
|
FLAGS = ["-Wall", "-Werror", "-g", "-DDEBUG"]
|
2012-02-07 21:07:27 -05:00
|
|
|
POSTFIX = "-debug"
|
2011-08-28 11:10:58 -04:00
|
|
|
|
2011-10-28 14:17:59 -04:00
|
|
|
env = Environment(CCFLAGS = FLAGS)
|
2011-08-28 11:10:58 -04:00
|
|
|
if ARGUMENTS.get('VERBOSE') != "1":
|
|
|
|
env.Append(CXXCOMSTR = "CXX $TARGET")
|
|
|
|
env.Append(LINKCOMSTR = "Linking $TARGET")
|
|
|
|
env.Append(CPPPATH = "include")
|
2011-09-17 14:16:06 -04:00
|
|
|
|
2011-08-28 11:10:58 -04:00
|
|
|
env.ParseConfig('pkg-config --cflags --libs gtk+-2.0')
|
|
|
|
env.ParseConfig('pkg-config --cflags --libs gstreamer-0.10')
|
2012-02-01 08:29:25 -05:00
|
|
|
env.ParseConfig('pkg-config --cflags --libs gstreamer-interfaces-0.10')
|
2011-09-17 14:16:06 -04:00
|
|
|
env.ParseConfig('pkg-config --cflags --libs taglib')
|
2011-08-28 11:10:58 -04:00
|
|
|
|
2011-11-09 23:17:59 -05:00
|
|
|
def version_h(target, source, env):
|
2011-08-28 11:10:58 -04:00
|
|
|
f = open("include/version.h", "w")
|
|
|
|
for line in open("include/version.tmpl", "r"):
|
|
|
|
line = line.replace("__MAJOR__", str(MAJOR))
|
|
|
|
line = line.replace("__MINOR__", str(MINOR))
|
|
|
|
line = line.replace("__BUG__", str(BUG))
|
2011-10-28 14:17:59 -04:00
|
|
|
line = line.replace("__EXTRA__", str(EXTRA))
|
2011-08-28 11:10:58 -04:00
|
|
|
f.write(line)
|
|
|
|
f.close()
|
|
|
|
|
|
|
|
def list_dirs(directory):
|
|
|
|
import os
|
|
|
|
dirs = [x[0] for x in os.walk(directory)]
|
|
|
|
return [Glob(dir + "/*.cpp") for dir in dirs]
|
|
|
|
|
2011-11-09 23:17:59 -05:00
|
|
|
# Note: a version.h file is not created in this directory,
|
|
|
|
# so the command will always run.
|
2012-02-09 08:21:46 -05:00
|
|
|
version_h=env.Command("version.h", None, version_h)
|
2011-09-07 08:12:02 -04:00
|
|
|
ocarina=env.Program('ocarina.bin', list_dirs('libsaria') + list_dirs('ocarina'))
|
2012-02-09 08:21:46 -05:00
|
|
|
Default([version_h, ocarina])
|
|
|
|
|
|
|
|
tests=os.listdir("tests/")
|
|
|
|
test_list = []
|
|
|
|
for test in tests:
|
|
|
|
if test[0] == ".":
|
|
|
|
continue;
|
|
|
|
split = test.rsplit(".", 1);
|
|
|
|
src = "tests/" + test
|
|
|
|
dst = "test_" + split[0]
|
|
|
|
test_list.append(env.Program(dst, list_dirs('libsaria') + [src]))
|
|
|
|
|
|
|
|
env.Alias("tests", [version_h] + [test_list]);
|
2011-11-07 23:42:59 -05:00
|
|
|
|
|
|
|
# Install Ocarina
|
2012-02-07 22:07:48 -05:00
|
|
|
scripts = os.listdir("scripts/")
|
2012-02-17 22:06:45 -05:00
|
|
|
baselib = PREFIX + "/lib/ocarina" + POSTFIX
|
|
|
|
lib = DESTDIR + baselib
|
2012-02-07 22:07:48 -05:00
|
|
|
bin = DESTDIR + PREFIX + "/bin/"
|
2011-11-07 23:42:59 -05:00
|
|
|
images = lib + "/images"
|
|
|
|
env.Install(lib, ocarina)
|
|
|
|
env.Alias("install", [lib, images, bin])
|
|
|
|
env.Command(images, "./images/", [Copy(images, "./images")])
|
2012-02-07 22:07:48 -05:00
|
|
|
|
|
|
|
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):
|
2012-02-17 22:06:45 -05:00
|
|
|
line = line.replace("%%BIN%%", baselib + "/ocarina.bin")
|
2012-02-07 22:07:48 -05:00
|
|
|
line = line.replace("%%OCARINA%%", ocarina)
|
|
|
|
line = line.replace("%%SARIA%%", saria)
|
2012-02-07 21:07:27 -05:00
|
|
|
f.write(line)
|
2011-11-07 23:42:59 -05:00
|
|
|
f.close()
|
2012-02-07 22:07:48 -05:00
|
|
|
|
|
|
|
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)])
|
2011-11-07 23:42:59 -05:00
|
|
|
|
|
|
|
# Clean up the build directory
|
|
|
|
Clean(ocarina, ["include/version.h"])
|
2011-11-09 23:01:18 -05:00
|
|
|
|
|
|
|
# Create a tarball
|
|
|
|
def git_archive(target, source, env):
|
|
|
|
import os
|
2011-11-11 08:07:58 -05:00
|
|
|
version = "%s.%s" % (MAJOR, MINOR)
|
2011-11-09 23:01:18 -05:00
|
|
|
if BUG != 0:
|
|
|
|
version += ".%s" % BUG
|
|
|
|
if EXTRA != "":
|
|
|
|
version += "-%s" % EXTRA
|
|
|
|
if DEBUG == True:
|
|
|
|
version += "-debug"
|
2011-11-11 08:07:58 -05:00
|
|
|
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()
|
2011-11-09 23:01:18 -05:00
|
|
|
env.Command("archive", None, [git_archive])
|