From 38c074d8985d2077ef2598555db40313ccfb1238 Mon Sep 17 00:00:00 2001 From: Bryan Schumaker Date: Fri, 5 Jul 2013 11:40:34 -0400 Subject: [PATCH] build: Improve aliasing for tests scons tests - Compile all tests scons tests/basic - Compile basic tests scons tests/basic/print - Compile text printing test Signed-off-by: Bryan Schumaker --- Sconstruct | 1 - config | 1 + include/Sconscript | 17 ++++++++++++++--- tests/Sconscript | 17 ++++++++++------- tests/basic/Sconscript | 6 ++---- 5 files changed, 27 insertions(+), 15 deletions(-) diff --git a/Sconstruct b/Sconstruct index 82677b9e..edaba2f8 100644 --- a/Sconstruct +++ b/Sconstruct @@ -3,7 +3,6 @@ config = SConscript("config") - #import os, sys #import config # diff --git a/config b/config index 046deee9..292e4cb9 100644 --- a/config +++ b/config @@ -28,3 +28,4 @@ Export("release", "debug", "env") # Import SConscript files include = SConscript("include/Sconscript") tests = SConscript("tests/Sconscript") +Alias("tests", tests) diff --git a/include/Sconscript b/include/Sconscript index fd63af23..d06487c8 100644 --- a/include/Sconscript +++ b/include/Sconscript @@ -1,8 +1,21 @@ #!/usr/bin/python Import("VERSION", "DEBUG") -text = [ "#ifndef OCARINA_VERSION_H", +vers = str(VERSION) +if DEBUG == True: + vers += "-debug" + +text = [ "/*", + " * Automatically generated by include/Sconscript", + " */", + "", + "#ifndef OCARINA_VERSION_H", "#define OCARINA_VERSION_H", + "", + "static inline const char *get_version() {", + " return \"%s\";" % vers, + "}", + "", "#endif /* OCARINA_VERSION_H */" ] @@ -10,5 +23,3 @@ 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 index ee2dc9d8..8b18ad0c 100644 --- a/tests/Sconscript +++ b/tests/Sconscript @@ -1,17 +1,20 @@ #!/usr/bin/python Import("release", "debug") -def make_test(env, name, src): +def make_test(group, src, name, env): o = env.StaticObject(name, src) p = env.Program("%s.test" % name, o) + Alias("tests", [o, p]) + Alias("tests/%s" % group, [o, p]) + Alias("tests/%s/%s" % (group, name), [o, p]) -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) +def Test(group, src): + name, extension = src.rsplit(".", 1) + make_test(group, src, name, release) + make_test(group, src, "%s-debug" % name, debug) -Export("make_tests") + +Export("Test") diff --git a/tests/basic/Sconscript b/tests/basic/Sconscript index c397e342..bc4a6ff9 100644 --- a/tests/basic/Sconscript +++ b/tests/basic/Sconscript @@ -1,6 +1,4 @@ #!/usr/bin/python +Import("Test") -tests = [ "print.cpp" ] - -Import("make_tests") -make_tests(tests) +Test("basic", "print.cpp")