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)
def shutdown(ctx): bld = wutils.bld if wutils.bld is None: return env = bld.env # Only print the lists if a build was done. if (env['PRINT_BUILT_MODULES_AT_END']): # Print the list of built modules. print print 'Modules built:' names_without_prefix = [] for name in env['NS3_ENABLED_MODULES']: name1 = name[len('ns3-'):] if name not in env.MODULAR_BINDINGS_MODULES: name1 += " (no Python)" names_without_prefix.append(name1) print_module_names(names_without_prefix) print # Print the list of enabled modules that were not built. if env['MODULES_NOT_BUILT']: print 'Modules not built (see ns-3 tutorial for explanation):' print_module_names(env['MODULES_NOT_BUILT']) print # Set this so that the lists won't be printed until the next # build is done. bld.env['PRINT_BUILT_MODULES_AT_END'] = False # Write the build status file. build_status_file = os.path.join(bld.out_dir, 'build-status.py') out = open(build_status_file, 'w') out.write('#! /usr/bin/env python\n') out.write('\n') out.write('# Programs that are runnable.\n') out.write('ns3_runnable_programs = ' + str(env['NS3_RUNNABLE_PROGRAMS']) + '\n') out.write('\n') out.write('# Scripts that are runnable.\n') out.write('ns3_runnable_scripts = ' + str(env['NS3_RUNNABLE_SCRIPTS']) + '\n') out.write('\n') out.close() if Options.options.lcov_report: lcov_report(bld) if Options.options.run: wutils.run_program(Options.options.run, env, wutils.get_command_template(env), visualize=Options.options.visualize) raise SystemExit(0) if Options.options.pyrun: wutils.run_python_program(Options.options.pyrun, env, visualize=Options.options.visualize) raise SystemExit(0) if Options.options.shell: raise WafError("Please run `./waf shell' now, instead of `./waf --shell'") if Options.options.check: raise WafError("Please run `./test.py' now, instead of `./waf --check'") check_shell(bld)
if not os.path.exists(reference_traces_path): print "Cannot locate reference traces in " + reference_traces_path return 1 if is_pyscript: script = os.path.abspath(os.path.join('..', *os.path.split(program))) argv = [self.env['PYTHON'], script] + arguments try: wutils.run_argv(argv, self.env, cwd=trace_output_path, force_no_valgrind=True) except Utils.WafError, ex: print >> sys.stderr, ex return 1 else: try: wutils.run_program(program, self.env, command_template=wutils.get_command_template(self.env, arguments), cwd=trace_output_path) except Utils.WafError, ex: print >> sys.stderr, ex return 1 rc = diff(trace_output_path, reference_traces_path, Options.options.verbose) if rc: print "----------" print "Traces differ in test: ", self.test_name print "Reference traces in directory: " + reference_traces_path print "Traces in directory: " + trace_output_path print "Run the following command for details:" print "\tdiff -u %s %s" % (reference_traces_path, trace_output_path) if not Options.options.verbose: print "Or re-run regression testing with option -v"