wscript
author Mitch Watrous <watrous@u.washington.edu>
Fri, 27 May 2011 14:48:14 -0700
changeset 7291 d39c09dbc3d9
parent 7131 77b75cd826d0
child 7293 0f574c532cee
permissions -rw-r--r--
Make emu and template modules not be built if not appropriate
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; -*-
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
     2
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
     3
# python lib modules
647
04f34a8befb8 In WAF win32 builds, add -Wl,--enable-runtime-pseudo-reloc to LINKFLAGS to solve dll linking problems.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 642
diff changeset
     4
import sys
695
90a68c1c4328 WAF: add a dist_hook function to exclude the generated documentation from waf dist
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents: 694
diff changeset
     5
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: 1213
diff changeset
     6
import types
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: 1213
diff changeset
     7
import optparse
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: 1213
diff changeset
     8
import os.path
4450
0ca9b9b410a0 bug 567: --enable-static does not work on i686
Andrey Hippo <ahippo@yandex.ru>
parents: 4447
diff changeset
     9
import re
6670
c43b992a4f5b Bug 1032 - Unable to specify multiple Compiler/Linker flags
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6669
diff changeset
    10
import shlex
7088
3f0535480de9 Bug 1110 - Sort alphabetically and display Modules built in columns
Mitch Watrous <watrous@u.washington.edu>
parents: 7066
diff changeset
    11
import textwrap
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
    12
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
    13
# WAF modules
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: 2990
diff changeset
    14
import pproc as subprocess
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
    15
import Options
4326
179f86838e62 Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4202
diff changeset
    16
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
    17
import Logs
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
    18
import TaskGen
4195
e0a27ec2991a WAF: fix Task.maxjobs=1 (for sudo); icc flags.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4190
diff changeset
    19
import Constants
4076
1c67ab5f959a Upgrade WAF; fix Darwin (OSX) build problems.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4075
diff changeset
    20
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: 2990
diff changeset
    21
import ccroot
4076
1c67ab5f959a Upgrade WAF; fix Darwin (OSX) build problems.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4075
diff changeset
    22
ccroot.USE_TOP_LEVEL = True
1c67ab5f959a Upgrade WAF; fix Darwin (OSX) build problems.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4075
diff changeset
    23
3826
40c5841b616d merge in tap device
Craig Dowell <craigdo@ee.washington.edu>
parents: 3703
diff changeset
    24
import Task
4195
e0a27ec2991a WAF: fix Task.maxjobs=1 (for sudo); icc flags.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4190
diff changeset
    25
Task.algotype = Constants.JOBCONTROL # so that Task.maxjobs=1 takes effect
e0a27ec2991a WAF: fix Task.maxjobs=1 (for sudo); icc flags.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4190
diff changeset
    26
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
    27
import Utils
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
    28
import Build
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
    29
import Configure
4326
179f86838e62 Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4202
diff changeset
    30
import Scripting
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
    31
6886
690b7a78bbd0 Make test.py handle examples-to-run.py files
Mitch Watrous <watrous@u.washington.edu>
parents: 6884
diff changeset
    32
from utils import read_config_file
6857
d7db3cee241f Add parsing of ns-3 configuration file
Mitch Watrous <watrous@u.washington.edu>
parents: 6834
diff changeset
    33
7024
4392d52b3536 Make examples not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents: 7023
diff changeset
    34
# By default, all modules will be enabled, examples will be disabled,
7023
af9c5ac72f2c Make examples and tests be enabled from the .ns3rc file
Mitch Watrous <watrous@u.washington.edu>
parents: 7019
diff changeset
    35
# and tests will be disabled.
af9c5ac72f2c Make examples and tests be enabled from the .ns3rc file
Mitch Watrous <watrous@u.washington.edu>
parents: 7019
diff changeset
    36
modules_enabled  = ['all_modules']
7024
4392d52b3536 Make examples not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents: 7023
diff changeset
    37
examples_enabled = False
7023
af9c5ac72f2c Make examples and tests be enabled from the .ns3rc file
Mitch Watrous <watrous@u.washington.edu>
parents: 7019
diff changeset
    38
tests_enabled    = False
6857
d7db3cee241f Add parsing of ns-3 configuration file
Mitch Watrous <watrous@u.washington.edu>
parents: 6834
diff changeset
    39
7023
af9c5ac72f2c Make examples and tests be enabled from the .ns3rc file
Mitch Watrous <watrous@u.washington.edu>
parents: 7019
diff changeset
    40
# Get the information out of the NS-3 configuration file.
af9c5ac72f2c Make examples and tests be enabled from the .ns3rc file
Mitch Watrous <watrous@u.washington.edu>
parents: 7019
diff changeset
    41
config_file_exists = False
af9c5ac72f2c Make examples and tests be enabled from the .ns3rc file
Mitch Watrous <watrous@u.washington.edu>
parents: 7019
diff changeset
    42
(config_file_exists, modules_enabled, examples_enabled, tests_enabled) = read_config_file()
6857
d7db3cee241f Add parsing of ns-3 configuration file
Mitch Watrous <watrous@u.washington.edu>
parents: 6834
diff changeset
    43
5447
bfa1fc626775 Upgrade to upstream WAF 1.5.9 plus a bunch of 'waf tools' layered on top.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5201
diff changeset
    44
sys.path.insert(0, os.path.abspath('waf-tools'))
6274
3e8b3f2306c9 Upgrade to WAF 1.5.16. Fixes bug #855.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6254
diff changeset
    45
try:
3e8b3f2306c9 Upgrade to WAF 1.5.16. Fixes bug #855.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6254
diff changeset
    46
    import cflags # override the build profiles from waf
3e8b3f2306c9 Upgrade to WAF 1.5.16. Fixes bug #855.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6254
diff changeset
    47
finally:
3e8b3f2306c9 Upgrade to WAF 1.5.16. Fixes bug #855.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6254
diff changeset
    48
    sys.path.pop(0)
5447
bfa1fc626775 Upgrade to upstream WAF 1.5.9 plus a bunch of 'waf tools' layered on top.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5201
diff changeset
    49
4069
430a6edb0fa0 New WAF cflags tool, to add back the compilation flags (debug/optimized)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4064
diff changeset
    50
cflags.profiles = {
430a6edb0fa0 New WAF cflags tool, to add back the compilation flags (debug/optimized)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4064
diff changeset
    51
	# profile name: [optimization_level, warnings_level, debug_level]
430a6edb0fa0 New WAF cflags tool, to add back the compilation flags (debug/optimized)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4064
diff changeset
    52
	'debug':     [0, 2, 3],
430a6edb0fa0 New WAF cflags tool, to add back the compilation flags (debug/optimized)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4064
diff changeset
    53
	'optimized': [3, 2, 1],
5452
15524c57a627 introduce new build profile "release": -O3 -g0.
Andrey Mazo <mazo@iitp.ru>
parents: 5448
diff changeset
    54
	'release':   [3, 2, 0],
4069
430a6edb0fa0 New WAF cflags tool, to add back the compilation flags (debug/optimized)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4064
diff changeset
    55
	}
430a6edb0fa0 New WAF cflags tool, to add back the compilation flags (debug/optimized)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4064
diff changeset
    56
cflags.default_profile = 'debug'
430a6edb0fa0 New WAF cflags tool, to add back the compilation flags (debug/optimized)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4064
diff changeset
    57
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
    58
# local modules
3866
9e946fee902c Refactor wscript code to move regression testing code to a separate python module (bug 325)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3845
diff changeset
    59
import wutils
9e946fee902c Refactor wscript code to move regression testing code to a separate python module (bug 325)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3845
diff changeset
    60
4070
c2ad9c39fa06 Correct way to enable WAF autoconfigure
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4069
diff changeset
    61
Configure.autoconfig = 1
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
    62
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
    63
# the following two variables are used by the target "waf dist"
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
    64
VERSION = file("VERSION", "rt").read().strip()
694
bfad4514a789 WAF: correct values of VERSION and APPNAME, for waf dist
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents: 693
diff changeset
    65
APPNAME = 'ns'
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
    66
3866
9e946fee902c Refactor wscript code to move regression testing code to a separate python module (bug 325)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3845
diff changeset
    67
wutils.VERSION = VERSION
9e946fee902c Refactor wscript code to move regression testing code to a separate python module (bug 325)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3845
diff changeset
    68
wutils.APPNAME = APPNAME
9e946fee902c Refactor wscript code to move regression testing code to a separate python module (bug 325)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3845
diff changeset
    69
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
    70
# these variables are mandatory ('/' are converted automatically)
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
    71
srcdir = '.'
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
    72
blddir = 'build'
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
    73
4594
14ce84fd7ae3 make dist generation work again
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4550
diff changeset
    74
def load_env():
14ce84fd7ae3 make dist generation work again
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4550
diff changeset
    75
    bld_cls = getattr(Utils.g_module, 'build_context', Utils.Context)
14ce84fd7ae3 make dist generation work again
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4550
diff changeset
    76
    bld_ctx = bld_cls()
14ce84fd7ae3 make dist generation work again
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4550
diff changeset
    77
    bld_ctx.load_dirs(os.path.abspath(os.path.join (srcdir,'..')),
14ce84fd7ae3 make dist generation work again
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4550
diff changeset
    78
                      os.path.abspath(os.path.join (srcdir,'..', blddir)))
14ce84fd7ae3 make dist generation work again
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4550
diff changeset
    79
    bld_ctx.load_envs()
14ce84fd7ae3 make dist generation work again
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4550
diff changeset
    80
    env = bld_ctx.get_env()
14ce84fd7ae3 make dist generation work again
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4550
diff changeset
    81
    return env
14ce84fd7ae3 make dist generation work again
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4550
diff changeset
    82
14ce84fd7ae3 make dist generation work again
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4550
diff changeset
    83
def get_files(base_dir):
14ce84fd7ae3 make dist generation work again
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4550
diff changeset
    84
    retval = []
14ce84fd7ae3 make dist generation work again
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4550
diff changeset
    85
    reference=os.path.dirname(base_dir)
14ce84fd7ae3 make dist generation work again
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4550
diff changeset
    86
    for root, dirs, files in os.walk(base_dir):
14ce84fd7ae3 make dist generation work again
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4550
diff changeset
    87
        if root.find('.hg') != -1:
14ce84fd7ae3 make dist generation work again
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4550
diff changeset
    88
            continue
14ce84fd7ae3 make dist generation work again
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4550
diff changeset
    89
        for file in files:
14ce84fd7ae3 make dist generation work again
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4550
diff changeset
    90
            if file.find('.hg') != -1:
14ce84fd7ae3 make dist generation work again
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4550
diff changeset
    91
                continue
14ce84fd7ae3 make dist generation work again
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4550
diff changeset
    92
            fullname = os.path.join(root,file)
14ce84fd7ae3 make dist generation work again
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4550
diff changeset
    93
            # we can't use os.path.relpath because it's new in python 2.6
14ce84fd7ae3 make dist generation work again
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4550
diff changeset
    94
            relname = fullname.replace(reference + '/','')
14ce84fd7ae3 make dist generation work again
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4550
diff changeset
    95
            retval.append([fullname,relname])
14ce84fd7ae3 make dist generation work again
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4550
diff changeset
    96
    return retval
14ce84fd7ae3 make dist generation work again
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4550
diff changeset
    97
2881
81d1080cd0ae Integrate regression testing into the main waf script.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2866
diff changeset
    98
1531
ebd805503b55 WAF: update to WAF trunk to get bug fixes and smaller script.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1506
diff changeset
    99
def dist_hook():
2886
8226157800a8 Create regression traces tarball automatically on waf dist.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2884
diff changeset
   100
    import tarfile
921
37b54ed96b09 WAF: ignore errors on shutil.rmtree in dist_hook, so that waf dist works even when no docs were previously generated.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 919
diff changeset
   101
    shutil.rmtree("doc/html", True)
37b54ed96b09 WAF: ignore errors on shutil.rmtree in dist_hook, so that waf dist works even when no docs were previously generated.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 919
diff changeset
   102
    shutil.rmtree("doc/latex", True)
3627
672f2a6de8b4 Exclude any possible 'nsc' folder from the dist tarball (nsc is ~= 100MB).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3625
diff changeset
   103
    shutil.rmtree("nsc", True)
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   104
7291
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   105
# Print the module names without prefixes, sorted, and in columns.
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   106
def print_module_names(names):
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   107
    # Get the sorted list of module names without the "ns3-" prefix.
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   108
    names_without_prefix =[name[len('ns3-'):] for name in names]
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   109
    names_without_prefix.sort()
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   110
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   111
    # Print the list of module names in 3 columns.
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   112
    i = 1
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   113
    for name in names_without_prefix:
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   114
        print name.ljust(25),
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   115
        if i == 3:
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   116
                print
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   117
                i = 0
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   118
        i = i+1
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   119
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   120
    if i != 1:
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   121
        print
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   122
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   123
def set_options(opt):
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   124
    # options provided by the modules
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: 5975
diff changeset
   125
    opt.tool_options('compiler_cc')
642
033f1f4891ab Make WAF check for the abstract tool 'compiler_cxx', instead of manually checking for multiple compilers.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 600
diff changeset
   126
    opt.tool_options('compiler_cxx')
4069
430a6edb0fa0 New WAF cflags tool, to add back the compilation flags (debug/optimized)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4064
diff changeset
   127
    opt.tool_options('cflags')
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   128
2846
7689461231ac start of regression tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 2622
diff changeset
   129
    opt.add_option('--cwd',
7689461231ac start of regression tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 2622
diff changeset
   130
                   help=('Set the working directory for a program.'),
7689461231ac start of regression tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 2622
diff changeset
   131
                   action="store", type="string", default=None,
7689461231ac start of regression tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 2622
diff changeset
   132
                   dest='cwd_launch')
7689461231ac start of regression tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 2622
diff changeset
   133
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   134
    opt.add_option('--enable-gcov',
787
778784e6bd8d WAF: simplify --debug-level option to only have debug and optimized as possible values (debug becomes the former ultradebug); Add a warning to some options help text saying they only work in configure.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 786
diff changeset
   135
                   help=('Enable code coverage analysis.'
778784e6bd8d WAF: simplify --debug-level option to only have debug and optimized as possible values (debug becomes the former ultradebug); Add a warning to some options help text saying they only work in configure.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 786
diff changeset
   136
                         ' WARNING: this option only has effect '
778784e6bd8d WAF: simplify --debug-level option to only have debug and optimized as possible values (debug becomes the former ultradebug); Add a warning to some options help text saying they only work in configure.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 786
diff changeset
   137
                         'with the configure command.'),
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   138
                   action="store_true", default=False,
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   139
                   dest='enable_gcov')
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   140
2866
1d829915f092 Add a --no-task-lines WAF option; together with -v it makes WAF just print executed commands, like 'make' does.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2846
diff changeset
   141
    opt.add_option('--no-task-lines',
1d829915f092 Add a --no-task-lines WAF option; together with -v it makes WAF just print executed commands, like 'make' does.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2846
diff changeset
   142
                   help=("Don't print task lines, i.e. messages saying which tasks are being executed by WAF."
1d829915f092 Add a --no-task-lines WAF option; together with -v it makes WAF just print executed commands, like 'make' does.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2846
diff changeset
   143
                         "  Coupled with a single -v will cause WAF to output only the executed commands,"
1d829915f092 Add a --no-task-lines WAF option; together with -v it makes WAF just print executed commands, like 'make' does.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2846
diff changeset
   144
                         " just like 'make' does by default."),
1d829915f092 Add a --no-task-lines WAF option; together with -v it makes WAF just print executed commands, like 'make' does.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2846
diff changeset
   145
                   action="store_true", default=False,
1d829915f092 Add a --no-task-lines WAF option; together with -v it makes WAF just print executed commands, like 'make' does.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2846
diff changeset
   146
                   dest='no_task_lines')
