89 lines
2.4 KiB
Python
89 lines
2.4 KiB
Python
#!/usr/bin/python
|
|
import os, sys
|
|
import config
|
|
|
|
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
|
|
|
|
# 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")
|
|
|
|
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 = Clean(ocarina, ["include/version.h", "bin/", "lib/"])
|
|
|
|
# Create a tarball and a PKGBUILD script
|
|
def prepare_release(target, source, env):
|
|
import datetime
|
|
|
|
ocarina="ocarina-%s" % config.version
|
|
os.popen("git archive --prefix=%s/ -o %s.tar.gz HEAD" % (ocarina, ocarina))
|
|
md5 = os.popen("md5sum %s.tar.gz | awk '{print $1}'" % ocarina).read().strip()
|
|
|
|
now = datetime.datetime.now()
|
|
year = str(now.year)
|
|
month = str(now.month)
|
|
|
|
f = open("PKGBUILD", "w")
|
|
for line in open("PKGBUILD.tmpl"):
|
|
line = line.replace("pkgver=", "pkgver=%s.%s" % (config.MAJOR, config.MINOR))
|
|
line = line.replace("md5sums=", "md5sums=('%s')" % md5)
|
|
line = line.replace("YEAR", year)
|
|
line = line.replace("MONTH", month)
|
|
f.write(line)
|
|
f.close()
|
|
|
|
env.Command("release", None, [prepare_release])
|