wscript
changeset 2846 7689461231ac
parent 2622 6440851b111a
child 2866 1d829915f092
equal deleted inserted replaced
2740:45f6c609e22c 2846:7689461231ac
    17 APPNAME = 'ns'
    17 APPNAME = 'ns'
    18 
    18 
    19 # these variables are mandatory ('/' are converted automatically)
    19 # these variables are mandatory ('/' are converted automatically)
    20 srcdir = '.'
    20 srcdir = '.'
    21 blddir = 'build'
    21 blddir = 'build'
    22 
       
    23 
    22 
    24 def dist_hook():
    23 def dist_hook():
    25     shutil.rmtree("doc/html", True)
    24     shutil.rmtree("doc/html", True)
    26     shutil.rmtree("doc/latex", True)
    25     shutil.rmtree("doc/latex", True)
    27 
    26 
    45                          'with the configure command.'),
    44                          'with the configure command.'),
    46                    callback=debug_option_callback)
    45                    callback=debug_option_callback)
    47     
    46     
    48     # options provided by the modules
    47     # options provided by the modules
    49     opt.tool_options('compiler_cxx')
    48     opt.tool_options('compiler_cxx')
       
    49 
       
    50     opt.add_option('--cwd',
       
    51                    help=('Set the working directory for a program.'),
       
    52                    action="store", type="string", default=None,
       
    53                    dest='cwd_launch')
    50 
    54 
    51     opt.add_option('--enable-gcov',
    55     opt.add_option('--enable-gcov',
    52                    help=('Enable code coverage analysis.'
    56                    help=('Enable code coverage analysis.'
    53                          ' WARNING: this option only has effect '
    57                          ' WARNING: this option only has effect '
    54                          'with the configure command.'),
    58                          'with the configure command.'),
   162     return program
   166     return program
   163 
   167 
   164 
   168 
   165 def build(bld):
   169 def build(bld):
   166     Params.g_cwd_launch = Params.g_build.m_curdirnode.abspath()
   170     Params.g_cwd_launch = Params.g_build.m_curdirnode.abspath()
   167 
   171         
   168     bld.create_ns3_program = types.MethodType(create_ns3_program, bld)
   172     bld.create_ns3_program = types.MethodType(create_ns3_program, bld)
   169 
   173 
   170     variant_name = bld.env_of_name('default')['NS3_ACTIVE_VARIANT']
   174     variant_name = bld.env_of_name('default')['NS3_ACTIVE_VARIANT']
   171     variant_env = bld.env_of_name(variant_name)
   175     variant_env = bld.env_of_name(variant_name)
   172     bld.m_allenvs['default'] = variant_env # switch to the active variant
   176     bld.m_allenvs['default'] = variant_env # switch to the active variant
   376         except AttributeError:
   380         except AttributeError:
   377             Params.fatal("%s does not appear to be a program" % (program_name,))
   381             Params.fatal("%s does not appear to be a program" % (program_name,))
   378 
   382 
   379         execvec = shlex.split(command_template % (program_node.abspath(env),))
   383         execvec = shlex.split(command_template % (program_node.abspath(env),))
   380 
   384 
   381 
       
   382     former_cwd = os.getcwd()
   385     former_cwd = os.getcwd()
   383     os.chdir(Params.g_cwd_launch)
   386     if (Params.g_options.cwd_launch):
       
   387         os.chdir(Params.g_options.cwd_launch)
       
   388     else:
       
   389         os.chdir(Params.g_cwd_launch)
   384     try:
   390     try:
   385         retval = _run_argv(execvec)
   391         retval = _run_argv(execvec)
   386     finally:
   392     finally:
   387         os.chdir(former_cwd)
   393         os.chdir(former_cwd)
   388 
   394 
   413     else:
   419     else:
   414         shell = os.environ.get("SHELL", "/bin/sh")
   420         shell = os.environ.get("SHELL", "/bin/sh")
   415 
   421 
   416     env = Params.g_build.env_of_name('default')
   422     env = Params.g_build.env_of_name('default')
   417     _run_argv([shell], {'NS3_MODULE_PATH': os.pathsep.join(env['NS3_MODULE_PATH'])})
   423     _run_argv([shell], {'NS3_MODULE_PATH': os.pathsep.join(env['NS3_MODULE_PATH'])})
   418 
       
   419 
   424 
   420 def doxygen():
   425 def doxygen():
   421     if not os.path.exists('doc/introspected-doxygen.h'):
   426     if not os.path.exists('doc/introspected-doxygen.h'):
   422         Params.warning("doc/introspected-doxygen.h does not exist; run waf check to generate it.")
   427         Params.warning("doc/introspected-doxygen.h does not exist; run waf check to generate it.")
   423 
   428