18 |
15 |
19 # these variables are mandatory ('/' are converted automatically) |
16 # these variables are mandatory ('/' are converted automatically) |
20 srcdir = '.' |
17 srcdir = '.' |
21 blddir = 'build' |
18 blddir = 'build' |
22 |
19 |
23 class Ns3Header(Object.genobj): |
|
24 """A set of NS-3 header files""" |
|
25 def __init__(self, env=None): |
|
26 Object.genobj.__init__(self, 'other') |
|
27 self.inst_var = 'INCLUDEDIR' |
|
28 self.inst_dir = 'ns3' |
|
29 self.env = env |
|
30 if not self.env: |
|
31 self.env = Params.g_build.m_allenvs['default'] |
|
32 |
|
33 def apply(self): |
|
34 ns3_dir_node = Params.g_build.m_srcnode.find_dir("ns3") |
|
35 inputs = [] |
|
36 outputs = [] |
|
37 for filename in self.to_list(self.source): |
|
38 src_node = self.path.find_source(filename) |
|
39 if src_node is None: |
|
40 Params.fatal("source ns3 header file %s not found" % (filename,)) |
|
41 dst_node = ns3_dir_node.find_build(os.path.basename(filename)) |
|
42 assert dst_node is not None |
|
43 inputs.append(src_node) |
|
44 outputs.append(dst_node) |
|
45 task = self.create_task('ns3_headers', self.env, 1) |
|
46 task.set_inputs(inputs) |
|
47 task.set_outputs(outputs) |
|
48 |
|
49 def install(self): |
|
50 for i in self.m_tasks: |
|
51 current = Params.g_build.m_curdirnode |
|
52 lst = map(lambda a: a.relpath_gen(current), i.m_outputs) |
|
53 Common.install_files(self.inst_var, self.inst_dir, lst) |
|
54 |
|
55 def _ns3_headers_inst(task): |
|
56 assert len(task.m_inputs) == len(task.m_outputs) |
|
57 inputs = [node.srcpath(task.m_env) for node in task.m_inputs] |
|
58 outputs = [node.bldpath(task.m_env) for node in task.m_outputs] |
|
59 for src, dst in zip(inputs, outputs): |
|
60 try: |
|
61 os.chmod(dst, 0600) |
|
62 except OSError: |
|
63 pass |
|
64 shutil.copy2(src, dst) |
|
65 ## make the headers in builddir read-only, to prevent |
|
66 ## accidental modification |
|
67 os.chmod(dst, 0400) |
|
68 return 0 |
|
69 |
|
70 def init(): |
|
71 Object.register('ns3header', Ns3Header) |
|
72 Action.Action('ns3_headers', func=_ns3_headers_inst, color='BLUE') |
|
73 |
20 |
74 def set_options(opt): |
21 def set_options(opt): |
75 # options provided by the modules |
22 # options provided by the modules |
76 opt.tool_options('compiler_cxx') |
23 opt.tool_options('compiler_cxx') |
77 |
24 |