import sys, os, glob if sys.platform == 'linux2' : sys.path+=['../libs'] else : sys.path+=[os.getcwd() + '\\..\\libs'] from buildtools import * # CLAM unit tests build def parse_pkg_config( env ) : prefix = env['clam_prefix'] descriptor_path = prefix + "\\lib\\pkgconfig\\*.pc" descriptors = glob.glob( descriptor_path ) libpath = dict() libs = dict() cppflags = dict() cpppath = dict() ccflags = dict() for desc_file in descriptors : instream = open( desc_file ) for line in instream : tokens = line.strip().split(' ') if tokens[0] == 'Libs:' : for token in tokens[1:] : if "/LIBPATH:" in token : libpath[token.replace("/LIBPATH:", "")] = True else : libs[token] = True elif tokens[0] == 'Cflags:': for token in tokens[1:] : if "/I" in token : cpppath[ token.replace("/I","") ] = True elif "/D" in token or "-D" in token : cppflags[ token ] = True else : ccflags[token] = True else : pass instream.close() env.Append( LIBPATH = libpath.keys() ) env.Append( LIBS = libs.keys() ) env.Append( CPPFLAGS = cppflags.keys() ) env.Append( CCFLAGS = ccflags.keys() ) env.Append( CPPPATH = cpppath.keys() ) tests_env = Environment( ENV=os.environ ) Export( 'tests_env' ) opts = Options('unit_tests.conf') opts.Add( PathOption( 'clam_prefix', 'Prefix were CLAM was installed', '/usr') ) if sys.platform != 'linux2' : opts.Add( PathOption( 'clam_sandbox', 'Absolute path to CLAM sandbox', 'c:\\Sandboxes' ) ) opts.Update(tests_env) opts.Save('unit_tests.conf', tests_env) Help(opts.GenerateHelpText(tests_env)) if sys.platform == 'linux2' : tests_env.Append( LIBS=['cppunit','dl'] ) tests_env.Append( CCFLAGS=['-O2','-Wall'] ) # read flags from pkg-config clam library descriptors tests_env.ParseConfig( 'pkg-config --cflags --libs clam_core clam_processing clam_audioio') else : if sys.platform == 'win32' : parse_pkg_config( tests_env ) tests_env.Append( CPPPATH=[ '%s\\cppunit\\include'%tests_env['clam_sandbox']] ) tests_env.Append( CCFLAGS=[ '/EHsc','/Ob2' ] ) tests_env.Append( LIBS=['cppunit','delayimp','imm32'] ) tests_env.Append( LIBPATH=[ '%s\\cppunit\\lib'%tests_env['clam_sandbox']] ) # This is necessary since if we leave it out, then MSVC linker # will assume they are 'windows' apps. tests_env.Append(LINKFLAGS=['/subsystem:console','/MACHINE:X86']) else : raise RuntimeError, "Not implemented yet!" SConscript('unit_tests/SConscript') SConscript('functional_tests/SConscript') Alias( 'all', ['run_unit_tests','run_functional_tests'] )