Exemple #1
0
 def __init__(self, *args, **kwargs):
     super(SuidBuild_task, self).__init__(*args, **kwargs)
     self.m_display = 'build-suid'
     try:
         program_obj = wutils.find_program(self.generator.name, self.generator.env)
     except ValueError, ex:
         raise WafError(str(ex))
Exemple #2
0
def _doxygen(bld):
    env = wutils.bld.env
    proc_env = wutils.get_proc_env()

    if not env['DOXYGEN']:
        Logs.error("waf configure did not detect doxygen in the system -> cannot build api docs.")
        raise SystemExit(1)
        return

    try:
        program_obj = wutils.find_program('print-introspected-doxygen', env)
    except ValueError: 
        Logs.warn("print-introspected-doxygen does not exist")
        raise SystemExit(1)
        return

    prog = program_obj.path.find_or_declare(program_obj.target).get_bld().abspath()

    if not os.path.exists(prog):
        Logs.error("print-introspected-doxygen has not been built yet."
                   " You need to build ns-3 at least once before "
                   "generating doxygen docs...")
        raise SystemExit(1)

    # Create a header file with the introspected information.
    doxygen_out = open(os.path.join('doc', 'introspected-doxygen.h'), 'w')
    if subprocess.Popen([prog], stdout=doxygen_out, env=proc_env).wait():
        raise SystemExit(1)
    doxygen_out.close()

    # Create a text file with the introspected information.
    text_out = open(os.path.join('doc', 'ns3-object.txt'), 'w')
    if subprocess.Popen([prog, '--output-text'], stdout=text_out, env=proc_env).wait():
        raise SystemExit(1)
    text_out.close()

    _getVersion()
    doxygen_config = os.path.join('doc', 'doxygen.conf')
    if subprocess.Popen([env['DOXYGEN'], doxygen_config]).wait():
        Logs.error("Doxygen build returned an error.")
        raise SystemExit(1)
Exemple #3
0
    def run(self):
        ## generate the trace sources list docs
        env = wutils.bld.env
        proc_env = wutils.get_proc_env()
        try:
            program_obj = wutils.find_program('print-introspected-doxygen', env)
        except ValueError: # could happen if print-introspected-doxygen is
                           # not built because of waf configure
                           # --enable-modules=xxx
            pass
        else:
            prog = program_obj.path.find_or_declare(ccroot.get_target_name(program_obj)).get_bld().abspath(env)

            # Create a header file with the introspected information.
            doxygen_out = open(os.path.join('doc', 'introspected-doxygen.h'), 'w')
            if subprocess.Popen([prog], stdout=doxygen_out, env=proc_env).wait():
                raise SystemExit(1)
            doxygen_out.close()
        
            # Create a text file with the introspected information.
            text_out = open(os.path.join('doc', 'ns3-object.txt'), 'w')
            if subprocess.Popen([prog, '--output-text'], stdout=text_out, env=proc_env).wait():
                raise SystemExit(1)
            text_out.close()
