src/wscript
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Thu, 13 Mar 2008 12:56:49 -0700
changeset 2602 d9262bff6df2
parent 2178 763aa96fffd4
child 2603 1308da4cb3bf
permissions -rw-r--r--
add back support for introspected doxygen.
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',
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
    17
    '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
    18
    '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
    19
    'internet-node',
972
6946c8237a73 src/devices/p2p -> src/devices/point-to-point
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents: 969
diff changeset
    20
    'devices/point-to-point',
1272
67a2ba1143e0 rename to csma
Craig Dowell <craigdo@ee.washington.edu>
parents: 1220
diff changeset
    21
    'devices/csma',
1496
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents: 1306
diff changeset
    22
    'applications/onoff',
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents: 1306
diff changeset
    23
    'applications/packet-sink',
0ad4c18b475c start of udp echo applications
Craig Dowell <craigdo@ee.washington.edu>
parents: 1306
diff changeset
    24
    '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
    25
    'routing/olsr',
1120
050454d7d028 interim
Tom Henderson <tomh@tomh.org>
parents: 1119
diff changeset
    26
    'routing/global-routing',
968
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 955
diff changeset
    27
    'mobility',
1882
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1272
diff changeset
    28
    'devices/wifi',
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
    29
    )
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
    30
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
    31
def set_options(opt):
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
    32
    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
    33
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
    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
    35
                   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
    36
                         " (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
    37
                         " --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
    38
                         " 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
    39
                   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
    40
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
    41
    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
    42
                   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
    43
                   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
    44
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
    45
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
    46
def configure(conf):
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
    47
    conf.sub_config('core')
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
    48
    conf.sub_config('simulator')
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
    49
761
0ffbc9fa8ef0 Define env['NS3_MODULE_PATH'] in configure rather than build.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 693
diff changeset
    50
    blddir = os.path.abspath(os.path.join(conf.m_blddir, conf.env.variant()))
1880
0148d5911946 New waf snapshot; move the ns3 library back to the top build dir (the 'lib' was only a workaround for a waf problem); allow --enable-modules on a per build run basis.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1878
diff changeset
    51
    conf.env['NS3_MODULE_PATH'] = [blddir]
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
    52
    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
    53
        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
    54
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
    55
    ## 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
    56
    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
    57
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
    58
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
    59
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
    60
    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
    61
    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
    62
    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
    63
    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
    64
    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
    65
    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
    66
    
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
    67
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
    68
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
    69
    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
    70
    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
    71
    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
    72
    
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
    73
    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
    74
1220
4933e0890acd Build all modules as a single ns3 shared library.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1217
diff changeset
    75
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
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
    77
    """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
    78
    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
    79
        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
    80
        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
    81
        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
    82
        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
    83
        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
    84
        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
    85
            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
    86
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
    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
    88
        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
    89
        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
    90
            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
    91
        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
    92
            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
    93
            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
    94
                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
    95
            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
    96
            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
    97
            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
    98
            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
    99
            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
   100
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
   101
    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
   102
        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
   103
            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
   104
        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
   105
            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
   106
        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
   107
            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
   108
            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
   109
            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
   110
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
   111
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
   112
    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
   113
    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
   114
    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
   115
    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
   116
        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
   117
            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
   118
        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
   119
            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
   120
        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
   121
        ## 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
   122
        ## 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
   123
        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
   124
    return 0