src/wscript
author He Wu <mdzz@u.washington.edu>
Wed, 07 Jul 2010 21:54:32 -0700
changeset 6429 5ee11b58989d
parent 6398 35e28482eae9
child 6639 e09e8803df26
child 7041 70c8f8e0b08d
permissions -rw-r--r--
Initial import of energy model
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
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
    13
6168
c737d0a0e9a0 Bug 860: waf dies while executing ns3header task in case of parallel jobs.
Andrey Mazo <mazo@iitp.ru>
parents: 6127
diff changeset
    14
try:
c737d0a0e9a0 Bug 860: waf dies while executing ns3header task in case of parallel jobs.
Andrey Mazo <mazo@iitp.ru>
parents: 6127
diff changeset
    15
    set
c737d0a0e9a0 Bug 860: waf dies while executing ns3header task in case of parallel jobs.
Andrey Mazo <mazo@iitp.ru>
parents: 6127
diff changeset
    16
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
    17
    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
    18
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
    19
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
    20
    'core',
fd944dbf33c6 WAF: simplify wscripts using the new chained uselib_local dependencies feature of WAF SVN; now build all samples and examples; add --disable-rpath configure option; add WAF build instructions.
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents: 537
diff changeset
    21
    'common',
fd944dbf33c6 WAF: simplify wscripts using the new chained uselib_local dependencies feature of WAF SVN; now build all samples and examples; add --disable-rpath configure option; add WAF build instructions.
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents: 537
diff changeset
    22
    'simulator',
1878
f947cd18f0bb Create a new contrib module; move event-garbage-collector.{h,cc} to the contrib module.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1877
diff changeset
    23
    'contrib',
600
fd944dbf33c6 WAF: simplify wscripts using the new chained uselib_local dependencies feature of WAF SVN; now build all samples and examples; add --disable-rpath configure option; add WAF build instructions.
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents: 537
diff changeset
    24
    'node',
3260
8c0ab08144e6 bug 186: internet-node directory must be renamed to internet-stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3063
diff changeset
    25
    'internet-stack',
972
6946c8237a73 src/devices/p2p -> src/devices/point-to-point
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents: 969
diff changeset
    26
    'devices/point-to-point',
1272
67a2ba1143e0 rename to csma
Craig Dowell <craigdo@ee.washington.edu>
parents: 1220
diff changeset
    27
    'devices/csma',
3854
c049b25f2ded osx doesn't emu
Craig Dowell <craigdo@ee.washington.edu>
parents: 3839
diff changeset
    28
    'devices/emu',
3826
40c5841b616d merge in tap device
Craig Dowell <craigdo@ee.washington.edu>
parents: 3581
diff changeset
    29
    'devices/bridge',
4163
8c48682b3d42 checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents: 4126
diff changeset
    30
    'devices/tap-bridge',
4541
e943b94bf523 Rename TapNetDevice to VirtualNetDevice
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4539
diff changeset
    31
    'devices/virtual-net-device',
1496
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents: 1306
diff changeset
    32
    'applications/onoff',
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents: 1306
diff changeset
    33
    'applications/packet-sink',
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents: 1306
diff changeset
    34
    'applications/udp-echo',
5224
06f639d05b8f Merge NixVector Routing code
Josh Pelkey <jpelkey@gatech.edu>
parents: 5211
diff changeset
    35
    'routing/nix-vector-routing',
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 969
diff changeset
    36
    'routing/olsr',
1120
050454d7d028 interim
Tom Henderson <tomh@tomh.org>
parents: 1119
diff changeset
    37
    'routing/global-routing',
4573
01e876191f2e move list routing and static routing to src/routing directories
Tom Henderson <tomh@tomh.org>
parents: 4541
diff changeset
    38
    'routing/static-routing',
01e876191f2e move list routing and static routing to src/routing directories
Tom Henderson <tomh@tomh.org>
parents: 4541
diff changeset
    39
    'routing/list-routing',
5749
1c6600743c9e routing/manet directory removed
Pavel Boyko <boyko@iitp.ru>
parents: 5748
diff changeset
    40
    'routing/aodv',
968
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 955
diff changeset
    41
    'mobility',
1882
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1272
diff changeset
    42
    'devices/wifi',
2603
1308da4cb3bf move helpers to their own dir.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2178
diff changeset
    43
    'helper',