1d829915f092 Add a --no-task-lines WAF option; together with -v it makes WAF just print executed commands, like 'make' does.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2846
diff changeset
   147
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   148
    opt.add_option('--lcov-report',
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   149
                   help=('Generate a code coverage report '
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   150
                         '(use this option at build time, not in configure)'),
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   151
                   action="store_true", default=False,
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   152
                   dest='lcov_report')
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   153
672
184d5a505279 WAF: remove the rpath options, and add --run and --shell as replacements; additionally, the new options "should" work on Mac OS X, as well as linux2 and win32.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 671
diff changeset
   154
    opt.add_option('--run',
935
53e1e53c373f WAF: add a --command-template option to e.g. allow running programs with valgrind, gdb, etc.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 934
diff changeset
   155
                   help=('Run a locally built program; argument can be a program name,'
53e1e53c373f WAF: add a --command-template option to e.g. allow running programs with valgrind, gdb, etc.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 934
diff changeset
   156
                         ' or a command starting with the program name.'),
672
184d5a505279 WAF: remove the rpath options, and add --run and --shell as replacements; additionally, the new options "should" work on Mac OS X, as well as linux2 and win32.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 671
diff changeset
   157
                   type="string", default='', dest='run')
6676
8a57344a8d09 Codereview Issue 2692041: Add pyviz module
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6670
diff changeset
   158
    opt.add_option('--visualize',
8a57344a8d09 Codereview Issue 2692041: Add pyviz module
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6670
diff changeset
   159
                   help=('Modify --run arguments to enable the visualizer'),
8a57344a8d09 Codereview Issue 2692041: Add pyviz module
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6670
diff changeset
   160
                   action="store_true", default=False, dest='visualize')
935
53e1e53c373f WAF: add a --command-template option to e.g. allow running programs with valgrind, gdb, etc.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 934
diff changeset
   161
    opt.add_option('--command-template',
53e1e53c373f WAF: add a --command-template option to e.g. allow running programs with valgrind, gdb, etc.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 934
diff changeset
   162
                   help=('Template of the command used to run the program given by --run;'
53e1e53c373f WAF: add a --command-template option to e.g. allow running programs with valgrind, gdb, etc.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 934
diff changeset
   163
                         ' It should be a shell command string containing %s inside,'
53e1e53c373f WAF: add a --command-template option to e.g. allow running programs with valgrind, gdb, etc.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 934
diff changeset
   164
                         ' which will be replaced by the actual program.'),
53e1e53c373f WAF: add a --command-template option to e.g. allow running programs with valgrind, gdb, etc.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 934
diff changeset
   165
                   type="string", default=None, dest='command_template')
3419
8d3f5c0f55fa Add WAF option --pyrun, to make it easier to run Python programs.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3418
diff changeset
   166
    opt.add_option('--pyrun',
8d3f5c0f55fa Add WAF option --pyrun, to make it easier to run Python programs.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3418
diff changeset
   167
                   help=('Run a python program using locally built ns3 python module;'
8d3f5c0f55fa Add WAF option --pyrun, to make it easier to run Python programs.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3418
diff changeset
   168
                         ' argument is the path to the python program, optionally followed'
8d3f5c0f55fa Add WAF option --pyrun, to make it easier to run Python programs.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3418
diff changeset
   169
                         ' by command-line options that are passed to the program.'),
8d3f5c0f55fa Add WAF option --pyrun, to make it easier to run Python programs.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3418
diff changeset
   170
                   type="string", default='', dest='pyrun')
