comparing with http://code.nsnam.org/ns-3-dev searching for changes changeset: 5930:0aaaaf92b988 user: Andrey Mazo date: Fri Jan 29 21:28:04 2010 +0300 files: wscript wutils.py description: Introduce NS3_EXECUTABLE_PATH variable similar to NS3_MODULE_PATH (e.g. may be used for various sock-creators). diff -r 6fc881b42bff -r 0aaaaf92b988 wscript --- a/wscript Wed Jan 27 12:09:07 2010 +0100 +++ b/wscript Fri Jan 29 21:28:04 2010 +0300 @@ -697,12 +697,14 @@ self.bld.env, proc_env, force_no_valgrind=True) def check_shell(bld): - if 'NS3_MODULE_PATH' not in os.environ: + if ('NS3_MODULE_PATH' not in os.environ) or ('NS3_EXECUTABLE_PATH' not in os.environ): return env = bld.env correct_modpath = os.pathsep.join(env['NS3_MODULE_PATH']) found_modpath = os.environ['NS3_MODULE_PATH'] - if found_modpath != correct_modpath: + correct_execpath = os.pathsep.join(env['NS3_EXECUTABLE_PATH']) + found_execpath = os.environ['NS3_EXECUTABLE_PATH'] + if (found_modpath != correct_modpath) or (correct_execpath != found_execpath): msg = ("Detected shell (./waf shell) with incorrect configuration\n" "=========================================================\n" "Possible reasons for this problem:\n" @@ -728,7 +730,8 @@ shell = os.environ.get("SHELL", "/bin/sh") env = wutils.bld.env - wutils.run_argv([shell], env, {'NS3_MODULE_PATH': os.pathsep.join(env['NS3_MODULE_PATH'])}) + os_env = {'NS3_MODULE_PATH': os.pathsep.join(env['NS3_MODULE_PATH']), 'NS3_EXECUTABLE_PATH': os.pathsep.join(env['NS3_EXECUTABLE_PATH'])} + wutils.run_argv([shell], env, os_env) def _doxygen(bld): env = wutils.bld.env diff -r 6fc881b42bff -r 0aaaaf92b988 wutils.py --- a/wutils.py Wed Jan 27 12:09:07 2010 +0100 +++ b/wutils.py Fri Jan 29 21:28:04 2010 +0300 @@ -112,6 +112,11 @@ else: proc_env['PYTHONPATH'] = pymoddir + if 'PATH' in proc_env: + proc_env['PATH'] = os.pathsep.join(list(env['NS3_EXECUTABLE_PATH']) + [proc_env['PATH']]) + else: + proc_env['PATH'] = os.pathsep.join(list(env['NS3_EXECUTABLE_PATH'])) + return proc_env def run_argv(argv, env, os_env=None, cwd=None, force_no_valgrind=False): changeset: 5931:79429e0a20ce tag: tip user: Andrey Mazo date: Fri Jan 29 21:31:25 2010 +0300 files: src/devices/emu/emu-net-device.cc src/devices/emu/emu-net-device.h src/devices/emu/wscript src/devices/tap-bridge/tap-bridge.cc src/devices/tap-bridge/tap-bridge.h src/devices/tap-bridge/wscript description: Bug 720: TapBridge creation fails from a script outside the ns3 tree. Look for {tap,emu-sock}-creator in $PATH. Get use of NS3_EXECUTABLE_PATH: append with "build/_ns3_active_variant_/src/devices/{tap-bridge,emu}". diff -r 0aaaaf92b988 -r 79429e0a20ce src/devices/emu/emu-net-device.cc --- a/src/devices/emu/emu-net-device.cc Fri Jan 29 21:28:04 2010 +0300 +++ b/src/devices/emu/emu-net-device.cc Fri Jan 29 21:31:25 2010 +0300 @@ -444,16 +444,16 @@ // // Execute the socket creation process image. // - status = ::execl (FindCreator ("emu-sock-creator").c_str (), + status = ::execlp ("emu-sock-creator", "emu-sock-creator", // argv[0] (filename) oss.str ().c_str (), // argv[1] (-p::const_iterator i = locations.begin (); i != locations.end (); ++i) - { - struct stat st; - - if (::stat ((*i + creatorName).c_str (), &st) == 0) - { - NS_LOG_INFO ("Found Creator " << *i + creatorName); - return *i + creatorName; - } - } - - NS_FATAL_ERROR ("EmuNetDevice::FindCreator(): Couldn't find creator"); - return ""; // quiet compiler -} - void EmuNetDevice::StopDevice (void) { diff -r 0aaaaf92b988 -r 79429e0a20ce src/devices/emu/emu-net-device.h --- a/src/devices/emu/emu-net-device.h Fri Jan 29 21:28:04 2010 +0300 +++ b/src/devices/emu/emu-net-device.h Fri Jan 29 21:31:25 2010 +0300 @@ -214,11 +214,6 @@ void CreateSocket (void); /** - * Figure out where the raw socket creation process lives on the system. - */ - std::string FindCreator (std::string creatorName); - - /** * Get a copy of the attached Queue. * * This method is provided for any derived class that may need to get diff -r 0aaaaf92b988 -r 79429e0a20ce src/devices/emu/wscript --- a/src/devices/emu/wscript Fri Jan 29 21:28:04 2010 +0300 +++ b/src/devices/emu/wscript Fri Jan 29 21:31:25 2010 +0300 @@ -1,5 +1,7 @@ ## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- +import os.path + def configure(conf): if conf.env['ENABLE_THREADING']: conf.env['ENABLE_EMU'] = conf.check(header_name='netpacket/packet.h', @@ -12,6 +14,11 @@ False, "needs threading support which is not available") + if conf.env['ENABLE_EMU']: + blddir = os.path.abspath(os.path.join(conf.blddir, conf.env.variant())) + emucreatordir = os.path.abspath(os.path.join(blddir, "src/devices/emu")) + conf.env.append_value('NS3_EXECUTABLE_PATH', emucreatordir) + def build(bld): module = bld.create_ns3_module('emu', ['node']) module.source = [ diff -r 0aaaaf92b988 -r 79429e0a20ce src/devices/tap-bridge/tap-bridge.cc --- a/src/devices/tap-bridge/tap-bridge.cc Fri Jan 29 21:28:04 2010 +0300 +++ b/src/devices/tap-bridge/tap-bridge.cc Fri Jan 29 21:31:25 2010 +0300 @@ -477,8 +477,8 @@ // // Execute the socket creation process image. // - status = ::execl (FindCreator ("tap-creator").c_str (), - FindCreator ("tap-creator").c_str (), // argv[0] (filename) + status = ::execlp ("tap-creator", + "tap-creator", // argv[0] (filename) ossDeviceName.str ().c_str (), // argv[1] (-d) ossGateway.str ().c_str (), // argv[2] (-g) ossIp.str ().c_str (), // argv[3] (-i) @@ -489,10 +489,10 @@ (char *)NULL); // - // If the execl successfully completes, it never returns. If it returns it failed or the OS is + // If the execlp successfully completes, it never returns. If it returns it failed or the OS is // broken. In either case, we bail. // - NS_FATAL_ERROR ("TapBridge::CreateTap(): Back from execl(), errno = " << ::strerror (errno)); + NS_FATAL_ERROR ("TapBridge::CreateTap(): Back from execlp(), errno = " << ::strerror (errno)); } else { @@ -614,44 +614,6 @@ } } -std::string -TapBridge::FindCreator (std::string creatorName) -{ - NS_LOG_FUNCTION (creatorName); - - std::list locations; - - // The path to the bits if we're sitting in the root of the repo - locations.push_back ("./build/optimized/src/devices/tap-bridge/"); - locations.push_back ("./build/debug/src/devices/tap-bridge/"); - - // if in src - locations.push_back ("../build/optimized/src/devices/tap-bridge/"); - locations.push_back ("../build/debug/src/devices/tap-bridge/"); - - // if in src/devices - locations.push_back ("../../build/optimized/src/devices/tap-bridge/"); - locations.push_back ("../../build/debug/src/devices/tap-bridge/"); - - // if in src/devices/tap-bridge - locations.push_back ("../../../build/optimized/src/devices/tap-bridge/"); - locations.push_back ("../../../build/debug/src/devices/tap-bridge/"); - - for (std::list::const_iterator i = locations.begin (); i != locations.end (); ++i) - { - struct stat st; - - if (::stat ((*i + creatorName).c_str (), &st) == 0) - { - NS_LOG_INFO ("Found Creator " << *i + creatorName); - return *i + creatorName; - } - } - - NS_FATAL_ERROR ("TapBridge::FindCreator(): Couldn't find creator"); - return ""; // quiet compiler -} - void TapBridge::ReadThread (void) { diff -r 0aaaaf92b988 -r 79429e0a20ce src/devices/tap-bridge/tap-bridge.h --- a/src/devices/tap-bridge/tap-bridge.h Fri Jan 29 21:28:04 2010 +0300 +++ b/src/devices/tap-bridge/tap-bridge.h Fri Jan 29 21:31:25 2010 +0300 @@ -234,16 +234,6 @@ /** * \internal * - * Figure out where the tap creation program lives on the system. - * - * \param creatorName The name of the program used to create the Tap. - * \returns A path name to use when you want to create a Tap. - */ - std::string FindCreator (std::string creatorName); - - /** - * \internal - * * Spin up the device */ void StartTapDevice (void); diff -r 0aaaaf92b988 -r 79429e0a20ce src/devices/tap-bridge/wscript --- a/src/devices/tap-bridge/wscript Fri Jan 29 21:28:04 2010 +0300 +++ b/src/devices/tap-bridge/wscript Fri Jan 29 21:31:25 2010 +0300 @@ -1,5 +1,7 @@ ## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- +import os.path + def configure(conf): if conf.env['ENABLE_THREADING']: conf.env['ENABLE_TAP'] = conf.check(header_name='linux/if_tun.h', @@ -12,6 +14,11 @@ False, "needs threading support which is not available") + if conf.env['ENABLE_TAP']: + blddir = os.path.abspath(os.path.join(conf.blddir, conf.env.variant())) + tapcreatordir = os.path.abspath(os.path.join(blddir, "src/devices/tap-bridge")) + conf.env.append_value('NS3_EXECUTABLE_PATH', tapcreatordir) + def build(bld): module = bld.create_ns3_module('tap-bridge', ['node']) module.source = [