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 <bjschuma@gmail.com>
This commit is contained in:
Bryan Schumaker 2013-07-05 11:40:34 -04:00 committed by Anna Schumaker
parent d8c8ea1bbf
commit 38c074d898
5 changed files with 27 additions and 15 deletions

View File

@ -3,7 +3,6 @@
config = SConscript("config")
#import os, sys
#import config
#

1
config
View File

@ -28,3 +28,4 @@ Export("release", "debug", "env")
# Import SConscript files
include = SConscript("include/Sconscript")
tests = SConscript("tests/Sconscript")
Alias("tests", tests)

View File

@ -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")

View File

@ -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")

View File

@ -1,6 +1,4 @@
#!/usr/bin/python
Import("Test")
tests = [ "print.cpp" ]
Import("make_tests")
make_tests(tests)
Test("basic", "print.cpp")