comparing with http://code.nsnam.org/ns-3-dev
searching for changes
changeset: 5930:0aaaaf92b988
user: Andrey Mazo <mazo@iitp.ru>
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).
--- a/src/devices/emu/emu-net-device.cc Fri Jan 08 15:27:53 2010 -0800
+++ b/src/devices/emu/emu-net-device.cc Fri Feb 05 10:15:18 2010 -0800
@@ -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<path?
(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 ("EmuNetDevice::CreateSocket(): Back from execl(), errno = " << ::strerror (errno));
+ NS_FATAL_ERROR ("EmuNetDevice::CreateSocket(): Back from execlp(), errno = " << ::strerror (errno));
}
else
{
@@ -581,52 +581,6 @@
}
}
-std::string
-EmuNetDevice::FindCreator (std::string creatorName)
-{
- NS_LOG_FUNCTION (creatorName);
-
- std::list<std::string> locations;
-
- // The path to the bits if we're sitting there with them
- locations.push_back ("./");
- locations.push_back ("./");
-
- // The path to the bits if we're sitting in the root of the repo
- locations.push_back ("./build/optimized/src/devices/emu/");
- locations.push_back ("./build/debug/src/devices/emu/");
-
- // if at the level of src (or build)
- locations.push_back ("../build/optimized/src/devices/emu/");
- locations.push_back ("../build/debug/src/devices/emu/");
-
- // src/devices (or build/debug)
- locations.push_back ("../../build/optimized/src/devices/emu/");
- locations.push_back ("../../build/debug/src/devices/emu/");
-
- // src/devices/emu (or build/debug/examples)
- locations.push_back ("../../../build/optimized/src/devices/emu/");
- locations.push_back ("../../../build/debug/src/devices/emu/");
-
- // src/devices/emu (or build/debug/examples/emulation)
- locations.push_back ("../../../../build/optimized/src/devices/emu/");
- locations.push_back ("../../../../build/debug/src/devices/emu/");
-
- for (std::list<std::string>::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)
{
--- a/src/devices/emu/emu-net-device.h Fri Jan 08 15:27:53 2010 -0800
+++ b/src/devices/emu/emu-net-device.h Fri Feb 05 10:15:18 2010 -0800
@@ -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
--- a/src/devices/emu/wscript Fri Jan 08 15:27:53 2010 -0800
+++ b/src/devices/emu/wscript Fri Feb 05 10:15:18 2010 -0800
@@ -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 = [
--- a/src/devices/tap-bridge/tap-bridge.cc Fri Jan 08 15:27:53 2010 -0800
+++ b/src/devices/tap-bridge/tap-bridge.cc Fri Feb 05 10:15:18 2010 -0800
@@ -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<device name>)
ossGateway.str ().c_str (), // argv[2] (-g<gateway>)
ossIp.str ().c_str (), // argv[3] (-i<IP address>)
@@ -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<std::string> 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<std::string>::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)
{
--- a/src/devices/tap-bridge/tap-bridge.h Fri Jan 08 15:27:53 2010 -0800
+++ b/src/devices/tap-bridge/tap-bridge.h Fri Feb 05 10:15:18 2010 -0800
@@ -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);
--- a/src/devices/tap-bridge/wscript Fri Jan 08 15:27:53 2010 -0800
+++ b/src/devices/tap-bridge/wscript Fri Feb 05 10:15:18 2010 -0800
@@ -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 = [
--- a/wscript Fri Jan 08 15:27:53 2010 -0800
+++ b/wscript Fri Feb 05 10:15:18 2010 -0800
@@ -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
--- a/wutils.py Fri Jan 08 15:27:53 2010 -0800
+++ b/wutils.py Fri Feb 05 10:15:18 2010 -0800
@@ -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):