author | Mitch Watrous <watrous@u.washington.edu> |
Thu, 24 Mar 2011 09:23:44 -0700 | |
changeset 6941 | 9d2c79c992d7 |
parent 6939 | 9fe35f79fd8f |
child 6942 | 3b9ce3a727a5 |
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 |
|
6913
54679ab32585
Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
6902
diff
changeset
|
15 |
import ccroot |
54679ab32585
Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
6902
diff
changeset
|
16 |
ccroot.USE_TOP_LEVEL = True |
54679ab32585
Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
6902
diff
changeset
|
17 |
|
6168
c737d0a0e9a0
Bug 860: waf dies while executing ns3header task in case of parallel jobs.
Andrey Mazo <mazo@iitp.ru>
parents:
6127
diff
changeset
|
18 |
try: |
c737d0a0e9a0
Bug 860: waf dies while executing ns3header task in case of parallel jobs.
Andrey Mazo <mazo@iitp.ru>
parents:
6127
diff
changeset
|
19 |
set |
c737d0a0e9a0
Bug 860: waf dies while executing ns3header task in case of parallel jobs.
Andrey Mazo <mazo@iitp.ru>
parents:
6127
diff
changeset
|
20 |
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
|
21 |
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
|
22 |
|
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
|
23 |
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
|
24 |
'core', |
6823
a27f86fb4e55
Merge node and common modules into new network module
Tom Henderson <tomh@tomh.org>
parents:
6821
diff
changeset
|
25 |
'network', |
6941
9d2c79c992d7
Split contrib module into config-store and tools
Mitch Watrous <watrous@u.washington.edu>
parents:
6939
diff
changeset
|
26 |
'config-store', |
6834
036f9a0b9899
Rename internet-stack to internet, and organize module
Tom Henderson <tomh@tomh.org>
parents:
6825
diff
changeset
|
27 |
'internet', |
6794
5dce93cfc499
create propagation module; move files from common module
Tom Henderson <tomh@tomh.org>
parents:
6717
diff
changeset
|
28 |
'propagation', |
6852
8f1a53d3f6ca
Moves devices/* and routing/* to src/
Lalith Suresh <suresh.lalith@gmail.com>
parents:
6851
diff
changeset
|
29 |
'point-to-point', |
8f1a53d3f6ca
Moves devices/* and routing/* to src/
Lalith Suresh <suresh.lalith@gmail.com>
parents:
6851
diff
changeset
|
30 |
'csma', |
8f1a53d3f6ca
Moves devices/* and routing/* to src/
Lalith Suresh <suresh.lalith@gmail.com>
parents:
6851
diff
changeset
|
31 |
'emu', |
8f1a53d3f6ca
Moves devices/* and routing/* to src/
Lalith Suresh <suresh.lalith@gmail.com>
parents:
6851
diff
changeset
|
32 |
'bridge', |
8f1a53d3f6ca
Moves devices/* and routing/* to src/
Lalith Suresh <suresh.lalith@gmail.com>
parents:
6851
diff
changeset
|
33 |
'tap-bridge', |
8f1a53d3f6ca
Moves devices/* and routing/* to src/
Lalith Suresh <suresh.lalith@gmail.com>
parents:
6851
diff
changeset
|
34 |
'virtual-net-device', |
6847
138f00c56381
Move applications to a single module
Mitch Watrous <watrous@u.washington.edu>
parents:
6834
diff
changeset
|
35 |
'applications', |
6852
8f1a53d3f6ca
Moves devices/* and routing/* to src/
Lalith Suresh <suresh.lalith@gmail.com>
parents:
6851
diff
changeset
|
36 |
'nix-vector-routing', |
8f1a53d3f6ca
Moves devices/* and routing/* to src/
Lalith Suresh <suresh.lalith@gmail.com>
parents:
6851
diff
changeset
|
37 |
'olsr', |
8f1a53d3f6ca
Moves devices/* and routing/* to src/
Lalith Suresh <suresh.lalith@gmail.com>
parents:
6851
diff
changeset
|
38 |
'aodv', |
8f1a53d3f6ca
Moves devices/* and routing/* to src/
Lalith Suresh <suresh.lalith@gmail.com>
parents:
6851
diff
changeset
|
39 |
'dsdv', |
8f1a53d3f6ca
Moves devices/* and routing/* to src/
Lalith Suresh <suresh.lalith@gmail.com>
parents:
6851
diff
changeset
|
40 |
'click', |
6890 | 41 |
'openflow', |
968
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
955
diff
changeset
|
42 |
'mobility', |
6852
8f1a53d3f6ca
Moves devices/* and routing/* to src/
Lalith Suresh <suresh.lalith@gmail.com>
parents:
6851
diff
changeset
|
43 |
'wifi', |
6864 | 44 |
'netanim', |
6855
104f16f72979
Modularize stats module and move it to src
Mitch Watrous <watrous@u.washington.edu>
parents:
6854
diff
changeset
|
45 |
'stats', |
6852
8f1a53d3f6ca
Moves devices/* and routing/* to src/
Lalith Suresh <suresh.lalith@gmail.com>
parents:
6851
diff
changeset
|
46 |
'uan', |
6801 | 47 |
'spectrum', |
6851
7fdad61b88f1
Modularize mesh module and move it to src
Mitch Watrous <watrous@u.washington.edu>
parents:
6850
diff
changeset
|
48 |
'mesh', |
5270 | 49 |
'test', |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4750
diff
changeset
|
50 |
'test/ns3tcp', |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4750
diff
changeset
|
51 |
'test/ns3wifi', |
6939
9fe35f79fd8f
Move flow-monitor module out of contrib directory
Mitch Watrous <watrous@u.washington.edu>
parents:
6938
diff
changeset
|
52 |
'flow-monitor', |
6852
8f1a53d3f6ca
Moves devices/* and routing/* to src/
Lalith Suresh <suresh.lalith@gmail.com>
parents:
6851
diff
changeset
|
53 |
'wimax', |
8f1a53d3f6ca
Moves devices/* and routing/* to src/
Lalith Suresh <suresh.lalith@gmail.com>
parents:
6851
diff
changeset
|
54 |
'lte', |
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
6111
diff
changeset
|
55 |
'mpi', |
6854
dc1057c9879d
Modularize topology-read module and move it to src
Mitch Watrous <watrous@u.washington.edu>
parents:
6852
diff
changeset
|
56 |
'topology-read', |
6938
85d201f1c67f
Move energy module out of contrib directory
Mitch Watrous <watrous@u.washington.edu>
parents:
6934
diff
changeset
|
57 |
'energy', |
6941
9d2c79c992d7
Split contrib module into config-store and tools
Mitch Watrous <watrous@u.washington.edu>
parents:
6939
diff
changeset
|
58 |
'tools', |
6676
8a57344a8d09
Codereview Issue 2692041: Add pyviz module
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6671
diff
changeset
|
59 |
'tools/visualizer', |
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
|
60 |
) |
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
|
61 |
|
537
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
62 |
def set_options(opt): |
6821
203367ae7433
merge src/simulator into src/core; move src/core to new module layout
Tom Henderson <tomh@tomh.org>
parents:
6801
diff
changeset
|
63 |
opt.sub_options('core') |
6852
8f1a53d3f6ca
Moves devices/* and routing/* to src/
Lalith Suresh <suresh.lalith@gmail.com>
parents:
6851
diff
changeset
|
64 |
opt.sub_options('click') |
6890 | 65 |
opt.sub_options('openflow') |
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
|
66 |
|
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
|
67 |
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
|
68 |
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
|
69 |
" (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
|
70 |
" --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
|
71 |
" 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
|
72 |
action="store_true", dest='enable_rpath', default=False) |
4164
1f6ae48061a9
checkpoint tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
4163
diff
changeset
|
73 |
|
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
|
74 |
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
|
75 |
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
|
76 |
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
|
77 |
|
537
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
78 |
def configure(conf): |
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
79 |
conf.sub_config('core') |
6852
8f1a53d3f6ca
Moves devices/* and routing/* to src/
Lalith Suresh <suresh.lalith@gmail.com>
parents:
6851
diff
changeset
|
80 |
conf.sub_config('emu') |
8f1a53d3f6ca
Moves devices/* and routing/* to src/
Lalith Suresh <suresh.lalith@gmail.com>
parents:
6851
diff
changeset
|
81 |
conf.sub_config('tap-bridge') |
6941
9d2c79c992d7
Split contrib module into config-store and tools
Mitch Watrous <watrous@u.washington.edu>
parents:
6939
diff
changeset
|
82 |
conf.sub_config('config-store') |
6834
036f9a0b9899
Rename internet-stack to internet, and organize module
Tom Henderson <tomh@tomh.org>
parents:
6825
diff
changeset
|
83 |
conf.sub_config('internet') |
6864 | 84 |
conf.sub_config('netanim') |
6034
de2824cc388d
add a place for perf tests
Craig Dowell <craigdo@ee.washington.edu>
parents:
6029
diff
changeset
|
85 |
conf.sub_config('test') |
6852
8f1a53d3f6ca
Moves devices/* and routing/* to src/
Lalith Suresh <suresh.lalith@gmail.com>
parents:
6851
diff
changeset
|
86 |
conf.sub_config('click') |
6890 | 87 |
conf.sub_config('openflow') |
537
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
88 |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
89 |
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
|
90 |
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
|
91 |
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
|
92 |
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
|
93 |
|
5361
e8989b44bffb
Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
5270
diff
changeset
|
94 |
## 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
|
95 |
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
|
96 |
|
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
|
97 |
|
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
|
98 |
def create_ns3_module(bld, name, dependencies=()): |
6913
54679ab32585
Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
6902
diff
changeset
|
99 |
# Create a separate library for this module. |
54679ab32585
Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
6902
diff
changeset
|
100 |
if bld.env['ENABLE_STATIC_NS3']: |
54679ab32585
Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
6902
diff
changeset
|
101 |
module = bld.new_task_gen('cxx', 'cstaticlib') |
54679ab32585
Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
6902
diff
changeset
|
102 |
else: |
54679ab32585
Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
6902
diff
changeset
|
103 |
module = bld.new_task_gen('cxx', 'cshlib') |
6639
e09e8803df26
(missing from last commit)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6429
diff
changeset
|
104 |
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
|
105 |
module.name = 'ns3-' + name |
6913
54679ab32585
Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
6902
diff
changeset
|
106 |
# Add the proper path to the module's name. |
54679ab32585
Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
6902
diff
changeset
|
107 |
module.target = '%s/ns3-%s' % (bld.srcnode.relpath_gen(bld.path), name) |
54679ab32585
Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
6902
diff
changeset
|
108 |
# Set the libraries this module depends on. |
54679ab32585
Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
6902
diff
changeset
|
109 |
module.uselib_local = ['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
|
110 |
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
|
111 |
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
|
112 |
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
|
113 |
module.env.append_value('CCFLAGS', module.env['shlib_CXXFLAGS']) |
6913
54679ab32585
Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
6902
diff
changeset
|
114 |
# Turn on the link flags for shared libraries if we have the |
54679ab32585
Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
6902
diff
changeset
|
115 |
# proper compiler and platform. |
54679ab32585
Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
6902
diff
changeset
|
116 |
if module.env['CXX_NAME'] in ['gcc', 'icc'] and module.env['WL_SONAME_SUPPORTED']: |
54679ab32585
Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
6902
diff
changeset
|
117 |
# Get the module library name without any relative paths |
54679ab32585
Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
6902
diff
changeset
|
118 |
# at its beginning because all of the libraries will end |
54679ab32585
Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
6902
diff
changeset
|
119 |
# up in the same directory. |
54679ab32585
Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
6902
diff
changeset
|
120 |
module_library_name = os.path.basename(ccroot.get_target_name(module)) |
54679ab32585
Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
6902
diff
changeset
|
121 |
module.env.append_value('LINKFLAGS', '-Wl,--soname=%s' % module_library_name) |
5252
481053e0cd10
Bug 681: wrong compilation options for icpc (Intel C/C++ Compiler)
Andrey Mazo <mazo@iitp.ru>
parents:
5230
diff
changeset
|
122 |
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
|
123 |
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
|
124 |
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
|
125 |
# 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
|
126 |
# 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
|
127 |
# (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
|
128 |
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
|
129 |
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
|
130 |
|
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
|
131 |
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
|
132 |
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
|
133 |
return module |
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
134 |
|
6913
54679ab32585
Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
6902
diff
changeset
|
135 |
def create_ns3_module_test_library(bld, name): |
54679ab32585
Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
6902
diff
changeset
|
136 |
# Create an ns3 module for the test library that depends only on |
54679ab32585
Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
6902
diff
changeset
|
137 |
# the module being tested. |
54679ab32585
Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
6902
diff
changeset
|
138 |
library_name = name + "-test" |
54679ab32585
Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
6902
diff
changeset
|
139 |
library = bld.create_ns3_module(library_name, [name]) |
54679ab32585
Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
6902
diff
changeset
|
140 |
|
54679ab32585
Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
6902
diff
changeset
|
141 |
# Modify attributes for the test library that are different from a |
54679ab32585
Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
6902
diff
changeset
|
142 |
# normal module. |
54679ab32585
Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
6902
diff
changeset
|
143 |
del library.is_ns3_module |
54679ab32585
Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
6902
diff
changeset
|
144 |
library.is_ns3_module_test_library = True |
54679ab32585
Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
6902
diff
changeset
|
145 |
library.module_name = 'ns3-' + name |
54679ab32585
Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
6902
diff
changeset
|
146 |
|
6925
43d9c7eedf7b
Test implicitly dependent modules
Mitch Watrous <watrous@u.washington.edu>
parents:
6921
diff
changeset
|
147 |
# Add this module and test library to the list. |
43d9c7eedf7b
Test implicitly dependent modules
Mitch Watrous <watrous@u.washington.edu>
parents:
6921
diff
changeset
|
148 |
bld.env.append_value('NS3_MODULES_WITH_TEST_LIBRARIES', (library.module_name, library.name)) |
6913
54679ab32585
Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
6902
diff
changeset
|
149 |
|
54679ab32585
Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
6902
diff
changeset
|
150 |
# Set the include path from the build directory to modules. |
54679ab32585
Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
6902
diff
changeset
|
151 |
relative_path_from_build_to_here = bld.path.relpath_gen(bld.bldnode) |
54679ab32585
Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
6902
diff
changeset
|
152 |
include_flag = '-I' + relative_path_from_build_to_here |
54679ab32585
Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
6902
diff
changeset
|
153 |
library.env.append_value('CXXFLAGS', include_flag) |
54679ab32585
Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
6902
diff
changeset
|
154 |
library.env.append_value('CCFLAGS', include_flag) |
54679ab32585
Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
6902
diff
changeset
|
155 |
|
54679ab32585
Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
6902
diff
changeset
|
156 |
return library |
54679ab32585
Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
6902
diff
changeset
|
157 |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
158 |
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
|
159 |
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
|
160 |
DeprecationWarning, stacklevel=2) |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
161 |
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
|
162 |
|
6874
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
163 |
|
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
164 |
def ns3_python_bindings(bld): |
6933
4bbaa92c3220
./waf --apiscan=all: now only scans modules that have bld.ns3_python_bindings() in their wscript
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6925
diff
changeset
|
165 |
# this method is called from a module wscript, so remember bld.path is not bindings/python! |
4bbaa92c3220
./waf --apiscan=all: now only scans modules that have bld.ns3_python_bindings() in their wscript
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6925
diff
changeset
|
166 |
module_abs_src_path = bld.path.abspath() |
4bbaa92c3220
./waf --apiscan=all: now only scans modules that have bld.ns3_python_bindings() in their wscript
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6925
diff
changeset
|
167 |
module = os.path.basename(module_abs_src_path) |
6874
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
168 |
env = bld.env |
6933
4bbaa92c3220
./waf --apiscan=all: now only scans modules that have bld.ns3_python_bindings() in their wscript
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6925
diff
changeset
|
169 |
env.append_value("MODULAR_BINDINGS_MODULES", "ns3-"+module) |
4bbaa92c3220
./waf --apiscan=all: now only scans modules that have bld.ns3_python_bindings() in their wscript
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6925
diff
changeset
|
170 |
|
6874
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
171 |
if not env['ENABLE_PYTHON_BINDINGS']: |
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
172 |
return |
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
173 |
if env['BINDINGS_TYPE'] not in ('modular', 'both'): |
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
174 |
return |
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
175 |
|
6921
f4aa5d190c7b
Modular bindings: bug fixes, more verbose scanning
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6920
diff
changeset
|
176 |
if not os.path.exists(bld.path.find_dir("bindings").abspath()): |
6876
9ac9bd55541d
Make ns3_python_bindings skip bindings with warning if apidefs dir not found
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6875
diff
changeset
|
177 |
warnings.warn("(in %s) Requested to build modular python bindings, but apidefs dir not found " |
9ac9bd55541d
Make ns3_python_bindings skip bindings with warning if apidefs dir not found
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6875
diff
changeset
|
178 |
"=> skipped the bindings." % str(bld.path), |
9ac9bd55541d
Make ns3_python_bindings skip bindings with warning if apidefs dir not found
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6875
diff
changeset
|
179 |
Warning, stacklevel=2) |
9ac9bd55541d
Make ns3_python_bindings skip bindings with warning if apidefs dir not found
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6875
diff
changeset
|
180 |
return |
9ac9bd55541d
Make ns3_python_bindings skip bindings with warning if apidefs dir not found
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6875
diff
changeset
|
181 |
|
6920
b1b821ae64c1
Modular bindings: skip a binding module if the corresponding ns-3 module is not enabled
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6913
diff
changeset
|
182 |
if ("ns3-%s" % (module,)) not in env.NS3_ENABLED_MODULES: |
b1b821ae64c1
Modular bindings: skip a binding module if the corresponding ns-3 module is not enabled
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6913
diff
changeset
|
183 |
#print "bindings for module %s which is not enabled, skip" % module |
b1b821ae64c1
Modular bindings: skip a binding module if the corresponding ns-3 module is not enabled
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6913
diff
changeset
|
184 |
return |
b1b821ae64c1
Modular bindings: skip a binding module if the corresponding ns-3 module is not enabled
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6913
diff
changeset
|
185 |
|
6897
f338f17b0238
Modular bindings: generate a compatibility 'ns3' module that imports the modular bindings
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6894
diff
changeset
|
186 |
env.append_value('PYTHON_MODULES_BUILT', module) |
6874
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
187 |
apidefs = env['PYTHON_BINDINGS_APIDEFS'].replace("-", "_") |
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
188 |
|
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
189 |
#debug = ('PYBINDGEN_DEBUG' in os.environ) |
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
190 |
debug = True # XXX |
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
191 |
source = [bld.srcnode.find_resource('bindings/python/ns3modulegen-modular.py').relpath_gen(bld.path), |
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
192 |
"bindings/modulegen__%s.py" % apidefs] |
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
193 |
|
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
194 |
# the local customization file may or not exist |
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
195 |
if bld.path.find_resource("bindings/modulegen_local.py"): |
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
196 |
source.append("bindings/modulegen_local.py") |
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
197 |
|
6893
5dccd86f90cf
Modular Python bindings work (many bug fixes, more modules tested)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6882
diff
changeset
|
198 |
target = ['bindings/ns3module.cc', 'bindings/ns3module.h', 'bindings/ns3modulegen.log'] |
6874
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
199 |
#if not debug: |
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
200 |
# target.append('ns3modulegen.log') |
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
201 |
|
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
202 |
argv = ['NS3_ENABLED_FEATURES=${FEATURES}', '${PYTHON}'] |
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
203 |
#if debug: |
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
204 |
# argv.extend(["-m", "pdb"]) |
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
205 |
|
6893
5dccd86f90cf
Modular Python bindings work (many bug fixes, more modules tested)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6882
diff
changeset
|
206 |
argv.extend(['${SRC[0]}', module_abs_src_path, apidefs, '${TGT[0]}']) |
5dccd86f90cf
Modular Python bindings work (many bug fixes, more modules tested)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6882
diff
changeset
|
207 |
|
5dccd86f90cf
Modular Python bindings work (many bug fixes, more modules tested)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6882
diff
changeset
|
208 |
argv.extend(['2>', '${TGT[2]}']) # 2> ns3modulegen.log |
6874
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
209 |
|
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
210 |
features = [] |
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
211 |
for (name, caption, was_enabled, reason_not_enabled) in env['NS3_OPTIONAL_FEATURES']: |
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
212 |
if was_enabled: |
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
213 |
features.append(name) |
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
214 |
|
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
215 |
bindgen = bld.new_task_gen('command', source=source, target=target, command=argv) |
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
216 |
bindgen.env['FEATURES'] = ','.join(features) |
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
217 |
bindgen.dep_vars = ['FEATURES'] |
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
218 |
bindgen.before = 'cxx' |
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
219 |
bindgen.after = 'gen_ns3_module_header_task' |
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
220 |
bindgen.name = "pybindgen(ns3 module %s)" % module |
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
221 |
|
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
222 |
pymod = bld.new_task_gen(features='cxx cshlib pyext') |
6893
5dccd86f90cf
Modular Python bindings work (many bug fixes, more modules tested)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6882
diff
changeset
|
223 |
pymod.source = ['bindings/ns3module.cc'] |
6902
3aa6e43dfe41
Modular bindings: handle module names with hyphens
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6897
diff
changeset
|
224 |
pymod.target = '%s/%s' % (bld.srcnode.find_dir("bindings/python/ns").relpath_gen(bld.path), module.replace('-', '_')) |
6874
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
225 |
pymod.name = 'ns3module_%s' % module |
6934
96d88633a72f
Modular bindings: make each python extension module link only to the required ns-3 modular libraries
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6933
diff
changeset
|
226 |
pymod.uselib_local = "ns3-"+module |
6874
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
227 |
if pymod.env['ENABLE_STATIC_NS3']: |
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
228 |
if sys.platform == 'darwin': |
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
229 |
pymod.env.append_value('LINKFLAGS', '-Wl,-all_load') |
6913
54679ab32585
Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
6902
diff
changeset
|
230 |
for mod in pymod.uselib_local: |
54679ab32585
Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
6902
diff
changeset
|
231 |
pymod.env.append_value('LINKFLAGS', '-l' + mod) |
6874
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
232 |
else: |
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
233 |
pymod.env.append_value('LINKFLAGS', '-Wl,--whole-archive,-Bstatic') |
6913
54679ab32585
Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
6902
diff
changeset
|
234 |
for mod in pymod.uselib_local: |
54679ab32585
Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
6902
diff
changeset
|
235 |
pymod.env.append_value('LINKFLAGS', '-l' + mod) |
6874
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
236 |
pymod.env.append_value('LINKFLAGS', '-Wl,-Bdynamic,--no-whole-archive') |
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
237 |
defines = list(pymod.env['CXXDEFINES']) |
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
238 |
defines.extend(['NS_DEPRECATED=', 'NS3_DEPRECATED_H']) |
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
239 |
if Options.platform == 'win32': |
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
240 |
try: |
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
241 |
defines.remove('_DEBUG') # causes undefined symbols on win32 |
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
242 |
except ValueError: |
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
243 |
pass |
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
244 |
pymod.env['CXXDEFINES'] = defines |
6893
5dccd86f90cf
Modular Python bindings work (many bug fixes, more modules tested)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6882
diff
changeset
|
245 |
pymod.includes = 'bindings' |
5dccd86f90cf
Modular Python bindings work (many bug fixes, more modules tested)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6882
diff
changeset
|
246 |
return pymod |
6874
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
247 |
|
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
248 |
|
537
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
249 |
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
|
250 |
bld.create_ns3_module = types.MethodType(create_ns3_module, bld) |
6913
54679ab32585
Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
6902
diff
changeset
|
251 |
bld.create_ns3_module_test_library = types.MethodType(create_ns3_module_test_library, bld) |
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
252 |
bld.create_obj = types.MethodType(create_obj, bld) |
6874
c7537e62f2fa
Start of work on modular Python bindings, unstable
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
253 |
bld.ns3_python_bindings = types.MethodType(ns3_python_bindings, 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
|
254 |
|
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
|
255 |
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
|
256 |
|
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
|
257 |
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
|
258 |
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
|
259 |
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
|
260 |
|
1220
4933e0890acd
Build all modules as a single ns3 shared library.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1217
diff
changeset
|
261 |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
262 |
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
|
263 |
"""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
|
264 |
COLOR = 'BLUE' |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
265 |
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
|
266 |
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
|
267 |
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
|
268 |
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
|
269 |
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
|
270 |
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
|
271 |
|
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
|
272 |
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
|
273 |
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
|
274 |
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
|
275 |
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
|
276 |
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
|
277 |
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
|
278 |
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
|
279 |
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
|
280 |
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
|
281 |
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
|
282 |
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
|
283 |
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
|
284 |
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
|
285 |
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
|
286 |
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
|
287 |
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
|
288 |
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
|
289 |
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
|
290 |
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
|
291 |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
292 |
class ns3header_task(Task.Task): |
4066
d2309cf765d8
Fix --python-scan
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4064
diff
changeset
|
293 |
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
|
294 |
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
|
295 |
|
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
|
296 |
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
|
297 |
"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
|
298 |
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
|
299 |
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
|
300 |
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
|
301 |
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
|
302 |
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
|
303 |
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
|
304 |
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
|
305 |
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
|
306 |
|
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
|
307 |
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
|
308 |
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
|
309 |
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
|
310 |
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
|
311 |
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
|
312 |
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
|
313 |
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
|
314 |
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
|
315 |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
316 |
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
|
317 |
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
|
318 |
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
|
319 |
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
|
320 |
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
|
321 |
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
|
322 |
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
|
323 |
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
|
324 |
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
|
325 |
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
|
326 |
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
|
327 |
## 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
|
328 |
## 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
|
329 |
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
|
330 |
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
|
331 |
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
|
332 |
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
|
333 |
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
|
334 |
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
|
335 |
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
|
336 |
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
|
337 |
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
|
338 |
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
|
339 |
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
|
340 |
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
|
341 |
|
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
|
342 |
|
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
|
343 |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
344 |
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
|
345 |
before = 'cc cxx' |
4066
d2309cf765d8
Fix --python-scan
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4064
diff
changeset
|
346 |
after = 'ns3header_task' |
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
347 |
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
|
348 |
|
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
|
349 |
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
|
350 |
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
|
351 |
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
|
352 |
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
|
353 |
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
|
354 |
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
|
355 |
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
|
356 |
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
|
357 |
|
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
|
358 |
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
|
359 |
"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
|
360 |
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
|
361 |
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
|
362 |
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
|
363 |
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
|
364 |
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
|
365 |
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
|
366 |
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
|
367 |
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
|
368 |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
369 |
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
|
370 |
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
|
371 |
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
|
372 |
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
|
373 |
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
|
374 |
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
|
375 |
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
|
376 |
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
|
377 |
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
|
378 |
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
|
379 |
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
|
380 |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
381 |
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
|
382 |
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
|
383 |
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
|
384 |
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
|
385 |
header_files.sort() |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
386 |
|
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
387 |
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
|
388 |
#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
|
389 |
# 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
|
390 |
#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
|
391 |
|
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
|
392 |
#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
|
393 |
""" % (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
|
394 |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
395 |
# if self.module_deps: |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
396 |
# print >> outfile, "// Module dependencies:" |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
397 |
# 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
|
398 |
# 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
|
399 |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
400 |
print >> outfile |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
401 |
print >> outfile, "// Module headers:" |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
402 |
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
|
403 |
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
|
404 |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
405 |
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
|
406 |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
407 |
outfile.close() |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
408 |
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
|
409 |
|
4126
0ba0346d655b
Workaround WAF issue 325 for generating module header files
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4066
diff
changeset
|
410 |
def sig_explicit_deps(self): |
6671
b3d5193a2f94
Bug 1004 - module header not rebuilt
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
411 |
self.m.update('\n'.join([node.abspath(self.env) for node in self.inputs])) |
b3d5193a2f94
Bug 1004 - module header not rebuilt
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6647
diff
changeset
|
412 |
return self.m.digest() |
4126
0ba0346d655b
Workaround WAF issue 325 for generating module header files
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4066
diff
changeset
|
413 |
|
0ba0346d655b
Workaround WAF issue 325 for generating module header files
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4066
diff
changeset
|
414 |
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
|
415 |
try: |
0ba0346d655b
Workaround WAF issue 325 for generating module header files
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4066
diff
changeset
|
416 |
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
|
417 |
except AttributeError: |
0ba0346d655b
Workaround WAF issue 325 for generating module header files
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4066
diff
changeset
|
418 |
"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
|
419 |
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
|
420 |
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
|
421 |
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
|
422 |
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
|
423 |
|
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
|
424 |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
425 |
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
|
426 |
""" |
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
|
427 |
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
|
428 |
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
|
429 |
""" |
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
430 |
COLOR = 'BLUE' |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
431 |
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
|
432 |
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
|
433 |
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
|
434 |
|
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
|
435 |
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
|
436 |
## 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
|
437 |
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
|
438 |
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
|
439 |
found_the_module = False |
4326
179f86838e62
Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4164
diff
changeset
|
440 |
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
|
441 |
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
|
442 |
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
|
443 |
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
|
444 |
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
|
445 |
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
|
446 |
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
|
447 |
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
|
448 |
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
|
449 |
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
|
450 |
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
|
451 |
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
|
452 |
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
|
453 |
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
|
454 |
return |
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3854
diff
changeset
|
455 |
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
|
456 |
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
|
457 |
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
|
458 |
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
|
459 |
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
|
460 |
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
|
461 |
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
|
462 |
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
|
463 |
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
|
464 |
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
|
465 |
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
|
466 |
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
|
467 |
|
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
|
468 |
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
|
469 |
pass |