Exemple #4
0
def build(bld):
    env = bld.env

    # If --enabled-modules option was given, then print a warning
    # message and exit this function.
    if Options.options.enable_modules:
        Logs.warn("No modules were built.  Use waf configure --enable-modules to enable modules.")
        return

    bld.env['NS3_MODULES_WITH_TEST_LIBRARIES'] = []
    bld.env['NS3_ENABLED_MODULE_TEST_LIBRARIES'] = []
    bld.env['NS3_SCRIPT_DEPENDENCIES'] = []
    bld.env['NS3_RUNNABLE_PROGRAMS'] = []
    bld.env['NS3_RUNNABLE_SCRIPTS'] = []

    wutils.bld = bld
    if Options.options.no_task_lines:
        from waflib import Runner
        def null_printout(s):
            pass
        Runner.printout = null_printout

    Options.cwd_launch = bld.path.abspath()
    bld.create_ns3_program = types.MethodType(create_ns3_program, bld)
    bld.register_ns3_script = types.MethodType(register_ns3_script, bld)
    bld.create_suid_program = types.MethodType(create_suid_program, bld)
    bld.__class__.all_task_gen = property(_get_all_task_gen)
    bld.exclude_taskgen = types.MethodType(_exclude_taskgen, bld)
    bld.find_ns3_module = types.MethodType(_find_ns3_module, bld)

    # Clean documentation build directories; other cleaning happens later
    if bld.cmd == 'clean':
        _cleandocs()

    # process subfolders from here
    bld.recurse('src')

    # If modules have been enabled, then set lists of enabled modules
    # and enabled module test libraries.
    if env['NS3_ENABLED_MODULES']:
        modules = env['NS3_ENABLED_MODULES']

        # Find out about additional modules that need to be enabled
        # due to dependency constraints.
        changed = True
        while changed:
            changed = False
            for module in modules:
                module_obj = bld.get_tgen_by_name(module)
                if module_obj is None:
                    raise ValueError("module %s not found" % module)
                # Each enabled module has its own library.
                for dep in module_obj.use:
                    if not dep.startswith('ns3-'):
                        continue
                    if dep not in modules:
                        modules.append(dep)
                        changed = True

        env['NS3_ENABLED_MODULES'] = modules

        # If tests are being built, then set the list of the enabled
        # module test libraries.
        if env['ENABLE_TESTS']:
            for (mod, testlib) in bld.env['NS3_MODULES_WITH_TEST_LIBRARIES']:
                if mod in bld.env['NS3_ENABLED_MODULES']:
                    bld.env.append_value('NS3_ENABLED_MODULE_TEST_LIBRARIES', testlib)

    add_examples_programs(bld)
    add_scratch_programs(bld)

    if env['NS3_ENABLED_MODULES']:
        modules = env['NS3_ENABLED_MODULES']

        # Exclude the programs other misc task gens that depend on disabled modules
        for obj in list(bld.all_task_gen):

            # check for ns3moduleheader_taskgen
            if 'ns3moduleheader' in getattr(obj, "features", []):
                if ("ns3-%s" % obj.module) not in modules:
                    obj.mode = 'remove' # tell it to remove headers instead of installing

            # check for programs
            if hasattr(obj, 'ns3_module_dependencies'):
                # this is an NS-3 program (bld.create_ns3_program)
                program_built = True
                for dep in obj.ns3_module_dependencies:
                    if dep not in modules: # prog. depends on a module that isn't enabled?
                        bld.exclude_taskgen(obj)
                        program_built = False
                        break

                # Add this program to the list if all of its
                # dependencies will be built.
                if program_built:
                    object_name = "%s%s-%s%s" % (wutils.APPNAME, wutils.VERSION, 
                                                  obj.name, bld.env.BUILD_SUFFIX)

                    # Get the relative path to the program from the
                    # launch directory.
                    launch_dir = os.path.abspath(Context.launch_dir)
                    object_relative_path = os.path.join(
                        wutils.relpath(obj.path.get_bld().abspath(), launch_dir),
                        object_name)

                    bld.env.append_value('NS3_RUNNABLE_PROGRAMS', object_relative_path)

            # disable the modules themselves
            if hasattr(obj, "is_ns3_module") and obj.name not in modules:
                bld.exclude_taskgen(obj) # kill the module

            # disable the module test libraries
            if hasattr(obj, "is_ns3_module_test_library"):
                if not env['ENABLE_TESTS'] or (obj.module_name not in modules):
                    bld.exclude_taskgen(obj) # kill the module test library

            # disable the ns3header_taskgen
            if 'ns3header' in getattr(obj, "features", []):
                if ("ns3-%s" % obj.module) not in modules:
                    obj.mode = 'remove' # tell it to remove headers instead of installing 

            # disable the ns3privateheader_taskgen
            if 'ns3privateheader' in getattr(obj, "features", []):
                if ("ns3-%s" % obj.module) not in modules:
                    obj.mode = 'remove' # tell it to remove headers instead of installing 

            # disable pcfile taskgens for disabled modules
            if 'ns3pcfile' in getattr(obj, "features", []):
                if obj.module not in bld.env.NS3_ENABLED_MODULES:
                    bld.exclude_taskgen(obj)


    if env['NS3_ENABLED_MODULES']:
        env['NS3_ENABLED_MODULES'] = list(modules)

    # Determine which scripts will be runnable.
    for (script, dependencies) in bld.env['NS3_SCRIPT_DEPENDENCIES']:
        script_runnable = True
        for dep in dependencies:
            if dep not in modules:
                script_runnable = False
                break

        # Add this script to the list if all of its dependencies will
        # be built.
        if script_runnable:
            bld.env.append_value('NS3_RUNNABLE_SCRIPTS', script)

    bld.recurse('bindings/python')

    # Process this subfolder here after the lists of enabled modules
    # and module test libraries have been set.
    bld.recurse('utils')

    # Set this so that the lists will be printed at the end of this
    # build command.
    bld.env['PRINT_BUILT_MODULES_AT_END'] = True

    # Do not print the modules built if build command was "clean"
    if bld.cmd == 'clean':
        bld.env['PRINT_BUILT_MODULES_AT_END'] = False

    if Options.options.run:
        # Check that the requested program name is valid
        program_name, dummy_program_argv = wutils.get_run_program(Options.options.run, wutils.get_command_template(env))

        # When --run'ing a program, tell WAF to only build that program,
        # nothing more; this greatly speeds up compilation when all you
        # want to do is run a test program.
        Options.options.targets += ',' + os.path.basename(program_name)
        if getattr(Options.options, "visualize", False):
            program_obj = wutils.find_program(program_name, bld.env)
            program_obj.use.append('ns3-visualizer')
        for gen in bld.all_task_gen:
            if type(gen).__name__ in ['ns3header_taskgen', 'ns3privateheader_taskgen', 'ns3moduleheader_taskgen']:
                gen.post()
        bld.env['PRINT_BUILT_MODULES_AT_END'] = False 

    if Options.options.doxygen_no_build:
        _doxygen(bld)
        raise SystemExit(0)