Please note:The SCons wiki is now restored from the attack in March 2013. All old passwords have been invalidated. Please reset your password if you have an account. If you note missing pages, please report them to webmaster@scons.org. Also, new account creation is currently disabled due to an ongoing spam flood (2013/08/27).

NDDS 4 (also known as RTI DDS) is the Network Data Distribution Service, a commercial implementation of the OMG Data Distribution Service (DDS) standard. DDS is a real-time publish-subscribe middleware which one could consider a peer of CORBA.

This was developed on the Linux platform, and has not been tested on any other platform.

Here's the python source for the tool (ndds4.py):

   1 """SCons.Tool.ndds
   2 Tool-specific initialization for NDDS
   3 
   4 There normally shouldn't be any need to import this module directly.
   5 It will usually be imported through the generic SCons.Tool.Tool()
   6 selection method.
   7 
   8 """
   9 
  10 import os
  11 import re
  12 
  13 import SCons.Action
  14 import SCons.Builder
  15 import SCons.Defaults
  16 import SCons.Scanner.IDL
  17 import SCons.Tool
  18 import SCons.Util
  19 
  20 class ToolNddsWarning(SCons.Warnings.Warning):
  21    pass
  22 
  23 class NddsHomeNotFound(ToolNddsWarning):
  24    pass
  25 
  26 def emitNddsType(target, source, env):
  27    """Produce a list of files created by nddsgen"""
  28    base, ext = SCons.Util.splitext(str(source[0].abspath) )
  29       
  30    filenames = [base, base + 'Support', base + 'Plugin']
  31    
  32    dot_cxx = map(lambda f: f + '.cxx', filenames)
  33    dot_h = map(lambda f: f + '.h', filenames)
  34    
  35    #Don't forget to clean up the generated headers
  36    env.Clean(dot_cxx, dot_h)
  37    
  38    return dot_cxx, source
  39 
  40 scanNddsIDL = SCons.Scanner.IDL.IDLScan()
  41 
  42 actNddsGen = SCons.Action.Action('nddsgen -replace $SOURCE -d $TARGET.dir -I$SOURCE.dir')
  43 
  44 buildNddsType = SCons.Builder.Builder(action = actNddsGen,
  45                                       emitter = emitNddsType,
  46                                       source_scanner = scanNddsIDL,
  47                                       src_suffix='.idl')
  48 
  49 def _detect(env):
  50    """Not really safe, but fast method to detect NDDSHOME"""
  51 
  52    NDDSHOME = env['ENV'].get('NDDSHOME',None)
  53    if NDDSHOME!=None : return NDDSHOME
  54 
  55    NDDSHOME = os.environ.get('NDDSHOME',None)
  56    if NDDSHOME!=None : return NDDSHOME
  57 
  58    nddsgen = env.WhereIs('nddsgen')
  59    if nddsgen:
  60       SCons.Warnings.warn(
  61          NddsHomeNotFound,
  62          "NDDSHOME variable is not defined, using nddsgen executable as a hint (NDDSHOME=%s)" % NDDSHOME)
  63       return os.path.dirname(os.path.dirname(nddsgen))
  64 
  65    SCons.Warnings.warn(
  66       NddsHomeNotFound,
  67       "Could not detect ndds, using empty NDDSHOME")
  68    return None
  69 
  70 def generate(env):
  71    """Add Builder and Scanner for ndds to the Environment."""
  72 
  73    
  74    
  75    try:
  76       NDDSHOME = _detect(env)
  77 
  78       NDDSARCH = os.listdir(os.path.join(NDDSHOME, 'lib') )[0]
  79    except:
  80       print "Error looking for NDDSHOME and/or libraries"
  81 
  82    print "Loading ndds4 tool..."
  83 
  84    #Set up NDDS environment      
  85    env.AppendUnique(CPPPATH = [os.path.join(NDDSHOME,'include')] )
  86    env.AppendUnique(CPPPATH = [os.path.join(NDDSHOME,'include', 'ndds')] )
  87    
  88    env.AppendUnique(CPPDEFINES = ['RTI_UNIX'] )
  89 
  90    #TODO: Options for static vs. dynamic and debug vs. optimized?
  91    env.AppendUnique(LIBS = SCons.Util.Split("""
  92                                                nddscppzd
  93                                                nddsczd
  94                                                nddscorezd
  95                                                pthread                    
  96                                             """) )
  97 
  98    env.Append(LIBPATH = os.path.join(NDDSHOME, 'lib', NDDSARCH) )
  99 
 100 
 101    
 102    #Add the scanner and builder to the environment
 103    env.Append(SCANNERS = [scanNddsIDL])
 104    env.Append(BUILDERS = {'NddsType' : buildNddsType})
 105    
 106    #Add them to the object builders
 107    static_obj, shared_obj = SCons.Tool.createObjBuilders(env)
 108    
 109    static_obj.src_builder.append('NddsType')
 110    shared_obj.src_builder.append('NddsType')
 111    
 112 def exists(env):
 113    return _detect(env)

The tool must be loaded into your environment like so:

   1 env.Tool('ndds4', ['path_to_ndds4.py_file'])

See the section on Tool objects in the SCons User Guide for more details.

The following python source demonstrates several ways you may use the tool:

   1 #Precondition: Environment 'env' must have the ndds4 tool loaded.
   2 
   3 #(1) Run nddsgen on the idl file specified (generates source and header files)
   4 env.NddsType('Foo.idl')
   5 
   6 # (2) Run nddsgen on Foo.idl, then compile the resulting source files (Foo.cxx, FooSupport.cxx, FooPlugin.cxx)
   7 env.StaticObject('Foo.idl')
   8 
   9 # (3) Run nddsgen on Foo.idl, compile the source files and roll them into a static library
  10 env.StaticLibrary('Foo.idl')
  11 
  12 # (4) Run nddsgen on Foo.idl, compile the source files and link them into an executable
  13 env.Program(['main.cpp', 'Foo.idl'])

NDDS4_Tool (last edited 2008-03-12 02:47:10 by localhost)