initial build of module
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Tue, 19 Apr 2011 14:49:49 +0200
changeset 64015a353a487b
parent 63 e89dca438df6
child 65 227f6347e4e1
initial build of module
helper/dce-application-helper.cc
helper/dce-manager-helper.cc
model/dce-application.cc
wscript
     1.1 --- a/helper/dce-application-helper.cc	Mon Apr 18 12:13:02 2011 +0200
     1.2 +++ b/helper/dce-application-helper.cc	Tue Apr 19 14:49:49 2011 +0200
     1.3 @@ -1,5 +1,5 @@
     1.4  #include "dce-application-helper.h"
     1.5 -#include "ns3/dce-application.h"
     1.6 +#include "dce-application.h"
     1.7  #include "ns3/log.h"
     1.8  #include <stdarg.h>
     1.9  
     2.1 --- a/helper/dce-manager-helper.cc	Mon Apr 18 12:13:02 2011 +0200
     2.2 +++ b/helper/dce-manager-helper.cc	Tue Apr 19 14:49:49 2011 +0200
     2.3 @@ -1,9 +1,9 @@
     2.4  #include "dce-manager-helper.h"
     2.5 -#include "ns3/dce-manager.h"
     2.6 -#include "ns3/socket-fd-factory.h"
     2.7 -#include "ns3/task-scheduler.h"
     2.8 -#include "ns3/task-manager.h"
     2.9 -#include "ns3/loader-factory.h"
    2.10 +#include "dce-manager.h"
    2.11 +#include "socket-fd-factory.h"
    2.12 +#include "task-scheduler.h"
    2.13 +#include "task-manager.h"
    2.14 +#include "loader-factory.h"
    2.15  #include "ns3/random-variable.h"
    2.16  #include "ns3/uinteger.h"
    2.17  #include "ns3/string.h"
     3.1 --- a/model/dce-application.cc	Mon Apr 18 12:13:02 2011 +0200
     3.2 +++ b/model/dce-application.cc	Tue Apr 19 14:49:49 2011 +0200
     3.3 @@ -1,7 +1,7 @@
     3.4  #include "dce-application.h"
     3.5 +#include "dce-manager.h"
     3.6  #include "ns3/assert.h"
     3.7  #include "ns3/log.h"
     3.8 -#include "ns3/dce-manager.h"
     3.9  #include "ns3/trace-source-accessor.h"
    3.10  
    3.11  namespace ns3 {
     4.1 --- a/wscript	Mon Apr 18 12:13:02 2011 +0200
     4.2 +++ b/wscript	Tue Apr 19 14:49:49 2011 +0200
     4.3 @@ -1,90 +1,29 @@
     4.4  ## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
     4.5  
     4.6  import os
     4.7 -
     4.8  import Options
     4.9  import os.path
    4.10 +import ns3waf
    4.11  
    4.12 -class CouldNotFindFile:
    4.13 -    pass
    4.14 -
    4.15 -def search_file(files):
    4.16 -    for f in files:
    4.17 -        if os.path.isfile (f):
    4.18 -            return f
    4.19 -    raise CouldNotFindFile ()
    4.20 -
    4.21 -
    4.22 -
    4.23 -
    4.24 -def create_dce_program(bld, name, is_c_only = False):
    4.25 -    if not is_c_only:
    4.26 -        program = bld.new_task_gen('cxx', 'program')
    4.27 -        var = 'CXXFLAGS'
    4.28 -    else:
    4.29 -        program = bld.new_task_gen('cc', 'program')
    4.30 -        var = 'CCFLAGS'
    4.31 -    program.env.append_value(var, '-fpie')
    4.32 -    program.env.append_value(var, '-U_FORTIFY_SOURCE')
    4.33 -    if os.uname()[4] == 'x86_64':
    4.34 -        program.env.append_value(var, '-mcmodel=large')
    4.35 -#    program.env.append_value('LINKFLAGS', '-Wl,--dynamic-linker=/usr/lib/debug/ld-linux-x86-64.so.2')
    4.36 -    program.is_ns3_program = True
    4.37 -    program.name = name
    4.38 -    program.target = name
    4.39 -    program.env.append_value('LINKFLAGS', '-pie')
    4.40 -    return program
    4.41 -
    4.42 -def add_build_dir(conf,d):
    4.43 -    build_dir = os.path.abspath(os.path.join(conf.blddir, conf.env.variant(), 'src', 'dce', d))
    4.44 -    conf.env.append_value('NS3_MODULE_PATH', build_dir)
    4.45 -
    4.46 -
    4.47 -def set_options(opt):
    4.48 +def options(opt):
    4.49      opt.tool_options('compiler_cc') 
    4.50 -    opt.add_option('--with-linux-stack',
    4.51 -                   help=('Path to the linux module'),
    4.52 -                   default=None,
    4.53 -                   dest='linux_stack', type="string")
    4.54 +    ns3waf.options(opt)
    4.55  
    4.56  def configure(conf):
    4.57 -    add_build_dir(conf, 'model')
    4.58 -    add_build_dir(conf, 'vdl')
    4.59 -    add_build_dir(conf, 'test')
    4.60 -    add_build_dir(conf, 'example')
    4.61 +    ns3waf.check_modules(conf, ['core', 'network', 'internet'], mandatory = True)
    4.62  
    4.63      conf.check_tool('compiler_cc')
    4.64 -    conf.check(function_name='makecontext', 
    4.65 -               header_name='ucontext.h',
    4.66 -               mandatory=True)
    4.67 +
    4.68      conf.env.append_value('LINKFLAGS', '-pthread')
    4.69      conf.env['HAVE_DL'] = conf.check (lib='dl')
    4.70  
    4.71 -    if Options.options.linux_stack is not None and os.path.isdir(Options.options.linux_stack):
    4.72 -        conf.check_message("linux stack location", '', True, 
    4.73 -                           ("%s (given)" % Options.options.linux_stack))
    4.74 -        conf.report_optional_feature("linux stack", "Linux stack", True,
    4.75 -                                     "enabled (found in %s)" % Options.options.linux_stack)
    4.76 -        conf.env['LINUX_STACK'] = os.path.abspath(Options.options.linux_stack)
    4.77 -        conf.env.append_value('NS3_MODULE_PATH', conf.env['LINUX_STACK'])
    4.78 -    else:
    4.79 -        conf.check_message("linux stack location", '', False)
    4.80 -        conf.report_optional_feature("linux stack", "Linux stack", False,
    4.81 -                                     "linux stack not found")
    4.82 -
    4.83 -    vg_h = conf.check(header_name='valgrind/valgrind.h')
    4.84 -    vg_memcheck_h = conf.check(header_name='valgrind/memcheck.h')
    4.85 +    vg_h = conf.check(header_name='valgrind/valgrind.h', mandatory=False)
    4.86 +    vg_memcheck_h = conf.check(header_name='valgrind/memcheck.h', mandatory=False)
    4.87      if vg_h and vg_memcheck_h:
    4.88          conf.env.append_value('CXXDEFINES', 'HAVE_VALGRIND_H')
    4.89  
    4.90 -    conf.sub_config('vdl')
    4.91 -
    4.92  def build(bld):
    4.93 -    import types
    4.94 -    bld.create_dce_program = types.MethodType(create_dce_program, bld)
    4.95 -    # beeeurk: most deps below are un-needed.
    4.96 -    dce = bld.create_ns3_module('dce', ['core', 'network', 'internet', 'point-to-point'])
    4.97 -    dce.source = [
    4.98 +    module_source = [
    4.99          'model/dce-manager.cc',
   4.100  	'model/dce-application.cc',
   4.101          'model/dce.cc',
   4.102 @@ -141,11 +80,7 @@
   4.103          'helper/dce-manager-helper.cc',
   4.104          'helper/dce-application-helper.cc',
   4.105          ]
   4.106 -    dce.uselib = 'DL'
   4.107 -
   4.108 -    headers = bld.new_task_gen('ns3header')
   4.109 -    headers.module = 'dce'
   4.110 -    headers.source = [
   4.111 +    module_headers = [
   4.112          'model/dce-manager.h',
   4.113          'model/task-scheduler.h',
   4.114          'model/task-manager.h',
   4.115 @@ -160,86 +95,12 @@
   4.116          'model/netlink-attribute.h',
   4.117          'model/netlink-socket-address.h',
   4.118          ]
   4.119 -
   4.120 -    if dce.env['LINUX_STACK']:
   4.121 -        dce.source.extend([
   4.122 -                'model/linux-socket-fd-factory.cc',
   4.123 -                'model/linux-socket-fd.cc',
   4.124 -                ])
   4.125 -        dce.includes = dce.env['LINUX_STACK']
   4.126 -        headers.source.extend ([
   4.127 -                'model/linux-socket-fd-factory.h'])
   4.128 -
   4.129 -
   4.130 -    rvd = bld.new_task_gen('cc', 'program')
   4.131 -    rvd.name = 'readversiondef'
   4.132 -    rvd.target = 'readversiondef'
   4.133 -    rvd.source = ['model/readversiondef.c']
   4.134 -
   4.135 -    bld.add_group('dce_version_files')
   4.136 -
   4.137 -    libc = search_file ([
   4.138 -            '/lib64/libc.so.6',
   4.139 -            '/lib/libc.so.6',
   4.140 -            ])
   4.141 -    libpthread = search_file ([
   4.142 -            '/lib64/libpthread.so.0',
   4.143 -            '/lib/libpthread.so.0',
   4.144 -            ])
   4.145 -
   4.146 -    bld.new_task_gen(source=['readversiondef', 'model/libc-ns3.version'],
   4.147 -                     target='libc.version',
   4.148 -                     rule='${SRC[0].abspath(env)} ' + libc + ' |' \
   4.149 -                         'cat ${SRC[1].abspath()} - > ${TGT}')
   4.150 -
   4.151 -    bld.new_task_gen(source=['readversiondef', 'model/libpthread-ns3.version'],
   4.152 -                     target='libpthread.version',
   4.153 -                     rule='${SRC[0].abspath(env)} ' + libpthread + ' |' \
   4.154 -                         'cat ${SRC[1].abspath()} - > ${TGT}')
   4.155 -
   4.156 -    bld.add_group('dce_use_version_files')
   4.157 -
   4.158 -    # The very small libc used to replace the glibc
   4.159 -    # and forward to the dce_* code
   4.160 -    module = bld.new_task_gen('cc', 'shlib')
   4.161 -    module.name = 'c-ns3'
   4.162 -    module.target = module.name
   4.163 -    module.env.append_value('CCFLAGS', module.env['shlib_CCFLAGS'])
   4.164 -    module.env.append_value('CCFLAGS', '-g')
   4.165 -    module.env.append_value('CCDEFINES', 'LIBSETUP=libc_setup')
   4.166 -    module.env.append_value('LINKFLAGS', '-nostdlib')
   4.167 -    module.env.append_value('LINKFLAGS', 
   4.168 -                            '-Wl,--version-script=' + bld.path.find_or_declare('libc.version').bldpath(bld.env))
   4.169 -    module.env.append_value('LINKFLAGS', '-Wl,-soname=libc.so.6')
   4.170 -    module.source = ['model/libc.c', 'model/libc-global-variables.c']
   4.171 -
   4.172 -    # The very small libpthread used to replace the glibc
   4.173 -    # and forward to the dce_* code
   4.174 -    module = bld.new_task_gen('cc', 'shlib')
   4.175 -    module.name = 'pthread-ns3'
   4.176 -    module.target = module.name
   4.177 -    module.env.append_value('CCFLAGS', module.env['shlib_CCFLAGS'])
   4.178 -    module.env.append_value('CCFLAGS', '-g')
   4.179 -    module.env.append_value('CCDEFINES', 'LIBSETUP=libpthread_setup')
   4.180 -    module.env.append_value('LINKFLAGS', '-nostdlib')
   4.181 -    module.env.append_value('LINKFLAGS', '-lc')
   4.182 -    module.env.append_value('LINKFLAGS', 
   4.183 -                            '-Wl,--version-script=' + bld.path.find_or_declare('libpthread.version').bldpath(bld.env))
   4.184 -    module.env.append_value('LINKFLAGS', '-Wl,-soname=libpthread.so.0')
   4.185 -    module.source = ['model/libc.c']
   4.186 -
   4.187 -    # The following is needed to debug loader errors on ubuntu when you install libc6-dbg.
   4.188 -    #obj.env.append_value('LINKFLAGS', '-Wl,--dynamic-linker=/usr/lib/debug/ld-linux.so.2')
   4.189 -
   4.190 -    bld.set_group(0)
   4.191 -
   4.192 -    dce_test = bld.create_ns3_module_test_library('dce')
   4.193 -    dce_test.source = [
   4.194 +    module_test = [
   4.195          'test/dce-manager-test.cc',
   4.196          'test/netlink-socket-test.cc',
   4.197          ]
   4.198 -
   4.199 -    if (bld.env['ENABLE_EXAMPLES']):
   4.200 -        bld.add_subdirs(['example'])
   4.201 -
   4.202 -    bld.add_subdirs(['vdl', 'test', 'utils'])
   4.203 +    uselib = ns3waf.modules_uselib(bld, ['core', 'network', 'internet'])
   4.204 +    ns3waf.build_module(bld, 'dce',
   4.205 +                        source=module_source,
   4.206 +                        headers=module_headers,
   4.207 +                        use=uselib)