diff -r 0aa205436740 -r 9b9cd17a0791 src/SConscript --- a/src/SConscript Tue Dec 21 08:23:53 2010 -0800 +++ b/src/SConscript Tue Dec 21 08:24:23 2010 -0800 @@ -61,17 +61,22 @@ super(SourceMeta, cls).__init__(name, bases, dict) cls.all = [] - def get(cls, **kwargs): + def get(cls, **flags): for src in cls.all: - for attr,value in kwargs.iteritems(): - if getattr(src, attr) != value: + for flag,value in flags.iteritems(): + # if the flag is found and has a different value, skip + # this file + if src.all_flags.get(flag, False) != value: break else: yield src class SourceFile(object): __metaclass__ = SourceMeta - def __init__(self, source): + def __init__(self, source, parent=None, **flags): + self.flags = flags + self.parent = parent + tnode = source if not isinstance(source, SCons.Node.FS.File): tnode = File(source) @@ -92,6 +97,15 @@ if issubclass(base, SourceFile): base.all.append(self) + @property + def all_flags(self): + flags = {} + if self.parent: + flags.update(self.parent.flags) + flags.update(self.flags) + return flags + + def __lt__(self, other): return self.filename < other.filename def __le__(self, other): return self.filename <= other.filename def __gt__(self, other): return self.filename > other.filename @@ -101,14 +115,11 @@ class Source(SourceFile): '''Add a c/c++ source file to the build''' - def __init__(self, source, Werror=True, swig=False, bin_only=False, - skip_lib=False): - super(Source, self).__init__(source) + def __init__(self, source, Werror=True, swig=False, **flags): + super(Source, self).__init__(source, **flags) self.Werror = Werror self.swig = swig - self.bin_only = bin_only - self.skip_lib = bin_only or skip_lib class PySource(SourceFile): '''Add a python source file to the named package''' @@ -117,8 +128,8 @@ tnodes = {} symnames = {} - def __init__(self, package, source): - super(PySource, self).__init__(source) + def __init__(self, package, source, **flags): + super(PySource, self).__init__(source, **flags) modname,ext = self.extname assert ext == 'py' @@ -168,8 +179,8 @@ class SwigSource(SourceFile): '''Add a swig file to build''' - def __init__(self, package, source): - super(SwigSource, self).__init__(source) + def __init__(self, package, source, **flags): + super(SwigSource, self).__init__(source, **flags) modname,ext = self.extname assert ext == 'i' @@ -178,8 +189,8 @@ cc_file = joinpath(self.dirname, modname + '_wrap.cc') py_file = joinpath(self.dirname, modname + '.py') - self.cc_source = Source(cc_file, swig=True) - self.py_source = PySource(package, py_file) + self.cc_source = Source(cc_file, swig=True, parent=self) + self.py_source = PySource(package, py_file, parent=self) unit_tests = [] def UnitTest(target, sources): @@ -824,8 +835,9 @@ return obj - static_objs = [ make_obj(s, True) for s in Source.get(skip_lib=False)] - shared_objs = [ make_obj(s, False) for s in Source.get(skip_lib=False)] + sources = Source.get(main=False, skip_lib=False) + static_objs = [ make_obj(s, True) for s in sources ] + shared_objs = [ make_obj(s, False) for s in sources ] static_date = make_obj(date_source, static=True, extra_deps=static_objs) static_objs.append(static_date) @@ -843,12 +855,13 @@ new_env.Program("unittest/%s.%s" % (target, label), objs + static_objs) # Now link a stub with main() and the static library. - bin_objs = [make_obj(s, True) for s in Source.get(bin_only=True) ] + main_objs = [ make_obj(s, True) for s in Source.get(main=True) ] + progname = exename if strip: progname += '.unstripped' - targets = new_env.Program(progname, bin_objs + static_objs) + targets = new_env.Program(progname, main_objs + static_objs) if strip: if sys.platform == 'sunos5': diff -r 0aa205436740 -r 9b9cd17a0791 src/sim/SConscript --- a/src/sim/SConscript Tue Dec 21 08:23:53 2010 -0800 +++ b/src/sim/SConscript Tue Dec 21 08:24:23 2010 -0800 @@ -39,7 +39,7 @@ Source('debug.cc') Source('eventq.cc') Source('init.cc') -Source('main.cc', bin_only=True) +Source('main.cc', main=True, kip_lib=True) Source('root.cc') Source('serialize.cc') Source('sim_events.cc')