2207
d841cca00990 Add a --valgrind WAF option (bug #124)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2178
diff changeset
   171
    opt.add_option('--valgrind',
d841cca00990 Add a --valgrind WAF option (bug #124)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2178
diff changeset
   172
                   help=('Change the default command template to run programs and unit tests with valgrind'),
d841cca00990 Add a --valgrind WAF option (bug #124)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2178
diff changeset
   173
                   action="store_true", default=False,
d841cca00990 Add a --valgrind WAF option (bug #124)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2178
diff changeset
   174
                   dest='valgrind')
672
184d5a505279 WAF: remove the rpath options, and add --run and --shell as replacements; additionally, the new options "should" work on Mac OS X, as well as linux2 and win32.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 671
diff changeset
   175
    opt.add_option('--shell',
4326
179f86838e62 Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4202
diff changeset
   176
                   help=('DEPRECATED (run ./waf shell)'),
672
184d5a505279 WAF: remove the rpath options, and add --run and --shell as replacements; additionally, the new options "should" work on Mac OS X, as well as linux2 and win32.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 671
diff changeset
   177
                   action="store_true", default=False,
184d5a505279 WAF: remove the rpath options, and add --run and --shell as replacements; additionally, the new options "should" work on Mac OS X, as well as linux2 and win32.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 671
diff changeset
   178
                   dest='shell')
4164
1f6ae48061a9 checkpoint tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents: 4119
diff changeset
   179
    opt.add_option('--enable-sudo',
1f6ae48061a9 checkpoint tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents: 4119
diff changeset
   180
                   help=('Use sudo to setup suid bits on ns3 executables.'),
1f6ae48061a9 checkpoint tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents: 4119
diff changeset
   181
                   dest='enable_sudo', action='store_true',
1f6ae48061a9 checkpoint tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents: 4119
diff changeset
   182
                   default=False)
6998
1c2b8cfb71d2 Make tests not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents: 6981
diff changeset
   183
    opt.add_option('--enable-tests',
1c2b8cfb71d2 Make tests not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents: 6981
diff changeset
   184
                   help=('Build the ns-3 tests.'),
1c2b8cfb71d2 Make tests not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents: 6981
diff changeset
   185
                   dest='enable_tests', action='store_true',
1c2b8cfb71d2 Make tests not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents: 6981
diff changeset
   186
                   default=False)
1c2b8cfb71d2 Make tests not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents: 6981
diff changeset
   187
    opt.add_option('--disable-tests',
1c2b8cfb71d2 Make tests not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents: 6981
diff changeset
   188
                   help=('Do not build the ns-3 tests.'),
7023
af9c5ac72f2c Make examples and tests be enabled from the .ns3rc file
Mitch Watrous <watrous@u.washington.edu>
parents: 7019
diff changeset
   189
                   dest='disable_tests', action='store_true',
af9c5ac72f2c Make examples and tests be enabled from the .ns3rc file
Mitch Watrous <watrous@u.washington.edu>
parents: 7019
diff changeset
   190
                   default=False)
5369
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5368
diff changeset
   191
    opt.add_option('--enable-examples',
7025
32212c736ab4 Move examples out of samples directory and remove it
Mitch Watrous <watrous@u.washington.edu>
parents: 7024
diff changeset
   192
                   help=('Build the ns-3 examples.'),
5369
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5368
diff changeset
   193
                   dest='enable_examples', action='store_true',
7023
af9c5ac72f2c Make examples and tests be enabled from the .ns3rc file
Mitch Watrous <watrous@u.washington.edu>
parents: 7019
diff changeset
   194
                   default=False)
5369
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5368
diff changeset
   195
    opt.add_option('--disable-examples',
7025
32212c736ab4 Move examples out of samples directory and remove it
Mitch Watrous <watrous@u.washington.edu>
parents: 7024
diff changeset
   196
                   help=('Do not build the ns-3 examples.'),
7023
af9c5ac72f2c Make examples and tests be enabled from the .ns3rc file
Mitch Watrous <watrous@u.washington.edu>
parents: 7019
diff changeset
   197
                   dest='disable_examples', action='store_true',
af9c5ac72f2c Make examples and tests be enabled from the .ns3rc file
Mitch Watrous <watrous@u.washington.edu>
parents: 7019
diff changeset
   198
                   default=False)
4531
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   199
    opt.add_option('--check',
5361
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5252
diff changeset
   200
                   help=('DEPRECATED (run ./test.py)'),
4531
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   201
                   default=False, dest='check', action="store_true")
4392
25d38a0c9851 bug 537: no support to build static ns-3 binaries
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4388
diff changeset
   202
    opt.add_option('--enable-static',
25d38a0c9851 bug 537: no support to build static ns-3 binaries
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4388
diff changeset
   203
                   help=('Compile NS-3 statically: works only on linux, without python'),
25d38a0c9851 bug 537: no support to build static ns-3 binaries
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4388
diff changeset
   204
                   dest='enable_static', action='store_true',
25d38a0c9851 bug 537: no support to build static ns-3 binaries
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4388
diff changeset
   205
                   default=False)
6113
0ce37bf4f1c1 Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents: 6099
diff changeset
   206
    opt.add_option('--enable-mpi',
0ce37bf4f1c1 Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents: 6099
diff changeset
   207
                   help=('Compile NS-3 with MPI and distributed simulation support'),
0ce37bf4f1c1 Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents: 6099
diff changeset
   208
                   dest='enable_mpi', action='store_true',
0ce37bf4f1c1 Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents: 6099
diff changeset
   209
                   default=False)
5468
6eebad1fb54d Bring back the --doxygen-no-build option from the dead.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5463
diff changeset
   210
    opt.add_option('--doxygen-no-build',
6eebad1fb54d Bring back the --doxygen-no-build option from the dead.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5463
diff changeset
   211
                   help=('Run doxygen to generate html documentation from source comments, '
6eebad1fb54d Bring back the --doxygen-no-build option from the dead.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5463
diff changeset
   212
                         'but do not wait for ns-3 to finish the full build.'),
6eebad1fb54d Bring back the --doxygen-no-build option from the dead.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5463
diff changeset
   213
                   action="store_true", default=False,
6eebad1fb54d Bring back the --doxygen-no-build option from the dead.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5463
diff changeset
   214
                   dest='doxygen_no_build')
2881
81d1080cd0ae Integrate regression testing into the main waf script.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2866
diff changeset
   215
5468
6eebad1fb54d Bring back the --doxygen-no-build option from the dead.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5463
diff changeset
   216
    # options provided in subdirectories
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   217
    opt.sub_options('src')
3408
2cc40b3e4fa5 python bindings
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3331
diff changeset
   218
    opt.sub_options('bindings/python')
6834
036f9a0b9899 Rename internet-stack to internet, and organize module
Tom Henderson <tomh@tomh.org>
parents: 6821
diff changeset
   219
    opt.sub_options('src/internet')
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   220
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   221
6099
b37a72870f2d Test the support for the -Wno-error=deprecated-declarations option independently for the C and C++ compilers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6001
diff changeset
   222
def _check_compilation_flag(conf, flag, mode='cxx'):
3407
038f13c8741c Check that the compiler accepts -Wno-error=deprecated-declarations before using it
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3406
diff changeset
   223
    """
038f13c8741c Check that the compiler accepts -Wno-error=deprecated-declarations before using it
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3406
diff changeset
   224
    Checks if the C++ compiler accepts a certain compilation flag or flags
038f13c8741c Check that the compiler accepts -Wno-error=deprecated-declarations before using it
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3406
diff changeset
   225
    flag: can be a string or a list of strings
038f13c8741c Check that the compiler accepts -Wno-error=deprecated-declarations before using it
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3406
diff changeset
   226
    """
038f13c8741c Check that the compiler accepts -Wno-error=deprecated-declarations before using it
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3406
diff changeset
   227
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
   228
    env = conf.env.copy()
6099
b37a72870f2d Test the support for the -Wno-error=deprecated-declarations option independently for the C and C++ compilers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6001
diff changeset
   229
    if mode == 'cxx':
b37a72870f2d Test the support for the -Wno-error=deprecated-declarations option independently for the C and C++ compilers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6001
diff changeset
   230
        fname = 'test.cc'
b37a72870f2d Test the support for the -Wno-error=deprecated-declarations option independently for the C and C++ compilers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6001
diff changeset
   231
        env.append_value('CXXFLAGS', flag)
b37a72870f2d Test the support for the -Wno-error=deprecated-declarations option independently for the C and C++ compilers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6001
diff changeset
   232
    else:
b37a72870f2d Test the support for the -Wno-error=deprecated-declarations option independently for the C and C++ compilers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6001
diff changeset
   233
        fname = 'test.c'
b37a72870f2d Test the support for the -Wno-error=deprecated-declarations option independently for the C and C++ compilers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6001
diff changeset
   234
        env.append_value('CCFLAGS', flag)
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
   235
    try:
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
   236
        retval = conf.run_c_code(code='#include <stdio.h>\nint main() { return 0; }\n',
6099
b37a72870f2d Test the support for the -Wno-error=deprecated-declarations option independently for the C and C++ compilers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6001
diff changeset
   237
                                 env=env, compile_filename=fname,
b37a72870f2d Test the support for the -Wno-error=deprecated-declarations option independently for the C and C++ compilers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6001
diff changeset
   238
                                 compile_mode=mode, type='cprogram', execute=False)
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
   239
    except Configure.ConfigurationError:
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
   240
        ok = False
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
   241
    else:
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
   242
        ok = (retval == 0)
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
   243
    conf.check_message_custom(flag, 'support', (ok and 'yes' or 'no'))
4069
430a6edb0fa0 New WAF cflags tool, to add back the compilation flags (debug/optimized)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4064
diff changeset
   244
    return ok
3407
038f13c8741c Check that the compiler accepts -Wno-error=deprecated-declarations before using it
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3406
diff changeset
   245
038f13c8741c Check that the compiler accepts -Wno-error=deprecated-declarations before using it
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3406
diff changeset
   246
    
3625
30afad8324d5 Add a summary of optional features at the end of the configuration stage.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3623
diff changeset
   247
def report_optional_feature(conf, name, caption, was_enabled, reason_not_enabled):
30afad8324d5 Add a summary of optional features at the end of the configuration stage.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3623
diff changeset
   248
    conf.env.append_value('NS3_OPTIONAL_FEATURES', (name, caption, was_enabled, reason_not_enabled))
3407
038f13c8741c Check that the compiler accepts -Wno-error=deprecated-declarations before using it
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3406
diff changeset
   249
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   250
def configure(conf):
3625
30afad8324d5 Add a summary of optional features at the end of the configuration stage.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3623
diff changeset
   251
    # attach some extra methods
4326
179f86838e62 Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4202
diff changeset
   252
    conf.check_compilation_flag = types.MethodType(_check_compilation_flag, conf)
3625
30afad8324d5 Add a summary of optional features at the end of the configuration stage.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3623
diff changeset
   253
    conf.report_optional_feature = types.MethodType(report_optional_feature, conf)
30afad8324d5 Add a summary of optional features at the end of the configuration stage.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3623
diff changeset
   254
    conf.env['NS3_OPTIONAL_FEATURES'] = []
30afad8324d5 Add a summary of optional features at the end of the configuration stage.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3623
diff changeset
   255
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
   256
    conf.env['NS3_BUILDDIR'] = conf.blddir
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: 5975
diff changeset
   257
    conf.check_tool('compiler_cc')
1531
ebd805503b55 WAF: update to WAF trunk to get bug fixes and smaller script.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1506
diff changeset
   258
    conf.check_tool('compiler_cxx')
6274
3e8b3f2306c9 Upgrade to WAF 1.5.16. Fixes bug #855.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6254
diff changeset
   259
    conf.check_tool('cflags', ['waf-tools'])
4075
bc8a646b1338 Gracefully ignore missing pkg-config
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4070
diff changeset
   260
    try:
6274
3e8b3f2306c9 Upgrade to WAF 1.5.16. Fixes bug #855.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6254
diff changeset
   261
        conf.check_tool('pkgconfig', ['waf-tools'])
4075
bc8a646b1338 Gracefully ignore missing pkg-config
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4070
diff changeset
   262
    except Configure.ConfigurationError:
bc8a646b1338 Gracefully ignore missing pkg-config
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4070
diff changeset
   263
        pass
6274
3e8b3f2306c9 Upgrade to WAF 1.5.16. Fixes bug #855.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6254
diff changeset
   264
    conf.check_tool('command', ['waf-tools'])
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   265
4594
14ce84fd7ae3 make dist generation work again
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4550
diff changeset
   266
    # create the second environment, set the variant and set its name
14ce84fd7ae3 make dist generation work again
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4550
diff changeset
   267
    variant_env = conf.env.copy()
14ce84fd7ae3 make dist generation work again
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4550
diff changeset
   268
    variant_name = Options.options.build_profile
14ce84fd7ae3 make dist generation work again
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4550
diff changeset
   269
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
   270
    if Options.options.enable_gcov:
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   271
        variant_name += '-gcov'
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   272
        variant_env.append_value('CCFLAGS', '-fprofile-arcs')
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   273
        variant_env.append_value('CCFLAGS', '-ftest-coverage')
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   274
        variant_env.append_value('CXXFLAGS', '-fprofile-arcs')
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   275
        variant_env.append_value('CXXFLAGS', '-ftest-coverage')
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   276
        variant_env.append_value('LINKFLAGS', '-fprofile-arcs')
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   277
    
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   278
    conf.env['NS3_ACTIVE_VARIANT'] = variant_name
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   279
    variant_env['NS3_ACTIVE_VARIANT'] = variant_name
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   280
    variant_env.set_variant(variant_name)
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   281
    conf.set_env_name(variant_name, variant_env)
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   282
    conf.setenv(variant_name)
4069
430a6edb0fa0 New WAF cflags tool, to add back the compilation flags (debug/optimized)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4064
diff changeset
   283
    env = variant_env
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   284
4069
430a6edb0fa0 New WAF cflags tool, to add back the compilation flags (debug/optimized)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4064
diff changeset
   285
    if Options.options.build_profile == 'debug':
430a6edb0fa0 New WAF cflags tool, to add back the compilation flags (debug/optimized)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4064
diff changeset
   286
        env.append_value('CXXDEFINES', 'NS3_ASSERT_ENABLE')
430a6edb0fa0 New WAF cflags tool, to add back the compilation flags (debug/optimized)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4064
diff changeset
   287
        env.append_value('CXXDEFINES', 'NS3_LOG_ENABLE')
1426
30b9f2b59a1c WAF: in optimized builds, replace -O2 with -O3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1425
diff changeset
   288
4190
b6734a5d920c work around to allow FreeBSD to run tap-bridge
Craig Dowell <craigdo@ee.washington.edu>
parents: 4179
diff changeset
   289
    env['PLATFORM'] = sys.platform
b6734a5d920c work around to allow FreeBSD to run tap-bridge
Craig Dowell <craigdo@ee.washington.edu>
parents: 4179
diff changeset
   290
5252
481053e0cd10 Bug 681: wrong compilation options for icpc (Intel C/C++ Compiler)
Andrey Mazo <mazo@iitp.ru>
parents: 5201
diff changeset
   291
    if conf.env['CXX_NAME'] in ['gcc', 'icc']:
5463
f2f95faff5bb omit -march=native for <gcc-4.2;
Andrey Mazo <mazo@iitp.ru>
parents: 5454
diff changeset
   292
        if Options.options.build_profile == 'release': 
f2f95faff5bb omit -march=native for <gcc-4.2;
Andrey Mazo <mazo@iitp.ru>
parents: 5454
diff changeset
   293
            env.append_value('CXXFLAGS', '-fomit-frame-pointer') 
f2f95faff5bb omit -march=native for <gcc-4.2;
Andrey Mazo <mazo@iitp.ru>
parents: 5454
diff changeset
   294
            if conf.check_compilation_flag('-march=native'):
f2f95faff5bb omit -march=native for <gcc-4.2;
Andrey Mazo <mazo@iitp.ru>
parents: 5454
diff changeset
   295
                env.append_value('CXXFLAGS', '-march=native') 
f2f95faff5bb omit -march=native for <gcc-4.2;
Andrey Mazo <mazo@iitp.ru>
parents: 5454
diff changeset
   296
4348
0572c4011b3d Enable the link option --enable-auto-import on cygwin; closes #525.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4333
diff changeset
   297
        if sys.platform == 'win32':
4069
430a6edb0fa0 New WAF cflags tool, to add back the compilation flags (debug/optimized)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4064
diff changeset
   298
            env.append_value("LINKFLAGS", "-Wl,--enable-runtime-pseudo-reloc")
4348
0572c4011b3d Enable the link option --enable-auto-import on cygwin; closes #525.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4333
diff changeset
   299
        elif sys.platform == 'cygwin':
0572c4011b3d Enable the link option --enable-auto-import on cygwin; closes #525.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4333
diff changeset
   300
            env.append_value("LINKFLAGS", "-Wl,--enable-auto-import")
4446
56b16bcd3afc Add -Wl,--soname=libns3.so to link flags to allow dlopen hacks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4441
diff changeset
   301
4386
2e79cbd62d28 bug 553: Running code built with a special gcc
Gustavo Carneiro <gjcarneiro@gmail.com>
parents: 4369
diff changeset
   302
        cxx, = env['CXX']
4446
56b16bcd3afc Add -Wl,--soname=libns3.so to link flags to allow dlopen hacks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4441
diff changeset
   303
4386
2e79cbd62d28 bug 553: Running code built with a special gcc
Gustavo Carneiro <gjcarneiro@gmail.com>
parents: 4369
diff changeset
   304
        p = subprocess.Popen([cxx, '-print-file-name=libstdc++.so'], stdout=subprocess.PIPE)
4387
dff0992d7cce Make sure the 'g++ -print-file-name' code does not break if gcc doesn't know anything about the libstdc++.so file.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4386
diff changeset
   305
        libstdcxx_location = os.path.dirname(p.stdout.read().strip())
4386
2e79cbd62d28 bug 553: Running code built with a special gcc
Gustavo Carneiro <gjcarneiro@gmail.com>
parents: 4369
diff changeset
   306
        p.wait()
4387
dff0992d7cce Make sure the 'g++ -print-file-name' code does not break if gcc doesn't know anything about the libstdc++.so file.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4386
diff changeset
   307
        if libstdcxx_location:
dff0992d7cce Make sure the 'g++ -print-file-name' code does not break if gcc doesn't know anything about the libstdc++.so file.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4386
diff changeset
   308
            conf.env.append_value('NS3_MODULE_PATH', libstdcxx_location)
647
04f34a8befb8 In WAF win32 builds, add -Wl,--enable-runtime-pseudo-reloc to LINKFLAGS to solve dll linking problems.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 642
diff changeset
   309
4447
0b42685f6b78 Don't event try to enable -Wl,--soname option if we're not on linux.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4446
diff changeset
   310
        if Options.platform in ['linux']:
0b42685f6b78 Don't event try to enable -Wl,--soname option if we're not on linux.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4446
diff changeset
   311
            if conf.check_compilation_flag('-Wl,--soname=foo'):
0b42685f6b78 Don't event try to enable -Wl,--soname option if we're not on linux.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4446
diff changeset
   312
                env['WL_SONAME_SUPPORTED'] = True
4446
56b16bcd3afc Add -Wl,--soname=libns3.so to link flags to allow dlopen hacks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4441
diff changeset
   313
7291
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   314
    env['ENABLE_STATIC_NS3'] = False
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   315
    if Options.options.enable_static:
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   316
        if env['PLATFORM'].startswith('linux') and \
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   317
                env['CXX_NAME'] in ['gcc', 'icc']:
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   318
            if re.match('i[3-6]86', os.uname()[4]):
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   319
                conf.report_optional_feature("static", "Static build", True, '')
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   320
                env['ENABLE_STATIC_NS3'] = True
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   321
            elif os.uname()[4] == 'x86_64':
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   322
                if env['ENABLE_PYTHON_BINDINGS'] and \
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   323
                        not conf.check_compilation_flag('-mcmodel=large'):
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   324
                    conf.report_optional_feature("static", "Static build", False,
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   325
                                                 "Can't enable static builds because " + \
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   326
                                                     "no -mcmodel=large compiler " \
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   327
                                                     "option. Try --disable-python or upgrade your " \
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   328
                                                     "compiler to at least gcc 4.3.x.")
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   329
                else:
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   330
                    conf.report_optional_feature("static", "Static build", True, '')
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   331
                    env['ENABLE_STATIC_NS3'] = True                    
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   332
        elif env['CXX_NAME'] == 'gcc' and \
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   333
                (env['PLATFORM'].startswith('darwin') or \
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   334
                     env['PLATFORM'].startswith('cygwin')):
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   335
                conf.report_optional_feature("static", "Static build", True, '')
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   336
                env['ENABLE_STATIC_NS3'] = True
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   337
        else:
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   338
            conf.report_optional_feature("static", "Static build", False,
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   339
                                         "Unsupported platform")
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   340
    else:
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   341
        conf.report_optional_feature("static", "Static build", False,
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   342
                                     "option --enable-static not selected")
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   343
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   344
    conf.sub_config('src')
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   345
6857
d7db3cee241f Add parsing of ns-3 configuration file
Mitch Watrous <watrous@u.washington.edu>
parents: 6834
diff changeset
   346
    # Set the list of enabled modules.
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
   347
    if Options.options.enable_modules:
6857
d7db3cee241f Add parsing of ns-3 configuration file
Mitch Watrous <watrous@u.washington.edu>
parents: 6834
diff changeset
   348
        # Use the modules explicitly enabled. 
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: 1858
diff changeset
   349
        conf.env['NS3_ENABLED_MODULES'] = ['ns3-'+mod for mod in
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
   350
                                           Options.options.enable_modules.split(',')]
6857
d7db3cee241f Add parsing of ns-3 configuration file
Mitch Watrous <watrous@u.washington.edu>
parents: 6834
diff changeset
   351
    else:
d7db3cee241f Add parsing of ns-3 configuration file
Mitch Watrous <watrous@u.washington.edu>
parents: 6834
diff changeset
   352
        # Use the enabled modules list from the ns3 configuration file.
d7db3cee241f Add parsing of ns-3 configuration file
Mitch Watrous <watrous@u.washington.edu>
parents: 6834
diff changeset
   353
        if modules_enabled[0] == 'all_modules':
d7db3cee241f Add parsing of ns-3 configuration file
Mitch Watrous <watrous@u.washington.edu>
parents: 6834
diff changeset
   354
            # Enable all modules if requested.
d7db3cee241f Add parsing of ns-3 configuration file
Mitch Watrous <watrous@u.washington.edu>
parents: 6834
diff changeset
   355
            conf.env['NS3_ENABLED_MODULES'] = conf.env['NS3_MODULES']
d7db3cee241f Add parsing of ns-3 configuration file
Mitch Watrous <watrous@u.washington.edu>
parents: 6834
diff changeset
   356
        else:
d7db3cee241f Add parsing of ns-3 configuration file
Mitch Watrous <watrous@u.washington.edu>
parents: 6834
diff changeset
   357
            # Enable the modules from the list.
d7db3cee241f Add parsing of ns-3 configuration file
Mitch Watrous <watrous@u.washington.edu>
parents: 6834
diff changeset
   358
            conf.env['NS3_ENABLED_MODULES'] = ['ns3-'+mod for mod in
d7db3cee241f Add parsing of ns-3 configuration file
Mitch Watrous <watrous@u.washington.edu>
parents: 6834
diff changeset
   359
                                               modules_enabled]
7291
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   360
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   361
    # Remove the emu module from the list of enabled modules if it
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   362
    # is there and emu is not enabled.
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   363
    conf.env['NS3_ENABLED_MODULES_NOT_BUILT'] = []
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   364
    emu_module_name = 'ns3-emu'
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   365
    if emu_module_name in conf.env['NS3_ENABLED_MODULES']:
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   366
        if not conf.env['ENABLE_EMU']:
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   367
            conf.env['NS3_ENABLED_MODULES'].remove(emu_module_name)
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   368
            conf.env['NS3_ENABLED_MODULES_NOT_BUILT'].append(emu_module_name)
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   369
            if not conf.env['NS3_ENABLED_MODULES']:
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   370
                raise Utils.WafError("Exiting because the emu module can not be built and it was the only one enabled.")
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   371
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   372
    # Remove the template module from the list of enabled modules if
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   373
    # this is a static build on Darwin because they don't work there
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   374
    # for the template module.  This is probably because it is empty.
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   375
    template_module_name = 'ns3-template'
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   376
    if template_module_name in conf.env['NS3_ENABLED_MODULES']:
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   377
        if conf.env['ENABLE_STATIC_NS3'] and sys.platform == 'darwin':
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   378
            conf.env['NS3_ENABLED_MODULES'].remove(template_module_name)
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   379
            conf.env['NS3_ENABLED_MODULES_NOT_BUILT'].append(template_module_name)
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   380
            if not conf.env['NS3_ENABLED_MODULES']:
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   381
                raise Utils.WafError("Exiting because the template module can not be built and it was the only one enabled.")
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   382
6919
82217d4007bc Bug 1076 - Waf gives an error if you enable only a single module
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6913
diff changeset
   383
    conf.sub_config('bindings/python')
6857
d7db3cee241f Add parsing of ns-3 configuration file
Mitch Watrous <watrous@u.washington.edu>
parents: 6834
diff changeset
   384
7019
23bec5444c05 The mpi waf configuration code belongs in src/mpi/wscript, not toplevel wscript
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6998
diff changeset
   385
    conf.sub_config('src/mpi')
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: 1858
diff changeset
   386
3826
40c5841b616d merge in tap device
Craig Dowell <craigdo@ee.washington.edu>
parents: 3703
diff changeset
   387
    # for suid bits
40c5841b616d merge in tap device
Craig Dowell <craigdo@ee.washington.edu>
parents: 3703
diff changeset
   388
    conf.find_program('sudo', var='SUDO')
40c5841b616d merge in tap device
Craig Dowell <craigdo@ee.washington.edu>
parents: 3703
diff changeset
   389
4171
902589866374 teach enable-sudo to be a config time thing
Craig Dowell <craigdo@ee.washington.edu>
parents: 4164
diff changeset
   390
    why_not_sudo = "because we like it"
902589866374 teach enable-sudo to be a config time thing
Craig Dowell <craigdo@ee.washington.edu>
parents: 4164
diff changeset
   391
    if Options.options.enable_sudo and conf.env['SUDO']:
902589866374 teach enable-sudo to be a config time thing
Craig Dowell <craigdo@ee.washington.edu>
parents: 4164
diff changeset
   392
        env['ENABLE_SUDO'] = True
902589866374 teach enable-sudo to be a config time thing
Craig Dowell <craigdo@ee.washington.edu>
parents: 4164
diff changeset
   393
    else:
902589866374 teach enable-sudo to be a config time thing
Craig Dowell <craigdo@ee.washington.edu>
parents: 4164
diff changeset
   394
        env['ENABLE_SUDO'] = False
902589866374 teach enable-sudo to be a config time thing
Craig Dowell <craigdo@ee.washington.edu>
parents: 4164
diff changeset
   395
        if Options.options.enable_sudo:
902589866374 teach enable-sudo to be a config time thing
Craig Dowell <craigdo@ee.washington.edu>
parents: 4164
diff changeset
   396
            why_not_sudo = "program sudo not found"
902589866374 teach enable-sudo to be a config time thing
Craig Dowell <craigdo@ee.washington.edu>
parents: 4164
diff changeset
   397
        else:
902589866374 teach enable-sudo to be a config time thing
Craig Dowell <craigdo@ee.washington.edu>
parents: 4164
diff changeset
   398
            why_not_sudo = "option --enable-sudo not selected"
902589866374 teach enable-sudo to be a config time thing
Craig Dowell <craigdo@ee.washington.edu>
parents: 4164
diff changeset
   399
902589866374 teach enable-sudo to be a config time thing
Craig Dowell <craigdo@ee.washington.edu>
parents: 4164
diff changeset
   400
    conf.report_optional_feature("ENABLE_SUDO", "Use sudo to set suid bit", env['ENABLE_SUDO'], why_not_sudo)
902589866374 teach enable-sudo to be a config time thing
Craig Dowell <craigdo@ee.washington.edu>
parents: 4164
diff changeset
   401
7023
af9c5ac72f2c Make examples and tests be enabled from the .ns3rc file
Mitch Watrous <watrous@u.washington.edu>
parents: 7019
diff changeset
   402
    # Decide if tests will be built or not.
6998
1c2b8cfb71d2 Make tests not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents: 6981
diff changeset
   403
    if Options.options.enable_tests:
7023
af9c5ac72f2c Make examples and tests be enabled from the .ns3rc file
Mitch Watrous <watrous@u.washington.edu>
parents: 7019
diff changeset
   404
        # Tests were explicitly enabled. 
6998
1c2b8cfb71d2 Make tests not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents: 6981
diff changeset
   405
        env['ENABLE_TESTS'] = True
1c2b8cfb71d2 Make tests not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents: 6981
diff changeset
   406
        why_not_tests = "option --enable-tests selected"
7023
af9c5ac72f2c Make examples and tests be enabled from the .ns3rc file
Mitch Watrous <watrous@u.washington.edu>
parents: 7019
diff changeset
   407
    elif Options.options.disable_tests:
af9c5ac72f2c Make examples and tests be enabled from the .ns3rc file
Mitch Watrous <watrous@u.washington.edu>
parents: 7019
diff changeset
   408
        # Tests were explicitly disabled. 
6998
1c2b8cfb71d2 Make tests not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents: 6981
diff changeset
   409
        env['ENABLE_TESTS'] = False
7023
af9c5ac72f2c Make examples and tests be enabled from the .ns3rc file
Mitch Watrous <watrous@u.washington.edu>
parents: 7019
diff changeset
   410
        why_not_tests = "option --disable-tests selected"
af9c5ac72f2c Make examples and tests be enabled from the .ns3rc file
Mitch Watrous <watrous@u.washington.edu>
parents: 7019
diff changeset
   411
    else:
af9c5ac72f2c Make examples and tests be enabled from the .ns3rc file
Mitch Watrous <watrous@u.washington.edu>
parents: 7019
diff changeset
   412
        # Enable tests based on the ns3 configuration file.
af9c5ac72f2c Make examples and tests be enabled from the .ns3rc file
Mitch Watrous <watrous@u.washington.edu>
parents: 7019
diff changeset
   413
        env['ENABLE_TESTS'] = tests_enabled
af9c5ac72f2c Make examples and tests be enabled from the .ns3rc file
Mitch Watrous <watrous@u.washington.edu>
parents: 7019
diff changeset
   414
        if config_file_exists:
af9c5ac72f2c Make examples and tests be enabled from the .ns3rc file
Mitch Watrous <watrous@u.washington.edu>
parents: 7019
diff changeset
   415
            why_not_tests = "based on configuration file"
af9c5ac72f2c Make examples and tests be enabled from the .ns3rc file
Mitch Watrous <watrous@u.washington.edu>
parents: 7019
diff changeset
   416
        elif tests_enabled:
af9c5ac72f2c Make examples and tests be enabled from the .ns3rc file
Mitch Watrous <watrous@u.washington.edu>
parents: 7019
diff changeset
   417
            why_not_tests = "defaults to enabled"
af9c5ac72f2c Make examples and tests be enabled from the .ns3rc file
Mitch Watrous <watrous@u.washington.edu>
parents: 7019
diff changeset
   418
        else:
af9c5ac72f2c Make examples and tests be enabled from the .ns3rc file
Mitch Watrous <watrous@u.washington.edu>
parents: 7019
diff changeset
   419
            why_not_tests = "defaults to disabled"
6998
1c2b8cfb71d2 Make tests not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents: 6981
diff changeset
   420
1c2b8cfb71d2 Make tests not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents: 6981
diff changeset
   421
    conf.report_optional_feature("ENABLE_TESTS", "Build tests", env['ENABLE_TESTS'], why_not_tests)
1c2b8cfb71d2 Make tests not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents: 6981
diff changeset
   422
7023
af9c5ac72f2c Make examples and tests be enabled from the .ns3rc file
Mitch Watrous <watrous@u.washington.edu>
parents: 7019
diff changeset
   423
    # Decide if examples will be built or not.
5369
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5368
diff changeset
   424
    if Options.options.enable_examples:
7023
af9c5ac72f2c Make examples and tests be enabled from the .ns3rc file
Mitch Watrous <watrous@u.washington.edu>
parents: 7019
diff changeset
   425
        # Examples were explicitly enabled. 
5369
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5368
diff changeset
   426
        env['ENABLE_EXAMPLES'] = True
7023
af9c5ac72f2c Make examples and tests be enabled from the .ns3rc file
Mitch Watrous <watrous@u.washington.edu>
parents: 7019
diff changeset
   427
        why_not_examples = "option --enable-examples selected"
af9c5ac72f2c Make examples and tests be enabled from the .ns3rc file
Mitch Watrous <watrous@u.washington.edu>
parents: 7019
diff changeset
   428
    elif Options.options.disable_examples:
af9c5ac72f2c Make examples and tests be enabled from the .ns3rc file
Mitch Watrous <watrous@u.washington.edu>
parents: 7019
diff changeset
   429
        # Examples were explicitly disabled. 
5369
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5368
diff changeset
   430
        env['ENABLE_EXAMPLES'] = False
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5368
diff changeset
   431
        why_not_examples = "option --disable-examples selected"
7023
af9c5ac72f2c Make examples and tests be enabled from the .ns3rc file
Mitch Watrous <watrous@u.washington.edu>
parents: 7019
diff changeset
   432
    else:
af9c5ac72f2c Make examples and tests be enabled from the .ns3rc file
Mitch Watrous <watrous@u.washington.edu>
parents: 7019
diff changeset
   433
        # Enable examples based on the ns3 configuration file.
af9c5ac72f2c Make examples and tests be enabled from the .ns3rc file
Mitch Watrous <watrous@u.washington.edu>
parents: 7019
diff changeset
   434
        env['ENABLE_EXAMPLES'] = examples_enabled
af9c5ac72f2c Make examples and tests be enabled from the .ns3rc file
Mitch Watrous <watrous@u.washington.edu>
parents: 7019
diff changeset
   435
        if config_file_exists:
af9c5ac72f2c Make examples and tests be enabled from the .ns3rc file
Mitch Watrous <watrous@u.washington.edu>
parents: 7019
diff changeset
   436
            why_not_examples = "based on configuration file"
af9c5ac72f2c Make examples and tests be enabled from the .ns3rc file
Mitch Watrous <watrous@u.washington.edu>
parents: 7019
diff changeset
   437
        elif examples_enabled:
af9c5ac72f2c Make examples and tests be enabled from the .ns3rc file
Mitch Watrous <watrous@u.washington.edu>
parents: 7019
diff changeset
   438
            why_not_examples = "defaults to enabled"
af9c5ac72f2c Make examples and tests be enabled from the .ns3rc file
Mitch Watrous <watrous@u.washington.edu>
parents: 7019
diff changeset
   439
        else:
af9c5ac72f2c Make examples and tests be enabled from the .ns3rc file
Mitch Watrous <watrous@u.washington.edu>
parents: 7019
diff changeset
   440
            why_not_examples = "defaults to disabled"
5369
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5368
diff changeset
   441
6857
d7db3cee241f Add parsing of ns-3 configuration file
Mitch Watrous <watrous@u.washington.edu>
parents: 6834
diff changeset
   442
    env['EXAMPLE_DIRECTORIES'] = []
d7db3cee241f Add parsing of ns-3 configuration file
Mitch Watrous <watrous@u.washington.edu>
parents: 6834
diff changeset
   443
    for dir in os.listdir('examples'):
d7db3cee241f Add parsing of ns-3 configuration file
Mitch Watrous <watrous@u.washington.edu>
parents: 6834
diff changeset
   444
        if dir.startswith('.') or dir == 'CVS':
d7db3cee241f Add parsing of ns-3 configuration file
Mitch Watrous <watrous@u.washington.edu>
parents: 6834
diff changeset
   445
            continue
d7db3cee241f Add parsing of ns-3 configuration file
Mitch Watrous <watrous@u.washington.edu>
parents: 6834
diff changeset
   446
        if os.path.isdir(os.path.join('examples', dir)):
d7db3cee241f Add parsing of ns-3 configuration file
Mitch Watrous <watrous@u.washington.edu>
parents: 6834
diff changeset
   447
            env['EXAMPLE_DIRECTORIES'].append(dir)
d7db3cee241f Add parsing of ns-3 configuration file
Mitch Watrous <watrous@u.washington.edu>
parents: 6834
diff changeset
   448
7025
32212c736ab4 Move examples out of samples directory and remove it
Mitch Watrous <watrous@u.washington.edu>
parents: 7024
diff changeset
   449
    conf.report_optional_feature("ENABLE_EXAMPLES", "Build examples", env['ENABLE_EXAMPLES'], 
5369
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5368
diff changeset
   450
                                 why_not_examples)
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5368
diff changeset
   451
4119
9ffcf2400aa5 Bug #323: waf --valgrind doesn't check for valgrind first
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4118
diff changeset
   452
    conf.find_program('valgrind', var='VALGRIND')
9ffcf2400aa5 Bug #323: waf --valgrind doesn't check for valgrind first
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4118
diff changeset
   453
6913
54679ab32585 Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents: 6886
diff changeset
   454
    # These flags are used for the implicitly dependent modules.
54679ab32585 Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents: 6886
diff changeset
   455
    if env['ENABLE_STATIC_NS3']:
54679ab32585 Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents: 6886
diff changeset
   456
        if sys.platform == 'darwin':
54679ab32585 Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents: 6886
diff changeset
   457
            env.STATICLIB_MARKER = '-Wl,-all_load'
54679ab32585 Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents: 6886
diff changeset
   458
        else:
54679ab32585 Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents: 6886
diff changeset
   459
            env.STATICLIB_MARKER = '-Wl,--whole-archive,-Bstatic'
54679ab32585 Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents: 6886
diff changeset
   460
            env.SHLIB_MARKER = '-Wl,-Bdynamic,--no-whole-archive'
54679ab32585 Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents: 6886
diff changeset
   461
4773
904c1803d5dc test framework should probably work on all supported machines
Craig Dowell <craigdo@ee.washington.edu>
parents: 4770
diff changeset
   462
    have_gsl = conf.pkg_check_modules('GSL', 'gsl', mandatory=False)
904c1803d5dc test framework should probably work on all supported machines
Craig Dowell <craigdo@ee.washington.edu>
parents: 4770
diff changeset
   463
    conf.env['ENABLE_GSL'] = have_gsl
4436
56fc927210c6 attempt to detect broken --enable-static invocations.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4395
diff changeset
   464
4773
904c1803d5dc test framework should probably work on all supported machines
Craig Dowell <craigdo@ee.washington.edu>
parents: 4770
diff changeset
   465
    conf.report_optional_feature("GSL", "GNU Scientific Library (GSL)",
904c1803d5dc test framework should probably work on all supported machines
Craig Dowell <craigdo@ee.washington.edu>
parents: 4770
diff changeset
   466
                                 conf.env['ENABLE_GSL'],
904c1803d5dc test framework should probably work on all supported machines
Craig Dowell <craigdo@ee.washington.edu>
parents: 4770
diff changeset
   467
                                 "GSL not found")
904c1803d5dc test framework should probably work on all supported machines
Craig Dowell <craigdo@ee.washington.edu>
parents: 4770
diff changeset
   468
    if have_gsl:
904c1803d5dc test framework should probably work on all supported machines
Craig Dowell <craigdo@ee.washington.edu>
parents: 4770
diff changeset
   469
        conf.env.append_value('CXXDEFINES', "ENABLE_GSL")
904c1803d5dc test framework should probably work on all supported machines
Craig Dowell <craigdo@ee.washington.edu>
parents: 4770
diff changeset
   470
        conf.env.append_value('CCDEFINES', "ENABLE_GSL")
4392
25d38a0c9851 bug 537: no support to build static ns-3 binaries
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4388
diff changeset
   471
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: 5975
diff changeset
   472
    # for compiling C code, copy over the CXX* flags
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: 5975
diff changeset
   473
    conf.env.append_value('CCFLAGS', conf.env['CXXFLAGS'])
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: 5975
diff changeset
   474
    conf.env.append_value('CCDEFINES', conf.env['CXXDEFINES'])
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: 5975
diff changeset
   475
6362
ca7a4f7e24e7 Add -fstrict-aliasing and -Wstrict-aliasing compilation flags, to catch some potential strict aliasing violations earlier
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6274
diff changeset
   476
    def add_gcc_flag(flag):
ca7a4f7e24e7 Add -fstrict-aliasing and -Wstrict-aliasing compilation flags, to catch some potential strict aliasing violations earlier
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6274
diff changeset
   477
        if env['COMPILER_CXX'] == 'g++' and 'CXXFLAGS' not in os.environ:
ca7a4f7e24e7 Add -fstrict-aliasing and -Wstrict-aliasing compilation flags, to catch some potential strict aliasing violations earlier
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6274
diff changeset
   478
            if conf.check_compilation_flag(flag, mode='cxx'):
ca7a4f7e24e7 Add -fstrict-aliasing and -Wstrict-aliasing compilation flags, to catch some potential strict aliasing violations earlier
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6274
diff changeset
   479
                env.append_value('CXXFLAGS', flag)
ca7a4f7e24e7 Add -fstrict-aliasing and -Wstrict-aliasing compilation flags, to catch some potential strict aliasing violations earlier
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6274
diff changeset
   480
        if env['COMPILER_CC'] == 'gcc' and 'CCFLAGS' not in os.environ:
ca7a4f7e24e7 Add -fstrict-aliasing and -Wstrict-aliasing compilation flags, to catch some potential strict aliasing violations earlier
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6274
diff changeset
   481
            if conf.check_compilation_flag(flag, mode='cc'):
ca7a4f7e24e7 Add -fstrict-aliasing and -Wstrict-aliasing compilation flags, to catch some potential strict aliasing violations earlier
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6274
diff changeset
   482
                env.append_value('CCFLAGS', flag)
ca7a4f7e24e7 Add -fstrict-aliasing and -Wstrict-aliasing compilation flags, to catch some potential strict aliasing violations earlier
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6274
diff changeset
   483
ca7a4f7e24e7 Add -fstrict-aliasing and -Wstrict-aliasing compilation flags, to catch some potential strict aliasing violations earlier
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6274
diff changeset
   484
    add_gcc_flag('-Wno-error=deprecated-declarations')
ca7a4f7e24e7 Add -fstrict-aliasing and -Wstrict-aliasing compilation flags, to catch some potential strict aliasing violations earlier
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6274
diff changeset
   485
    add_gcc_flag('-fstrict-aliasing')
ca7a4f7e24e7 Add -fstrict-aliasing and -Wstrict-aliasing compilation flags, to catch some potential strict aliasing violations earlier
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6274
diff changeset
   486
    add_gcc_flag('-Wstrict-aliasing')
ca7a4f7e24e7 Add -fstrict-aliasing and -Wstrict-aliasing compilation flags, to catch some potential strict aliasing violations earlier
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6274
diff changeset
   487
6669
dbf2efe4b762 Give a more user-friendly error message when doxygen is not found
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6647
diff changeset
   488
    conf.find_program('doxygen', var='DOXYGEN')
6099
b37a72870f2d Test the support for the -Wno-error=deprecated-declarations option independently for the C and C++ compilers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6001
diff changeset
   489
5454
6db6a279dfff append {CC,CXX,LINK,LD}FLAGS_EXTRA to corresponding {CC,CXX,LINK}FLAGS.
Andrey Mazo <mazo@iitp.ru>
parents: 5453
diff changeset
   490
    # append user defined flags after all our ones
6db6a279dfff append {CC,CXX,LINK,LD}FLAGS_EXTRA to corresponding {CC,CXX,LINK}FLAGS.
Andrey Mazo <mazo@iitp.ru>
parents: 5453
diff changeset
   491
    for (confvar, envvar) in [['CCFLAGS', 'CCFLAGS_EXTRA'],
6db6a279dfff append {CC,CXX,LINK,LD}FLAGS_EXTRA to corresponding {CC,CXX,LINK}FLAGS.
Andrey Mazo <mazo@iitp.ru>
parents: 5453
diff changeset
   492
                              ['CXXFLAGS', 'CXXFLAGS_EXTRA'],
6db6a279dfff append {CC,CXX,LINK,LD}FLAGS_EXTRA to corresponding {CC,CXX,LINK}FLAGS.
Andrey Mazo <mazo@iitp.ru>
parents: 5453
diff changeset
   493
                              ['LINKFLAGS', 'LINKFLAGS_EXTRA'],
6db6a279dfff append {CC,CXX,LINK,LD}FLAGS_EXTRA to corresponding {CC,CXX,LINK}FLAGS.
Andrey Mazo <mazo@iitp.ru>
parents: 5453
diff changeset
   494
                              ['LINKFLAGS', 'LDFLAGS_EXTRA']]:
6db6a279dfff append {CC,CXX,LINK,LD}FLAGS_EXTRA to corresponding {CC,CXX,LINK}FLAGS.
Andrey Mazo <mazo@iitp.ru>
parents: 5453
diff changeset
   495
        if envvar in os.environ:
6670
c43b992a4f5b Bug 1032 - Unable to specify multiple Compiler/Linker flags
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6669
diff changeset
   496
            value = shlex.split(os.environ[envvar])
c43b992a4f5b Bug 1032 - Unable to specify multiple Compiler/Linker flags
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6669
diff changeset
   497
            conf.env.append_value(confvar, value)
5454
6db6a279dfff append {CC,CXX,LINK,LD}FLAGS_EXTRA to corresponding {CC,CXX,LINK}FLAGS.
Andrey Mazo <mazo@iitp.ru>
parents: 5453
diff changeset
   498
3625
30afad8324d5 Add a summary of optional features at the end of the configuration stage.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3623
diff changeset
   499
    # Write a summary of optional features status
30afad8324d5 Add a summary of optional features at the end of the configuration stage.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3623
diff changeset
   500
    print "---- Summary of optional NS-3 features:"
30afad8324d5 Add a summary of optional features at the end of the configuration stage.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3623
diff changeset
   501
    for (name, caption, was_enabled, reason_not_enabled) in conf.env['NS3_OPTIONAL_FEATURES']:
30afad8324d5 Add a summary of optional features at the end of the configuration stage.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3623
diff changeset
   502
        if was_enabled:
30afad8324d5 Add a summary of optional features at the end of the configuration stage.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3623
diff changeset
   503
            status = 'enabled'
30afad8324d5 Add a summary of optional features at the end of the configuration stage.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3623
diff changeset
   504
        else:
30afad8324d5 Add a summary of optional features at the end of the configuration stage.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3623
diff changeset
   505
            status = 'not enabled (%s)' % reason_not_enabled
30afad8324d5 Add a summary of optional features at the end of the configuration stage.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3623
diff changeset
   506
        print "%-30s: %s" % (caption, status)
30afad8324d5 Add a summary of optional features at the end of the configuration stage.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3623
diff changeset
   507
3826
40c5841b616d merge in tap device
Craig Dowell <craigdo@ee.washington.edu>
parents: 3703
diff changeset
   508
class SuidBuildTask(Task.TaskBase):
40c5841b616d merge in tap device
Craig Dowell <craigdo@ee.washington.edu>
parents: 3703
diff changeset
   509
    """task that makes a binary Suid
40c5841b616d merge in tap device
Craig Dowell <craigdo@ee.washington.edu>
parents: 3703
diff changeset
   510
    """
4179
2758871405b7 tweak wifi example, fix waf problems (thanks to Gustavo)
Craig Dowell <craigdo@ee.washington.edu>
parents: 4172
diff changeset
   511
    after = 'cxx_link cc_link'
2758871405b7 tweak wifi example, fix waf problems (thanks to Gustavo)
Craig Dowell <craigdo@ee.washington.edu>
parents: 4172
diff changeset
   512
    maxjobs = 1
3826
40c5841b616d merge in tap device
Craig Dowell <craigdo@ee.washington.edu>
parents: 3703
diff changeset
   513
    def __init__(self, bld, program):
4367
63c04791fae2 Make the --enable-sudo option work correctly again
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4354
diff changeset
   514
        self.bld = bld
3826
40c5841b616d merge in tap device
Craig Dowell <craigdo@ee.washington.edu>
parents: 3703
diff changeset
   515
        self.m_display = 'build-suid'
40c5841b616d merge in tap device
Craig Dowell <craigdo@ee.washington.edu>
parents: 3703
diff changeset
   516
        self.__program = program
4164
1f6ae48061a9 checkpoint tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents: 4119
diff changeset
   517
        self.__env = bld.env.copy ()
4367
63c04791fae2 Make the --enable-sudo option work correctly again
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4354
diff changeset
   518
        super(SuidBuildTask, self).__init__(generator=self)
3826
40c5841b616d merge in tap device
Craig Dowell <craigdo@ee.washington.edu>
parents: 3703
diff changeset
   519
        try:
3866
9e946fee902c Refactor wscript code to move regression testing code to a separate python module (bug 325)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3845
diff changeset
   520
            program_obj = wutils.find_program(self.__program.target, self.__env)
3826
40c5841b616d merge in tap device
Craig Dowell <craigdo@ee.washington.edu>
parents: 3703
diff changeset
   521
        except ValueError, ex:
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
   522
            raise Utils.WafError(str(ex))
4179
2758871405b7 tweak wifi example, fix waf problems (thanks to Gustavo)
Craig Dowell <craigdo@ee.washington.edu>
parents: 4172
diff changeset
   523
        program_node = program_obj.path.find_or_declare(ccroot.get_target_name(program_obj))
2758871405b7 tweak wifi example, fix waf problems (thanks to Gustavo)
Craig Dowell <craigdo@ee.washington.edu>
parents: 4172
diff changeset
   524
        self.filename = program_node.abspath(self.__env)
3826
40c5841b616d merge in tap device
Craig Dowell <craigdo@ee.washington.edu>
parents: 3703
diff changeset
   525
4179
2758871405b7 tweak wifi example, fix waf problems (thanks to Gustavo)
Craig Dowell <craigdo@ee.washington.edu>
parents: 4172
diff changeset
   526
2758871405b7 tweak wifi example, fix waf problems (thanks to Gustavo)
Craig Dowell <craigdo@ee.washington.edu>
parents: 4172
diff changeset
   527
    def run(self):
2758871405b7 tweak wifi example, fix waf problems (thanks to Gustavo)
Craig Dowell <craigdo@ee.washington.edu>
parents: 4172
diff changeset
   528
        print >> sys.stderr, 'setting suid bit on executable ' + self.filename
2758871405b7 tweak wifi example, fix waf problems (thanks to Gustavo)
Craig Dowell <craigdo@ee.washington.edu>
parents: 4172
diff changeset
   529
        if subprocess.Popen(['sudo', 'chown', 'root', self.filename]).wait():
2758871405b7 tweak wifi example, fix waf problems (thanks to Gustavo)
Craig Dowell <craigdo@ee.washington.edu>
parents: 4172
diff changeset
   530
            return 1
2758871405b7 tweak wifi example, fix waf problems (thanks to Gustavo)
Craig Dowell <craigdo@ee.washington.edu>
parents: 4172
diff changeset
   531
        if subprocess.Popen(['sudo', 'chmod', 'u+s', self.filename]).wait():
2758871405b7 tweak wifi example, fix waf problems (thanks to Gustavo)
Craig Dowell <craigdo@ee.washington.edu>
parents: 4172
diff changeset
   532
            return 1
2758871405b7 tweak wifi example, fix waf problems (thanks to Gustavo)
Craig Dowell <craigdo@ee.washington.edu>
parents: 4172
diff changeset
   533
        return 0
2758871405b7 tweak wifi example, fix waf problems (thanks to Gustavo)
Craig Dowell <craigdo@ee.washington.edu>
parents: 4172
diff changeset
   534
2758871405b7 tweak wifi example, fix waf problems (thanks to Gustavo)
Craig Dowell <craigdo@ee.washington.edu>
parents: 4172
diff changeset
   535
    def runnable_status(self):
2758871405b7 tweak wifi example, fix waf problems (thanks to Gustavo)
Craig Dowell <craigdo@ee.washington.edu>
parents: 4172
diff changeset
   536
        "RUN_ME SKIP_ME or ASK_LATER"
2758871405b7 tweak wifi example, fix waf problems (thanks to Gustavo)
Craig Dowell <craigdo@ee.washington.edu>
parents: 4172
diff changeset
   537
        st = os.stat(self.filename)
2758871405b7 tweak wifi example, fix waf problems (thanks to Gustavo)
Craig Dowell <craigdo@ee.washington.edu>
parents: 4172
diff changeset
   538
        if st.st_uid == 0:
2758871405b7 tweak wifi example, fix waf problems (thanks to Gustavo)
Craig Dowell <craigdo@ee.washington.edu>
parents: 4172
diff changeset
   539
            return Constants.SKIP_ME
2758871405b7 tweak wifi example, fix waf problems (thanks to Gustavo)
Craig Dowell <craigdo@ee.washington.edu>
parents: 4172
diff changeset
   540
        else:
2758871405b7 tweak wifi example, fix waf problems (thanks to Gustavo)
Craig Dowell <craigdo@ee.washington.edu>
parents: 4172
diff changeset
   541
            return Constants.RUN_ME
2758871405b7 tweak wifi example, fix waf problems (thanks to Gustavo)
Craig Dowell <craigdo@ee.washington.edu>
parents: 4172
diff changeset
   542
3826
40c5841b616d merge in tap device
Craig Dowell <craigdo@ee.washington.edu>
parents: 3703
diff changeset
   543
40c5841b616d merge in tap device
Craig Dowell <craigdo@ee.washington.edu>
parents: 3703
diff changeset
   544
def create_suid_program(bld, name):
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
   545
    program = bld.new_task_gen('cxx', 'program')
3826
40c5841b616d merge in tap device
Craig Dowell <craigdo@ee.washington.edu>
parents: 3703
diff changeset
   546
    program.is_ns3_program = True
40c5841b616d merge in tap device
Craig Dowell <craigdo@ee.washington.edu>
parents: 3703
diff changeset
   547
    program.module_deps = list()
40c5841b616d merge in tap device
Craig Dowell <craigdo@ee.washington.edu>
parents: 3703
diff changeset
   548
    program.name = name
40c5841b616d merge in tap device
Craig Dowell <craigdo@ee.washington.edu>
parents: 3703
diff changeset
   549
    program.target = name
4164
1f6ae48061a9 checkpoint tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents: 4119
diff changeset
   550
4171
902589866374 teach enable-sudo to be a config time thing
Craig Dowell <craigdo@ee.washington.edu>
parents: 4164
diff changeset
   551
    if bld.env['ENABLE_SUDO']:
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
   552
        SuidBuildTask(bld, program)
4171
902589866374 teach enable-sudo to be a config time thing
Craig Dowell <craigdo@ee.washington.edu>
parents: 4164
diff changeset
   553
3826
40c5841b616d merge in tap device
Craig Dowell <craigdo@ee.washington.edu>
parents: 3703
diff changeset
   554
    return program
40c5841b616d merge in tap device
Craig Dowell <craigdo@ee.washington.edu>
parents: 3703
diff changeset
   555
6821
203367ae7433 merge src/simulator into src/core; move src/core to new module layout
Tom Henderson <tomh@tomh.org>
parents: 6676
diff changeset
   556
def create_ns3_program(bld, name, dependencies=('core',)):
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
   557
    program = bld.new_task_gen('cxx', 'program')
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: 2990
diff changeset
   558
    program.is_ns3_program = True
1217
2f7791ae388d WAF: add new bld.create_ns3_module() and bld.create_ns3_program() methods to make declaration of modules and programs simpler, and allowing us to change how ns-3 is built in a centralized way, without needing to change every module wscript file.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1213
diff changeset
   559
    program.name = 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: 1213
diff changeset
   560
    program.target = program.name
6913
54679ab32585 Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents: 6886
diff changeset
   561
    # Each of the modules this program depends on has its own library.
54679ab32585 Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents: 6886
diff changeset
   562
    program.uselib_local = ['ns3-' + dep for dep in dependencies]
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: 1855
diff changeset
   563
    program.ns3_module_dependencies = ['ns3-'+dep for dep in dependencies]
4392
25d38a0c9851 bug 537: no support to build static ns-3 binaries
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4388
diff changeset
   564
    if program.env['ENABLE_STATIC_NS3']:
4438
8d9f6e489f94 enable darwin static builds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4436
diff changeset
   565
        if sys.platform == 'darwin':
8d9f6e489f94 enable darwin static builds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4436
diff changeset
   566
            program.env.append_value('LINKFLAGS', '-Wl,-all_load')
6913
54679ab32585 Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents: 6886
diff changeset
   567
            for dep in dependencies:
54679ab32585 Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents: 6886
diff changeset
   568
                program.env.append_value('LINKFLAGS', '-lns3-' + dep)
4438
8d9f6e489f94 enable darwin static builds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4436
diff changeset
   569
        else:
8d9f6e489f94 enable darwin static builds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4436
diff changeset
   570
            program.env.append_value('LINKFLAGS', '-Wl,--whole-archive,-Bstatic')
6913
54679ab32585 Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents: 6886
diff changeset
   571
            for dep in dependencies:
54679ab32585 Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents: 6886
diff changeset
   572
                program.env.append_value('LINKFLAGS', '-lns3-' + dep)
4438
8d9f6e489f94 enable darwin static builds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4436
diff changeset
   573
            program.env.append_value('LINKFLAGS', '-Wl,-Bdynamic,--no-whole-archive')
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: 1213
diff changeset
   574
    return program
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: 1213
diff changeset
   575
7094
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   576
def register_ns3_script(bld, name, dependencies=('core',)):
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   577
    ns3_module_dependencies = ['ns3-'+dep for dep in dependencies]
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   578
    bld.env.append_value('NS3_SCRIPT_DEPENDENCIES', (name, ns3_module_dependencies))
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   579
5848
ee2c83ed68cf get rid of examples waf script
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5468
diff changeset
   580
def add_examples_programs(bld):
ee2c83ed68cf get rid of examples waf script
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5468
diff changeset
   581
    env = bld.env_of_name('default')
ee2c83ed68cf get rid of examples waf script
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5468
diff changeset
   582
    if env['ENABLE_EXAMPLES']:
ee2c83ed68cf get rid of examples waf script
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5468
diff changeset
   583
        for dir in os.listdir('examples'):
6214
3f7f94c78f0a Bug 801 - ns-3.7 and SVN not coexisting nicely
Andrey Mazo <mazo@iitp.ru>
parents: 6113
diff changeset
   584
            if dir.startswith('.') or dir == 'CVS':
3f7f94c78f0a Bug 801 - ns-3.7 and SVN not coexisting nicely
Andrey Mazo <mazo@iitp.ru>
parents: 6113
diff changeset
   585
                continue
5848
ee2c83ed68cf get rid of examples waf script
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5468
diff changeset
   586
            if os.path.isdir(os.path.join('examples', dir)):
ee2c83ed68cf get rid of examples waf script
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5468
diff changeset
   587
                bld.add_subdirs(os.path.join('examples', dir))
ee2c83ed68cf get rid of examples waf script
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5468
diff changeset
   588
ee2c83ed68cf get rid of examples waf script
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5468
diff changeset
   589
3275
b0d91237f2ec [Bug 221] need a scratch directory
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3189
diff changeset
   590
def add_scratch_programs(bld):
6962
7df7b903d035 Bug 1083 - scratch doesn't work when only some modules are enabled
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6925
diff changeset
   591
    all_modules = [mod[len("ns3-"):] for mod in bld.env['NS3_ENABLED_MODULES']]
3275
b0d91237f2ec [Bug 221] need a scratch directory
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3189
diff changeset
   592
    for filename in os.listdir("scratch"):
3867
e29698e2e158 Bug 387: Build fails with junk subdirectories in "scratch" directory
Andrey Hippo <ahippo@yandex.ru>
parents: 3866
diff changeset
   593
        if filename.startswith('.') or filename == 'CVS':
e29698e2e158 Bug 387: Build fails with junk subdirectories in "scratch" directory
Andrey Hippo <ahippo@yandex.ru>
parents: 3866
diff changeset
   594
	    continue
3275
b0d91237f2ec [Bug 221] need a scratch directory
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3189
diff changeset
   595
        if os.path.isdir(os.path.join("scratch", filename)):
b0d91237f2ec [Bug 221] need a scratch directory
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3189
diff changeset
   596
            obj = bld.create_ns3_program(filename, all_modules)
4108
92bae583f934 waf --run now takes either full path to a program or just the (flat) program name, for all C++ programs
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4103
diff changeset
   597
            obj.path = obj.path.find_dir('scratch').find_dir(filename)
92bae583f934 waf --run now takes either full path to a program or just the (flat) program name, for all C++ programs
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4103
diff changeset
   598
            obj.find_sources_in_dirs('.')
92bae583f934 waf --run now takes either full path to a program or just the (flat) program name, for all C++ programs
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4103
diff changeset
   599
            obj.target = filename
3927
a2a992900b0b Make sure obj.name == obj.target for 'scratch' programs; fixes issue reported in ns-3-users with ./waf --run scratch/simple not working.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3919
diff changeset
   600
            obj.name = obj.target
3275
b0d91237f2ec [Bug 221] need a scratch directory
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3189
diff changeset
   601
        elif filename.endswith(".cc"):
b0d91237f2ec [Bug 221] need a scratch directory
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3189
diff changeset
   602
            name = filename[:-len(".cc")]
b0d91237f2ec [Bug 221] need a scratch directory
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3189
diff changeset
   603
            obj = bld.create_ns3_program(name, all_modules)
4108
92bae583f934 waf --run now takes either full path to a program or just the (flat) program name, for all C++ programs
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4103
diff changeset
   604
            obj.path = obj.path.find_dir('scratch')
92bae583f934 waf --run now takes either full path to a program or just the (flat) program name, for all C++ programs
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4103
diff changeset
   605
            obj.source = filename
92bae583f934 waf --run now takes either full path to a program or just the (flat) program name, for all C++ programs
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4103
diff changeset
   606
            obj.target = name
3927
a2a992900b0b Make sure obj.name == obj.target for 'scratch' programs; fixes issue reported in ns-3-users with ./waf --run scratch/simple not working.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3919
diff changeset
   607
            obj.name = obj.target
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: 1213
diff changeset
   608
3282
5e57c2f1cfb7 Add a WAF workaround for the 'Input line is too long.' error in win32/mingw.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3281
diff changeset
   609
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   610
def build(bld):
7131
77b75cd826d0 Make modules no longer be enabled from waf build
Mitch Watrous <watrous@u.washington.edu>
parents: 7100
diff changeset
   611
    # If --enabled-modules option was given, then print a warning
77b75cd826d0 Make modules no longer be enabled from waf build
Mitch Watrous <watrous@u.washington.edu>
parents: 7100
diff changeset
   612
    # message and exit this function.
77b75cd826d0 Make modules no longer be enabled from waf build
Mitch Watrous <watrous@u.washington.edu>
parents: 7100
diff changeset
   613
    if Options.options.enable_modules:
77b75cd826d0 Make modules no longer be enabled from waf build
Mitch Watrous <watrous@u.washington.edu>
parents: 7100
diff changeset
   614
        Logs.warn("No modules were built.  Use waf configure --enable-modules to enable modules.")
77b75cd826d0 Make modules no longer be enabled from waf build
Mitch Watrous <watrous@u.washington.edu>
parents: 7100
diff changeset
   615
        return
77b75cd826d0 Make modules no longer be enabled from waf build
Mitch Watrous <watrous@u.washington.edu>
parents: 7100
diff changeset
   616
6925
43d9c7eedf7b Test implicitly dependent modules
Mitch Watrous <watrous@u.washington.edu>
parents: 6919
diff changeset
   617
    bld.env['NS3_MODULES_WITH_TEST_LIBRARIES'] = []
6913
54679ab32585 Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents: 6886
diff changeset
   618
    bld.env['NS3_ENABLED_MODULE_TEST_LIBRARIES'] = []
7094
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   619
    bld.env['NS3_SCRIPT_DEPENDENCIES'] = []
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   620
    bld.env['NS3_RUNNABLE_PROGRAMS'] = []
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   621
    bld.env['NS3_RUNNABLE_SCRIPTS'] = []
6913
54679ab32585 Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents: 6886
diff changeset
   622
4326
179f86838e62 Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4202
diff changeset
   623
    wutils.bld = bld
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
   624
    if Options.options.no_task_lines:
2866
1d829915f092 Add a --no-task-lines WAF option; together with -v it makes WAF just print executed commands, like 'make' does.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2846
diff changeset
   625
        import Runner
1d829915f092 Add a --no-task-lines WAF option; together with -v it makes WAF just print executed commands, like 'make' does.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2846
diff changeset
   626
        def null_printout(s):
1d829915f092 Add a --no-task-lines WAF option; together with -v it makes WAF just print executed commands, like 'make' does.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2846
diff changeset
   627
            pass
1d829915f092 Add a --no-task-lines WAF option; together with -v it makes WAF just print executed commands, like 'make' does.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2846
diff changeset
   628
        Runner.printout = null_printout
1d829915f092 Add a --no-task-lines WAF option; together with -v it makes WAF just print executed commands, like 'make' does.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2846
diff changeset
   629
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
   630
    Options.cwd_launch = bld.path.abspath()
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: 1213
diff changeset
   631
    bld.create_ns3_program = types.MethodType(create_ns3_program, bld)
7094
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   632
    bld.register_ns3_script = types.MethodType(register_ns3_script, bld)
3826
40c5841b616d merge in tap device
Craig Dowell <craigdo@ee.washington.edu>
parents: 3703
diff changeset
   633
    bld.create_suid_program = types.MethodType(create_suid_program, bld)
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
   634
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
   635
    # switch default variant to the one matching our debug level
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   636
    variant_name = bld.env_of_name('default')['NS3_ACTIVE_VARIANT']
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   637
    variant_env = bld.env_of_name(variant_name)
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
   638
    bld.all_envs['default'] = variant_env
762
b64b1d4eadc0 WAF: process --run and --shell command-line options sooner, before running the build, since we may need a shell before the build finishes, in case the program to debug is part of the build itself.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 695
diff changeset
   639
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   640
    # process subfolders from here
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   641
    bld.add_subdirs('src')
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   642
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
   643
    env = bld.env
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: 1858
diff changeset
   644
6925
43d9c7eedf7b Test implicitly dependent modules
Mitch Watrous <watrous@u.washington.edu>
parents: 6919
diff changeset
   645
    # If modules have been enabled, then set lists of enabled modules
43d9c7eedf7b Test implicitly dependent modules
Mitch Watrous <watrous@u.washington.edu>
parents: 6919
diff changeset
   646
    # and enabled module test libraries.
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: 1858
diff changeset
   647
    if env['NS3_ENABLED_MODULES']:
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: 1858
diff changeset
   648
        modules = env['NS3_ENABLED_MODULES']
6638
ec4cdb1ca3ed Revive the option --enable-modules from bit-rot; however it won't yet work in practice due to dependencies not declared and non-modular python bindings
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6637
diff changeset
   649
ec4cdb1ca3ed Revive the option --enable-modules from bit-rot; however it won't yet work in practice due to dependencies not declared and non-modular python bindings
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6637
diff changeset
   650
        # Find out about additional modules that need to be enabled
ec4cdb1ca3ed Revive the option --enable-modules from bit-rot; however it won't yet work in practice due to dependencies not declared and non-modular python bindings
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6637
diff changeset
   651
        # due to dependency constraints.
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: 1858
diff changeset
   652
        changed = True
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: 1858
diff changeset
   653
        while changed:
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: 1858
diff changeset
   654
            changed = False
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: 1858
diff changeset
   655
            for module in modules:
6638
ec4cdb1ca3ed Revive the option --enable-modules from bit-rot; however it won't yet work in practice due to dependencies not declared and non-modular python bindings
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6637
diff changeset
   656
                module_obj = bld.name_to_obj(module, env)
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: 1858
diff changeset
   657
                if module_obj is None:
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: 1858
diff changeset
   658
                    raise ValueError("module %s not found" % module)
6913
54679ab32585 Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents: 6886
diff changeset
   659
                # Each enabled module has its own library.
54679ab32585 Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents: 6886
diff changeset
   660
                for dep in module_obj.uselib_local:
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: 1858
diff changeset
   661
                    if not dep.startswith('ns3-'):
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: 1858
diff changeset
   662
                        continue
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: 1858
diff changeset
   663
                    if dep not in modules:
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: 1858
diff changeset
   664
                        modules.append(dep)
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: 1858
diff changeset
   665
                        changed = True
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: 1858
diff changeset
   666
6638
ec4cdb1ca3ed Revive the option --enable-modules from bit-rot; however it won't yet work in practice due to dependencies not declared and non-modular python bindings
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6637
diff changeset
   667
        env['NS3_ENABLED_MODULES'] = modules
ec4cdb1ca3ed Revive the option --enable-modules from bit-rot; however it won't yet work in practice due to dependencies not declared and non-modular python bindings
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6637
diff changeset
   668
6998
1c2b8cfb71d2 Make tests not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents: 6981
diff changeset
   669
        # If tests are being built, then set the list of the enabled
1c2b8cfb71d2 Make tests not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents: 6981
diff changeset
   670
        # module test libraries.
1c2b8cfb71d2 Make tests not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents: 6981
diff changeset
   671
        if env['ENABLE_TESTS']:
1c2b8cfb71d2 Make tests not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents: 6981
diff changeset
   672
            for (mod, testlib) in bld.env['NS3_MODULES_WITH_TEST_LIBRARIES']:
1c2b8cfb71d2 Make tests not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents: 6981
diff changeset
   673
                if mod in bld.env['NS3_ENABLED_MODULES']:
1c2b8cfb71d2 Make tests not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents: 6981
diff changeset
   674
                    bld.env.append_value('NS3_ENABLED_MODULE_TEST_LIBRARIES', testlib)
6925
43d9c7eedf7b Test implicitly dependent modules
Mitch Watrous <watrous@u.washington.edu>
parents: 6919
diff changeset
   675
43d9c7eedf7b Test implicitly dependent modules
Mitch Watrous <watrous@u.washington.edu>
parents: 6919
diff changeset
   676
    # Process this subfolder here after the lists of enabled modules
43d9c7eedf7b Test implicitly dependent modules
Mitch Watrous <watrous@u.washington.edu>
parents: 6919
diff changeset
   677
    # and module test libraries have been set.
43d9c7eedf7b Test implicitly dependent modules
Mitch Watrous <watrous@u.washington.edu>
parents: 6919
diff changeset
   678
    bld.add_subdirs('utils')
43d9c7eedf7b Test implicitly dependent modules
Mitch Watrous <watrous@u.washington.edu>
parents: 6919
diff changeset
   679
43d9c7eedf7b Test implicitly dependent modules
Mitch Watrous <watrous@u.washington.edu>
parents: 6919
diff changeset
   680
    add_examples_programs(bld)
43d9c7eedf7b Test implicitly dependent modules
Mitch Watrous <watrous@u.washington.edu>
parents: 6919
diff changeset
   681
    add_scratch_programs(bld)
43d9c7eedf7b Test implicitly dependent modules
Mitch Watrous <watrous@u.washington.edu>
parents: 6919
diff changeset
   682
43d9c7eedf7b Test implicitly dependent modules
Mitch Watrous <watrous@u.washington.edu>
parents: 6919
diff changeset
   683
    if env['NS3_ENABLED_MODULES']:
43d9c7eedf7b Test implicitly dependent modules
Mitch Watrous <watrous@u.washington.edu>
parents: 6919
diff changeset
   684
        modules = env['NS3_ENABLED_MODULES']
6913
54679ab32585 Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents: 6886
diff changeset
   685
6647
bdbbfbc6bda7 When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6641
diff changeset
   686
        def exclude_taskgen(bld, taskgen):
6641
cfd3533cc1ef One more stop to fixing --enable-modules
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6638
diff changeset
   687
            # ok, so WAF does not provide an API to prevent an
6647
bdbbfbc6bda7 When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6641
diff changeset
   688
            # arbitrary taskgen from running; we have to muck around with
6641
cfd3533cc1ef One more stop to fixing --enable-modules
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6638
diff changeset
   689
            # WAF internal state, something that might stop working if
cfd3533cc1ef One more stop to fixing --enable-modules
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6638
diff changeset
   690
            # WAF is upgraded...
6647
bdbbfbc6bda7 When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6641
diff changeset
   691
            bld.all_task_gen.remove(taskgen)
6641
cfd3533cc1ef One more stop to fixing --enable-modules
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6638
diff changeset
   692
            for group in bld.task_manager.groups:
cfd3533cc1ef One more stop to fixing --enable-modules
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6638
diff changeset
   693
                try:
6647
bdbbfbc6bda7 When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6641
diff changeset
   694
                    group.tasks_gen.remove(taskgen)
6641
cfd3533cc1ef One more stop to fixing --enable-modules
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6638
diff changeset
   695
                except ValueError:
cfd3533cc1ef One more stop to fixing --enable-modules
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6638
diff changeset
   696
                    pass
cfd3533cc1ef One more stop to fixing --enable-modules
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6638
diff changeset
   697
                else:
cfd3533cc1ef One more stop to fixing --enable-modules
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6638
diff changeset
   698
                    break
cfd3533cc1ef One more stop to fixing --enable-modules
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6638
diff changeset
   699
6638
ec4cdb1ca3ed Revive the option --enable-modules from bit-rot; however it won't yet work in practice due to dependencies not declared and non-modular python bindings
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6637
diff changeset
   700
        # Exclude the programs other misc task gens that depend on disabled modules
4326
179f86838e62 Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4202
diff changeset
   701
        for obj in list(bld.all_task_gen):
6638
ec4cdb1ca3ed Revive the option --enable-modules from bit-rot; however it won't yet work in practice due to dependencies not declared and non-modular python bindings
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6637
diff changeset
   702
ec4cdb1ca3ed Revive the option --enable-modules from bit-rot; however it won't yet work in practice due to dependencies not declared and non-modular python bindings
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6637
diff changeset
   703
            # check for ns3moduleheader_taskgen
ec4cdb1ca3ed Revive the option --enable-modules from bit-rot; however it won't yet work in practice due to dependencies not declared and non-modular python bindings
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6637
diff changeset
   704
            if type(obj).__name__ == 'ns3moduleheader_taskgen':
ec4cdb1ca3ed Revive the option --enable-modules from bit-rot; however it won't yet work in practice due to dependencies not declared and non-modular python bindings
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6637
diff changeset
   705
                if ("ns3-%s" % obj.module) not in modules:
6647
bdbbfbc6bda7 When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6641
diff changeset
   706
                    obj.mode = 'remove' # tell it to remove headers instead of installing
6638
ec4cdb1ca3ed Revive the option --enable-modules from bit-rot; however it won't yet work in practice due to dependencies not declared and non-modular python bindings
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6637
diff changeset
   707
ec4cdb1ca3ed Revive the option --enable-modules from bit-rot; however it won't yet work in practice due to dependencies not declared and non-modular python bindings
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6637
diff changeset
   708
            # check for programs
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: 1858
diff changeset
   709
            if hasattr(obj, 'ns3_module_dependencies'):
6638
ec4cdb1ca3ed Revive the option --enable-modules from bit-rot; however it won't yet work in practice due to dependencies not declared and non-modular python bindings
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6637
diff changeset
   710
                # this is an NS-3 program (bld.create_ns3_program)
7094
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   711
                program_built = True
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: 1858
diff changeset
   712
                for dep in obj.ns3_module_dependencies:
6638
ec4cdb1ca3ed Revive the option --enable-modules from bit-rot; however it won't yet work in practice due to dependencies not declared and non-modular python bindings
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6637
diff changeset
   713
                    if dep not in modules: # prog. depends on a module that isn't enabled?
6647
bdbbfbc6bda7 When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6641
diff changeset
   714
                        exclude_taskgen(bld, obj)
7094
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   715
                        program_built = False
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: 1858
diff changeset
   716
                        break
6638
ec4cdb1ca3ed Revive the option --enable-modules from bit-rot; however it won't yet work in practice due to dependencies not declared and non-modular python bindings
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6637
diff changeset
   717
7094
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   718
                # Add this program to the list if all of its
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   719
                # dependencies will be built.
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   720
                if program_built:
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   721
                    bld.env.append_value('NS3_RUNNABLE_PROGRAMS', obj.name)
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   722
6641
cfd3533cc1ef One more stop to fixing --enable-modules
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6638
diff changeset
   723
            # disable the modules themselves
6638
ec4cdb1ca3ed Revive the option --enable-modules from bit-rot; however it won't yet work in practice due to dependencies not declared and non-modular python bindings
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6637
diff changeset
   724
            if hasattr(obj, "is_ns3_module") and obj.name not in modules:
6647
bdbbfbc6bda7 When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6641
diff changeset
   725
                exclude_taskgen(bld, obj) # kill the module
6641
cfd3533cc1ef One more stop to fixing --enable-modules
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6638
diff changeset
   726
6913
54679ab32585 Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents: 6886
diff changeset
   727
            # disable the module test libraries
6998
1c2b8cfb71d2 Make tests not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents: 6981
diff changeset
   728
            if hasattr(obj, "is_ns3_module_test_library"):
1c2b8cfb71d2 Make tests not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents: 6981
diff changeset
   729
                if not env['ENABLE_TESTS'] or (obj.module_name not in modules):
1c2b8cfb71d2 Make tests not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents: 6981
diff changeset
   730
                    exclude_taskgen(bld, obj) # kill the module test library
6913
54679ab32585 Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents: 6886
diff changeset
   731
6641
cfd3533cc1ef One more stop to fixing --enable-modules
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6638
diff changeset
   732
            # disable the ns3header_taskgen
cfd3533cc1ef One more stop to fixing --enable-modules
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6638
diff changeset
   733
            if type(obj).__name__ == 'ns3header_taskgen':
cfd3533cc1ef One more stop to fixing --enable-modules
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6638
diff changeset
   734
                if ("ns3-%s" % obj.module) not in modules:
6647
bdbbfbc6bda7 When a module is disabled, remove xxx-module.h and module header files from build/variant/ns3
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6641
diff changeset
   735
                    obj.mode = 'remove' # tell it to remove headers instead of installing 
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: 1858
diff changeset
   736
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: 1858
diff changeset
   737
    if env['NS3_ENABLED_MODULES']:
3408
2cc40b3e4fa5 python bindings
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3331
diff changeset
   738
        env['NS3_ENABLED_MODULES'] = list(modules)
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: 1858
diff changeset
   739
7094
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   740
    # Determine which scripts will be runnable.
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   741
    for (script, dependencies) in bld.env['NS3_SCRIPT_DEPENDENCIES']:
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   742
        script_runnable = True
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   743
        for dep in dependencies:
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   744
            if dep not in modules:
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   745
                script_runnable = False
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   746
                break
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   747
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   748
        # Add this script to the list if all of its dependencies will
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   749
        # be built.
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   750
        if script_runnable:
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   751
            bld.env.append_value('NS3_RUNNABLE_SCRIPTS', script)
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   752
3408
2cc40b3e4fa5 python bindings
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3331
diff changeset
   753
    bld.add_subdirs('bindings/python')
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: 1858
diff changeset
   754
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
   755
    if Options.options.run:
3919
fd796ed5b166 Post-fix the last patch, to make sure invalid program names passed into --run trigger an informative error message as before.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3918
diff changeset
   756
        # Check that the requested program name is valid
4119
9ffcf2400aa5 Bug #323: waf --valgrind doesn't check for valgrind first
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4118
diff changeset
   757
        program_name, dummy_program_argv = wutils.get_run_program(Options.options.run, wutils.get_command_template(env))
3933
3c149230e98a Fix waf problem running programs with arguments.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3927
diff changeset
   758
3919
fd796ed5b166 Post-fix the last patch, to make sure invalid program names passed into --run trigger an informative error message as before.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3918
diff changeset
   759
        # When --run'ing a program, tell WAF to only build that program,
fd796ed5b166 Post-fix the last patch, to make sure invalid program names passed into --run trigger an informative error message as before.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3918
diff changeset
   760
        # nothing more; this greatly speeds up compilation when all you
fd796ed5b166 Post-fix the last patch, to make sure invalid program names passed into --run trigger an informative error message as before.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3918
diff changeset
   761
        # want to do is run a test program.
4760
f774ff724ee4 Bug #609: --check and --regression should build only the required binaries
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4751
diff changeset
   762
        Options.options.compile_targets += ',' + os.path.basename(program_name)
f774ff724ee4 Bug #609: --check and --regression should build only the required binaries
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4751
diff changeset
   763
        for gen in bld.all_task_gen:
f774ff724ee4 Bug #609: --check and --regression should build only the required binaries
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4751
diff changeset
   764
            if type(gen).__name__ in ['ns3header_taskgen', 'ns3moduleheader_taskgen']:
f774ff724ee4 Bug #609: --check and --regression should build only the required binaries
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4751
diff changeset
   765
                gen.post()
3919
fd796ed5b166 Post-fix the last patch, to make sure invalid program names passed into --run trigger an informative error message as before.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3918
diff changeset
   766
5468
6eebad1fb54d Bring back the --doxygen-no-build option from the dead.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5463
diff changeset
   767
    if Options.options.doxygen_no_build:
6eebad1fb54d Bring back the --doxygen-no-build option from the dead.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5463
diff changeset
   768
        _doxygen(bld)
6eebad1fb54d Bring back the --doxygen-no-build option from the dead.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5463
diff changeset
   769
        raise SystemExit(0)
6eebad1fb54d Bring back the --doxygen-no-build option from the dead.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5463
diff changeset
   770
4326
179f86838e62 Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4202
diff changeset
   771
def shutdown(ctx):
179f86838e62 Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4202
diff changeset
   772
    bld = wutils.bld
4328
20a0a6244177 waf fix
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4326
diff changeset
   773
    if wutils.bld is None:
20a0a6244177 waf fix
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4326
diff changeset
   774
        return
4326
179f86838e62 Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4202
diff changeset
   775
    env = bld.env
179f86838e62 Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4202
diff changeset
   776
7291
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   777
    # Don't print the lists if this a clean or distribution clean.
7100
c3796788794a Make built modules list not be printed for clean and distclean
Mitch Watrous <watrous@u.washington.edu>
parents: 7097
diff changeset
   778
    if ('clean' not in Options.arg_line) and ('distclean' not in Options.arg_line):
c3796788794a Make built modules list not be printed for clean and distclean
Mitch Watrous <watrous@u.washington.edu>
parents: 7097
diff changeset
   779
7291
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   780
        # Print the list of built modules.
7100
c3796788794a Make built modules list not be printed for clean and distclean
Mitch Watrous <watrous@u.washington.edu>
parents: 7097
diff changeset
   781
        print
c3796788794a Make built modules list not be printed for clean and distclean
Mitch Watrous <watrous@u.washington.edu>
parents: 7097
diff changeset
   782
        print 'Modules built:'
7291
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   783
        print_module_names(env['NS3_ENABLED_MODULES'])
7100
c3796788794a Make built modules list not be printed for clean and distclean
Mitch Watrous <watrous@u.washington.edu>
parents: 7097
diff changeset
   784
        print
7291
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   785
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   786
        # Print the list of enabled modules that were not built.
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   787
        if env['NS3_ENABLED_MODULES_NOT_BUILT']:
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   788
            print 'Modules not built:'
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   789
            print_module_names(env['NS3_ENABLED_MODULES_NOT_BUILT'])
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   790
            print
7066
948694386867 Print modules built list at end of waf build
Mitch Watrous <watrous@u.washington.edu>
parents: 7062
diff changeset
   791
7094
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   792
    # Write the build status file.
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   793
    build_status_file = os.path.join (env['NS3_BUILDDIR'], env['NS3_ACTIVE_VARIANT'], 'build-status.py')
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   794
    out = open(build_status_file, 'w')
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   795
    out.write('#! /usr/bin/env python\n')
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   796
    out.write('\n')
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   797
    out.write('# Programs that are runnable.\n')
7096
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7094
diff changeset
   798
    out.write('ns3_runnable_programs = ' + str(env['NS3_RUNNABLE_PROGRAMS']) + '\n')
7094
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   799
    out.write('\n')
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   800
    out.write('# Scripts that are runnable.\n')
7096
7357a40d2dde Make test.py not run examples that are not runnable
Mitch Watrous <watrous@u.washington.edu>
parents: 7094
diff changeset
   801
    out.write('ns3_runnable_scripts = ' + str(env['NS3_RUNNABLE_SCRIPTS']) + '\n')
7094
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   802
    out.write('\n')
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   803
    out.close()
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   804
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
   805
    if Options.options.lcov_report:
671
4bec4600950c WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 649
diff changeset
   806
        lcov_report()
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   807
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
   808
    if Options.options.run:
6676
8a57344a8d09 Codereview Issue 2692041: Add pyviz module
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6670
diff changeset
   809
        wutils.run_program(Options.options.run, env, wutils.get_command_template(env),
8a57344a8d09 Codereview Issue 2692041: Add pyviz module
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6670
diff changeset
   810
                           visualize=Options.options.visualize)
935
53e1e53c373f WAF: add a --command-template option to e.g. allow running programs with valgrind, gdb, etc.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 934
diff changeset
   811
        raise SystemExit(0)
53e1e53c373f WAF: add a --command-template option to e.g. allow running programs with valgrind, gdb, etc.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 934
diff changeset
   812
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
   813
    if Options.options.pyrun:
6676
8a57344a8d09 Codereview Issue 2692041: Add pyviz module
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6670
diff changeset
   814
        wutils.run_python_program(Options.options.pyrun, env,
8a57344a8d09 Codereview Issue 2692041: Add pyviz module
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6670
diff changeset
   815
                                  visualize=Options.options.visualize)
3419
8d3f5c0f55fa Add WAF option --pyrun, to make it easier to run Python programs.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3418
diff changeset
   816
        raise SystemExit(0)
8d3f5c0f55fa Add WAF option --pyrun, to make it easier to run Python programs.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3418
diff changeset
   817
4326
179f86838e62 Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4202
diff changeset
   818
    if Options.options.shell:
5361
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5252
diff changeset
   819
        raise Utils.WafError("Please run `./waf shell' now, instead of `./waf --shell'")
4326
179f86838e62 Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4202
diff changeset
   820
5361
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5252
diff changeset
   821
    if Options.options.check:
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5252
diff changeset
   822
        raise Utils.WafError("Please run `./test.py' now, instead of `./waf --check'")
4326
179f86838e62 Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4202
diff changeset
   823
179f86838e62 Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4202
diff changeset
   824
    check_shell(bld)
179f86838e62 Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4202
diff changeset
   825
179f86838e62 Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4202
diff changeset
   826
check_context = Build.BuildContext
179f86838e62 Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4202
diff changeset
   827
179f86838e62 Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4202
diff changeset
   828
def check(bld):
5372
716ca842b52c convince waf to run test.py on check command
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
   829
    """run the equivalent of the old ns-3 unit tests using test.py"""
5392
80b9ae7b5e26 remind waf how to generate introspected doxygen
Craig Dowell <craigdo@ee.washington.edu>
parents: 5372
diff changeset
   830
    env = wutils.bld.env
80b9ae7b5e26 remind waf how to generate introspected doxygen
Craig Dowell <craigdo@ee.washington.edu>
parents: 5372
diff changeset
   831
    wutils.run_python_program("test.py -n -c core", env)
4531
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   832
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   833
class print_introspected_doxygen_task(Task.TaskBase):
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   834
    after = 'cc cxx cc_link cxx_link'
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   835
    color = 'BLUE'
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   836
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   837
    def __init__(self, bld):
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   838
        self.bld = bld
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   839
        super(print_introspected_doxygen_task, self).__init__(generator=self)
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   840
        
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   841
    def __str__(self):
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   842
        return 'print-introspected-doxygen\n'
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   843
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   844
    def runnable_status(self):
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   845
        return Task.RUN_ME
1540
fd4e69513199 Now run doxygen again before the build, but the doc/trace-source-list.h is generated during waf check; make doxygen less verbose, and give a warning when doc/trace-source-list.h is missing.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1536
diff changeset
   846
4531
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   847
    def run(self):
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   848
        ## generate the trace sources list docs
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   849
        env = wutils.bld.env
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   850
        proc_env = wutils.get_proc_env()
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   851
        try:
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   852
            program_obj = wutils.find_program('print-introspected-doxygen', env)
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   853
        except ValueError: # could happen if print-introspected-doxygen is
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   854
                           # not built because of waf configure
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   855
                           # --enable-modules=xxx
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   856
            pass
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   857
        else:
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   858
            prog = program_obj.path.find_or_declare(ccroot.get_target_name(program_obj)).abspath(env)
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   859
            out = open(os.path.join('..', 'doc', 'introspected-doxygen.h'), 'w')
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   860
            if subprocess.Popen([prog], stdout=out, env=proc_env).wait():
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   861
                raise SystemExit(1)
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   862
            out.close()
1536
23593050aa96 Run the program print-trace-sources to generate doc/trace-source-list.h when generating docs. As a side effect, --doxygen is now has to be processed at the end of the build.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1532
diff changeset
   863
4531
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   864
class run_python_unit_tests_task(Task.TaskBase):
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   865
    after = 'cc cxx cc_link cxx_link'
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   866
    color = 'BLUE'
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   867
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   868
    def __init__(self, bld):
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   869
        self.bld = bld
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   870
        super(run_python_unit_tests_task, self).__init__(generator=self)
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   871
        
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   872
    def __str__(self):
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   873
        return 'run-python-unit-tests\n'
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   874
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   875
    def runnable_status(self):
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   876
        return Task.RUN_ME
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   877
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   878
    def run(self):
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   879
        proc_env = wutils.get_proc_env()
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   880
        wutils.run_argv([self.bld.env['PYTHON'], os.path.join("..", "utils", "python-unit-tests.py")],
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   881
                        self.bld.env, proc_env, force_no_valgrind=True)
3408
2cc40b3e4fa5 python bindings
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3331
diff changeset
   882
4326
179f86838e62 Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4202
diff changeset
   883
def check_shell(bld):
5975
c85cb9b073a0 comparing with http://code.nsnam.org/ns-3-dev
Craig Dowell <craigdo@ee.washington.edu>
parents: 5848
diff changeset
   884
    if ('NS3_MODULE_PATH' not in os.environ) or ('NS3_EXECUTABLE_PATH' not in os.environ):
1016
58a56b52a08b Detect when running waf --shell with stale environment variables and give an error when it happens.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1015
diff changeset
   885
        return
4326
179f86838e62 Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4202
diff changeset
   886
    env = bld.env
1016
58a56b52a08b Detect when running waf --shell with stale environment variables and give an error when it happens.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1015
diff changeset
   887
    correct_modpath = os.pathsep.join(env['NS3_MODULE_PATH'])
58a56b52a08b Detect when running waf --shell with stale environment variables and give an error when it happens.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1015
diff changeset
   888
    found_modpath = os.environ['NS3_MODULE_PATH']
5975
c85cb9b073a0 comparing with http://code.nsnam.org/ns-3-dev
Craig Dowell <craigdo@ee.washington.edu>
parents: 5848
diff changeset
   889
    correct_execpath = os.pathsep.join(env['NS3_EXECUTABLE_PATH'])
c85cb9b073a0 comparing with http://code.nsnam.org/ns-3-dev
Craig Dowell <craigdo@ee.washington.edu>
parents: 5848
diff changeset
   890
    found_execpath = os.environ['NS3_EXECUTABLE_PATH']
c85cb9b073a0 comparing with http://code.nsnam.org/ns-3-dev
Craig Dowell <craigdo@ee.washington.edu>
parents: 5848
diff changeset
   891
    if (found_modpath != correct_modpath) or (correct_execpath != found_execpath):
4326
179f86838e62 Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4202
diff changeset
   892
        msg = ("Detected shell (./waf shell) with incorrect configuration\n"
1016
58a56b52a08b Detect when running waf --shell with stale environment variables and give an error when it happens.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1015
diff changeset
   893
               "=========================================================\n"
58a56b52a08b Detect when running waf --shell with stale environment variables and give an error when it happens.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1015
diff changeset
   894
               "Possible reasons for this problem:\n"
58a56b52a08b Detect when running waf --shell with stale environment variables and give an error when it happens.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1015
diff changeset
   895
               "  1. You switched to another ns-3 tree from inside this shell\n"
58a56b52a08b Detect when running waf --shell with stale environment variables and give an error when it happens.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1015
diff changeset
   896
               "  2. You switched ns-3 debug level (waf configure --debug)\n"
58a56b52a08b Detect when running waf --shell with stale environment variables and give an error when it happens.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1015
diff changeset
   897
               "  3. You modified the list of built ns-3 modules\n"
58a56b52a08b Detect when running waf --shell with stale environment variables and give an error when it happens.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1015
diff changeset
   898
               "You should correct this situation before running any program.  Possible solutions:\n"
58a56b52a08b Detect when running waf --shell with stale environment variables and give an error when it happens.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1015
diff changeset
   899
               "  1. Exit this shell, and start a new one\n"
58a56b52a08b Detect when running waf --shell with stale environment variables and give an error when it happens.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1015
diff changeset
   900
               "  2. Run a new nested shell")
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
   901
        raise Utils.WafError(msg)
1016
58a56b52a08b Detect when running waf --shell with stale environment variables and give an error when it happens.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1015
diff changeset
   902
672
184d5a505279 WAF: remove the rpath options, and add --run and --shell as replacements; additionally, the new options "should" work on Mac OS X, as well as linux2 and win32.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 671
diff changeset
   903
4326
179f86838e62 Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4202
diff changeset
   904
shell_context = Build.BuildContext
179f86838e62 Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4202
diff changeset
   905
def shell(ctx):
179f86838e62 Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4202
diff changeset
   906
    """run a shell with an environment suitably modified to run locally built programs"""
179f86838e62 Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4202
diff changeset
   907
179f86838e62 Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4202
diff changeset
   908
    #make sure we build first"
179f86838e62 Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4202
diff changeset
   909
    Scripting.build(ctx)
179f86838e62 Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4202
diff changeset
   910
672
184d5a505279 WAF: remove the rpath options, and add --run and --shell as replacements; additionally, the new options "should" work on Mac OS X, as well as linux2 and win32.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 671
diff changeset
   911
    if sys.platform == 'win32':
184d5a505279 WAF: remove the rpath options, and add --run and --shell as replacements; additionally, the new options "should" work on Mac OS X, as well as linux2 and win32.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 671
diff changeset
   912
        shell = os.environ.get("COMSPEC", "cmd.exe")
184d5a505279 WAF: remove the rpath options, and add --run and --shell as replacements; additionally, the new options "should" work on Mac OS X, as well as linux2 and win32.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 671
diff changeset
   913
    else:
184d5a505279 WAF: remove the rpath options, and add --run and --shell as replacements; additionally, the new options "should" work on Mac OS X, as well as linux2 and win32.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 671
diff changeset
   914
        shell = os.environ.get("SHELL", "/bin/sh")
1016
58a56b52a08b Detect when running waf --shell with stale environment variables and give an error when it happens.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1015
diff changeset
   915
4326
179f86838e62 Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4202
diff changeset
   916
    env = wutils.bld.env
5975
c85cb9b073a0 comparing with http://code.nsnam.org/ns-3-dev
Craig Dowell <craigdo@ee.washington.edu>
parents: 5848
diff changeset
   917
    os_env = {'NS3_MODULE_PATH': os.pathsep.join(env['NS3_MODULE_PATH']), 'NS3_EXECUTABLE_PATH': os.pathsep.join(env['NS3_EXECUTABLE_PATH'])}
c85cb9b073a0 comparing with http://code.nsnam.org/ns-3-dev
Craig Dowell <craigdo@ee.washington.edu>
parents: 5848
diff changeset
   918
    wutils.run_argv([shell], env, os_env)
672
184d5a505279 WAF: remove the rpath options, and add --run and --shell as replacements; additionally, the new options "should" work on Mac OS X, as well as linux2 and win32.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 671
diff changeset
   919
5468
6eebad1fb54d Bring back the --doxygen-no-build option from the dead.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5463
diff changeset
   920
def _doxygen(bld):
5392
80b9ae7b5e26 remind waf how to generate introspected doxygen
Craig Dowell <craigdo@ee.washington.edu>
parents: 5372
diff changeset
   921
    env = wutils.bld.env
80b9ae7b5e26 remind waf how to generate introspected doxygen
Craig Dowell <craigdo@ee.washington.edu>
parents: 5372
diff changeset
   922
    proc_env = wutils.get_proc_env()
1536
23593050aa96 Run the program print-trace-sources to generate doc/trace-source-list.h when generating docs. As a side effect, --doxygen is now has to be processed at the end of the build.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1532
diff changeset
   923
6669
dbf2efe4b762 Give a more user-friendly error message when doxygen is not found
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6647
diff changeset
   924
    if not env['DOXYGEN']:
dbf2efe4b762 Give a more user-friendly error message when doxygen is not found
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6647
diff changeset
   925
        Logs.error("waf configure did not detect doxygen in the system -> cannot build api docs.")
dbf2efe4b762 Give a more user-friendly error message when doxygen is not found
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6647
diff changeset
   926
        raise SystemExit(1)
dbf2efe4b762 Give a more user-friendly error message when doxygen is not found
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6647
diff changeset
   927
        return
dbf2efe4b762 Give a more user-friendly error message when doxygen is not found
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6647
diff changeset
   928
5392
80b9ae7b5e26 remind waf how to generate introspected doxygen
Craig Dowell <craigdo@ee.washington.edu>
parents: 5372
diff changeset
   929
    try:
80b9ae7b5e26 remind waf how to generate introspected doxygen
Craig Dowell <craigdo@ee.washington.edu>
parents: 5372
diff changeset
   930
        program_obj = wutils.find_program('print-introspected-doxygen', env)
80b9ae7b5e26 remind waf how to generate introspected doxygen
Craig Dowell <craigdo@ee.washington.edu>
parents: 5372
diff changeset
   931
    except ValueError: 
80b9ae7b5e26 remind waf how to generate introspected doxygen
Craig Dowell <craigdo@ee.washington.edu>
parents: 5372
diff changeset
   932
        Logs.warn("print-introspected-doxygen does not exist")
80b9ae7b5e26 remind waf how to generate introspected doxygen
Craig Dowell <craigdo@ee.washington.edu>
parents: 5372
diff changeset
   933
        raise SystemExit(1)
80b9ae7b5e26 remind waf how to generate introspected doxygen
Craig Dowell <craigdo@ee.washington.edu>
parents: 5372
diff changeset
   934
        return
80b9ae7b5e26 remind waf how to generate introspected doxygen
Craig Dowell <craigdo@ee.washington.edu>
parents: 5372
diff changeset
   935
80b9ae7b5e26 remind waf how to generate introspected doxygen
Craig Dowell <craigdo@ee.washington.edu>
parents: 5372
diff changeset
   936
    prog = program_obj.path.find_or_declare(ccroot.get_target_name(program_obj)).abspath(env)
6254
e794047931fb Make --doxygen-no-build check if print-introspected-doxygen has been built, error out if not. Fixes #884
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6214
diff changeset
   937
e794047931fb Make --doxygen-no-build check if print-introspected-doxygen has been built, error out if not. Fixes #884
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6214
diff changeset
   938
    if not os.path.exists(prog):
e794047931fb Make --doxygen-no-build check if print-introspected-doxygen has been built, error out if not. Fixes #884
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6214
diff changeset
   939
        Logs.error("print-introspected-doxygen has not been built yet."
e794047931fb Make --doxygen-no-build check if print-introspected-doxygen has been built, error out if not. Fixes #884
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6214
diff changeset
   940
                   " You need to build ns-3 at least once before "
e794047931fb Make --doxygen-no-build check if print-introspected-doxygen has been built, error out if not. Fixes #884
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6214
diff changeset
   941
                   "generating doxygen docs...")
e794047931fb Make --doxygen-no-build check if print-introspected-doxygen has been built, error out if not. Fixes #884
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6214
diff changeset
   942
        raise SystemExit(1)
e794047931fb Make --doxygen-no-build check if print-introspected-doxygen has been built, error out if not. Fixes #884
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6214
diff changeset
   943
5392
80b9ae7b5e26 remind waf how to generate introspected doxygen
Craig Dowell <craigdo@ee.washington.edu>
parents: 5372
diff changeset
   944
    out = open(os.path.join('doc', 'introspected-doxygen.h'), 'w')
80b9ae7b5e26 remind waf how to generate introspected doxygen
Craig Dowell <craigdo@ee.washington.edu>
parents: 5372
diff changeset
   945
80b9ae7b5e26 remind waf how to generate introspected doxygen
Craig Dowell <craigdo@ee.washington.edu>
parents: 5372
diff changeset
   946
    if subprocess.Popen([prog], stdout=out, env=proc_env).wait():
80b9ae7b5e26 remind waf how to generate introspected doxygen
Craig Dowell <craigdo@ee.washington.edu>
parents: 5372
diff changeset
   947
        raise SystemExit(1)
80b9ae7b5e26 remind waf how to generate introspected doxygen
Craig Dowell <craigdo@ee.washington.edu>
parents: 5372
diff changeset
   948
    out.close()
80b9ae7b5e26 remind waf how to generate introspected doxygen
Craig Dowell <craigdo@ee.washington.edu>
parents: 5372
diff changeset
   949
671
4bec4600950c WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 649
diff changeset
   950
    doxygen_config = os.path.join('doc', 'doxygen.conf')
6669
dbf2efe4b762 Give a more user-friendly error message when doxygen is not found
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6647
diff changeset
   951
    if subprocess.Popen([env['DOXYGEN'], doxygen_config]).wait():
671
4bec4600950c WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 649
diff changeset
   952
        raise SystemExit(1)
4bec4600950c WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 649
diff changeset
   953
5468
6eebad1fb54d Bring back the --doxygen-no-build option from the dead.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5463
diff changeset
   954
def doxygen(bld):
6eebad1fb54d Bring back the --doxygen-no-build option from the dead.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5463
diff changeset
   955
    """do a full build, generate the introspected doxygen and then the doxygen"""
6eebad1fb54d Bring back the --doxygen-no-build option from the dead.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5463
diff changeset
   956
    Scripting.build(bld)
6eebad1fb54d Bring back the --doxygen-no-build option from the dead.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5463
diff changeset
   957
    _doxygen(bld)
6eebad1fb54d Bring back the --doxygen-no-build option from the dead.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5463
diff changeset
   958
671
4bec4600950c WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 649
diff changeset
   959
def lcov_report():
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
   960
    env = Build.bld.env
671
4bec4600950c WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 649
diff changeset
   961
    variant_name = env['NS3_ACTIVE_VARIANT']
4bec4600950c WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 649
diff changeset
   962
4bec4600950c WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 649
diff changeset
   963
    if 'gcov' not in variant_name:
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
   964
        raise Utils.WafError("project not configured for code coverage;"
671
4bec4600950c WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 649
diff changeset
   965
                     " reconfigure with --enable-gcov")
4bec4600950c WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 649
diff changeset
   966
4bec4600950c WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 649
diff changeset
   967
    os.chdir(blddir)
4bec4600950c WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 649
diff changeset
   968
    try:
4bec4600950c WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 649
diff changeset
   969
        lcov_report_dir = os.path.join(variant_name, 'lcov-report')
4bec4600950c WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 649
diff changeset
   970
        create_dir_command = "rm -rf " + lcov_report_dir
4bec4600950c WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 649
diff changeset
   971
        create_dir_command += " && mkdir " + lcov_report_dir + ";"
4bec4600950c WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 649
diff changeset
   972
4bec4600950c WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 649
diff changeset
   973
        if subprocess.Popen(create_dir_command, shell=True).wait():
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   974
            raise SystemExit(1)
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   975
671
4bec4600950c WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 649
diff changeset
   976
        info_file = os.path.join(lcov_report_dir, variant_name + '.info')
4bec4600950c WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 649
diff changeset
   977
        lcov_command = "../utils/lcov/lcov -c -d . -o " + info_file
4bec4600950c WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 649
diff changeset
   978
        lcov_command += " --source-dirs=" + os.getcwd()
4bec4600950c WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 649
diff changeset
   979
        lcov_command += ":" + os.path.join(
4bec4600950c WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 649
diff changeset
   980
            os.getcwd(), variant_name, 'include')
4bec4600950c WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 649
diff changeset
   981
        if subprocess.Popen(lcov_command, shell=True).wait():
4bec4600950c WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 649
diff changeset
   982
            raise SystemExit(1)
4bec4600950c WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 649
diff changeset
   983
4bec4600950c WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 649
diff changeset
   984
        genhtml_command = "../utils/lcov/genhtml -o " + lcov_report_dir
4bec4600950c WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 649
diff changeset
   985
        genhtml_command += " " + info_file
4bec4600950c WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 649
diff changeset
   986
        if subprocess.Popen(genhtml_command, shell=True).wait():
4bec4600950c WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 649
diff changeset
   987
            raise SystemExit(1)
4bec4600950c WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 649
diff changeset
   988
    finally:
4bec4600950c WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 649
diff changeset
   989
        os.chdir("..")
4bec4600950c WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 649
diff changeset
   990
2622
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
   991
##
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
   992
## The default WAF DistDir implementation is rather slow, because it
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
   993
## first copies everything and only later removes unwanted files and
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
   994
## directories; this means that it needless copies the full build dir
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
   995
## and the .hg repository tree.  Here we provide a replacement DistDir
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
   996
## implementation that is more efficient.
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
   997
##
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
   998
import Scripting
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
   999
from Scripting import dist_exts, excludes, BLDDIR
2622
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1000
import Utils
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1001
import os
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1002
4326
179f86838e62 Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4202
diff changeset
  1003
def _copytree(src, dst, symlinks=False, excludes=(), build_dir=None):
2622
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1004
    """Recursively copy a directory tree using copy2().
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1005
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1006
    The destination directory must not already exist.
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1007
    If exception(s) occur, an Error is raised with a list of reasons.
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1008
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1009
    If the optional symlinks flag is true, symbolic links in the
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1010
    source tree result in symbolic links in the destination tree; if
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1011
    it is false, the contents of the files pointed to by symbolic
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1012
    links are copied.
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1013
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1014
    XXX Consider this example code rather than the ultimate tool.
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1015
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1016
    Note: this is a modified version of shutil.copytree from python
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1017
    2.5.2 library; modified for WAF purposes to exclude dot dirs and
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1018
    another list of files.
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1019
    """
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1020
    names = os.listdir(src)
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1021
    os.makedirs(dst)
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1022
    errors = []
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1023
    for name in names:
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1024
        srcname = os.path.join(src, name)
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1025
        dstname = os.path.join(dst, name)
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1026
        try:
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1027
            if symlinks and os.path.islink(srcname):
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1028
                linkto = os.readlink(srcname)
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1029
                os.symlink(linkto, dstname)
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1030
            elif os.path.isdir(srcname):
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1031
                if name in excludes:
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1032
                    continue
3867
e29698e2e158 Bug 387: Build fails with junk subdirectories in "scratch" directory
Andrey Hippo <ahippo@yandex.ru>
parents: 3866
diff changeset
  1033
                elif name.startswith('.') or name.startswith(',,') or name.startswith('++') or name.startswith('CVS'):
2622
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1034
                    continue
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1035
                elif name == build_dir:
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1036
                    continue
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1037
                else:
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1038
                    ## build_dir is not passed into the recursive
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1039
                    ## copytree, but that is intentional; it is a
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1040
                    ## directory name valid only at the top level.
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1041
                    copytree(srcname, dstname, symlinks, excludes)
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1042
            else:
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1043
                ends = name.endswith
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1044
                to_remove = False
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1045
                if name.startswith('.') or name.startswith('++'):
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1046
                    to_remove = True
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1047
                else:
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
  1048
                    for x in dist_exts:
2622
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1049
                        if ends(x):
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1050
                            to_remove = True
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1051
                            break
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1052
                if not to_remove:
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1053
                    shutil.copy2(srcname, dstname)
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1054
            # XXX What about devices, sockets etc.?
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1055
        except (IOError, os.error), why:
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1056
            errors.append((srcname, dstname, str(why)))
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1057
        # catch the Error from the recursive copytree so that we can
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1058
        # continue with other files
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1059
        except shutil.Error, err:
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1060
            errors.extend(err.args[0])
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1061
    try:
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1062
        shutil.copystat(src, dst)
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1063
    except WindowsError:
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1064
        # can't copy file access times on Windows
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1065
        pass
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1066
    except OSError, why:
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1067
        errors.extend((src, dst, str(why)))
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1068
    if errors:
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1069
        raise shutil.Error, errors
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1070
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1071
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1072
def DistDir(appname, version):
4326
179f86838e62 Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4202
diff changeset
  1073
    #"make a distribution directory with all the sources in it"
2622
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1074
    import shutil
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1075
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1076
    # Our temporary folder where to put our files
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1077
    TMPFOLDER=appname+'-'+version
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1078
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1079
    # Remove an old package directory
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1080
    if os.path.exists(TMPFOLDER): shutil.rmtree(TMPFOLDER)
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1081
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1082
    global g_dist_exts, g_excludes
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1083
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1084
    # Remove the Build dir
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1085
    build_dir = getattr(Utils.g_module, BLDDIR, None)
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1086
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1087
    # Copy everything into the new folder
4326
179f86838e62 Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4202
diff changeset
  1088
    _copytree('.', TMPFOLDER, excludes=excludes, build_dir=build_dir)
2622
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1089
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1090
    # TODO undocumented hook
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1091
    dist_hook = getattr(Utils.g_module, 'dist_hook', None)
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1092
    if dist_hook:
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1093
        os.chdir(TMPFOLDER)
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1094
        try:
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1095
            dist_hook()
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1096
        finally:
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1097
            # go back to the root directory
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1098
            os.chdir('..')
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1099
    return TMPFOLDER
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1100
6440851b111a Make waf dist much more efficient.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2345
diff changeset
  1101
Scripting.DistDir = DistDir
2881
81d1080cd0ae Integrate regression testing into the main waf script.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2866
diff changeset
  1102
81d1080cd0ae Integrate regression testing into the main waf script.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2866
diff changeset
  1103