45 lines
1.5 KiB
Python
45 lines
1.5 KiB
Python
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
|
|
import Object
|
|
|
|
def build(bld):
|
|
env = bld.env_of_name('default')
|
|
|
|
if env['NS3_ENABLED_MODULES']:
|
|
modules = env['NS3_ENABLED_MODULES']
|
|
changed = True
|
|
while changed:
|
|
changed = False
|
|
for module in modules:
|
|
module_obj = Object.name_to_obj(module)
|
|
if module_obj is None:
|
|
raise ValueError("module %s not found" % module)
|
|
for dep in module_obj.add_objects:
|
|
if not dep.startswith('ns3-'):
|
|
continue
|
|
if dep not in modules:
|
|
modules.append(dep)
|
|
changed = True
|
|
|
|
## remove objects that depend on modules not listed
|
|
for obj in list(Object.g_allobjs):
|
|
if hasattr(obj, 'ns3_module_dependencies'):
|
|
for dep in obj.ns3_module_dependencies:
|
|
if dep not in modules:
|
|
Object.g_allobjs.remove(obj)
|
|
break
|
|
if obj.name in env['NS3_MODULES'] and obj.name not in modules:
|
|
Object.g_allobjs.remove(obj)
|
|
|
|
|
|
|
|
## Create a single ns3 library containing all modules
|
|
lib = bld.create_obj('cpp', 'shlib')
|
|
lib.name = 'ns3'
|
|
lib.target = 'ns3'
|
|
if env['NS3_ENABLED_MODULES']:
|
|
lib.add_objects = list(modules)
|
|
else:
|
|
lib.add_objects = list(env['NS3_MODULES'])
|
|
|
|
|