diff --git a/.gitignore b/.gitignore index a6857989..93fba52f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ *.o *.swp +*.swo *.pyc +*.test *.tar.gz ocarina.bin .sconsign.dblite diff --git a/Sconstruct b/Sconstruct index 84adeecb..82677b9e 100644 --- a/Sconstruct +++ b/Sconstruct @@ -1,72 +1,77 @@ #!/usr/bin/python -import os, sys -import config -FLAGS = ["-O2"] -if config.DEBUG == True: - FLAGS = ["-Wall", "-Werror", "-g", "-DDEBUG"] - POSTFIX = "-debug" +config = SConscript("config") -config.env = Environment(CCFLAGS = FLAGS) -if ARGUMENTS.get('VERBOSE') != "1": - config.env.Append(CXXCOMSTR = "C++ $TARGET") - config.env.Append(LINKCOMSTR = "Linking $TARGET") -# 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") -config.include = SConscript("include/Sconscript") -config.libsaria = SConscript("libsaria/Sconscript") - -ocarina = SConscript("ocarina/Sconscript") -newgui = SConscript("newgui/Sconscript") -Default(ocarina) - -# 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) - config.env.Install(target, source) - res += [target] - return res - -dirs = install_dirs(["bin/", "lib/"]) -config.env.Alias("install", dirs) -config.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) - if (len(month) == 1): - month = "0" + month - - f = open("PKGBUILD", "w") - for line in open("PKGBUILD.tmpl"): - if config.BUG == 0: - line = line.replace("pkgver=", "pkgver=%s.%s" % (config.MAJOR, config.MINOR)) - else: - line = line.replace("pkgver=", "pkgver=%s.%s.%s" % (config.MAJOR, config.MINOR, config.BUG)) - line = line.replace("md5sums=", "md5sums=('%s')" % md5) - line = line.replace("YEAR", year) - line = line.replace("MONTH", month) - f.write(line) - f.close() - -config.env.Command("release", None, [prepare_release]) +#import os, sys +#import config +# +#FLAGS = ["-O2"] +#if config.DEBUG == True: +# FLAGS = ["-Wall", "-Werror", "-g", "-DDEBUG"] +# POSTFIX = "-debug" +# +#config.env = Environment(CCFLAGS = FLAGS) +#if ARGUMENTS.get('VERBOSE') != "1": +# config.env.Append(CXXCOMSTR = "C++ $TARGET") +# config.env.Append(LINKCOMSTR = "Linking $TARGET") +# +## 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") +# +#config.include = SConscript("include/Sconscript") +#config.libsaria = SConscript("libsaria/Sconscript") +# +#ocarina = SConscript("ocarina/Sconscript") +#newgui = SConscript("newgui/Sconscript") +#Default(ocarina) +# +## 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) +# config.env.Install(target, source) +# res += [target] +# return res +# +#dirs = install_dirs(["bin/", "lib/"]) +#config.env.Alias("install", dirs) +#config.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) +# if (len(month) == 1): +# month = "0" + month +# +# f = open("PKGBUILD", "w") +# for line in open("PKGBUILD.tmpl"): +# if config.BUG == 0: +# line = line.replace("pkgver=", "pkgver=%s.%s" % (config.MAJOR, config.MINOR)) +# else: +# line = line.replace("pkgver=", "pkgver=%s.%s.%s" % (config.MAJOR, config.MINOR, config.BUG)) +# line = line.replace("md5sums=", "md5sums=('%s')" % md5) +# line = line.replace("YEAR", year) +# line = line.replace("MONTH", month) +# f.write(line) +# f.close() +# +#config.env.Command("release", None, [prepare_release]) diff --git a/config b/config new file mode 100644 index 00000000..046deee9 --- /dev/null +++ b/config @@ -0,0 +1,30 @@ +#!/usr/bin/python +import os + +VERSION = 6.0 +DEBUG = True + +Export("VERSION", "DEBUG") + + +# Set up default environments +def get_env(flags): + e = Environment(CCFLAGS = flags) + e.Append(CPPPATH = os.path.abspath("include")) + e.Append(CXXCOMSTR = "C++ $TARGET") + e.Append(LINKCOMSTR = "Linking $TARGET") + return e + +release = get_env([ "-O2" ]) +debug = get_env([ "-Wall", "-Werror", "-g", "-DDEBUG" ]) + +env = release +if DEBUG == True: + env = debug +Export("release", "debug", "env") + + + +# Import SConscript files +include = SConscript("include/Sconscript") +tests = SConscript("tests/Sconscript") diff --git a/include/Sconscript b/include/Sconscript new file mode 100644 index 00000000..fd63af23 --- /dev/null +++ b/include/Sconscript @@ -0,0 +1,14 @@ +#!/usr/bin/python +Import("VERSION", "DEBUG") + +text = [ "#ifndef OCARINA_VERSION_H", + "#define OCARINA_VERSION_H", + "#endif /* OCARINA_VERSION_H */" +] + +f = open("version.h", 'w') +for line in text: + f.write("%s\n" % line) +f.close() + +Clean(True, "version.h") diff --git a/tests/Sconscript b/tests/Sconscript new file mode 100644 index 00000000..ee2dc9d8 --- /dev/null +++ b/tests/Sconscript @@ -0,0 +1,19 @@ +#!/usr/bin/python +Import("release", "debug") + +def make_test(env, name, src): + o = env.StaticObject(name, src) + p = env.Program("%s.test" % name, o) + +def make_tests(tests): + for src in tests: + name, extension = src.rsplit(".", 1) + make_test(release, name, src) + make_test(debug, "%s-debug" % name, src) + +Export("make_tests") + + + +# Read SConscript files +basic = SConscript("basic/Sconscript") diff --git a/tests/basic/Sconscript b/tests/basic/Sconscript new file mode 100644 index 00000000..c397e342 --- /dev/null +++ b/tests/basic/Sconscript @@ -0,0 +1,6 @@ +#!/usr/bin/python + +tests = [ "print.cpp" ] + +Import("make_tests") +make_tests(tests) diff --git a/tests/basic/print.cpp b/tests/basic/print.cpp new file mode 100644 index 00000000..91d0ccbc --- /dev/null +++ b/tests/basic/print.cpp @@ -0,0 +1,10 @@ +/* + * Prints version info to the screen when compiled in debug mode + */ + +#include + +int main(int argc, char **argv) +{ + return 0; +}