3570
44b0bc6817c6 Stats module and example merged in.
tjkopena@cs.drexel.edu
parents: 3498
diff changeset
    44
    'contrib/stats',
3821
9ea825f066a2 Apply icmp-application patch frm lacage
Craig Dowell <craigdo@ee.washington.edu>
parents: 3581
diff changeset
    45
    'applications/v4ping',
6376
4e133d0aa098 UAN module addition
Leonard Tracy <lentracy@u.washington.edu>
parents: 6349
diff changeset
    46
    'devices/uan',
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents: 6193
diff changeset
    47
    'devices/spectrum',
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents: 6193
diff changeset
    48
    'devices/mesh',   
4871
285d97537359 802.11s/ Moved to dot11s/
Kirill Andreev <andreev@iitp.ru>
parents: 4824
diff changeset
    49
    'devices/mesh/dot11s',
5078
697573fd6554 Added FLAME header
Kirill Andreev <andreev@iitp.ru>
parents: 5028
diff changeset
    50
    'devices/mesh/flame',
4731
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4573
diff changeset
    51
    'applications/ping6',
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4573
diff changeset
    52
    'applications/radvd',
5270
4b888ac54977 Add sample test suite file
Tom Henderson <tomh@tomh.org>
parents: 5252
diff changeset
    53
    'test',
6034
de2824cc388d add a place for perf tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 6029
diff changeset
    54
    'test/perf',
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4750
diff changeset
    55
    'test/ns3tcp',
6193
808bcfa200f4 add NSC version of TCP loss test suite
Tom Henderson <tomh@tomh.org>
parents: 6168
diff changeset
    56
    'test/nsctcp',
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4750
diff changeset
    57
    'test/ns3wifi',
5205
673aae891b2b Add a new 'flow-monitor' module.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4731
diff changeset
    58
    'contrib/flow-monitor',
5781
2557c340ea15 Adding 3 new applications:udp-client, udp-server, udp-trace-client.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents: 5776
diff changeset
    59
    'applications/udp-client-server',
6111
0b22ae082153 Merge WiMAX module
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents: 6054
diff changeset
    60
    'devices/wimax',
6113
0ce37bf4f1c1 Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents: 6111
diff changeset
    61
    'mpi',
6127
b5bc10de166d merge topology read system
Tommaso Pecorella <tpecorella@mac.com>
parents: 6113
diff changeset
    62
    'contrib/topology-read',
6429
5ee11b58989d Initial import of energy model
He Wu <mdzz@u.washington.edu>
parents: 6398
diff changeset
    63
    'contrib/energy',
969
3c3ce40492a6 WAF: make list of modules (all_modules) a tuple instead of list, because it is hashable, and this way newer WAF is able to notice changes in it and automatically trigger a reconfiguration.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 968
diff changeset
    64
    )
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
    65
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
    66
def set_options(opt):
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
    67
    opt.sub_options('simulator')
955
c9be0df711d2 WAF: add back the --enable-rpath option, per Mathieu's request, though disabled by default.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 954
diff changeset
    68
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
    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
    70
                   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
    71
                         " (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
    72
                         " --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
    73
                         " 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
    74
                   action="store_true", dest='enable_rpath', default=False)
4164
1f6ae48061a9 checkpoint tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents: 4163
diff changeset
    75
    
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
    76
    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
    77
                   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
    78
                   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
    79
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
    80
def configure(conf):
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
    81
    conf.sub_config('core')
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
    82
    conf.sub_config('simulator')
3854
c049b25f2ded osx doesn't emu
Craig Dowell <craigdo@ee.washington.edu>
parents: 3839
diff changeset
    83
    conf.sub_config('devices/emu')
4163
8c48682b3d42 checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents: 4126
diff changeset
    84
    conf.sub_config('devices/tap-bridge')
3063
a1c532e3bf18 a basic but useful Gtk+-based config-store
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3001
diff changeset
    85
    conf.sub_config('contrib')
3579
9e5eaef3e082 nsc: enable network simulation cradle
Florian Westphal <fw@strlen.de>
parents: 3498
diff changeset
    86
    conf.sub_config('internet-stack')
5776
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents: 5749
diff changeset
    87
    conf.sub_config('helper')
