build: Only create a single build environment
I was using a debug and a release environment for programs, that way both versions of tests could be checked. Instead, it'll be simpler to only use a single environment and then control debug information using CONFIG_DEBUG. Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
e13b4afa60
commit
13a0d25e8f
|
@ -5,6 +5,7 @@
|
||||||
*.run
|
*.run
|
||||||
*.test
|
*.test
|
||||||
*.tar.gz
|
*.tar.gz
|
||||||
|
.*
|
||||||
ocarina.bin
|
ocarina.bin
|
||||||
.sconsign.dblite
|
.sconsign.dblite
|
||||||
bin/
|
bin/
|
||||||
|
|
24
config
24
config
|
@ -7,23 +7,17 @@ CONFIG_DEBUG = True
|
||||||
Export("CONFIG_VERSION", "CONFIG_DEBUG")
|
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" ]
|
# Set up default environment
|
||||||
CONFIG_DEBUG = [ "-Wall", "-Werror", "-g", "-DCONFIG_DEBUG" ]
|
CONFIG_ENV = [ "-O2" ]
|
||||||
release = get_env(CONFIG_RELEASE)
|
|
||||||
debug = get_env(CONFIG_DEBUG)
|
|
||||||
|
|
||||||
env = release
|
|
||||||
if CONFIG_DEBUG == True:
|
if CONFIG_DEBUG == True:
|
||||||
env = debug
|
CONFIG_ENV = [ "-Wall", "-Werror", "-g", "-DCONFIG_DEBUG" ]
|
||||||
Export("release", "debug", "env", "CONFIG_RELEASE", "CONFIG_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")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
#!/usr/bin/python
|
#!/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 ]
|
if CONFIG_DEBUG:
|
||||||
CONFIG_DEBUG += [ "-DCONFIG_VERSION='\"%s-debug\"'" % CONFIG_VERSION ]
|
CONFIG_ENV += [ "-DCONFIG_VERSION='\"%s-debug\"'" % CONFIG_VERSION ]
|
||||||
|
else:
|
||||||
|
CONFIG_ENV += [ "-DCONFIG_VERSION='\"%s\"'" % CONFIG_VERSION ]
|
||||||
|
|
||||||
release.Replace(CCFLAGS = CONFIG_RELEASE)
|
env.Replace(CCFLAGS = CONFIG_ENV)
|
||||||
debug.Replace(CCFLAGS = CONFIG_DEBUG)
|
|
||||||
|
|
|
@ -1,34 +1,44 @@
|
||||||
#!/usr/bin/python
|
#!/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):
|
def run_test(group, name):
|
||||||
cmd = "tests/%s/%s.test" % (group, name)
|
cmd = CMD % (group, name)
|
||||||
out = "tests/%s/%s.run" % (group, name)
|
out = OUT % (group, name)
|
||||||
good = "tests/%s/%s.good" % (group, name)
|
good = GOOD % (group, name)
|
||||||
test = Command(out, None,
|
|
||||||
|
return Command("%s.run" % name, None,
|
||||||
[ "%s > %s" % (cmd, out),
|
[ "%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):
|
def Test(group, src, config = []):
|
||||||
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):
|
|
||||||
name, extension = src.rsplit(".", 1)
|
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")
|
Export("Test")
|
||||||
|
|
||||||
|
|
||||||
# Read SConscript files
|
# Read SConscript files
|
||||||
basic = SConscript("basic/Sconscript")
|
basic = SConscript("basic/Sconscript")
|
||||||
|
file = SConscript("file/Sconscript")
|
||||||
|
|
||||||
|
Default("tests")
|
||||||
|
|
Loading…
Reference in New Issue