author | Gustavo J. A. M. Carneiro <gjc@inescporto.pt> |
Tue, 26 Oct 2010 15:11:17 +0100 | |
changeset 6647 | bdbbfbc6bda7 |
parent 6639 | e09e8803df26 |
child 6671 | b3d5193a2f94 |
child 6874 | c7537e62f2fa |
permissions | -rw-r--r-- |
537
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
1 |
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- |
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
2 |
|
761
0ffbc9fa8ef0
Define env['NS3_MODULE_PATH'] in configure rather than build.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
693
diff
changeset
|
3 |
import os, os.path |
693
c8fc89076aa2
WAF: cleanup the main wscript file by moving the definition of the ns3header object type into src/wscript
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
672
diff
changeset
|
4 |
import shutil |
1217
2f7791ae388d
WAF: add new bld.create_ns3_module() and bld.create_ns3_program() methods to make declaration of modules and programs simpler, and allowing us to change how ns-3 is built in a centralized way, without needing to change every module wscript file.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1214
diff
changeset
|
5 |
import types |
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
6 |
import warnings |
693
c8fc89076aa2
WAF: cleanup the main wscript file by moving the definition of the ns3header object type into src/wscript
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
672
diff
changeset
|
7 |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
8 |
import TaskGen |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
9 |
import Task |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
10 |
import Options |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
11 |
import Build |
4326
179f86838e62
Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4164
diff
changeset
|
12 |
import Utils |
6647
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
13 |
import Constants |
693
c8fc89076aa2
WAF: cleanup the main wscript file by moving the definition of the ns3header object type into src/wscript
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
672
diff
changeset
|
14 |
|
6168
c737d0a0e9a0
Bug 860: waf dies while executing ns3header task in case of parallel jobs.
Andrey Mazo <mazo@iitp.ru>
parents:
6127
diff
changeset
|
15 |
try: |
c737d0a0e9a0
Bug 860: waf dies while executing ns3header task in case of parallel jobs.
Andrey Mazo <mazo@iitp.ru>
parents:
6127
diff
changeset
|
16 |
set |
c737d0a0e9a0
Bug 860: waf dies while executing ns3header task in case of parallel jobs.
Andrey Mazo <mazo@iitp.ru>
parents:
6127
diff
changeset
|
17 |
except NameError: |
c737d0a0e9a0
Bug 860: waf dies while executing ns3header task in case of parallel jobs.
Andrey Mazo <mazo@iitp.ru>
parents:
6127
diff
changeset
|
18 |
from sets import Set as set # Python 2.3 fallback |
c737d0a0e9a0
Bug 860: waf dies while executing ns3header task in case of parallel jobs.
Andrey Mazo <mazo@iitp.ru>
parents:
6127
diff
changeset
|
19 |
|
969
3c3ce40492a6
WAF: make list of modules (all_modules) a tuple instead of list, because it is hashable, and this way newer WAF is able to notice changes in it and automatically trigger a reconfiguration.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
968
diff
changeset
|
20 |
all_modules = ( |
600
fd944dbf33c6
WAF: simplify wscripts using the new chained uselib_local dependencies feature of WAF SVN; now build all samples and examples; add --disable-rpath configure option; add WAF build instructions.
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
537
diff
changeset
|
21 |
'core', |
fd944dbf33c6
WAF: simplify wscripts using the new chained uselib_local dependencies feature of WAF SVN; now build all samples and examples; add --disable-rpath configure option; add WAF build instructions.
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
537
diff
changeset
|
22 |
'common', |
fd944dbf33c6
WAF: simplify wscripts using the new chained uselib_local dependencies feature of WAF SVN; now build all samples and examples; add --disable-rpath configure option; add WAF build instructions.
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
537
diff
changeset
|
23 |
'simulator', |
1878
f947cd18f0bb
Create a new contrib module; move event-garbage-collector.{h,cc} to the contrib module.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1877
diff
changeset
|
24 |
'contrib', |
600
fd944dbf33c6
WAF: simplify wscripts using the new chained uselib_local dependencies feature of WAF SVN; now build all samples and examples; add --disable-rpath configure option; add WAF build instructions.
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
537
diff
changeset
|
25 |
'node', |
3260
8c0ab08144e6
bug 186: internet-node directory must be renamed to internet-stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3063
diff
changeset
|
26 |
'internet-stack', |
972
6946c8237a73
src/devices/p2p -> src/devices/point-to-point
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
969
diff
changeset
|
27 |
'devices/point-to-point', |
1272 | 28 |
'devices/csma', |
3854 | 29 |
'devices/emu', |
3826
40c5841b616d
merge in tap device
Craig Dowell <craigdo@ee.washington.edu>
parents:
3581
diff
changeset
|
30 |
'devices/bridge', |
4163
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
4126
diff
changeset
|
31 |
'devices/tap-bridge', |
4541
e943b94bf523
Rename TapNetDevice to VirtualNetDevice
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4539
diff
changeset
|
32 |
'devices/virtual-net-device', |
1496
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
1306
diff
changeset
|
33 |
'applications/onoff', |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
1306
diff
changeset
|
34 |
'applications/packet-sink', |
0ad4c18b475c
start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents:
1306
diff
changeset
|
35 |
'applications/udp-echo', |
5224
06f639d05b8f
Merge NixVector Routing code
Josh Pelkey <jpelkey@gatech.edu>
parents:
5211
diff
changeset
|
36 |
'routing/nix-vector-routing', |
1716
9757633a85da
Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
969
diff
changeset
|
37 |
'routing/olsr', |
1120 | 38 |
'routing/global-routing', |
4573
01e876191f2e
move list routing and static routing to src/routing directories
Tom Henderson <tomh@tomh.org>
parents:
4541
diff
changeset
|
39 |
'routing/static-routing', |
01e876191f2e
move list routing and static routing to src/routing directories
Tom Henderson <tomh@tomh.org>
parents:
4541
diff
changeset
|
40 |
'routing/list-routing', |
5749
1c6600743c9e
routing/manet directory removed
Pavel Boyko <boyko@iitp.ru>
parents:
5748
diff
changeset
|
41 |
'routing/aodv', |
968
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
955
diff
changeset
|
42 |
'mobility', |
1882
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1272
diff
changeset
|
43 |
'devices/wifi', |
2603
1308da4cb3bf
move helpers to their own dir.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2178
diff
changeset
|
44 |
'helper', |
3570
44b0bc6817c6
Stats module and example merged in.
tjkopena@cs.drexel.edu
parents:
3498
diff
changeset
|
45 |
'contrib/stats', |
3821
9ea825f066a2
Apply icmp-application patch frm lacage
Craig Dowell <craigdo@ee.washington.edu>
parents:
3581
diff
changeset
|
46 |
'applications/v4ping', |
6376
4e133d0aa098
UAN module addition
Leonard Tracy <lentracy@u.washington.edu>
parents:
6349
diff
changeset
|
47 |
'devices/uan', |
6349 | 48 |
'devices/spectrum', |
49 |
'devices/mesh', |
|
4871
285d97537359
802.11s/ Moved to dot11s/
Kirill Andreev <andreev@iitp.ru>
parents:
4824
diff
changeset
|
50 |
'devices/mesh/dot11s', |
5078 | 51 |
'devices/mesh/flame', |
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4573
diff
changeset
|
52 |
'applications/ping6', |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4573
diff
changeset
|
53 |
'applications/radvd', |
5270 | 54 |
'test', |
6034
de2824cc388d
add a place for perf tests
Craig Dowell <craigdo@ee.washington.edu>
parents:
6029
diff
changeset
|
55 |
'test/perf', |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4750
diff
changeset
|
56 |
'test/ns3tcp', |
6193
808bcfa200f4
add NSC version of TCP loss test suite
Tom Henderson <tomh@tomh.org>
parents:
6168
diff
changeset
|
57 |
'test/nsctcp', |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4750
diff
changeset
|
58 |
'test/ns3wifi', |
5205
673aae891b2b
Add a new 'flow-monitor' module.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4731
diff
changeset
|
59 |
'contrib/flow-monitor', |
5781
2557c340ea15
Adding 3 new applications:udp-client, udp-server, udp-trace-client.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
5776
diff
changeset
|
60 |
'applications/udp-client-server', |
6111
0b22ae082153
Merge WiMAX module
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
6054
diff
changeset
|
61 |
'devices/wimax', |
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
6111
diff
changeset
|
62 |
'mpi', |
6127
b5bc10de166d
merge topology read system
Tommaso Pecorella <tpecorella@mac.com>
parents:
6113
diff
changeset
|
63 |
'contrib/topology-read', |
6429
5ee11b58989d
Initial import of energy model
He Wu <mdzz@u.washington.edu>
parents:
6398
diff
changeset
|
64 |
'contrib/energy', |
969
3c3ce40492a6
WAF: make list of modules (all_modules) a tuple instead of list, because it is hashable, and this way newer WAF is able to notice changes in it and automatically trigger a reconfiguration.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
968
diff
changeset
|
65 |
) |
600
fd944dbf33c6
WAF: simplify wscripts using the new chained uselib_local dependencies feature of WAF SVN; now build all samples and examples; add --disable-rpath configure option; add WAF build instructions.
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
537
diff
changeset
|
66 |
|
537
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
67 |
def set_options(opt): |
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
68 |
opt.sub_options('simulator') |
955
c9be0df711d2
WAF: add back the --enable-rpath option, per Mathieu's request, though disabled by default.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
954
diff
changeset
|
69 |
|
c9be0df711d2
WAF: add back the --enable-rpath option, per Mathieu's request, though disabled by default.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
954
diff
changeset
|
70 |
opt.add_option('--enable-rpath', |
c9be0df711d2
WAF: add back the --enable-rpath option, per Mathieu's request, though disabled by default.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
954
diff
changeset
|
71 |
help=("Link programs with rpath" |
c9be0df711d2
WAF: add back the --enable-rpath option, per Mathieu's request, though disabled by default.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
954
diff
changeset
|
72 |
" (normally not needed, see " |
c9be0df711d2
WAF: add back the --enable-rpath option, per Mathieu's request, though disabled by default.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
954
diff
changeset
|
73 |
" --run and --shell; moreover, only works in some" |
c9be0df711d2
WAF: add back the --enable-rpath option, per Mathieu's request, though disabled by default.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
954
diff
changeset
|
74 |
" specific platforms, such as Linux and Solaris)"), |
c9be0df711d2
WAF: add back the --enable-rpath option, per Mathieu's request, though disabled by default.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
954
diff
changeset
|
75 |
action="store_true", dest='enable_rpath', default=False) |
4164
1f6ae48061a9
checkpoint tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
4163
diff
changeset
|
76 |
|
1858
68e1964c19e8
WAF: add a new --enable-modules configure option, to tell WAF to build only the specified set of ns-3 modules and its dependencies; programs depending on those modules are automatically excluded from the build.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1747
diff
changeset
|
77 |
opt.add_option('--enable-modules', |
68e1964c19e8
WAF: add a new --enable-modules configure option, to tell WAF to build only the specified set of ns-3 modules and its dependencies; programs depending on those modules are automatically excluded from the build.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1747
diff
changeset
|
78 |
help=("Build only these modules (and dependencies)"), |
68e1964c19e8
WAF: add a new --enable-modules configure option, to tell WAF to build only the specified set of ns-3 modules and its dependencies; programs depending on those modules are automatically excluded from the build.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1747
diff
changeset
|
79 |
dest='enable_modules') |
68e1964c19e8
WAF: add a new --enable-modules configure option, to tell WAF to build only the specified set of ns-3 modules and its dependencies; programs depending on those modules are automatically excluded from the build.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1747
diff
changeset
|
80 |
|
537
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
81 |
def configure(conf): |
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
82 |
conf.sub_config('core') |
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
83 |
conf.sub_config('simulator') |
3854 | 84 |
conf.sub_config('devices/emu') |
4163
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
4126
diff
changeset
|
85 |
conf.sub_config('devices/tap-bridge') |
3063
a1c532e3bf18
a basic but useful Gtk+-based config-store
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3001
diff
changeset
|
86 |
conf.sub_config('contrib') |
3579
9e5eaef3e082
nsc: enable network simulation cradle
Florian Westphal <fw@strlen.de>
parents:
3498
diff
changeset
|
87 |
conf.sub_config('internet-stack') |
5776
aae948449722
Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
5749
diff
changeset
|
88 |
conf.sub_config('helper') |
6034
de2824cc388d
add a place for perf tests
Craig Dowell <craigdo@ee.washington.edu>
parents:
6029
diff
changeset
|
89 |
conf.sub_config('test') |
537
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
90 |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
91 |
blddir = os.path.abspath(os.path.join(conf.blddir, conf.env.variant())) |
3498
ce35418645e9
bug 266: src/wscript unconditionally sets conf.env['NS3_MODULE_PATH']
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3439
diff
changeset
|
92 |
conf.env.append_value('NS3_MODULE_PATH', blddir) |
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
93 |
if Options.options.enable_rpath: |
1306
8834e434187f
Build the ns3 library in the build/<variant> root, not in build/<variant>/src.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1272
diff
changeset
|
94 |
conf.env.append_value('RPATH', '-Wl,-rpath=%s' % (os.path.join(blddir),)) |
761
0ffbc9fa8ef0
Define env['NS3_MODULE_PATH'] in configure rather than build.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
693
diff
changeset
|
95 |
|
5361
e8989b44bffb
Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
5270
diff
changeset
|
96 |
## Used to link the 'test-runner' program with all of ns-3 code |
928
218063b19458
WAF: derive the variable NS3_MODULES from the 'all_modules' list in src/wscript, instead of requiring every module to define a configure function to register themselves. This way module registration is done in one place only: src/wscript. Requires module naming conventions, though.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
770
diff
changeset
|
97 |
conf.env['NS3_MODULES'] = ['ns3-' + module.split('/')[-1] for module in all_modules] |
218063b19458
WAF: derive the variable NS3_MODULES from the 'all_modules' list in src/wscript, instead of requiring every module to define a configure function to register themselves. This way module registration is done in one place only: src/wscript. Requires module naming conventions, though.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
770
diff
changeset
|
98 |
|
1858
68e1964c19e8
WAF: add a new --enable-modules configure option, to tell WAF to build only the specified set of ns-3 modules and its dependencies; programs depending on those modules are automatically excluded from the build.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1747
diff
changeset
|
99 |
|
1217
2f7791ae388d
WAF: add new bld.create_ns3_module() and bld.create_ns3_program() methods to make declaration of modules and programs simpler, and allowing us to change how ns-3 is built in a centralized way, without needing to change every module wscript file.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1214
diff
changeset
|
100 |
def create_ns3_module(bld, name, dependencies=()): |
5996
84c404ad1d26
WAF: allow NS-3 modules to compile pure C code sources mixed with the C++ ones
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
5942
diff
changeset
|
101 |
module = bld.new_task_gen('cxx', 'cc') |
6639
e09e8803df26
(missing from last commit)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6429
diff
changeset
|
102 |
module.is_ns3_module = True |
1217
2f7791ae388d
WAF: add new bld.create_ns3_module() and bld.create_ns3_program() methods to make declaration of modules and programs simpler, and allowing us to change how ns-3 is built in a centralized way, without needing to change every module wscript file.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1214
diff
changeset
|
103 |
module.name = 'ns3-' + name |
2f7791ae388d
WAF: add new bld.create_ns3_module() and bld.create_ns3_program() methods to make declaration of modules and programs simpler, and allowing us to change how ns-3 is built in a centralized way, without needing to change every module wscript file.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1214
diff
changeset
|
104 |
module.target = module.name |
1220
4933e0890acd
Build all modules as a single ns3 shared library.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1217
diff
changeset
|
105 |
module.add_objects = ['ns3-' + dep for dep in dependencies] |
2611
79b1c42fef3e
Generate foo-module.h module aggreator header files, for use in user scripts.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2609
diff
changeset
|
106 |
module.module_deps = list(dependencies) |
4392
25d38a0c9851
bug 537: no support to build static ns-3 binaries
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4389
diff
changeset
|
107 |
if not module.env['ENABLE_STATIC_NS3']: |
25d38a0c9851
bug 537: no support to build static ns-3 binaries
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4389
diff
changeset
|
108 |
module.env.append_value('CXXFLAGS', module.env['shlib_CXXFLAGS']) |
5996
84c404ad1d26
WAF: allow NS-3 modules to compile pure C code sources mixed with the C++ ones
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
5942
diff
changeset
|
109 |
module.env.append_value('CCFLAGS', module.env['shlib_CXXFLAGS']) |
5252
481053e0cd10
Bug 681: wrong compilation options for icpc (Intel C/C++ Compiler)
Andrey Mazo <mazo@iitp.ru>
parents:
5230
diff
changeset
|
110 |
elif module.env['CXX_NAME'] in ['gcc', 'icc'] and \ |
4395
489abe44ed7e
enable static builds, even when python is enabled
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4392
diff
changeset
|
111 |
os.uname()[4] == 'x86_64' and \ |
489abe44ed7e
enable static builds, even when python is enabled
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4392
diff
changeset
|
112 |
module.env['ENABLE_PYTHON_BINDINGS']: |
489abe44ed7e
enable static builds, even when python is enabled
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4392
diff
changeset
|
113 |
# enable that flag for static builds only on x86-64 platforms |
489abe44ed7e
enable static builds, even when python is enabled
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4392
diff
changeset
|
114 |
# when gcc is present and only when we want python bindings |
489abe44ed7e
enable static builds, even when python is enabled
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4392
diff
changeset
|
115 |
# (it's more efficient to not use this option if we can avoid it) |
489abe44ed7e
enable static builds, even when python is enabled
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4392
diff
changeset
|
116 |
module.env.append_value('CXXFLAGS', '-mcmodel=large') |
5996
84c404ad1d26
WAF: allow NS-3 modules to compile pure C code sources mixed with the C++ ones
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
5942
diff
changeset
|
117 |
module.env.append_value('CCFLAGS', '-mcmodel=large') |
4395
489abe44ed7e
enable static builds, even when python is enabled
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4392
diff
changeset
|
118 |
|
2611
79b1c42fef3e
Generate foo-module.h module aggreator header files, for use in user scripts.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2609
diff
changeset
|
119 |
module.env.append_value('CXXDEFINES', "NS3_MODULE_COMPILATION") |
5996
84c404ad1d26
WAF: allow NS-3 modules to compile pure C code sources mixed with the C++ ones
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
5942
diff
changeset
|
120 |
module.env.append_value('CCDEFINES', "NS3_MODULE_COMPILATION") |
1217
2f7791ae388d
WAF: add new bld.create_ns3_module() and bld.create_ns3_program() methods to make declaration of modules and programs simpler, and allowing us to change how ns-3 is built in a centralized way, without needing to change every module wscript file.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1214
diff
changeset
|
121 |
return module |
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
122 |
|
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
123 |
def create_obj(bld, *args): |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
124 |
warnings.warn("(in %s) Use bld.new_task_gen(...) now, instead of bld.create_obj(...)" % str(bld.path), |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
125 |
DeprecationWarning, stacklevel=2) |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
126 |
return bld.new_task_gen(*args) |
955
c9be0df711d2
WAF: add back the --enable-rpath option, per Mathieu's request, though disabled by default.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
954
diff
changeset
|
127 |
|
537
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
128 |
def build(bld): |
1217
2f7791ae388d
WAF: add new bld.create_ns3_module() and bld.create_ns3_program() methods to make declaration of modules and programs simpler, and allowing us to change how ns-3 is built in a centralized way, without needing to change every module wscript file.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1214
diff
changeset
|
129 |
bld.create_ns3_module = types.MethodType(create_ns3_module, bld) |
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
130 |
bld.create_obj = types.MethodType(create_obj, bld) |
600
fd944dbf33c6
WAF: simplify wscripts using the new chained uselib_local dependencies feature of WAF SVN; now build all samples and examples; add --disable-rpath configure option; add WAF build instructions.
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
537
diff
changeset
|
131 |
|
969
3c3ce40492a6
WAF: make list of modules (all_modules) a tuple instead of list, because it is hashable, and this way newer WAF is able to notice changes in it and automatically trigger a reconfiguration.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
968
diff
changeset
|
132 |
bld.add_subdirs(list(all_modules)) |
693
c8fc89076aa2
WAF: cleanup the main wscript file by moving the definition of the ns3header object type into src/wscript
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
672
diff
changeset
|
133 |
|
2611
79b1c42fef3e
Generate foo-module.h module aggreator header files, for use in user scripts.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2609
diff
changeset
|
134 |
for module in all_modules: |
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
135 |
modheader = bld.new_task_gen('ns3moduleheader') |
2611
79b1c42fef3e
Generate foo-module.h module aggreator header files, for use in user scripts.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2609
diff
changeset
|
136 |
modheader.module = module.split('/')[-1] |
79b1c42fef3e
Generate foo-module.h module aggreator header files, for use in user scripts.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2609
diff
changeset
|
137 |
|
1220
4933e0890acd
Build all modules as a single ns3 shared library.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1217
diff
changeset
|
138 |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
139 |
class ns3header_taskgen(TaskGen.task_gen): |
693
c8fc89076aa2
WAF: cleanup the main wscript file by moving the definition of the ns3header object type into src/wscript
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
672
diff
changeset
|
140 |
"""A set of NS-3 header files""" |
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
141 |
COLOR = 'BLUE' |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
142 |
def __init__(self, *args, **kwargs): |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
143 |
super(ns3header_taskgen, self).__init__(*args, **kwargs) |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
144 |
self.install_path = None |
1877
b2ebc493cd58
Add support for publishing ns3 headers in a subdir of ns3/ (we probably won't be needing this, but since it was implemented it might as well be commited, in case we ever need it)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1858
diff
changeset
|
145 |
self.sub_dir = None # if not None, header files will be published as ns3/sub_dir/file.h |
2609
931d59bb1303
Add a 'module' attribute to the ns3header object specifying which module each set of headers belongs to.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2603
diff
changeset
|
146 |
self.module = None # module name |
6647
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
147 |
self.mode = 'install' |
2611
79b1c42fef3e
Generate foo-module.h module aggreator header files, for use in user scripts.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2609
diff
changeset
|
148 |
|
693
c8fc89076aa2
WAF: cleanup the main wscript file by moving the definition of the ns3header object type into src/wscript
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
672
diff
changeset
|
149 |
def apply(self): |
2609
931d59bb1303
Add a 'module' attribute to the ns3header object specifying which module each set of headers belongs to.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2603
diff
changeset
|
150 |
if self.module is None: |
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
151 |
raise Utils.WafError("'module' missing on ns3headers object %s" % self) |
4326
179f86838e62
Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4164
diff
changeset
|
152 |
ns3_dir_node = self.bld.path.find_dir("ns3") |
1877
b2ebc493cd58
Add support for publishing ns3 headers in a subdir of ns3/ (we probably won't be needing this, but since it was implemented it might as well be commited, in case we ever need it)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1858
diff
changeset
|
153 |
if self.sub_dir is not None: |
b2ebc493cd58
Add support for publishing ns3 headers in a subdir of ns3/ (we probably won't be needing this, but since it was implemented it might as well be commited, in case we ever need it)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1858
diff
changeset
|
154 |
ns3_dir_node = ns3_dir_node.find_dir(self.sub_dir) |
6168
c737d0a0e9a0
Bug 860: waf dies while executing ns3header task in case of parallel jobs.
Andrey Mazo <mazo@iitp.ru>
parents:
6127
diff
changeset
|
155 |
for filename in set(self.to_list(self.source)): |
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
156 |
src_node = self.path.find_resource(filename) |
693
c8fc89076aa2
WAF: cleanup the main wscript file by moving the definition of the ns3header object type into src/wscript
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
672
diff
changeset
|
157 |
if src_node is None: |
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
158 |
raise Utils.WafError("source ns3 header file %s not found" % (filename,)) |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
159 |
dst_node = ns3_dir_node.find_or_declare(os.path.basename(filename)) |
693
c8fc89076aa2
WAF: cleanup the main wscript file by moving the definition of the ns3header object type into src/wscript
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
672
diff
changeset
|
160 |
assert dst_node is not None |
5942
7c66549b828d
Upgrade waf from 1.5.9 to 1.5.11
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
5781
diff
changeset
|
161 |
task = self.create_task('ns3header', env=self.env) |
6647
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
162 |
task.mode = self.mode |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
163 |
if self.mode == 'install': |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
164 |
task.set_inputs([src_node]) |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
165 |
task.set_outputs([dst_node]) |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
166 |
else: |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
167 |
task.header_to_remove = dst_node |
693
c8fc89076aa2
WAF: cleanup the main wscript file by moving the definition of the ns3header object type into src/wscript
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
672
diff
changeset
|
168 |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
169 |
class ns3header_task(Task.Task): |
4066
d2309cf765d8
Fix --python-scan
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4064
diff
changeset
|
170 |
before = 'cc cxx gen_ns3_module_header_task' |
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
171 |
color = 'BLUE' |
6647
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
172 |
|
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
173 |
def __str__(self): |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
174 |
"string to display to the user" |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
175 |
env = self.env |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
176 |
src_str = ' '.join([a.nice_path(env) for a in self.inputs]) |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
177 |
tgt_str = ' '.join([a.nice_path(env) for a in self.outputs]) |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
178 |
if self.outputs: sep = ' -> ' |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
179 |
else: sep = '' |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
180 |
if self.mode == 'remove': |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
181 |
return 'rm-ns3-header %s\n' % (self.header_to_remove.bldpath(self.env),) |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
182 |
return 'install-ns3-header: %s%s%s\n' % (src_str, sep, tgt_str) |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
183 |
|
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
184 |
def runnable_status(self): |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
185 |
if self.mode == 'remove': |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
186 |
if os.path.exists(self.header_to_remove.bldpath(self.env)): |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
187 |
return Constants.RUN_ME |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
188 |
else: |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
189 |
return Constants.SKIP_ME |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
190 |
else: |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
191 |
return super(ns3header_task, self).runnable_status() |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
192 |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
193 |
def run(self): |
6647
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
194 |
if self.mode == 'install': |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
195 |
assert len(self.inputs) == len(self.outputs) |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
196 |
inputs = [node.srcpath(self.env) for node in self.inputs] |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
197 |
outputs = [node.bldpath(self.env) for node in self.outputs] |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
198 |
for src, dst in zip(inputs, outputs): |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
199 |
try: |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
200 |
os.chmod(dst, 0600) |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
201 |
except OSError: |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
202 |
pass |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
203 |
shutil.copy2(src, dst) |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
204 |
## make the headers in builddir read-only, to prevent |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
205 |
## accidental modification |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
206 |
os.chmod(dst, 0400) |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
207 |
return 0 |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
208 |
else: |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
209 |
assert len(self.inputs) == 0 |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
210 |
assert len(self.outputs) == 0 |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
211 |
out_file_name = self.header_to_remove.bldpath(self.env) |
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
212 |
try: |
6647
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
213 |
os.unlink(out_file_name) |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
214 |
except OSError, ex: |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
215 |
if ex.errno != 2: |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
216 |
raise |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
217 |
return 0 |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
218 |
|
2611
79b1c42fef3e
Generate foo-module.h module aggreator header files, for use in user scripts.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2609
diff
changeset
|
219 |
|
79b1c42fef3e
Generate foo-module.h module aggreator header files, for use in user scripts.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2609
diff
changeset
|
220 |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
221 |
class gen_ns3_module_header_task(Task.Task): |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
222 |
before = 'cc cxx' |
4066
d2309cf765d8
Fix --python-scan
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4064
diff
changeset
|
223 |
after = 'ns3header_task' |
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
224 |
color = 'BLUE' |
6647
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
225 |
|
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
226 |
def runnable_status(self): |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
227 |
if self.mode == 'remove': |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
228 |
if os.path.exists(self.header_to_remove.bldpath(self.env)): |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
229 |
return Constants.RUN_ME |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
230 |
else: |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
231 |
return Constants.SKIP_ME |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
232 |
else: |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
233 |
return super(gen_ns3_module_header_task, self).runnable_status() |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
234 |
|
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
235 |
def __str__(self): |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
236 |
"string to display to the user" |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
237 |
env = self.env |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
238 |
src_str = ' '.join([a.nice_path(env) for a in self.inputs]) |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
239 |
tgt_str = ' '.join([a.nice_path(env) for a in self.outputs]) |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
240 |
if self.outputs: sep = ' -> ' |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
241 |
else: sep = '' |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
242 |
if self.mode == 'remove': |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
243 |
return 'rm-module-header %s\n' % (self.header_to_remove.bldpath(self.env),) |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
244 |
return 'gen-module-header: %s%s%s\n' % (src_str, sep, tgt_str) |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
245 |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
246 |
def run(self): |
6647
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
247 |
if self.mode == 'remove': |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
248 |
assert len(self.inputs) == 0 |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
249 |
assert len(self.outputs) == 0 |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
250 |
out_file_name = self.header_to_remove.bldpath(self.env) |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
251 |
try: |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
252 |
os.unlink(out_file_name) |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
253 |
except OSError, ex: |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
254 |
if ex.errno != 2: |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
255 |
raise |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
256 |
return 0 |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
257 |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
258 |
assert len(self.outputs) == 1 |
6647
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
259 |
out_file_name = self.outputs[0].bldpath(self.env) |
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
260 |
header_files = [os.path.basename(node.abspath(self.env)) for node in self.inputs] |
6647
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
261 |
outfile = file(out_file_name, "w") |
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
262 |
header_files.sort() |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
263 |
|
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
264 |
print >> outfile, """ |
2611
79b1c42fef3e
Generate foo-module.h module aggreator header files, for use in user scripts.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2609
diff
changeset
|
265 |
#ifdef NS3_MODULE_COMPILATION |
79b1c42fef3e
Generate foo-module.h module aggreator header files, for use in user scripts.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2609
diff
changeset
|
266 |
# error "Do not include ns3 module aggregator headers from other modules; these are meant only for end user scripts." |
79b1c42fef3e
Generate foo-module.h module aggreator header files, for use in user scripts.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2609
diff
changeset
|
267 |
#endif |
79b1c42fef3e
Generate foo-module.h module aggreator header files, for use in user scripts.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2609
diff
changeset
|
268 |
|
79b1c42fef3e
Generate foo-module.h module aggreator header files, for use in user scripts.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2609
diff
changeset
|
269 |
#ifndef NS3_MODULE_%s |
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
270 |
""" % (self.module.upper().replace('-', '_'),) |
2611
79b1c42fef3e
Generate foo-module.h module aggreator header files, for use in user scripts.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2609
diff
changeset
|
271 |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
272 |
# if self.module_deps: |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
273 |
# print >> outfile, "// Module dependencies:" |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
274 |
# for dep in self.module_deps: |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
275 |
# print >> outfile, "#include \"%s-module.h\"" % dep |
2611
79b1c42fef3e
Generate foo-module.h module aggreator header files, for use in user scripts.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2609
diff
changeset
|
276 |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
277 |
print >> outfile |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
278 |
print >> outfile, "// Module headers:" |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
279 |
for header in header_files: |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
280 |
print >> outfile, "#include \"%s\"" % (header,) |
2611
79b1c42fef3e
Generate foo-module.h module aggreator header files, for use in user scripts.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2609
diff
changeset
|
281 |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
282 |
print >> outfile, "#endif" |
2611
79b1c42fef3e
Generate foo-module.h module aggreator header files, for use in user scripts.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2609
diff
changeset
|
283 |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
284 |
outfile.close() |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
285 |
return 0 |
2611
79b1c42fef3e
Generate foo-module.h module aggreator header files, for use in user scripts.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2609
diff
changeset
|
286 |
|
4126
0ba0346d655b
Workaround WAF issue 325 for generating module header files
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4066
diff
changeset
|
287 |
def sig_explicit_deps(self): |
4326
179f86838e62
Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4164
diff
changeset
|
288 |
m = Utils.md5() |
4126
0ba0346d655b
Workaround WAF issue 325 for generating module header files
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4066
diff
changeset
|
289 |
m.update('\n'.join([node.abspath(self.env) for node in self.inputs])) |
0ba0346d655b
Workaround WAF issue 325 for generating module header files
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4066
diff
changeset
|
290 |
return m.digest() |
0ba0346d655b
Workaround WAF issue 325 for generating module header files
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4066
diff
changeset
|
291 |
|
0ba0346d655b
Workaround WAF issue 325 for generating module header files
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4066
diff
changeset
|
292 |
def unique_id(self): |
0ba0346d655b
Workaround WAF issue 325 for generating module header files
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4066
diff
changeset
|
293 |
try: |
0ba0346d655b
Workaround WAF issue 325 for generating module header files
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4066
diff
changeset
|
294 |
return self.uid |
0ba0346d655b
Workaround WAF issue 325 for generating module header files
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4066
diff
changeset
|
295 |
except AttributeError: |
0ba0346d655b
Workaround WAF issue 325 for generating module header files
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4066
diff
changeset
|
296 |
"this is not a real hot zone, but we want to avoid surprizes here" |
4326
179f86838e62
Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4164
diff
changeset
|
297 |
m = Utils.md5() |
4126
0ba0346d655b
Workaround WAF issue 325 for generating module header files
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4066
diff
changeset
|
298 |
m.update("ns-3-module-header-%s" % self.module) |
0ba0346d655b
Workaround WAF issue 325 for generating module header files
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4066
diff
changeset
|
299 |
self.uid = m.digest() |
0ba0346d655b
Workaround WAF issue 325 for generating module header files
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4066
diff
changeset
|
300 |
return self.uid |
0ba0346d655b
Workaround WAF issue 325 for generating module header files
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4066
diff
changeset
|
301 |
|
2611
79b1c42fef3e
Generate foo-module.h module aggreator header files, for use in user scripts.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2609
diff
changeset
|
302 |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
303 |
class ns3moduleheader_taskgen(TaskGen.task_gen): |
2611
79b1c42fef3e
Generate foo-module.h module aggreator header files, for use in user scripts.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2609
diff
changeset
|
304 |
""" |
79b1c42fef3e
Generate foo-module.h module aggreator header files, for use in user scripts.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2609
diff
changeset
|
305 |
Generates a 'ns3/foo-module.h' header file that includes all |
79b1c42fef3e
Generate foo-module.h module aggreator header files, for use in user scripts.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2609
diff
changeset
|
306 |
public ns3 headers of a certain module. |
79b1c42fef3e
Generate foo-module.h module aggreator header files, for use in user scripts.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2609
diff
changeset
|
307 |
""" |
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
308 |
COLOR = 'BLUE' |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
309 |
def __init__(self, *args, **kwargs): |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
310 |
super(ns3moduleheader_taskgen, self).__init__(*args, **kwargs) |
6647
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
311 |
self.mode = 'install' |
2611
79b1c42fef3e
Generate foo-module.h module aggreator header files, for use in user scripts.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2609
diff
changeset
|
312 |
|
79b1c42fef3e
Generate foo-module.h module aggreator header files, for use in user scripts.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2609
diff
changeset
|
313 |
def apply(self): |
79b1c42fef3e
Generate foo-module.h module aggreator header files, for use in user scripts.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2609
diff
changeset
|
314 |
## get all of the ns3 headers |
4326
179f86838e62
Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4164
diff
changeset
|
315 |
ns3_dir_node = self.bld.path.find_dir("ns3") |
2611
79b1c42fef3e
Generate foo-module.h module aggreator header files, for use in user scripts.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2609
diff
changeset
|
316 |
all_headers_inputs = [] |
4750
7dd4ad5ac045
Allow ns3moduleheader taskgen with empty list of source headers (for completely optional ns-3 modules)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4731
diff
changeset
|
317 |
found_the_module = False |
4326
179f86838e62
Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4164
diff
changeset
|
318 |
for ns3headers in self.bld.all_task_gen: |
3001
f7aa2796627f
WAF: convert code to WAF 1.4 API; the 'waf' script bundle will be updated later, for now has been disabled.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2750
diff
changeset
|
319 |
if isinstance(ns3headers, ns3header_taskgen): |
2611
79b1c42fef3e
Generate foo-module.h module aggreator header files, for use in user scripts.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2609
diff
changeset
|
320 |
if ns3headers.module != self.module: |
79b1c42fef3e
Generate foo-module.h module aggreator header files, for use in user scripts.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2609
diff
changeset
|
321 |
continue |
4750
7dd4ad5ac045
Allow ns3moduleheader taskgen with empty list of source headers (for completely optional ns-3 modules)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4731
diff
changeset
|
322 |
found_the_module = True |
6168
c737d0a0e9a0
Bug 860: waf dies while executing ns3header task in case of parallel jobs.
Andrey Mazo <mazo@iitp.ru>
parents:
6127
diff
changeset
|
323 |
for source in set(ns3headers.to_list(ns3headers.source)): |
2611
79b1c42fef3e
Generate foo-module.h module aggreator header files, for use in user scripts.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2609
diff
changeset
|
324 |
source = os.path.basename(source) |
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
325 |
node = ns3_dir_node.find_or_declare(os.path.basename(source)) |
2611
79b1c42fef3e
Generate foo-module.h module aggreator header files, for use in user scripts.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2609
diff
changeset
|
326 |
if node is None: |
79b1c42fef3e
Generate foo-module.h module aggreator header files, for use in user scripts.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2609
diff
changeset
|
327 |
fatal("missing header file %s" % (source,)) |
79b1c42fef3e
Generate foo-module.h module aggreator header files, for use in user scripts.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2609
diff
changeset
|
328 |
all_headers_inputs.append(node) |
4750
7dd4ad5ac045
Allow ns3moduleheader taskgen with empty list of source headers (for completely optional ns-3 modules)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4731
diff
changeset
|
329 |
if not found_the_module: |
4326
179f86838e62
Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4164
diff
changeset
|
330 |
raise Utils.WscriptError("error finding headers for module %s" % self.module) |
4750
7dd4ad5ac045
Allow ns3moduleheader taskgen with empty list of source headers (for completely optional ns-3 modules)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4731
diff
changeset
|
331 |
if not all_headers_inputs: |
7dd4ad5ac045
Allow ns3moduleheader taskgen with empty list of source headers (for completely optional ns-3 modules)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4731
diff
changeset
|
332 |
return |
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
333 |
all_headers_outputs = [ns3_dir_node.find_or_declare("%s-module.h" % self.module)] |
5942
7c66549b828d
Upgrade waf from 1.5.9 to 1.5.11
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
5781
diff
changeset
|
334 |
task = self.create_task('gen_ns3_module_header', env=self.env) |
2611
79b1c42fef3e
Generate foo-module.h module aggreator header files, for use in user scripts.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2609
diff
changeset
|
335 |
task.module = self.module |
6647
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
336 |
task.mode = self.mode |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
337 |
if self.mode == 'install': |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
338 |
task.set_inputs(all_headers_inputs) |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
339 |
task.set_outputs(all_headers_outputs) |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
340 |
module_obj = self.bld.name_to_obj("ns3-" + self.module, self.env) |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
341 |
assert module_obj is not None, self.module |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
342 |
task.module_deps = module_obj.module_deps |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
343 |
else: |
bdbbfbc6bda7
When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6639
diff
changeset
|
344 |
task.header_to_remove = all_headers_outputs[0] |
2611
79b1c42fef3e
Generate foo-module.h module aggreator header files, for use in user scripts.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2609
diff
changeset
|
345 |
|
79b1c42fef3e
Generate foo-module.h module aggreator header files, for use in user scripts.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2609
diff
changeset
|
346 |
def install(self): |
79b1c42fef3e
Generate foo-module.h module aggreator header files, for use in user scripts.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2609
diff
changeset
|
347 |
pass |