2011-11-07 23:42:59 -05:00
|
|
|
#!/usr/bin/python
|
2011-11-10 17:31:27 -05:00
|
|
|
import sys
|
2011-11-07 23:42:59 -05:00
|
|
|
|
2011-08-28 11:10:58 -04:00
|
|
|
MAJOR = 5
|
2011-10-28 14:08:44 -04:00
|
|
|
MINOR = 3
|
2011-08-28 11:10:58 -04:00
|
|
|
BUG = 0
|
2011-11-11 08:07:58 -05:00
|
|
|
EXTRA = ""
|
2011-11-09 08:47:34 -05:00
|
|
|
DEBUG = False
|
2011-08-28 11:10:58 -04:00
|
|
|
|
2011-11-10 17:31:27 -05:00
|
|
|
PREFIX = "/usr"
|
|
|
|
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"]
|
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')
|
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.
|
|
|
|
Default( 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'))
|
2011-11-09 23:01:18 -05:00
|
|
|
Default(ocarina)
|
2011-11-07 23:42:59 -05:00
|
|
|
|
|
|
|
# Install Ocarina
|
2011-11-10 17:31:27 -05:00
|
|
|
lib = DESTDIR + PREFIX + "/lib/ocarina"
|
|
|
|
bin = DESTDIR + PREFIX + "/bin/ocarina"
|
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")])
|
2011-11-09 08:34:08 -05:00
|
|
|
def ocarina_sh(target, source, env):
|
2011-11-07 23:42:59 -05:00
|
|
|
f = open("ocarina.sh", "w")
|
|
|
|
f.write("#!/bin/bash\n")
|
2011-11-08 08:21:56 -05:00
|
|
|
f.write(PREFIX + "/lib/ocarina/ocarina.bin \"$*\"\n")
|
2011-11-07 23:42:59 -05:00
|
|
|
f.close()
|
2011-11-09 08:34:08 -05:00
|
|
|
env.Command(bin, None, [ocarina_sh, Move(bin, "ocarina.sh"), Chmod(bin, 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])
|