def CxxTest(env, target, source=None, **kwargs): """Usage: The function is modelled to be called as the Program() call is: env.CxxTest('target_name') will build the test from the source target_name + env['CXXTEST_SUFFIX'], env.CxxTest('target_name', source = 'test_src.t.h') will build the test from test_src.t.h source, env.CxxTest('target_name, source = ['test_src.t.h', other_srcs] builds the test from source[0] and links in other files mentioned in sources, You may also add additional arguments to the function. In that case, they will be passed to the actual Program builder call unmodified. Convenient for passing different CPPPATHs and the sort. This function also appends CXXTEST_CPPPATH to CPPPATH. It does not clutter the environment's CPPPATH. """ if (source == None): suffix = multiget([kwargs, env, os.environ], 'CXXTEST_SUFFIX', "") source = [t + suffix for t in target] sources = Flatten(Split(source)) headers = [] linkins = [] for l in sources: # check whether this is a file object or a string path try: s = l.abspath except AttributeError: s = l if s.endswith( multiget([kwargs, env, os.environ], 'CXXTEST_SUFFIX', None)): headers.append(l) else: linkins.append(l) deps = [] if len(headers) == 0: if len(linkins) != 0: # the 1st source specified is the test deps.append(env.CxxTestCpp(linkins.pop(0), **kwargs)) else: deps.append(env.CxxTestCpp(headers.pop(0), **kwargs)) deps.extend([ env.CxxTestCpp(header, CXXTEST_RUNNER='none', CXXTEST_ROOT_PART='--part', CXXTEST_OPTS='', **kwargs) for header in headers ]) deps.extend(linkins) kwargs['CPPPATH'] = unique( Split(kwargs.get('CPPPATH', [])) + Split(env.get('CPPPATH', [])) + Split(kwargs.get('CXXTEST_CPPPATH', [])) + Split(env.get('CXXTEST_CPPPATH', []))) kwargs['LIBPATH'] = unique( Split(kwargs.get('LIBPATH', [])) + Split(env.get('LIBPATH', [])) + Split(kwargs.get('CXXTEST_LIBPATH', [])) + Split(env.get('CXXTEST_LIBPATH', []))) return UnitTest(env, target, source=deps, **kwargs)
def CxxTest(env, target, source = None, **kwargs): """Usage: The function is modelled to be called as the Program() call is: env.CxxTest('target_name') will build the test from the source target_name + env['CXXTEST_SUFFIX'], env.CxxTest('target_name', source = 'test_src.t.h') will build the test from test_src.t.h source, env.CxxTest('target_name, source = ['test_src.t.h', other_srcs] builds the test from source[0] and links in other files mentioned in sources, You may also add additional arguments to the function. In that case, they will be passed to the actual Program builder call unmodified. Convenient for passing different CPPPATHs and the sort. This function also appends CXXTEST_CPPPATH to CPPPATH. It does not clutter the environment's CPPPATH. """ if (source == None): suffix = multiget([kwargs, env, os.environ], 'CXXTEST_SUFFIX', "") source = [t + suffix for t in target] sources = Flatten(Split(source)) headers = [] linkins = [] for l in sources: # check whether this is a file object or a string path try: s = l.abspath except AttributeError: s = l if s.endswith(multiget([kwargs, env, os.environ], 'CXXTEST_SUFFIX', None)): headers.append(l) else: linkins.append(l) deps = [] if len(headers) == 0: if len(linkins) != 0: # the 1st source specified is the test deps.append(env.CxxTestCpp(linkins.pop(0), **kwargs)) else: deps.append(env.CxxTestCpp(headers.pop(0), **kwargs)) deps.extend( [env.CxxTestCpp(header, CXXTEST_RUNNER = 'none', CXXTEST_ROOT_PART = '--part', **kwargs) for header in headers] ) deps.extend(linkins) kwargs['CPPPATH'] = unique( Split(kwargs.get('CPPPATH', [])) + Split(env.get( 'CPPPATH', [])) + Split(kwargs.get('CXXTEST_CPPPATH', [])) + Split(env.get( 'CXXTEST_CPPPATH', [])) ) kwargs['LIBPATH'] = unique( Split(kwargs.get('LIBPATH', [])) + Split(env.get( 'LIBPATH', [])) + Split(kwargs.get('CXXTEST_LIBPATH', [])) + Split(env.get( 'CXXTEST_LIBPATH', [])) ) return UnitTest(env, target, source = deps, **kwargs)
def _find_objects(env, target): """Find all object files that the **target** node depends on. :Parameters: env : SCons.Environment.Environment a SCons Environment object target node where we start our recursive search, usually program name or an alias which depends on one or more programs. Of course it may be a list of such things. Typically it's an alias target which runs test program (the 'check' target). """ from SCons.Util import NodeList, unique nodes = env.arg2nodes(target, target = target) object_builders = _get_object_builders(env) objects = NodeList() excludes = env.get('GCCCOV_EXCLUDE',[]) excludes = env.arg2nodes(excludes, target = target) recur = env.get('GCCCOV_MAX_RECURSION', 256) _find_objects_r(env, nodes, object_builders, objects, excludes, recur) return NodeList(unique(objects))
def _find_objects(env, target): """Find all object files that the **target** node depends on. :Parameters: env : SCons.Environment.Environment a SCons Environment object target node where we start our recursive search, usually program name or an alias which depends on one or more programs. Of course it may be a list of such things. Typically it's an alias target which runs test program (the 'check' target). """ from SCons.Util import NodeList, unique nodes = env.arg2nodes(target, target=target) object_builders = _get_object_builders(env) objects = NodeList() excludes = env.get('GCCCOV_EXCLUDE', []) excludes = env.arg2nodes(excludes, target=target) recur = env.get('GCCCOV_MAX_RECURSION', 256) _find_objects_r(env, nodes, object_builders, objects, excludes, recur) return NodeList(unique(objects))