diff --git a/.gitignore b/.gitignore index adc0e912..d0a76711 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ *.run *.test *.tar.gz +.* ocarina.bin .sconsign.dblite bin/ diff --git a/config b/config index 5ee03d62..1124b626 100644 --- a/config +++ b/config @@ -7,23 +7,17 @@ CONFIG_DEBUG = True Export("CONFIG_VERSION", "CONFIG_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 -CONFIG_RELEASE = [ "-O2" ] -CONFIG_DEBUG = [ "-Wall", "-Werror", "-g", "-DCONFIG_DEBUG" ] -release = get_env(CONFIG_RELEASE) -debug = get_env(CONFIG_DEBUG) - -env = release +# Set up default environment +CONFIG_ENV = [ "-O2" ] if CONFIG_DEBUG == True: - env = debug -Export("release", "debug", "env", "CONFIG_RELEASE", "CONFIG_DEBUG") + CONFIG_ENV = [ "-Wall", "-Werror", "-g", "-DCONFIG_DEBUG" ] + +env = Environment( CCFLAGS = CONFIG_ENV ) +env.Append(CPPPATH = os.path.abspath("include")) +env.Append(CXXCOMSTR = "C++ $TARGET") +env.Append(LINKCOMSTR = "Linking $TARGET") +Export("env", "CONFIG_ENV") diff --git a/include/Sconscript b/include/Sconscript index f286117c..a8e22d51 100644 --- a/include/Sconscript +++ b/include/Sconscript @@ -1,8 +1,9 @@ #!/usr/bin/python -Import("release", "debug", "CONFIG_VERSION", "CONFIG_RELEASE", "CONFIG_DEBUG") +Import("env", "CONFIG_DEBUG", "CONFIG_VERSION", "CONFIG_ENV") -CONFIG_RELEASE += [ "-DCONFIG_VERSION='\"%s\"'" % CONFIG_VERSION ] -CONFIG_DEBUG += [ "-DCONFIG_VERSION='\"%s-debug\"'" % CONFIG_VERSION ] +if CONFIG_DEBUG: + CONFIG_ENV += [ "-DCONFIG_VERSION='\"%s-debug\"'" % CONFIG_VERSION ] +else: + CONFIG_ENV += [ "-DCONFIG_VERSION='\"%s\"'" % CONFIG_VERSION ] -release.Replace(CCFLAGS = CONFIG_RELEASE) -debug.Replace(CCFLAGS = CONFIG_DEBUG) +env.Replace(CCFLAGS = CONFIG_ENV) diff --git a/tests/Sconscript b/tests/Sconscript index 586ece69..aa25d9b4 100644 --- a/tests/Sconscript +++ b/tests/Sconscript @@ -1,34 +1,44 @@ #!/usr/bin/python -Import("release", "debug") +Import("env", "CONFIG_DEBUG") + + +CMD = "tests/%s/%s.test" +OUT = "tests/%s/%s.run" +GOOD = "tests/%s/%s.good" +if CONFIG_DEBUG: + GOOD = "tests/%s/%s-debug.good" + def run_test(group, name): - cmd = "tests/%s/%s.test" % (group, name) - out = "tests/%s/%s.run" % (group, name) - good = "tests/%s/%s.good" % (group, name) - test = Command(out, None, + cmd = CMD % (group, name) + out = OUT % (group, name) + good = GOOD % (group, name) + + return Command("%s.run" % name, None, [ "%s > %s" % (cmd, out), - "diff -u %s %s" % (out, good) + "diff -u %s %s" % (out, good), ] ) - return test -def make_test(group, src, name, env): - obj = env.StaticObject(name, src) - prog = env.Program("%s.test" % name, obj) - test = run_test(group, name) - Depends(test, prog) - - Alias("tests", [obj, prog]) - Alias("tests/%s" % group, [obj, prog]) - Alias("tests/%s/%s" % (group, name), [obj, prog]) - -def Test(group, src): +def Test(group, src, config = []): name, extension = src.rsplit(".", 1) - make_test(group, src, name, release) - make_test(group, src, "%s-debug" % name, debug) + + lib = SConscript("../../lib/Sconscript", variant_dir = ".%s" % name) + prog = env.Program("%s.test" % name, [ src ] + lib) + test = run_test(group, name) + + Depends(test, prog) + AlwaysBuild(test) + + Alias("tests", [ prog, test ]) + Alias("tests/%s" % group, [ prog, test ]) + Alias("tests/%s/%s" % (group, name), [ prog, test ]) Export("Test") # Read SConscript files basic = SConscript("basic/Sconscript") +file = SConscript("file/Sconscript") + +Default("tests")