rendered paste body## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-import os.pathimport Actionimport Paramsimport Taskfrom Params import fataltry: import pyplusplusexcept ImportError, ex: HAVE_PYPLUSPLUS = False _PYPLUSPLUS_ERROR = str(ex)else: HAVE_PYPLUSPLUS = Truedef set_options(opt): opt.tool_options('python')def configure(conf): ## Check for Python if not (conf.check_tool('python') and conf.check_python_version((2,4,2)) and conf.check_python_headers()): fatal("Error: missing Python development environment.\n" "(Hint: if you do not have a debugging Python library installed" " try using the configure option '--debug-level release')") ## Check for Boost::Python e = conf.create_header_enumerator() e.mandatory = True e.uselib = 'PYEXT' e.name = 'boost/python.hpp' e.run() ## Check for Py++ conf.check_message('Py++', '', HAVE_PYPLUSPLUS, (HAVE_PYPLUSPLUS and pyplusplus.__version__ or _PYPLUSPLUS_ERROR)) if not HAVE_PYPLUSPLUS: fatal("Py++ is missing (%s)" % (_PYPLUSPLUS_ERROR,)) def pyplusplus_codegen(task): assert len(task.m_outputs) == 1 header_files = [node.abspath(task.m_env) for node in task.m_inputs] mb = pyplusplus.module_builder.module_builder_t( header_files, include_paths=[Params.g_build.m_curdirnode.abspath(task.m_env)]) outnode = task.m_outputs[0] module_name, _ = os.path.splitext(outnode.m_name) mb.build_code_creator(module_name) mb.write_module(outnode.abspath(task.m_env)) return 0def build(bld): Action.Action('py++', func=pyplusplus_codegen) ## get the ns3 headers for ns3headers in bld.m_outstanding_objs: if ns3headers.name == 'ns3headers': break else: raise AssertionError task = Task.Task('py++', bld.env_of_name('default'), 5) inputs = [] ns3_dir_node = Params.g_build.m_srcnode.find_dir("ns3") for source in ns3headers.to_list(ns3headers.source): inputs.append(ns3_dir_node.find_build(os.path.basename(source))) task.set_inputs(inputs) outputs = [bld.m_curdirnode.find_build('ns3.cpp')] task.set_outputs(outputs) pymod = bld.create_obj('cpp', 'shlib', 'pyext') pymod.source = 'ns3.cpp' pymod.target = 'ns3' pymod.add_objects = "ns3"