config: Simplify setting up initial environment

Rather than setting up all variables twice, just call reset() to
initialize everything.  *BONUS* Reset can be used to initialize the
value of CONFIG.TEST!

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
This commit is contained in:
Anna Schumaker 2013-09-29 21:07:15 -04:00 committed by Anna Schumaker
parent 9880e98d0d
commit 1f9ff4ae2d
2 changed files with 5 additions and 19 deletions

20
config
View File

@ -24,35 +24,23 @@ class Config:
self.VERSION = CONFIG_VERSION
self.DEBUG = CONFIG_DEBUG
self.ENV = CONFIG_ENV
self.DATABASE = False
self.FILE = False
self.FILTER = False
self.GROUP = False
self.IDLE = False
self.INDEX = False
self.TEST = False
self.reset();
def package(self, name):
env.ParseConfig("pkg-config --cflags --libs %s" % name)
def reconfigure(self):
env.Replace( CCFLAGS = self.ENV )
if self.DATABASE: env.Append( CCFLAGS = [ "-DCONFIG_DATABASE" ])
if self.FILE: env.Append( CCFLAGS = [ "-DCONFIG_FILE" ])
if self.FILTER: env.Append( CCFLAGS = [ "-DCONFIG_FILTER" ])
if self.GROUP: env.Append( CCFLAGS = [ "-DCONFIG_GROUP" ])
if self.IDLE: env.Append( CCFLAGS = [ "-DCONFIG_IDLE" ])
if self.INDEX: env.Append( CCFLAGS = [ "-DCONFIG_INDEX" ])
if self.TEST: env.Append( CCFLAGS = [ "-DCONFIG_TEST" ])
if self.TEST: env.Append( CCFLAGS = [ "-DCONFIG_TEST" ])
def reset(self):
def reset(self, TEST = False):
self.DATABASE = False
self.FILE = False
self.FILTER = False
self.GROUP = False
self.IDLE = False
self.INDEX = False
self.TEST = False
self.TEST = TEST
self.reconfigure()
CONFIG = Config()

View File

@ -23,7 +23,6 @@ def run_test(target, source, env):
def Test(group, src):
name, extension = src.rsplit(".", 1)
CONFIG.reconfigure()
lib = SConscript("../../lib/Sconscript")
prog = env.Program("%s.test" % name, [ src ] + lib)
@ -57,8 +56,7 @@ rm_test_dir(xdg.BaseDirectory.xdg_data_home);
#
scripts = [ "database", "file", "filter", "group", "idle", "index", "print" ]
for s in scripts:
CONFIG.reset()
CONFIG.TEST = True
CONFIG.reset(TEST = True)
SConscript("%s/Sconscript" % s)
Default("tests")