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-05-13 10:46:17 -04:00
|
|
|
MINOR = 9
|
2012-02-18 10:03:28 -05:00
|
|
|
BUG = 0
|
2012-03-06 08:25:47 -05:00
|
|
|
EXTRA = ""
|
2012-05-13 10:46:17 -04: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
|
|
|
|
2012-05-27 10:36:45 -04:00
|
|
|
Export("env", "MAJOR", "MINOR", "BUG", "EXTRA")
|
|
|
|
|
2012-05-27 10:40:19 -04:00
|
|
|
def directory(dirs):
|
2012-05-27 10:36:45 -04:00
|
|
|
objs = []
|
|
|
|
for dir in dirs:
|
|
|
|
files = SConscript("%s/Sconscript" % dir)
|
|
|
|
objs.append(files)
|
|
|
|
return objs
|
2011-08-28 11:10:58 -04:00
|
|
|
|
2012-05-27 17:37:25 -04:00
|
|
|
def symlink(target, source, env):
|
|
|
|
import os
|
|
|
|
os.symlink(str(source[0]), str(target[0]))
|
|
|
|
|
2012-05-27 10:22:10 -04:00
|
|
|
SConscript(['include/Sconscript'])
|
2012-05-27 17:37:25 -04:00
|
|
|
ocarina = env.Program('bin/ocarina-player', directory(["libsaria", "ocarina"]))
|
|
|
|
oc_link = env.Command("ocarina.bin", "bin/ocarina-player", symlink)
|
|
|
|
Default([ocarina, oc_link])
|
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])
|