6034
de2824cc388d add a place for perf tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 6029
diff changeset
    88
    conf.sub_config('test')
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
    89
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3854
diff changeset
    90
    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
    91
    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
    92
    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
    93
        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
    94
5361
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5270
diff changeset
    95
    ## 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
    96
    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
    97
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
    98
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
    99
def create_ns3_module(bld, name, dependencies=()):
5996
84c404ad1d26 WAF: allow NS-3 modules to compile pure C code sources mixed with the C++ ones
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5942
diff changeset
   100
    module = bld.new_task_gen('cxx', 'cc')
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
   101
    module.name = 'ns3-' + name
2f7791ae388d WAF: add new bld.create_ns3_module() and bld.create_ns3_program() methods to make declaration of modules and programs simpler, and allowing us to change how ns-3 is built in a centralized way, without needing to change every module wscript file.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1214
diff changeset
   102
    module.target = module.name
1220
4933e0890acd Build all modules as a single ns3 shared library.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1217
diff changeset
   103
    module.add_objects = ['ns3-' + dep for dep in dependencies]
2611
79b1c42fef3e Generate foo-module.h module aggreator header files, for use in user scripts.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2609
diff changeset
   104
    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
   105
    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
   106
        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
   107
        module.env.append_value('CCFLAGS', module.env['shlib_CXXFLAGS'])
5252
481053e0cd10 Bug 681: wrong compilation options for icpc (Intel C/C++ Compiler)
Andrey Mazo <mazo@iitp.ru>
parents: 5230
diff changeset
   108
    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
   109
            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
   110
            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
   111
        # 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
   112
        # 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
   113
        # (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
   114
        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
   115
        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
   116
        
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
   117
    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
   118
    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
   119
    return module
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3854
diff changeset
   120
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3854
diff changeset
   121
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
   122
    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
   123
                  DeprecationWarning, stacklevel=2)
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3854
diff changeset
   124
    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
   125
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   126
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
   127
    bld.create_ns3_module = types.MethodType(create_ns3_module, bld)
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3854
diff changeset
   128
    bld.create_obj = types.MethodType(create_obj, bld)
600
fd944dbf33c6 WAF: simplify wscripts using the new chained uselib_local dependencies feature of WAF SVN; now build all samples and examples; add --disable-rpath configure option; add WAF build instructions.
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents: 537
diff changeset
   129
    
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
   130
    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
   131
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
   132
    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
   133
        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
   134
        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
   135
