This commit is contained in:
Raj Bhattacharjea
2009-01-20 11:41:57 -05:00
17 changed files with 904 additions and 231 deletions

View File

@@ -137,7 +137,7 @@ def main():
root_module.classes.remove(root_module['ns3::%s' % clsname])
if 'RealTime' not in enabled_features:
for clsname in ['WallClockSynchronizer', 'RealtimeSimulatorImpl', 'RealtimeEventLock']:
for clsname in ['WallClockSynchronizer', 'RealtimeSimulatorImpl']:
root_module.classes.remove(root_module['ns3::%s' % clsname])
root_module.enums.remove(root_module['ns3::RealtimeSimulatorImpl::SynchronizationMode'])
@@ -146,5 +146,14 @@ def main():
out.close()
if __name__ == '__main__':
main()
if 0:
try:
import cProfile as profile
except ImportError:
main()
else:
print >> sys.stderr, "** running under profiler"
profile.run('main()', 'ns3modulegen.pstat')
else:
main()

View File

@@ -14,11 +14,6 @@ import Logs
import Build
import Utils
## Adjust python path to look for our local copy of pybindgen
LOCAL_PYBINDGEN_PATH = os.path.join(os.getcwd(), "bindings", "python", "pybindgen")
#PYBINDGEN_BRANCH = 'lp:pybindgen'
PYBINDGEN_BRANCH = 'https://launchpad.net/pybindgen'
## https://launchpad.net/pybindgen/
REQUIRED_PYBINDGEN_VERSION = (0, 9, 0, 605)
REQUIRED_PYGCCXML_VERSION = (0, 9, 5)
@@ -33,8 +28,6 @@ def add_to_python_path(path):
def set_pybindgen_pythonpath(env):
if env['WITH_PYBINDGEN']:
add_to_python_path(env['WITH_PYBINDGEN'])
else:
add_to_python_path(LOCAL_PYBINDGEN_PATH)
def set_options(opt):
@@ -47,67 +40,11 @@ def set_options(opt):
help=("Rescan Python bindings. Needs working GCCXML / pygccxml environment."),
action="store_true", default=False,
dest='python_scan')
opt.add_option('--pybindgen-checkout',
help=("During configure, force checkout of pybingen inside ns-3, "
"instead of using the system installed version."),
action="store_true", default=False,
dest='pybindgen_checkout')
opt.add_option('--with-pybindgen',
help=('Path to an existing pybindgen source tree to use.'),
default=None,
dest='with_pybindgen', type="string")
def fetch_pybindgen(conf):
"""
Fetches pybindgen from launchpad as bindings/python/pybindgen.
Returns True if successful, False it not.
"""
bzr = conf.find_program("bzr")
if not bzr:
Logs.warn("the program 'bzr' is needed in order to fetch pybindgen")
return False
if len(REQUIRED_PYBINDGEN_VERSION) == 4:
rev = "-rrevno:%i" % REQUIRED_PYBINDGEN_VERSION[3]
else:
rev = "-rtag:%s" % '.'.join([str(x) for x in REQUIRED_PYBINDGEN_VERSION])
if os.path.exists(LOCAL_PYBINDGEN_PATH):
print "Trying to update pybindgen; this will fail if no network connection is available. Hit Ctrl-C to skip."
cmd = [bzr, "pull", rev, PYBINDGEN_BRANCH]
print " => ", ' '.join(cmd)
try:
if subprocess.Popen(cmd, cwd=LOCAL_PYBINDGEN_PATH).wait():
return False
except KeyboardInterrupt:
print "Interrupted; Python bindings will be disabled."
return False
print "Update was successful."
else:
print "Trying to fetch pybindgen; this will fail if no network connection is available. Hit Ctrl-C to skip."
cmd = [bzr, "checkout", rev, PYBINDGEN_BRANCH, LOCAL_PYBINDGEN_PATH]
print " => ", ' '.join(cmd)
try:
if subprocess.Popen(cmd).wait():
return False
except KeyboardInterrupt:
print "Interrupted; Python bindings will be disabled."
shutil.rmtree(LOCAL_PYBINDGEN_PATH, True)
return False
print "Fetch was successful."
## generate a fake version.py file in pybindgen it's safer this
## way, since the normal version generation process requires
## bazaar python bindings, which may not be available.
vfile = open(os.path.join(LOCAL_PYBINDGEN_PATH, "pybindgen", "version.py"), "wt")
vfile.write("""
# (fake version generated by ns-3)
__version__ = %r
""" % list(REQUIRED_PYBINDGEN_VERSION))
vfile.close()
return True
def configure(conf):
conf.env['ENABLE_PYTHON_BINDINGS'] = False
@@ -140,9 +77,6 @@ def configure(conf):
conf.env['WITH_PYBINDGEN'] = os.path.abspath(Options.options.with_pybindgen)
no_net = True
if Options.options.pybindgen_checkout:
fetch_pybindgen(conf)
set_pybindgen_pythonpath(conf.env)
try:
@@ -484,7 +418,8 @@ def build(bld):
bindgen = bld.new_task_gen('command', source=source, target=target,
command=argv, variables=dict(FEATURES=(','.join(features))))
bindgen.before = 'cxx'
bindgen.after = 'gen_everything_h_task'
## we build python bindings if either we have the tools to
## generate them or if the pregenerated source file is already
@@ -499,7 +434,15 @@ def build(bld):
pymod.target = 'ns3/_ns3'
pymod.name = 'ns3module'
pymod.uselib_local = "ns3"
pymod.env.append_value('CXXDEFINES', ['NS_DEPRECATED=', 'NS3_DEPRECATED_H'])
defines = list(pymod.env['CXXDEFINES'])
defines.extend(['NS_DEPRECATED=', 'NS3_DEPRECATED_H'])
if Options.platform == 'win32':
try:
defines.remove('_DEBUG') # causes undefined symbols on win32
except ValueError:
pass
pymod.env['CXXDEFINES'] = defines
# copy the __init__.py file to the build dir. waf can't handle
# this, it's against waf's principles to have build dir files