2011-11-07 23:42:59 -05:00
|
|
|
#!/usr/bin/python
|
2012-02-07 22:07:48 -05:00
|
|
|
import os, sys
|
2012-05-28 11:31:36 -04:00
|
|
|
import config
|
2011-08-28 11:10:58 -04:00
|
|
|
|
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"]
|
2012-05-28 11:31:36 -04:00
|
|
|
if config.DEBUG == True:
|
2011-10-28 14:17:59 -04:00
|
|
|
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":
|
2012-05-27 23:25:14 -04:00
|
|
|
env.Append(CXXCOMSTR = "C++ $TARGET")
|
2011-08-28 11:10:58 -04:00
|
|
|
env.Append(LINKCOMSTR = "Linking $TARGET")
|
|
|
|
env.Append(CPPPATH = "include")
|
2011-09-17 14:16:06 -04:00
|
|
|
|
2012-05-28 11:31:36 -04:00
|
|
|
config.env = env
|
2012-05-27 10:36:45 -04:00
|
|
|
|
2012-06-02 12:00:34 -04:00
|
|
|
# Make sure these directories exist before doing anything
|
|
|
|
if not os.path.exists("bin"):
|
|
|
|
os.mkdir("bin")
|
|
|
|
if not os.path.exists("lib"):
|
|
|
|
os.mkdir("lib")
|
|
|
|
|
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)
|
2012-05-27 23:16:56 -04:00
|
|
|
if files:
|
|
|
|
objs.append(files)
|
2012-05-27 10:36:45 -04:00
|
|
|
return objs
|
2011-08-28 11:10:58 -04:00
|
|
|
|
2012-06-02 09:38:49 -04:00
|
|
|
def app_directory(app, dirs):
|
|
|
|
name = config.application
|
|
|
|
config.application = app
|
|
|
|
ret = directory(dirs)
|
|
|
|
config.application = name
|
|
|
|
return ret
|
|
|
|
|
2012-05-27 17:37:25 -04:00
|
|
|
def symlink(target, source, env):
|
|
|
|
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)
|
2012-06-02 10:17:22 -04:00
|
|
|
oc_other = app_directory("ocarina", ["scripts", "images"])
|
|
|
|
Default([ocarina, oc_link, oc_other])
|
2012-06-02 10:47:45 -04:00
|
|
|
env.Alias("ocarina", [ocarina, oc_link, oc_other])
|
2011-11-07 23:42:59 -05:00
|
|
|
|
2012-06-02 11:50:32 -04:00
|
|
|
# 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()))
|
2012-02-07 22:07:48 -05:00
|
|
|
|
2011-11-07 23:42:59 -05:00
|
|
|
# Clean up the build directory
|
2012-06-02 12:00:34 -04:00
|
|
|
clean = Clean(ocarina, ["include/version.h", "bin/", "lib/"])
|
2011-11-09 23:01:18 -05:00
|
|
|
|
|
|
|
# Create a tarball
|
|
|
|
def git_archive(target, source, env):
|
2012-06-02 12:19:45 -04:00
|
|
|
ocarina="ocarina-%s" % config.version
|
2011-11-11 08:07:58 -05:00
|
|
|
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])
|