initial build of module
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Tue, 19 Apr 2011 14:49:49 +0200
changeset 64 015a353a487b
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
--- a/helper/dce-application-helper.cc	Mon Apr 18 12:13:02 2011 +0200
+++ b/helper/dce-application-helper.cc	Tue Apr 19 14:49:49 2011 +0200
@@ -1,5 +1,5 @@
 #include "dce-application-helper.h"
-#include "ns3/dce-application.h"
+#include "dce-application.h"
 #include "ns3/log.h"
 #include <stdarg.h>
 
--- a/helper/dce-manager-helper.cc	Mon Apr 18 12:13:02 2011 +0200
+++ b/helper/dce-manager-helper.cc	Tue Apr 19 14:49:49 2011 +0200
@@ -1,9 +1,9 @@
 #include "dce-manager-helper.h"
-#include "ns3/dce-manager.h"
-#include "ns3/socket-fd-factory.h"
-#include "ns3/task-scheduler.h"
-#include "ns3/task-manager.h"
-#include "ns3/loader-factory.h"
+#include "dce-manager.h"
+#include "socket-fd-factory.h"
+#include "task-scheduler.h"
+#include "task-manager.h"
+#include "loader-factory.h"
 #include "ns3/random-variable.h"
 #include "ns3/uinteger.h"
 #include "ns3/string.h"
--- a/model/dce-application.cc	Mon Apr 18 12:13:02 2011 +0200
+++ b/model/dce-application.cc	Tue Apr 19 14:49:49 2011 +0200
@@ -1,7 +1,7 @@
 #include "dce-application.h"
+#include "dce-manager.h"
 #include "ns3/assert.h"
 #include "ns3/log.h"
