wscript
changeset 6624 a071889af159
parent 6362 ca7a4f7e24e7
child 6637 b7903dd92942
equal deleted inserted replaced
6623:616d42c69f05 6624:a071889af159
    41 	}
    41 	}
    42 cflags.default_profile = 'debug'
    42 cflags.default_profile = 'debug'
    43 
    43 
    44 # local modules
    44 # local modules
    45 import wutils
    45 import wutils
    46 import regression
       
    47 
    46 
    48 Configure.autoconfig = 1
    47 Configure.autoconfig = 1
    49 
    48 
    50 # the following two variables are used by the target "waf dist"
    49 # the following two variables are used by the target "waf dist"
    51 VERSION = file("VERSION", "rt").read().strip()
    50 VERSION = file("VERSION", "rt").read().strip()
    52 APPNAME = 'ns'
    51 APPNAME = 'ns'
    53 
    52 
    54 wutils.VERSION = VERSION
    53 wutils.VERSION = VERSION
    55 wutils.APPNAME = APPNAME
    54 wutils.APPNAME = APPNAME
    56 
       
    57 #
       
    58 # The last part of the path name to use to find the regression traces.  The
       
    59 # path will be APPNAME + '-' + VERSION + REGRESSION_SUFFIX, e.g.,
       
    60 # ns-3-dev-ref-traces
       
    61 #
       
    62 REGRESSION_SUFFIX = "-ref-traces"
       
    63 
       
    64 
    55 
    65 # these variables are mandatory ('/' are converted automatically)
    56 # these variables are mandatory ('/' are converted automatically)
    66 srcdir = '.'
    57 srcdir = '.'
    67 blddir = 'build'
    58 blddir = 'build'
    68 
    59 
    94 def dist_hook():
    85 def dist_hook():
    95     import tarfile
    86     import tarfile
    96     shutil.rmtree("doc/html", True)
    87     shutil.rmtree("doc/html", True)
    97     shutil.rmtree("doc/latex", True)
    88     shutil.rmtree("doc/latex", True)
    98     shutil.rmtree("nsc", True)
    89     shutil.rmtree("nsc", True)
    99 
       
   100     ## build the name of the traces subdirectory.  Will be something like
       
   101     ## ns-3-dev-ref-traces
       
   102     traces_name = APPNAME + '-' + VERSION + REGRESSION_SUFFIX
       
   103     ## Create a tar.bz2 file with the traces
       
   104     env = load_env()
       
   105     regression_dir = env['REGRESSION_TRACES']
       
   106     if not os.path.isdir(regression_dir):
       
   107         Logs.warn("Not creating traces archive: the %s directory does not exist" % regression_dir)
       
   108     else:
       
   109         traceball = traces_name + wutils.TRACEBALL_SUFFIX
       
   110         tar = tarfile.open(os.path.join("..", traceball), 'w:bz2')
       
   111         files = get_files(regression_dir)
       
   112         for fullfilename,relfilename in files:
       
   113             tar.add(fullfilename,arcname=relfilename)
       
   114         tar.close()
       
   115 
    90 
   116 def set_options(opt):
    91 def set_options(opt):
   117     # options provided by the modules
    92     # options provided by the modules
   118     opt.tool_options('compiler_cc')
    93     opt.tool_options('compiler_cc')
   119     opt.tool_options('compiler_cxx')
    94     opt.tool_options('compiler_cxx')
   175                    dest='enable_examples', action='store_true',
   150                    dest='enable_examples', action='store_true',
   176                    default=True)
   151                    default=True)
   177     opt.add_option('--disable-examples',
   152     opt.add_option('--disable-examples',
   178                    help=('Do not build the ns-3 examples and samples.'),
   153                    help=('Do not build the ns-3 examples and samples.'),
   179                    dest='enable_examples', action='store_false')
   154                    dest='enable_examples', action='store_false')
   180     opt.add_option('--regression',
       
   181                    help=("Enable regression testing; only used for the 'check' target"),
       
   182                    default=False, dest='regression', action="store_true")
       
   183     opt.add_option('--check',
   155     opt.add_option('--check',
   184                    help=('DEPRECATED (run ./test.py)'),
   156                    help=('DEPRECATED (run ./test.py)'),
   185                    default=False, dest='check', action="store_true")
   157                    default=False, dest='check', action="store_true")
   186     opt.add_option('--regression-generate',
       
   187                    help=("Generate new regression test traces."),
       
   188                    default=False, dest='regression_generate', action="store_true")
       
   189     opt.add_option('--regression-tests',
       
   190                    help=('For regression testing, only run/generate the indicated regression tests, '
       
   191                          'specified as a comma separated list of test names'),
       
   192                    dest='regression_tests', type="string")
       
   193     opt.add_option('--with-regression-traces',
       
   194                    help=('Path to the regression reference traces directory'),
       
   195                    default=None,
       
   196                    dest='regression_traces', type="string")
       
   197     opt.add_option('--enable-static',
   158     opt.add_option('--enable-static',
   198                    help=('Compile NS-3 statically: works only on linux, without python'),
   159                    help=('Compile NS-3 statically: works only on linux, without python'),
   199                    dest='enable_static', action='store_true',
   160                    dest='enable_static', action='store_true',
   200                    default=False)
   161                    default=False)
   201     opt.add_option('--enable-mpi',
   162     opt.add_option('--enable-mpi',
   256         conf.check_tool('pkgconfig', ['waf-tools'])
   217         conf.check_tool('pkgconfig', ['waf-tools'])
   257     except Configure.ConfigurationError:
   218     except Configure.ConfigurationError:
   258         pass
   219         pass
   259     conf.check_tool('command', ['waf-tools'])
   220     conf.check_tool('command', ['waf-tools'])
   260 
   221 
   261     # Check for the location of regression reference traces
       
   262     if Options.options.regression_traces is not None:
       
   263         if os.path.isdir(Options.options.regression_traces):
       
   264             conf.check_message("regression traces location", '', True, ("%s (given)" % Options.options.regression_traces))
       
   265             conf.env['REGRESSION_TRACES'] = os.path.abspath(Options.options.regression_traces)
       
   266     else:
       
   267         traces = os.path.join('..', "%s-%s%s" % (APPNAME, VERSION, REGRESSION_SUFFIX))
       
   268         if os.path.isdir(traces):
       
   269             conf.check_message("regression reference traces", '', True, ("%s (guessed)" % traces))
       
   270             conf.env['REGRESSION_TRACES'] = os.path.abspath(traces)
       
   271         del traces
       
   272     if not conf.env['REGRESSION_TRACES']:
       
   273         conf.check_message("regression reference traces", '', False)
       
   274 
       
   275     # create the second environment, set the variant and set its name
   222     # create the second environment, set the variant and set its name
   276     variant_env = conf.env.copy()
   223     variant_env = conf.env.copy()
   277     variant_name = Options.options.build_profile
   224     variant_name = Options.options.build_profile
   278 
   225 
   279     if Options.options.enable_gcov:
   226     if Options.options.enable_gcov:
   370         env['ENABLE_EXAMPLES'] = False
   317         env['ENABLE_EXAMPLES'] = False
   371         why_not_examples = "option --disable-examples selected"
   318         why_not_examples = "option --disable-examples selected"
   372 
   319 
   373     conf.report_optional_feature("ENABLE_EXAMPLES", "Build examples and samples", env['ENABLE_EXAMPLES'], 
   320     conf.report_optional_feature("ENABLE_EXAMPLES", "Build examples and samples", env['ENABLE_EXAMPLES'], 
   374                                  why_not_examples)
   321                                  why_not_examples)
   375 
       
   376     # we cannot pull regression traces without mercurial
       
   377     conf.find_program('hg', var='MERCURIAL')
       
   378 
   322 
   379     conf.find_program('valgrind', var='VALGRIND')
   323     conf.find_program('valgrind', var='VALGRIND')
   380 
   324 
   381     env['ENABLE_STATIC_NS3'] = False
   325     env['ENABLE_STATIC_NS3'] = False
   382     if Options.options.enable_static:
   326     if Options.options.enable_static:
   642         # want to do is run a test program.
   586         # want to do is run a test program.
   643         Options.options.compile_targets += ',' + os.path.basename(program_name)
   587         Options.options.compile_targets += ',' + os.path.basename(program_name)
   644         for gen in bld.all_task_gen:
   588         for gen in bld.all_task_gen:
   645             if type(gen).__name__ in ['ns3header_taskgen', 'ns3moduleheader_taskgen']:
   589             if type(gen).__name__ in ['ns3header_taskgen', 'ns3moduleheader_taskgen']:
   646                 gen.post()
   590                 gen.post()
   647 
       
   648     if Options.options.regression or Options.options.regression_generate:
       
   649         regression_traces = env['REGRESSION_TRACES']
       
   650         if not regression_traces:
       
   651             raise Utils.WafError("Cannot run regression tests: reference traces directory not given"
       
   652                                  " (--with-regression-traces configure option)")
       
   653 
       
   654         if env['ENABLE_EXAMPLES'] == True:
       
   655             regression.run_regression(bld, regression_traces)
       
   656         else:
       
   657             raise Utils.WafError("Cannot run regression tests: building the ns-3 examples is not enabled"
       
   658                                  " (regression tests are based on examples)")
       
   659 
       
   660 
   591 
   661     if Options.options.doxygen_no_build:
   592     if Options.options.doxygen_no_build:
   662         _doxygen(bld)
   593         _doxygen(bld)
   663         raise SystemExit(0)
   594         raise SystemExit(0)
   664 
   595