self.cc_source = Source(cc_file, swig=True, parent=self)
self.py_source = PySource(package, py_file, parent=self)
+class ProtoBuf(SourceFile):
+ '''Add a Protocol Buffer to build'''
+
+ def __init__(self, source, **guards):
+ '''Specify the source file, and any guards'''
+ super(ProtoBuf, self).__init__(source, **guards)
+
+ # Get the file name and the extension
+ modname,ext = self.extname
+ assert ext == 'proto'
+
+ # Currently, we stick to generating the C++ headers, so we
+ # only need to track the source and header.
+ self.cc_file = File(joinpath(self.dirname, modname + '.pb.cc'))
+ self.hh_file = File(joinpath(self.dirname, modname + '.pb.h'))
+
class UnitTest(object):
'''Create a UnitTest'''
Export('PySource')
Export('SimObject')
Export('SwigSource')
+Export('ProtoBuf')
Export('UnitTest')
########################################################################
MakeAction(makeEmbeddedSwigInit, Transform("EMBED SW")))
Source(init_file, **swig.guards)
+# Build all protocol buffers if we have got protoc and protobuf available
+if env['HAVE_PROTOBUF']:
+ for proto in ProtoBuf.all:
+ # Use both the source and header as the target, and the .proto
+ # file as the source. When executing the protoc compiler, also
+ # specify the proto_path to avoid having the generated files
+ # include the path.
+ env.Command([proto.cc_file, proto.hh_file], proto.tnode,
+ MakeAction('$PROTOC --cpp_out ${TARGET.dir} '
+ '--proto_path ${SOURCE.dir} $SOURCE',
+ Transform("PROTOC")))
+
+ # Add the C++ source file
+ Source(proto.cc_file, **proto.guards)
+elif ProtoBuf.all:
+ print 'Got protobuf to build, but lacks support!'
+ Exit(1)
+
#
# Handle debug flags
#
new_env.Append(**kwargs)
swig_env = new_env.Clone()
- swig_env.Append(CCFLAGS='-Werror')
+
+ # Both gcc and clang have issues with unused labels and values in
+ # the SWIG generated code
+ swig_env.Append(CCFLAGS=['-Wno-unused-label', '-Wno-unused-value'])
+
+ # Add additional warnings here that should not be applied to
+ # the SWIG generated code
+ new_env.Append(CXXFLAGS='-Wmissing-declarations')
+
if env['GCC']:
- swig_env.Append(CCFLAGS=['-Wno-uninitialized', '-Wno-sign-compare',
- '-Wno-parentheses', '-Wno-unused-label',
- '-Wno-unused-value'])
+ # Depending on the SWIG version, we also need to supress
+ # warnings about uninitialized variables and missing field
+ # initializers.
+ swig_env.Append(CCFLAGS=['-Wno-uninitialized',
+ '-Wno-missing-field-initializers'])
+
if compareVersions(env['GCC_VERSION'], '4.6') >= 0:
swig_env.Append(CCFLAGS='-Wno-unused-but-set-variable')
+
+ # If gcc supports it, also warn for deletion of derived
+ # classes with non-virtual desctructors. For gcc >= 4.7 we
+ # also have to disable warnings about the SWIG code having
+ # potentially uninitialized variables.
+ if compareVersions(env['GCC_VERSION'], '4.7') >= 0:
+ new_env.Append(CXXFLAGS='-Wdelete-non-virtual-dtor')
+ swig_env.Append(CCFLAGS='-Wno-maybe-uninitialized')
if env['CLANG']:
- swig_env.Append(CCFLAGS=['-Wno-unused-label', '-Wno-unused-value'])
+ # Always enable the warning for deletion of derived classes
+ # with non-virtual destructors
+ new_env.Append(CXXFLAGS=['-Wdelete-non-virtual-dtor'])
werror_env = new_env.Clone()
werror_env.Append(CCFLAGS='-Werror')
ccflags['fast'] += env['LTO_CCFLAGS']
ldflags['fast'] += env['LTO_LDFLAGS']
-
-elif env['SUNCC']:
- ccflags['debug'] += ['-g0']
- ccflags['opt'] += ['-O']
- for target in ['fast', 'prof', 'perf']:
- ccflags[target] += ['-fast']
-elif env['ICC']:
- ccflags['debug'] += ['-g', '-O0']
- ccflags['opt'] += ['-O']
- for target in ['fast', 'prof', 'perf']:
- ccflags[target] += ['-fast']
elif env['CLANG']:
ccflags['debug'] += ['-g', '-O0']
# opt, fast, prof and perf all share the same cc flags