1220
4933e0890acd Build all modules as a single ns3 shared library.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1217
diff changeset
   136
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3854
diff changeset
   137
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
   138
    """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
   139
    COLOR = 'BLUE'
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3854
diff changeset
   140
    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
   141
        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
   142
        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
   143
        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
   144
        self.module = None # module name
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
   145
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
   146
    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
   147
        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
   148
            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
   149
        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
   150
        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
   151
            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
   152
        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
   153
            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
   154
            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
   155
                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
   156
            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
   157
            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
   158
            task = self.create_task('ns3header', env=self.env)
954
a54d59850d03 WAF: use a separate 'waf task' for installing each public ns3 header to work around a dependency tracking bug in waf causing too many rebuilds when a single header file changes.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 928
diff changeset
   159
            task.set_inputs([src_node])
a54d59850d03 WAF: use a separate 'waf task' for installing each public ns3 header to work around a dependency tracking bug in waf causing too many rebuilds when a single header file changes.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 928
diff changeset
   160
            task.set_outputs([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
   161
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3854
diff changeset
   162
class ns3header_task(Task.Task):
4066
d2309cf765d8 Fix --python-scan
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4064
diff changeset
   163
    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
   164
    color = 'BLUE'
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3854
diff changeset
   165
    def run(self):
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3854
diff changeset
   166
        assert len(self.inputs) == len(self.outputs)
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3854
diff changeset
   167
        inputs = [node.srcpath(self.env) for node in self.inputs]
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3854
diff changeset
   168
        outputs = [node.bldpath(self.env) for node in self.outputs]
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3854
diff changeset
   169
        for src, dst in zip(inputs, outputs):
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3854
diff changeset
   170
            try:
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3854
diff changeset
   171
                os.chmod(dst, 0600)
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3854
diff changeset
   172
            except OSError:
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3854
diff changeset
   173
                pass
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3854
diff changeset
   174
            shutil.copy2(src, dst)
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3854
diff changeset
   175
            ## make the headers in builddir read-only, to prevent
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3854
diff changeset
   176
            ## accidental modification
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3854
diff changeset
   177
            os.chmod(dst, 0400)
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3854
diff changeset
   178
        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
   179
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
   180
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
   181
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3854
diff changeset
   182
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
   183
    before = 'cc cxx'
4066
d2309cf765d8 Fix --python-scan
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4064
diff changeset
   184
    after = 'ns3header_task'
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3854
diff changeset
   185
    color = 'BLUE'
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3854
diff changeset
   186
    def run(self):
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3854
diff changeset
   187
        assert len(self.outputs) == 1
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3854
diff changeset
   188
        header_files = [os.path.basename(node.abspath(self.env)) for node in self.inputs]
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3854
diff changeset
   189
        outfile = file(self.outputs[0].bldpath(self.env), "w")
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3854
diff changeset
   190
        header_files.sort()
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3854
diff changeset
   191
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3854
diff changeset
   192
        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
   193
#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
   194
# 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
   195
#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
   196
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
   197
#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
   198
    """ % (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
   199
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3854
diff changeset
   200
    #     if self.module_deps:
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3854
diff changeset
   201
    #         print >> outfile, "// Module dependencies:"
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3854
diff changeset
   202
    #     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
   203
    #         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
   204
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3854
diff changeset
   205
        print >> outfile
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3854
diff changeset
   206
        print >> outfile, "// Module headers:"
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3854
diff changeset
   207
        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
   208
            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
   209
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3854
diff changeset
   210
        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
   211
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3854
diff changeset
   212
        outfile.close()
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3854
diff changeset
   213
        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
   214
4126
0ba0346d655b Workaround WAF issue 325 for generating module header files
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4066
diff changeset
   215
    def sig_explicit_deps(self):
4326
179f86838e62 Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4164
diff changeset
   216
        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
   217
        m.update('\n'.join([node.abspath(self.env) for node in self.inputs]))
0ba0346d655b Workaround WAF issue 325 for generating module header files
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4066
diff changeset
   218
        return m.digest()
0ba0346d655b Workaround WAF issue 325 for generating module header files
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4066
diff changeset
   219
0ba0346d655b Workaround WAF issue 325 for generating module header files
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4066
diff changeset
   220
    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
   221
        try:
0ba0346d655b Workaround WAF issue 325 for generating module header files
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4066
diff changeset
   222
            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
   223
        except AttributeError:
0ba0346d655b Workaround WAF issue 325 for generating module header files
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4066
diff changeset
   224
            "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
   225
            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
   226
            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
   227
            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
   228
            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
   229
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
   230
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3854
diff changeset
   231
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
   232
    """
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
   233
    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
   234
    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
   235
    """
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3854
diff changeset
   236
    COLOR = 'BLUE'
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3854
diff changeset
   237
    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
   238
        super(ns3moduleheader_taskgen, self).__init__(*args, **kwargs)
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
   239
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
   240
    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
   241
        ## 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
   242
        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
   243
        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
   244
        found_the_module = False
4326
179f86838e62 Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4164
diff changeset
   245
        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
   246
            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
   247
                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
   248
                    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
   249
                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
   250
                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
   251
                    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
   252
                    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
   253
                    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
   254
                        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
   255
                    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
   256
        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
   257
            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
   258
        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
   259
            return
4326
179f86838e62 Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4164
diff changeset
   260
        module_obj = self.bld.name_to_obj("ns3-" + self.module, 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
   261
        assert module_obj is not None
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3854
diff changeset
   262
        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
   263
        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
   264
        task.set_inputs(all_headers_inputs)
79b1c42fef3e Generate foo-module.h module aggreator header files, for use in user scripts.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2609
diff changeset
   265
        task.set_outputs(all_headers_outputs)
79b1c42fef3e Generate foo-module.h module aggreator header files, for use in user scripts.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2609
diff changeset
   266
        task.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
   267
        task.module_deps = module_obj.module_deps
79b1c42fef3e Generate foo-module.h module aggreator header files, for use in user scripts.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2609
diff changeset
   268
79b1c42fef3e Generate foo-module.h module aggreator header files, for use in user scripts.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2609
diff changeset
   269
    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
   270
        pass