diff --git a/ns3/_placeholder_ b/ns3/_placeholder_ deleted file mode 100644 --- a/ns3/_placeholder_ +++ /dev/null @@ -1,1 +0,0 @@ -This is a placeholder file used only to keep the ns3 directory present (needed for the WAF build system). diff --git a/src/internet/model/tcp-option-rfc793.h b/src/internet/model/tcp-option-rfc793.h --- a/src/internet/model/tcp-option-rfc793.h +++ b/src/internet/model/tcp-option-rfc793.h @@ -20,7 +20,7 @@ #ifndef TCPOPTIONRFC793_H #define TCPOPTIONRFC793_H -#include "tcp-option.h" +#include "ns3/tcp-option.h" namespace ns3 { diff --git a/src/internet/model/tcp-option-ts.h b/src/internet/model/tcp-option-ts.h --- a/src/internet/model/tcp-option-ts.h +++ b/src/internet/model/tcp-option-ts.h @@ -21,7 +21,7 @@ #ifndef TCP_OPTION_TS_H #define TCP_OPTION_TS_H -#include "tcp-option.h" +#include "ns3/tcp-option.h" #include "ns3/timer.h" namespace ns3 { diff --git a/src/internet/model/tcp-option-winscale.h b/src/internet/model/tcp-option-winscale.h --- a/src/internet/model/tcp-option-winscale.h +++ b/src/internet/model/tcp-option-winscale.h @@ -22,7 +22,7 @@ #ifndef TCP_OPTION_WINSCALE_H #define TCP_OPTION_WINSCALE_H -#include "tcp-option.h" +#include "ns3/tcp-option.h" namespace ns3 { diff --git a/src/internet/test/tcp-header-test.cc b/src/internet/test/tcp-header-test.cc --- a/src/internet/test/tcp-header-test.cc +++ b/src/internet/test/tcp-header-test.cc @@ -23,8 +23,7 @@ #include "ns3/core-module.h" #include "ns3/tcp-header.h" #include "ns3/buffer.h" - -#include "../src/internet/model/tcp-option-rfc793.h" +#include "ns3/private/tcp-option-rfc793.h" namespace ns3 { diff --git a/src/internet/test/tcp-option-test.cc b/src/internet/test/tcp-option-test.cc --- a/src/internet/test/tcp-option-test.cc +++ b/src/internet/test/tcp-option-test.cc @@ -20,8 +20,8 @@ #include "ns3/test.h" #include "ns3/core-module.h" #include "ns3/tcp-option.h" -#include "../src/internet/model/tcp-option-winscale.h" -#include "../src/internet/model/tcp-option-ts.h" +#include "ns3/private/tcp-option-winscale.h" +#include "ns3/private/tcp-option-ts.h" #include diff --git a/src/internet/test/tcp-timestamp-test.cc b/src/internet/test/tcp-timestamp-test.cc --- a/src/internet/test/tcp-timestamp-test.cc +++ b/src/internet/test/tcp-timestamp-test.cc @@ -45,7 +45,7 @@ #include "ns3/udp-l4-protocol.h" #include "ns3/tcp-l4-protocol.h" -#include "../src/internet/model/tcp-option-ts.h" +#include "ns3/private/tcp-option-ts.h" namespace ns3 { diff --git a/src/internet/wscript b/src/internet/wscript --- a/src/internet/wscript +++ b/src/internet/wscript @@ -244,6 +244,13 @@ 'test/rtt-test.cc', 'test/codel-queue-test-suite.cc', ] + privateheaders = bld(features='ns3privateheader') + privateheaders.module = 'internet' + privateheaders.source = [ + 'model/tcp-option-winscale.h', + 'model/tcp-option-ts.h', + 'model/tcp-option-rfc793.h', + ] headers = bld(features='ns3header') headers.module = 'internet' headers.source = [ diff --git a/src/wscript b/src/wscript --- a/src/wscript +++ b/src/wscript @@ -442,7 +442,7 @@ def apply_ns3header(self): if self.module is None: raise WafError("'module' missing on ns3headers object %s" % self) - ns3_dir_node = self.bld.path.find_dir("ns3") + ns3_dir_node = self.bld.path.find_or_declare("ns3") for filename in set(self.to_list(self.source)): src_node = self.path.find_resource(filename) if src_node is None: @@ -530,6 +530,98 @@ return 0 +@TaskGen.feature('ns3privateheader') +@TaskGen.after_method('process_rule') +def apply_ns3privateheader(self): + if self.module is None: + raise WafError("'module' missing on ns3headers object %s" % self) + ns3_dir_node = self.bld.path.find_or_declare("ns3/private") + for filename in set(self.to_list(self.source)): + src_node = self.path.find_resource(filename) + if src_node is None: + raise WafError("source ns3 header file %s not found" % (filename,)) + dst_node = ns3_dir_node.find_or_declare(src_node.name) + assert dst_node is not None + task = self.create_task('ns3privateheader') + task.mode = getattr(self, 'mode', 'install') + if task.mode == 'install': + task.set_inputs([src_node]) + task.set_outputs([dst_node]) + else: + task.header_to_remove = dst_node + self.headers = set(self.to_list(self.source)) + self.source = '' # tell WAF not to process these files further + +class ns3privateheader_task(Task.Task): + before = 'cxx gen_ns3_module_header' + after = 'ns3_header' + color = 'BLUE' + + def __str__(self): + "string to display to the user" + env = self.env + src_str = ' '.join([a.nice_path(env) for a in self.inputs]) + tgt_str = ' '.join([a.nice_path(env) for a in self.outputs]) + if self.outputs: sep = ' -> ' + else: sep = '' + if self.mode == 'remove': + return 'rm-ns3-header %s\n' % (self.header_to_remove.abspath(),) + return 'install-ns3-header: %s%s%s\n' % (src_str, sep, tgt_str) + + def __repr__(self): + return str(self) + + def uid(self): + try: + return self.uid_ + except AttributeError: + m = Utils.md5() + up = m.update + up(self.__class__.__name__.encode()) + for x in self.inputs + self.outputs: + up(x.abspath().encode()) + up(self.mode) + if self.mode == 'remove': + up(self.header_to_remove.abspath().encode()) + self.uid_ = m.digest() + return self.uid_ + + def runnable_status(self): + if self.mode == 'remove': + if os.path.exists(self.header_to_remove.abspath()): + return Task.RUN_ME + else: + return Task.SKIP_ME + else: + return super(ns3privateheader_task, self).runnable_status() + + def run(self): + if self.mode == 'install': + assert len(self.inputs) == len(self.outputs) + inputs = [node.abspath() for node in self.inputs] + outputs = [node.abspath() for node in self.outputs] + for src, dst in zip(inputs, outputs): + try: + os.chmod(dst, 0600) + except OSError: + pass + shutil.copy2(src, dst) + ## make the headers in builddir read-only, to prevent + ## accidental modification + os.chmod(dst, 0400) + return 0 + else: + assert len(self.inputs) == 0 + assert len(self.outputs) == 0 + out_file_name = self.header_to_remove.abspath() + try: + os.unlink(out_file_name) + except OSError, ex: + if ex.errno != 2: + raise + return 0 + + class gen_ns3_module_header_task(Task.Task): before = 'cxx' after = 'ns3header' @@ -616,7 +708,7 @@ @TaskGen.after_method('process_rule') def apply_ns3moduleheader(self): ## get all of the ns3 headers - ns3_dir_node = self.bld.path.find_dir("ns3") + ns3_dir_node = self.bld.path.find_or_declare("ns3") all_headers_inputs = [] found_the_module = False for ns3headers in self.bld.all_task_gen: diff --git a/wscript b/wscript --- a/wscript +++ b/wscript @@ -807,6 +807,11 @@ 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: @@ -855,7 +860,7 @@ 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', 'ns3moduleheader_taskgen']: + if type(gen).__name__ in ['ns3header_taskgen', 'ns3privateheader_taskgen', 'ns3moduleheader_taskgen']: gen.post() bld.env['PRINT_BUILT_MODULES_AT_END'] = False