src/wscript
author Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
Wed, 05 Dec 2007 11:51:10 +0000
changeset 1877 b2ebc493cd58
parent 1858 68e1964c19e8
child 1878 f947cd18f0bb
permissions -rw-r--r--
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)
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
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
     6
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
import Action
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
     8
import Common
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
     9
import Object
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
    10
import Params
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
    11
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
    12
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
    13
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
    14
    '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
    15
    '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
    16
    'simulator',
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
    17
    'node',
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
    18
    'internet-node',
972
6946c8237a73 src/devices/p2p -> src/devices/point-to-point
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents: 969
diff changeset
    19
    'devices/point-to-point',
1272
67a2ba1143e0 rename to csma
Craig Dowell <craigdo@ee.washington.edu>
parents: 1220
diff changeset
    20
    'devices/csma',
1496
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents: 1306
diff changeset
    21
    'applications/onoff',
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents: 1306
diff changeset
    22
    'applications/packet-sink',
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents: 1306
diff changeset
    23
    'applications/udp-echo',
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
    24
    'routing/olsr',
1120
050454d7d028 interim
Tom Henderson <tomh@tomh.org>
parents: 1119
diff changeset
    25
    'routing/global-routing',
968
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 955
diff changeset
    26
    'mobility',
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
    27
    )
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
    28
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
    29
def set_options(opt):
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
    30
    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
    31
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
    32
    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
    33
                   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
    34
                         " (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
    35
                         " --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
    36
                         " 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
    37
                   action="store_true", dest='enable_rpath', default=False)
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
    38
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
    39
    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
    40
                   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
    41
                   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
    42
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
    43
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
    44
def configure(conf):
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
    45
    conf.sub_config('core')
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
    46
    conf.sub_config('simulator')
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
    47
761
0ffbc9fa8ef0 Define env['NS3_MODULE_PATH'] in configure rather than build.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 693
diff changeset
    48
    blddir = os.path.abspath(os.path.join(conf.m_blddir, conf.env.variant()))
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
    49
    conf.env['NS3_MODULE_PATH'] = [os.path.join(blddir, 'lib')]
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
    50
    if Params.g_options.enable_rpath:
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
    51
        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
    52
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
    53
    ## Used to link the 'run-tests' program with all of ns-3 code
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
    54
    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
    55
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
    56
    if Params.g_options.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
    57
        conf.env['NS3_ENABLED_MODULES'] = ['ns3-'+mod for mod in
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
    58
                                           Params.g_options.enable_modules.split(',')]
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
    59
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
    60
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
    61
def create_ns3_module(bld, name, dependencies=()):
1220
4933e0890acd Build all modules as a single ns3 shared library.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1217
diff changeset
    62
    module = bld.create_obj('cpp', 'objects')
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
    63
    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
    64
    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
    65
    module.add_objects = ['ns3-' + dep for dep in dependencies]
4933e0890acd Build all modules as a single ns3 shared library.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1217
diff changeset
    66
    module.env.append_value('CXXFLAGS', module.env['shlib_CXXFLAGS'])
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
    67
    return module
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
    68
    
955
c9be0df711d2 WAF: add back the --enable-rpath option, per Mathieu's request, though disabled by default.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 954
diff changeset
    69
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
    70
def build(bld):
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
    71
    Object.register('ns3header', Ns3Header)
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
    72
    Action.Action('ns3header', func=_ns3_headers_inst, color='BLUE')
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
    73
    bld.create_ns3_module = types.MethodType(create_ns3_module, 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
    74
    
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
    75
    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
    76
1220
4933e0890acd Build all modules as a single ns3 shared library.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1217
diff changeset
    77
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
    78
class Ns3Header(Object.genobj):
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
    79
    """A set of NS-3 header files"""
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
    80
    def __init__(self, env=None):
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
    81
        Object.genobj.__init__(self, 'other')
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
    82
        self.inst_var = 'INCLUDEDIR'
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
    83
        self.inst_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
    84
        self.sub_dir = None # if not None, header files will be published as ns3/sub_dir/file.h
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
    85
        self.env = env
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
    86
        if not self.env:
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
    87
            self.env = Params.g_build.m_allenvs['default']
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
    88
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
    89
    def apply(self):
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
    90
        ns3_dir_node = Params.g_build.m_srcnode.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
    91
        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
    92
            ns3_dir_node = ns3_dir_node.find_dir(self.sub_dir)
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
    93
        for filename in self.to_list(self.source):
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
    94
            src_node = self.path.find_source(filename)
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
    95
            if src_node is None:
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
    96
                Params.fatal("source ns3 header file %s not found" % (filename,))
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
    97
            dst_node = ns3_dir_node.find_build(os.path.basename(filename))
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
    98
            assert dst_node is not None
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
    99
            task = self.create_task('ns3header', self.env, 1)
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
   100
            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
   101
            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
   102
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
   103
    def install(self):
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
   104
        if self.sub_dir is 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
   105
            inst_dir = self.inst_dir
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
   106
        else:
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
   107
            inst_dir = os.path.join(self.inst_dir, self.sub_dir)
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
   108
        for i in self.m_tasks:
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
   109
            current = Params.g_build.m_curdirnode
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
   110
            lst = map(lambda a: a.relpath_gen(current), i.m_outputs)
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
   111
            Common.install_files(self.inst_var, inst_dir, lst)
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
   112
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
   113
def _ns3_headers_inst(task):
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
   114
    assert len(task.m_inputs) == len(task.m_outputs)
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
   115
    inputs = [node.srcpath(task.m_env) for node in task.m_inputs]
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
   116
    outputs = [node.bldpath(task.m_env) for node in task.m_outputs]
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
   117
    for src, dst in zip(inputs, outputs):
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
   118
        try:
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
   119
            os.chmod(dst, 0600)
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
   120
        except OSError:
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
   121
            pass
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
   122
        shutil.copy2(src, dst)
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
   123
        ## make the headers in builddir read-only, to prevent
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
   124
        ## accidental modification
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
   125
        os.chmod(dst, 0400)
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
   126
    return 0