All pastes #349634 Raw Edit

gjc

public text v1 · immutable
·published 2007-02-10 23:13 UTC
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):    print task.m_inputs    header_files = [node.abspath() for node in task.m_inputs]    mb = pyplusplus.module_builder.module_builder_t(        header_files,        include_paths=[os.path.join(Params.g_build.m_bdir, "default")])        mb.build_code_creator("ns3")    #mb.code_creator.precompiled_header = 'boost/python.hpp'    generated_files_dir = Params.g_build.m_curdirnode.find_build("bindins/python/generated", 1)    mb.write_module(os.path.join(generated_files_dir.abspath(), 'ns3.cpp'))        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('generated', 1).find_build('ns3.cpp')]    task.set_outputs(outputs)