WAF: convert code to WAF 1.4 API; the 'waf' script bundle will be updated later, for now has been disabled.

This commit is contained in:
Gustavo J. A. M. Carneiro
2008-04-26 21:54:36 +01:00
parent eb9fa68703
commit b61d0ff5f2
3 changed files with 21 additions and 26 deletions

View File

@@ -69,33 +69,27 @@ def create_ns3_module(bld, name, dependencies=()):
def build(bld):
Object.register('ns3header', Ns3Header)
#Object.register('ns3header', Ns3Header)
Action.Action('ns3header', func=_ns3_headers_inst, color='BLUE')
Object.register('ns3-module-header', Ns3ModuleHeader)
#Object.register('ns3-module-header', Ns3ModuleHeader)
Action.Action('gen-ns3-module-header', func=gen_ns3_module_header, color='BLUE')
bld.create_ns3_module = types.MethodType(create_ns3_module, bld)
bld.add_subdirs(list(all_modules))
for module in all_modules:
modheader = bld.create_obj('ns3-module-header')
modheader = bld.create_obj('ns3moduleheader')
modheader.module = module.split('/')[-1]
class Ns3Header(Object.genobj):
class ns3header_taskgen(Object.task_gen):
"""A set of NS-3 header files"""
def __init__(self, env=None):
Object.genobj.__init__(self, 'ns3header')
def __init__(self, *features):
Object.task_gen.__init__(self, *features)
self.inst_var = 'INCLUDEDIR'
self.inst_dir = 'ns3'
self.sub_dir = None # if not None, header files will be published as ns3/sub_dir/file.h
self.module = None # module name
self.env = env
if not self.env:
self.env = Params.g_build.m_allenvs['default']
def get_valid_types(self):
return ['ns3header']
def apply(self):
if self.module is None:
@@ -169,17 +163,13 @@ def gen_ns3_module_header(task):
return 0
class Ns3ModuleHeader(Object.genobj):
class ns3moduleheader_taskgen(Object.task_gen):
"""
Generates a 'ns3/foo-module.h' header file that includes all
public ns3 headers of a certain module.
"""
def __init__(self, env=None):
Object.genobj.__init__(self, 'other')
self.install_var = 0
self.env = env
if not self.env:
self.env = Params.g_build.m_allenvs['default'].copy()
def __init__(self, *features):
Object.task_gen.__init__(self, *features)
self.module_name = None
def apply(self):
@@ -187,7 +177,7 @@ class Ns3ModuleHeader(Object.genobj):
ns3_dir_node = Params.g_build.m_srcnode.find_dir("ns3")
all_headers_inputs = []
for ns3headers in Object.g_allobjs:
if ns3headers.m_type == 'ns3header':
if isinstance(ns3headers, ns3header_taskgen):
if ns3headers.module != self.module:
continue
for source in ns3headers.to_list(ns3headers.source):

3
waf vendored
View File

@@ -2,6 +2,9 @@
# encoding: utf-8
# Thomas Nagy, 2005-2008
raise RuntimeError("Sorry, this ns-3 branch temporarily requires WAF trunk (or 1.4.1);"
" I will update the WAF script later...")
"""
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions

14
wscript
View File

@@ -6,9 +6,11 @@ import types
import optparse
import os.path
import pproc as subprocess
import Params
import Object
import pproc as subprocess
import ccroot
Params.g_autoconfig = 1
@@ -218,6 +220,7 @@ def configure(conf):
def create_ns3_program(bld, name, dependencies=('simulator',)):
program = bld.create_obj('cpp', 'program')
program.is_ns3_program = True
program.name = name
program.target = program.name
program.uselib_local = 'ns3'
@@ -351,7 +354,7 @@ def _run_waf_check():
# --enable-modules=xxx
pass
else:
prog = program_obj.path.find_build(program_obj.get_target_name()).abspath(env)
prog = program_obj.path.find_build(ccroot.get_target_name(program_obj)).abspath(env)
out = open('doc/introspected-doxygen.h', 'w')
if subprocess.Popen([prog], stdout=out, env=proc_env).wait():
raise SystemExit(1)
@@ -359,12 +362,11 @@ def _run_waf_check():
run_program('run-tests', get_command_template())
def _find_program(program_name, env):
launch_dir = os.path.abspath(Params.g_cwd_launch)
found_programs = []
for obj in Object.g_allobjs:
if obj.m_type != 'program' or not obj.target:
if not getattr(obj, 'is_ns3_program', False):
continue
## filter out programs not in the subtree starting at the launch dir
@@ -430,7 +432,7 @@ def run_program(program_string, command_template=None):
Params.fatal(str(ex))
try:
program_node = program_obj.path.find_build(program_obj.get_target_name())
program_node = program_obj.path.find_build(ccroot.get_target_name(program_obj))
except AttributeError:
Params.fatal("%s does not appear to be a program" % (program_name,))
@@ -444,7 +446,7 @@ def run_program(program_string, command_template=None):
except ValueError, ex:
Params.fatal(str(ex))
try:
program_node = program_obj.path.find_build(program_obj.get_target_name())
program_node = program_obj.path.find_build(ccroot.get_target_name(program_obj))
except AttributeError:
Params.fatal("%s does not appear to be a program" % (program_name,))