-#include "ns3/dce-manager.h"
 #include "ns3/trace-source-accessor.h"
 
 namespace ns3 {
--- a/wscript	Mon Apr 18 12:13:02 2011 +0200
+++ b/wscript	Tue Apr 19 14:49:49 2011 +0200
@@ -1,90 +1,29 @@
 ## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
 
 import os
-
 import Options
 import os.path
-
-class CouldNotFindFile:
-    pass
-
-def search_file(files):
-    for f in files:
-        if os.path.isfile (f):
-            return f
-    raise CouldNotFindFile ()
-
-
-
+import ns3waf
 
-def create_dce_program(bld, name, is_c_only = False):
-    if not is_c_only:
-        program = bld.new_task_gen('cxx', 'program')
-        var = 'CXXFLAGS'
-    else:
-        program = bld.new_task_gen('cc', 'program')
-        var = 'CCFLAGS'
-    program.env.append_value(var, '-fpie')
-    program.env.append_value(var, '-U_FORTIFY_SOURCE')
-    if os.uname()[4] == 'x86_64':
-        program.env.append_value(var, '-mcmodel=large')
-#    program.env.append_value('LINKFLAGS', '-Wl,--dynamic-linker=/usr/lib/debug/ld-linux-x86-64.so.2')
-    program.is_ns3_program = True
-    program.name = name
-    program.target = name
-    program.env.append_value('LINKFLAGS', '-pie')
-    return program
-
-def add_build_dir(conf,d):
-    build_dir = os.path.abspath(os.path.join(conf.blddir, conf.env.variant(), 'src', 'dce', d))
-    conf.env.append_value('NS3_MODULE_PATH', build_dir)
-
-
-def set_options(opt):
+def options(opt):
     opt.tool_options('compiler_cc') 
-    opt.add_option('--with-linux-stack',
-                   help=('Path to the linux module'),
-                   default=None,
-                   dest='linux_stack', type="string")
+    ns3waf.options(opt)
 
 def configure(conf):
-    add_build_dir(conf, 'model')
-    add_build_dir(conf, 'vdl')
-    add_build_dir(conf, 'test')
-    add_build_dir(conf, 'example')
+    ns3waf.check_modules(conf, ['core', 'network', 'internet'], mandatory = True)
 
     conf.check_tool('compiler_cc')
-    conf.check(function_name='makecontext', 
-               header_name='ucontext.h',
-               mandatory=True)
+
     conf.env.append_value('LINKFLAGS', '-pthread')
     conf.env['HAVE_DL'] = conf.check (lib='dl')
 
-    if Options.options.linux_stack is not None and os.path.isdir(Options.options.linux_stack):
-        conf.check_message("linux stack location", '', True, 
-                           ("%s (given)" % Options.options.linux_stack))
-        conf.report_optional_feature("linux stack", "Linux stack", True,
-                                     "enabled (found in %s)" % Options.options.linux_stack)
-        conf.env['LINUX_STACK'] = os.path.abspath(Options.options.linux_stack)
-        conf.env.append_value('NS3_MODULE_PATH', conf.env['LINUX_STACK'])
-    else:
-        conf.check_message("linux stack location", '', False)
-        conf.report_optional_feature("linux stack", "Linux stack", False,
-                                     "linux stack not found")
-
-    vg_h = conf.check(header_name='valgrind/valgrind.h')
-    vg_memcheck_h = conf.check(header_name='valgrind/memcheck.h')
+    vg_h = conf.check(header_name='valgrind/valgrind.h', mandatory=False)
+    vg_memcheck_h = conf.check(header_name='valgrind/memcheck.h', mandatory=False)
     if vg_h and vg_memcheck_h:
         conf.env.append_value('CXXDEFINES', 'HAVE_VALGRIND_H')
 
-    conf.sub_config('vdl')
-
 def build(bld):
-    import types
-    bld.create_dce_program = types.MethodType(create_dce_program, bld)
-    # beeeurk: most deps below are un-needed.
-    dce = bld.create_ns3_module('dce', ['core', 'network', 'internet', 'point-to-point'])
-    dce.source = [
+    module_source = [
         'model/dce-manager.cc',
 	'model/dce-application.cc',
         'model/dce.cc',
@@ -141,11 +80,7 @@
         'helper/dce-manager-helper.cc',
         'helper/dce-application-helper.cc',
         ]
-    dce.uselib = 'DL'
-
-    headers = bld.new_task_gen('ns3header')
-    headers.module = 'dce'
-    headers.source = [
+    module_headers = [
         'model/dce-manager.h',
         'model/task-scheduler.h',
         'model/task-manager.h',
@@ -160,86 +95,12 @@
         'model/netlink-attribute.h',
         'model/netlink-socket-address.h',
         ]
-
-    if dce.env['LINUX_STACK']:
-        dce.source.extend([
-                'model/linux-socket-fd-factory.cc',
-                'model/linux-socket-fd.cc',
-                ])
-        dce.includes = dce.env['LINUX_STACK']
-        headers.source.extend ([
-                'model/linux-socket-fd-factory.h'])
-
-
-    rvd = bld.new_task_gen('cc', 'program')
-    rvd.name = 'readversiondef'
-    rvd.target = 'readversiondef'
-    rvd.source = ['model/readversiondef.c']
-
-    bld.add_group('dce_version_files')
-
-    libc = search_file ([
-            '/lib64/libc.so.6',
-            '/lib/libc.so.6',
-            ])
-    libpthread = search_file ([
-            '/lib64/libpthread.so.0',
-            '/lib/libpthread.so.0',
-            ])
-
-    bld.new_task_gen(source=['readversiondef', 'model/libc-ns3.version'],
-                     target='libc.version',
-                     rule='${SRC[0].abspath(env)} ' + libc + ' |' \
-                         'cat ${SRC[1].abspath()} - > ${TGT}')
-
-    bld.new_task_gen(source=['readversiondef', 'model/libpthread-ns3.version'],
-                     target='libpthread.version',
-                     rule='${SRC[0].abspath(env)} ' + libpthread + ' |' \
-                         'cat ${SRC[1].abspath()} - > ${TGT}')
-
-    bld.add_group('dce_use_version_files')
-
-    # The very small libc used to replace the glibc
-    # and forward to the dce_* code
-    module = bld.new_task_gen('cc', 'shlib')
-    module.name = 'c-ns3'
-    module.target = module.name
-    module.env.append_value('CCFLAGS', module.env['shlib_CCFLAGS'])
-    module.env.append_value('CCFLAGS', '-g')
-    module.env.append_value('CCDEFINES', 'LIBSETUP=libc_setup')
-    module.env.append_value('LINKFLAGS', '-nostdlib')
-    module.env.append_value('LINKFLAGS', 
-                            '-Wl,--version-script=' + bld.path.find_or_declare('libc.version').bldpath(bld.env))
-    module.env.append_value('LINKFLAGS', '-Wl,-soname=libc.so.6')
-    module.source = ['model/libc.c', 'model/libc-global-variables.c']
-
-    # The very small libpthread used to replace the glibc
-    # and forward to the dce_* code
-    module = bld.new_task_gen('cc', 'shlib')
-    module.name = 'pthread-ns3'
-    module.target = module.name
-    module.env.append_value('CCFLAGS', module.env['shlib_CCFLAGS'])
-    module.env.append_value('CCFLAGS', '-g')
-    module.env.append_value('CCDEFINES', 'LIBSETUP=libpthread_setup')
-    module.env.append_value('LINKFLAGS', '-nostdlib')
-    module.env.append_value('LINKFLAGS', '-lc')
-    module.env.append_value('LINKFLAGS', 
-                            '-Wl,--version-script=' + bld.path.find_or_declare('libpthread.version').bldpath(bld.env))
-    module.env.append_value('LINKFLAGS', '-Wl,-soname=libpthread.so.0')
-    module.source = ['model/libc.c']
-
-    # The following is needed to debug loader errors on ubuntu when you install libc6-dbg.
-    #obj.env.append_value('LINKFLAGS', '-Wl,--dynamic-linker=/usr/lib/debug/ld-linux.so.2')
-
-    bld.set_group(0)
-
-    dce_test = bld.create_ns3_module_test_library('dce')
-    dce_test.source = [
+    module_test = [
         'test/dce-manager-test.cc',
         'test/netlink-socket-test.cc',
         ]
-
-    if (bld.env['ENABLE_EXAMPLES']):
-        bld.add_subdirs(['example'])
-
-    bld.add_subdirs(['vdl', 'test', 'utils'])
+    uselib = ns3waf.modules_uselib(bld, ['core', 'network', 'internet'])
+    ns3waf.build_module(bld, 'dce',
+                        source=module_source,
+                        headers=module_headers,
+                        use=uselib)