SConscript (8233:15b5ea80fd95) | SConscript (8235:6381dc8bcfcc) |
---|---|
1# -*- mode:python -*- 2 3# Copyright (c) 2004-2005 The Regents of The University of Michigan 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions are 8# met: redistributions of source code must retain the above copyright --- 219 unchanged lines hidden (view full) --- 228 229 self.module = modname 230 cc_file = joinpath(self.dirname, modname + '_wrap.cc') 231 py_file = joinpath(self.dirname, modname + '.py') 232 233 self.cc_source = Source(cc_file, swig=True, parent=self) 234 self.py_source = PySource(package, py_file, parent=self) 235 | 1# -*- mode:python -*- 2 3# Copyright (c) 2004-2005 The Regents of The University of Michigan 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions are 8# met: redistributions of source code must retain the above copyright --- 219 unchanged lines hidden (view full) --- 228 229 self.module = modname 230 cc_file = joinpath(self.dirname, modname + '_wrap.cc') 231 py_file = joinpath(self.dirname, modname + '.py') 232 233 self.cc_source = Source(cc_file, swig=True, parent=self) 234 self.py_source = PySource(package, py_file, parent=self) 235 |
236unit_tests = [] 237def UnitTest(target, sources): 238 '''Create a unit test, specify the target name and a source or 239 list of sources''' 240 if not isinstance(sources, (list, tuple)): 241 sources = [ sources ] | 236class UnitTest(object): 237 '''Create a UnitTest''' |
242 | 238 |
243 sources = [ Source(src, skip_lib=True) for src in sources ] 244 unit_tests.append((target, sources)) | 239 all = [] 240 def __init__(self, target, *sources): 241 '''Specify the target name and any sources. Sources that are 242 not SourceFiles are evalued with Source(). All files are 243 guarded with a guard of the same name as the UnitTest 244 target.''' |
245 | 245 |
246 srcs = [] 247 for src in sources: 248 if not isinstance(src, SourceFile): 249 src = Source(src, skip_lib=True) 250 src.guards[target] = True 251 srcs.append(src) 252 253 self.sources = srcs 254 self.target = target 255 UnitTest.all.append(self) 256 |
|
246# Children should have access 247Export('Source') 248Export('PySource') 249Export('SimObject') 250Export('SwigSource') 251Export('UnitTest') 252 253######################################################################## --- 414 unchanged lines hidden (view full) --- 668''') 669 code.write(str(target[0])) 670 671# Build all swig modules 672for swig in SwigSource.all: 673 env.Command([swig.cc_source.tnode, swig.py_source.tnode], swig.tnode, 674 MakeAction('$SWIG $SWIGFLAGS -outdir ${TARGETS[1].dir} ' 675 '-o ${TARGETS[0]} $SOURCES', Transform("SWIG"))) | 257# Children should have access 258Export('Source') 259Export('PySource') 260Export('SimObject') 261Export('SwigSource') 262Export('UnitTest') 263 264######################################################################## --- 414 unchanged lines hidden (view full) --- 679''') 680 code.write(str(target[0])) 681 682# Build all swig modules 683for swig in SwigSource.all: 684 env.Command([swig.cc_source.tnode, swig.py_source.tnode], swig.tnode, 685 MakeAction('$SWIG $SWIGFLAGS -outdir ${TARGETS[1].dir} ' 686 '-o ${TARGETS[0]} $SOURCES', Transform("SWIG"))) |
676 init_file = 'python/swig/init_%s.cc' % swig.module | 687 cc_file = str(swig.tnode) 688 init_file = '%s/init_%s.cc' % (dirname(cc_file), basename(cc_file)) |
677 env.Command(init_file, Value(swig.module), 678 MakeAction(makeEmbeddedSwigInit, Transform("EMBED SW"))) | 689 env.Command(init_file, Value(swig.module), 690 MakeAction(makeEmbeddedSwigInit, Transform("EMBED SW"))) |
679 Source(init_file) | 691 Source(init_file, **swig.guards) |
680 681# 682# Handle debug flags 683# 684def makeDebugFlagCC(target, source, env): 685 assert(len(target) == 1 and len(source) == 1) 686 687 val = eval(source[0].get_contents()) --- 211 unchanged lines hidden (view full) --- 899 shared_date = make_obj(date_source, static=False, extra_deps=shared_objs) 900 shared_objs.append(shared_date) 901 902 # First make a library of everything but main() so other programs can 903 # link against m5. 904 static_lib = new_env.StaticLibrary(libname, static_objs) 905 shared_lib = new_env.SharedLibrary(libname, shared_objs) 906 | 692 693# 694# Handle debug flags 695# 696def makeDebugFlagCC(target, source, env): 697 assert(len(target) == 1 and len(source) == 1) 698 699 val = eval(source[0].get_contents()) --- 211 unchanged lines hidden (view full) --- 911 shared_date = make_obj(date_source, static=False, extra_deps=shared_objs) 912 shared_objs.append(shared_date) 913 914 # First make a library of everything but main() so other programs can 915 # link against m5. 916 static_lib = new_env.StaticLibrary(libname, static_objs) 917 shared_lib = new_env.SharedLibrary(libname, shared_objs) 918 |
907 for target, sources in unit_tests: 908 objs = [ make_obj(s, static=True) for s in sources ] 909 new_env.Program("unittest/%s.%s" % (target, label), objs + static_objs) 910 | |
911 # Now link a stub with main() and the static library. 912 main_objs = [ make_obj(s, True) for s in Source.get(main=True) ] 913 | 919 # Now link a stub with main() and the static library. 920 main_objs = [ make_obj(s, True) for s in Source.get(main=True) ] 921 |
922 for test in UnitTest.all: 923 flags = { test.target : True } 924 test_sources = Source.get(**flags) 925 test_objs = [ make_obj(s, static=True) for s in test_sources ] 926 testname = "unittest/%s.%s" % (test.target, label) 927 new_env.Program(testname, main_objs + test_objs + static_objs) 928 |
|
914 progname = exename 915 if strip: 916 progname += '.unstripped' 917 918 targets = new_env.Program(progname, main_objs + static_objs) 919 920 if strip: 921 if sys.platform == 'sunos5': --- 54 unchanged lines hidden --- | 929 progname = exename 930 if strip: 931 progname += '.unstripped' 932 933 targets = new_env.Program(progname, main_objs + static_objs) 934 935 if strip: 936 if sys.platform == 'sunos5': --- 54 unchanged lines hidden --- |