wscript
author Tom Henderson <tomh@tomh.org>
Thu, 30 Aug 2018 13:39:08 -0700
changeset 13764 ee1b8a17f63a
parent 13763 4b8dcdcf3129
child 13804 892d48b8900d
permissions -rw-r--r--
tcp: Update status of NSC TCP in manual
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
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11544
diff changeset
     4
from __future__ import print_function
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
     5
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
     6
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
     7
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
     8
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
     9
import os.path
4450
0ca9b9b410a0 bug 567: --enable-static does not work on i686
Andrey Hippo <ahippo@yandex.ru>
parents: 4447
diff changeset
    10
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
    11
import shlex
9277
0f87d1cb030c Upgrade waf to 1.7.10 and fix included wscripts
Vedran Miletić <rivanvx@gmail.com>
parents: 9261
diff changeset
    12
import subprocess
7088
3f0535480de9 Bug 1110 - Sort alphabetically and display Modules built in columns
Mitch Watrous <watrous@u.washington.edu>
parents: 7066
diff changeset
    13
import textwrap
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
    14
9277
0f87d1cb030c Upgrade waf to 1.7.10 and fix included wscripts
Vedran Miletić <rivanvx@gmail.com>
parents: 9261
diff changeset
    15
from utils import read_config_file
0f87d1cb030c Upgrade waf to 1.7.10 and fix included wscripts
Vedran Miletić <rivanvx@gmail.com>
parents: 9261
diff changeset
    16
0f87d1cb030c Upgrade waf to 1.7.10 and fix included wscripts
Vedran Miletić <rivanvx@gmail.com>
parents: 9261
diff changeset
    17
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
    18
# WAF modules
9277
0f87d1cb030c Upgrade waf to 1.7.10 and fix included wscripts
Vedran Miletić <rivanvx@gmail.com>
parents: 9261
diff changeset
    19
from waflib import Utils, Scripting, Configure, Build, Options, TaskGen, Context, Task, Logs, Errors
7494
d93f5e8e0a59 waf-1.6: Mac OSX and other fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7493
diff changeset
    20
from waflib.Errors import WafError
d93f5e8e0a59 waf-1.6: Mac OSX and other fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7493
diff changeset
    21
9277
0f87d1cb030c Upgrade waf to 1.7.10 and fix included wscripts
Vedran Miletić <rivanvx@gmail.com>
parents: 9261
diff changeset
    22
0f87d1cb030c Upgrade waf to 1.7.10 and fix included wscripts
Vedran Miletić <rivanvx@gmail.com>
parents: 9261
diff changeset
    23
# local modules
0f87d1cb030c Upgrade waf to 1.7.10 and fix included wscripts
Vedran Miletić <rivanvx@gmail.com>
parents: 9261
diff changeset
    24
import wutils
0f87d1cb030c Upgrade waf to 1.7.10 and fix included wscripts
Vedran Miletić <rivanvx@gmail.com>
parents: 9261
diff changeset
    25
6857
d7db3cee241f Add parsing of ns-3 configuration file
Mitch Watrous <watrous@u.washington.edu>
parents: 6834
diff changeset
    26
7024
4392d52b3536 Make examples not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents: 7023
diff changeset
    27
# 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
    28
# 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
    29
modules_enabled  = ['all_modules']
7024
4392d52b3536 Make examples not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents: 7023
diff changeset
    30
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
    31
tests_enabled    = False
6857
d7db3cee241f Add parsing of ns-3 configuration file
Mitch Watrous <watrous@u.washington.edu>
parents: 6834
diff changeset
    32
13556
c00634af395e build: (fixes #2915) Enforce gcc minimum version
Tom Henderson <tomh@tomh.org>
parents: 13439
diff changeset
    33
# GCC minimum version requirements for C++11 support
c00634af395e build: (fixes #2915) Enforce gcc minimum version
Tom Henderson <tomh@tomh.org>
parents: 13439
diff changeset
    34
gcc_min_version = (4, 9, 2)
10790
b445436fd51f bug 1868: enable -Wstrict-overflow only for newer gcc versions
Tom Henderson <tomh@tomh.org>
parents: 10769
diff changeset
    35
11682
daa3bfadabef bug 2181: Xcode 7.0 (clang-602.0.53) errors
Tom Henderson <tomh@tomh.org>
parents: 11661
diff changeset
    36
# Bug 2181:  clang warnings about unused local typedefs and potentially
daa3bfadabef bug 2181: Xcode 7.0 (clang-602.0.53) errors
Tom Henderson <tomh@tomh.org>
parents: 11661
diff changeset
    37
# evaluated expressions affecting darwin clang/LLVM version 7.0.0 (Xcode 7)
daa3bfadabef bug 2181: Xcode 7.0 (clang-602.0.53) errors
Tom Henderson <tomh@tomh.org>
parents: 11661
diff changeset
    38
# or clang/LLVM version 3.6 or greater.  We must make this platform-specific.
daa3bfadabef bug 2181: Xcode 7.0 (clang-602.0.53) errors
Tom Henderson <tomh@tomh.org>
parents: 11661
diff changeset
    39
darwin_clang_version_warn_unused_local_typedefs = ('7', '0', '0')
daa3bfadabef bug 2181: Xcode 7.0 (clang-602.0.53) errors
Tom Henderson <tomh@tomh.org>
parents: 11661
diff changeset
    40
darwin_clang_version_warn_potentially_evaluated = ('7', '0', '0')
daa3bfadabef bug 2181: Xcode 7.0 (clang-602.0.53) errors
Tom Henderson <tomh@tomh.org>
parents: 11661
diff changeset
    41
clang_version_warn_unused_local_typedefs = ('3', '6', '0')
daa3bfadabef bug 2181: Xcode 7.0 (clang-602.0.53) errors
Tom Henderson <tomh@tomh.org>
parents: 11661
diff changeset
    42
clang_version_warn_potentially_evaluated = ('3', '6', '0')
daa3bfadabef bug 2181: Xcode 7.0 (clang-602.0.53) errors
Tom Henderson <tomh@tomh.org>
parents: 11661
diff changeset
    43
7023
af9c5ac72f2c Make examples and tests be enabled from the .ns3rc file
Mitch Watrous <watrous@u.washington.edu>
parents: 7019
diff changeset
    44
# 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
    45
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
    46
(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
    47
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
    48
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
    49
try:
3e8b3f2306c9 Upgrade to WAF 1.5.16. Fixes bug #855.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6254
diff changeset
    50
    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
    51
finally:
3e8b3f2306c9 Upgrade to WAF 1.5.16. Fixes bug #855.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6254
diff changeset
    52
    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
    53
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
    54
cflags.profiles = {
12236
fd72e9c4c558 wscript: replace tab indenting with spaces
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12179
diff changeset
    55
    # profile name: [optimization_level, warnings_level, debug_level]
fd72e9c4c558 wscript: replace tab indenting with spaces
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12179
diff changeset
    56
    'debug':     [0, 2, 3],
fd72e9c4c558 wscript: replace tab indenting with spaces
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12179
diff changeset
    57
    'optimized': [3, 2, 1],
fd72e9c4c558 wscript: replace tab indenting with spaces
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12179
diff changeset
    58
    'release':   [3, 2, 0],
fd72e9c4c558 wscript: replace tab indenting with spaces
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12179
diff changeset
    59
    }
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
    60
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
    61
7487
82cd20da9650 Upgrade to waf-1.6.7, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7463
diff changeset
    62
Configure.autoconfig = 0
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
    63
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
    64
# the following two variables are used by the target "waf dist"
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11544
diff changeset
    65
VERSION = open("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
    66
APPNAME = 'ns'
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
    67
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
    68
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
    69
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
    70
7688
6f5c9b870e45 Still Bug 1327: disable VNUM in libraries, fix the .pc file deps
Vedran Miletić
parents: 7682
diff changeset
    71
# we don't use VNUM anymore (see bug #1327 for details)
7463
53b784adf3f4 Bug 1251 - OSX: test.py reports dyld: Library not loaded
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7430
diff changeset
    72
wutils.VNUM = None
7320
7334aa839e46 Bug 1175 postfix: only enable vnum if the VERSION matches x.y(.z) dotted number format
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7293
diff changeset
    73
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
    74
# these variables are mandatory ('/' are converted automatically)
7488
72d0c878f3c7 More waf 1.6.7 build fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7487
diff changeset
    75
top = '.'
72d0c878f3c7 More waf 1.6.7 build fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7487
diff changeset
    76
out = 'build'
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
    77
4594
14ce84fd7ae3 make dist generation work again
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4550
diff changeset
    78
def load_env():
14ce84fd7ae3 make dist generation work again
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4550
diff changeset
    79
    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
    80
    bld_ctx = bld_cls()
14ce84fd7ae3 make dist generation work again
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4550
diff changeset
    81
    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
    82
                      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
    83
    bld_ctx.load_envs()
14ce84fd7ae3 make dist generation work again
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4550
diff changeset
    84
    env = bld_ctx.get_env()
14ce84fd7ae3 make dist generation work again
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4550
diff changeset
    85
    return env
14ce84fd7ae3 make dist generation work again
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4550
diff changeset
    86
14ce84fd7ae3 make dist generation work again
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4550
diff changeset
    87
def get_files(base_dir):
14ce84fd7ae3 make dist generation work again
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4550
diff changeset
    88
    retval = []
14ce84fd7ae3 make dist generation work again
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4550
diff changeset
    89
    reference=os.path.dirname(base_dir)
14ce84fd7ae3 make dist generation work again
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4550
diff changeset
    90
    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
    91
        if root.find('.hg') != -1:
14ce84fd7ae3 make dist generation work again
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4550
diff changeset
    92
            continue
14ce84fd7ae3 make dist generation work again
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4550
diff changeset
    93
        for file in files:
14ce84fd7ae3 make dist generation work again
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4550
diff changeset
    94
            if file.find('.hg') != -1:
14ce84fd7ae3 make dist generation work again
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4550
diff changeset
    95
                continue
14ce84fd7ae3 make dist generation work again
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4550
diff changeset
    96
            fullname = os.path.join(root,file)
14ce84fd7ae3 make dist generation work again
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4550
diff changeset
    97
            # 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
    98
            relname = fullname.replace(reference + '/','')
14ce84fd7ae3 make dist generation work again
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4550
diff changeset
    99
            retval.append([fullname,relname])
14ce84fd7ae3 make dist generation work again
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4550
diff changeset
   100
    return retval
14ce84fd7ae3 make dist generation work again
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4550
diff changeset
   101
2881
81d1080cd0ae Integrate regression testing into the main waf script.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2866
diff changeset
   102
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
   103
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
   104
    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
   105
    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
   106
    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
   107
    shutil.rmtree("nsc", True)
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   108
7293
0f574c532cee Make test module not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7291
diff changeset
   109
# Print the sorted list of module names in columns.
7291
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   110
def print_module_names(names):
7293
0f574c532cee Make test module not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7291
diff changeset
   111
    # Sort the list of module names.
0f574c532cee Make test module not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7291
diff changeset
   112
    names.sort()
7291
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   113
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   114
    # 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
   115
    i = 1
7293
0f574c532cee Make test module not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7291
diff changeset
   116
    for name in names:
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11544
diff changeset
   117
        print(name.ljust(25), end=' ')
7291
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   118
        if i == 3:
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11544
diff changeset
   119
                print()
7291
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   120
                i = 0
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   121
        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
   122
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   123
    if i != 1:
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11544
diff changeset
   124
        print()
7291
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   125
11661
68c0e7f87bdf additional Python 2/3 compatibility
Tom Henderson <tomh@tomh.org>
parents: 11650
diff changeset
   126
# return types of some APIs differ in Python 2/3 (type string vs class bytes)
68c0e7f87bdf additional Python 2/3 compatibility
Tom Henderson <tomh@tomh.org>
parents: 11650
diff changeset
   127
# This method will decode('utf-8') a byte object in Python 3, 
68c0e7f87bdf additional Python 2/3 compatibility
Tom Henderson <tomh@tomh.org>
parents: 11650
diff changeset
   128
# and do nothing in Python 2
68c0e7f87bdf additional Python 2/3 compatibility
Tom Henderson <tomh@tomh.org>
parents: 11650
diff changeset
   129
def maybe_decode(input):
68c0e7f87bdf additional Python 2/3 compatibility
Tom Henderson <tomh@tomh.org>
parents: 11650
diff changeset
   130
    if sys.version_info < (3,):
68c0e7f87bdf additional Python 2/3 compatibility
Tom Henderson <tomh@tomh.org>
parents: 11650
diff changeset
   131
        return input
68c0e7f87bdf additional Python 2/3 compatibility
Tom Henderson <tomh@tomh.org>
parents: 11650
diff changeset
   132
    else:
68c0e7f87bdf additional Python 2/3 compatibility
Tom Henderson <tomh@tomh.org>
parents: 11650
diff changeset
   133
        try:
68c0e7f87bdf additional Python 2/3 compatibility
Tom Henderson <tomh@tomh.org>
parents: 11650
diff changeset
   134
            return input.decode('utf-8')
68c0e7f87bdf additional Python 2/3 compatibility
Tom Henderson <tomh@tomh.org>
parents: 11650
diff changeset
   135
        except:
68c0e7f87bdf additional Python 2/3 compatibility
Tom Henderson <tomh@tomh.org>
parents: 11650
diff changeset
   136
            sys.exc_clear()
68c0e7f87bdf additional Python 2/3 compatibility
Tom Henderson <tomh@tomh.org>
parents: 11650
diff changeset
   137
            return input
68c0e7f87bdf additional Python 2/3 compatibility
Tom Henderson <tomh@tomh.org>
parents: 11650
diff changeset
   138
7487
82cd20da9650 Upgrade to waf-1.6.7, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7463
diff changeset
   139
def options(opt):
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   140
    # options provided by the modules
7487
82cd20da9650 Upgrade to waf-1.6.7, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7463
diff changeset
   141
    opt.load('compiler_c')
82cd20da9650 Upgrade to waf-1.6.7, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7463
diff changeset
   142
    opt.load('compiler_cxx')
82cd20da9650 Upgrade to waf-1.6.7, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7463
diff changeset
   143
    opt.load('cflags')
82cd20da9650 Upgrade to waf-1.6.7, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7463
diff changeset
   144
    opt.load('gnu_dirs')
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   145
12329
e0d961707c93 build: (fixes #2459) Add ./waf --check-config option to reprint the summary
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12321
diff changeset
   146
    opt.add_option('--check-config',
e0d961707c93 build: (fixes #2459) Add ./waf --check-config option to reprint the summary
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12321
diff changeset
   147
                   help=('Print the current configuration.'),
e0d961707c93 build: (fixes #2459) Add ./waf --check-config option to reprint the summary
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12321
diff changeset
   148
                   action="store_true", default=False,
e0d961707c93 build: (fixes #2459) Add ./waf --check-config option to reprint the summary
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12321
diff changeset
   149
                   dest="check_config")
e0d961707c93 build: (fixes #2459) Add ./waf --check-config option to reprint the summary
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12321
diff changeset
   150
    
2846
7689461231ac start of regression tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 2622
diff changeset
   151
    opt.add_option('--cwd',
7689461231ac start of regression tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 2622
diff changeset
   152
                   help=('Set the working directory for a program.'),
7689461231ac start of regression tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 2622
diff changeset
   153
                   action="store", type="string", default=None,
7689461231ac start of regression tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 2622
diff changeset
   154
                   dest='cwd_launch')
7689461231ac start of regression tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 2622
diff changeset
   155
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   156
    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
   157
                   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
   158
                         ' 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
   159
                         'with the configure command.'),
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   160
                   action="store_true", default=False,
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   161
                   dest='enable_gcov')
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   162
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
   163
    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
   164
                   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
   165
                         "  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
   166
                         " 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
   167
                   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
   168
                   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
   169
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   170
    opt.add_option('--lcov-report',
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   171
                   help=('Generate a code coverage report '
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   172
                         '(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
   173
                   action="store_true", default=False,
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   174
                   dest='lcov_report')
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   175
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
   176
    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
   177
                   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
   178
                         ' 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
   179
                   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
   180
    opt.add_option('--visualize',
8a57344a8d09 Codereview Issue 2692041: Add pyviz module
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6670
diff changeset
   181
                   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
   182
                   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
   183
    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
   184
                   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
   185
                         ' 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
   186
                         ' 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
   187
                   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
   188
    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
   189
                   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
   190
                         ' 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
   191
                         ' 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
   192
                   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
   193
    opt.add_option('--valgrind',
d841cca00990 Add a --valgrind WAF option (bug #124)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2178
diff changeset
   194
                   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
   195
                   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
   196
                   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
   197
    opt.add_option('--shell',
4326
179f86838e62 Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4202
diff changeset
   198
                   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
   199
                   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
   200
                   dest='shell')
4164
1f6ae48061a9 checkpoint tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents: 4119
diff changeset
   201
    opt.add_option('--enable-sudo',
1f6ae48061a9 checkpoint tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents: 4119
diff changeset
   202
                   help=('Use sudo to setup suid bits on ns3 executables.'),
1f6ae48061a9 checkpoint tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents: 4119
diff changeset
   203
                   dest='enable_sudo', action='store_true',
1f6ae48061a9 checkpoint tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents: 4119
diff changeset
   204
                   default=False)
6998
1c2b8cfb71d2 Make tests not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents: 6981
diff changeset
   205
    opt.add_option('--enable-tests',
1c2b8cfb71d2 Make tests not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents: 6981
diff changeset
   206
                   help=('Build the ns-3 tests.'),
1c2b8cfb71d2 Make tests not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents: 6981
diff changeset
   207
                   dest='enable_tests', action='store_true',
1c2b8cfb71d2 Make tests not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents: 6981
diff changeset
   208
                   default=False)
1c2b8cfb71d2 Make tests not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents: 6981
diff changeset
   209
    opt.add_option('--disable-tests',
1c2b8cfb71d2 Make tests not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents: 6981
diff changeset
   210
                   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
   211
                   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
   212
                   default=False)
5369
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5368
diff changeset
   213
    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
   214
                   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
   215
                   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
   216
                   default=False)
5369
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5368
diff changeset
   217
    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
   218
                   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
   219
                   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
   220
                   default=False)
4531
14a102415139 Run unit tests as indenpendent WAF tasks
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4450
diff changeset
   221
    opt.add_option('--check',
5361
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5252
diff changeset
   222
                   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
   223
                   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
   224
    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
   225
                   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
   226
                   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
   227
                   default=False)
6113
0ce37bf4f1c1 Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents: 6099
diff changeset
   228
    opt.add_option('--enable-mpi',
0ce37bf4f1c1 Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents: 6099
diff changeset
   229
                   help=('Compile NS-3 with MPI and distributed simulation support'),
0ce37bf4f1c1 Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents: 6099
diff changeset
   230
                   dest='enable_mpi', action='store_true',
0ce37bf4f1c1 Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents: 6099
diff changeset
   231
                   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
   232
    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
   233
                   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
   234
                         '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
   235
                   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
   236
                   dest='doxygen_no_build')
12297
45c08cbed1f9 DES Metrics implementation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12236
diff changeset
   237
    opt.add_option('--enable-des-metrics',
45c08cbed1f9 DES Metrics implementation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12236
diff changeset
   238
                   help=('Log all events in a json file with the name of the executable (which must call CommandLine::Parse(argc, argv)'),
45c08cbed1f9 DES Metrics implementation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12236
diff changeset
   239
                   action="store_true", default=False,
45c08cbed1f9 DES Metrics implementation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12236
diff changeset
   240
                   dest='enable_desmetrics')
13192
6bb0ee10c0d6 build: (fixes 2800) Add CXX standard to use; default to c++11
Ryan Mast <mast9@llnl.gov>
parents: 13089
diff changeset
   241
    opt.add_option('--cxx-standard',
6bb0ee10c0d6 build: (fixes 2800) Add CXX standard to use; default to c++11
Ryan Mast <mast9@llnl.gov>
parents: 13089
diff changeset
   242
                   help=('Compile NS-3 with the given C++ standard'),
6bb0ee10c0d6 build: (fixes 2800) Add CXX standard to use; default to c++11
Ryan Mast <mast9@llnl.gov>
parents: 13089
diff changeset
   243
                   type='string', default='-std=c++11', dest='cxx_standard')
2881
81d1080cd0ae Integrate regression testing into the main waf script.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2866
diff changeset
   244
5468
6eebad1fb54d Bring back the --doxygen-no-build option from the dead.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5463
diff changeset
   245
    # options provided in subdirectories
9277
0f87d1cb030c Upgrade waf to 1.7.10 and fix included wscripts
Vedran Miletić <rivanvx@gmail.com>
parents: 9261
diff changeset
   246
    opt.recurse('src')
0f87d1cb030c Upgrade waf to 1.7.10 and fix included wscripts
Vedran Miletić <rivanvx@gmail.com>
parents: 9261
diff changeset
   247
    opt.recurse('bindings/python')
0f87d1cb030c Upgrade waf to 1.7.10 and fix included wscripts
Vedran Miletić <rivanvx@gmail.com>
parents: 9261
diff changeset
   248
    opt.recurse('src/internet')
12808
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   249
    opt.recurse('contrib')
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   250
7539
fd2a26e455b3 Determine whether static can be enabled based on link flags tests rather than a hardcoded whitelist of supported platforms
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7538
diff changeset
   251
def _check_compilation_flag(conf, flag, mode='cxx', linkflags=None):
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
   252
    """
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
   253
    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
   254
    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
   255
    """
7539
fd2a26e455b3 Determine whether static can be enabled based on link flags tests rather than a hardcoded whitelist of supported platforms
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7538
diff changeset
   256
    l = []
fd2a26e455b3 Determine whether static can be enabled based on link flags tests rather than a hardcoded whitelist of supported platforms
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7538
diff changeset
   257
    if flag:
fd2a26e455b3 Determine whether static can be enabled based on link flags tests rather than a hardcoded whitelist of supported platforms
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7538
diff changeset
   258
        l.append(flag)
fd2a26e455b3 Determine whether static can be enabled based on link flags tests rather than a hardcoded whitelist of supported platforms
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7538
diff changeset
   259
    if isinstance(linkflags, list):
fd2a26e455b3 Determine whether static can be enabled based on link flags tests rather than a hardcoded whitelist of supported platforms
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7538
diff changeset
   260
        l.extend(linkflags)
fd2a26e455b3 Determine whether static can be enabled based on link flags tests rather than a hardcoded whitelist of supported platforms
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7538
diff changeset
   261
    else:
fd2a26e455b3 Determine whether static can be enabled based on link flags tests rather than a hardcoded whitelist of supported platforms
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7538
diff changeset
   262
        if linkflags:
fd2a26e455b3 Determine whether static can be enabled based on link flags tests rather than a hardcoded whitelist of supported platforms
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7538
diff changeset
   263
            l.append(linkflags)
fd2a26e455b3 Determine whether static can be enabled based on link flags tests rather than a hardcoded whitelist of supported platforms
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7538
diff changeset
   264
    if len(l) > 1:
fd2a26e455b3 Determine whether static can be enabled based on link flags tests rather than a hardcoded whitelist of supported platforms
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7538
diff changeset
   265
        flag_str = 'flags ' + ' '.join(l)
fd2a26e455b3 Determine whether static can be enabled based on link flags tests rather than a hardcoded whitelist of supported platforms
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7538
diff changeset
   266
    else:
fd2a26e455b3 Determine whether static can be enabled based on link flags tests rather than a hardcoded whitelist of supported platforms
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7538
diff changeset
   267
        flag_str = 'flag ' + ' '.join(l)
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11544
diff changeset
   268
    if len(flag_str) > 28:
7539
fd2a26e455b3 Determine whether static can be enabled based on link flags tests rather than a hardcoded whitelist of supported platforms
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7538
diff changeset
   269
        flag_str = flag_str[:28] + "..."
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
   270
7539
fd2a26e455b3 Determine whether static can be enabled based on link flags tests rather than a hardcoded whitelist of supported platforms
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7538
diff changeset
   271
    conf.start_msg('Checking for compilation %s support' % (flag_str,))
9277
0f87d1cb030c Upgrade waf to 1.7.10 and fix included wscripts
Vedran Miletić <rivanvx@gmail.com>
parents: 9261
diff changeset
   272
    env = conf.env.derive()
7539
fd2a26e455b3 Determine whether static can be enabled based on link flags tests rather than a hardcoded whitelist of supported platforms
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7538
diff changeset
   273
11457
5f76cbf2850b Update Waf to 1.8.11
Matthieu Coudron <mattator@gmail.com>
parents: 11276
diff changeset
   274
    retval = False
7539
fd2a26e455b3 Determine whether static can be enabled based on link flags tests rather than a hardcoded whitelist of supported platforms
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7538
diff changeset
   275
    if mode == 'cc':
fd2a26e455b3 Determine whether static can be enabled based on link flags tests rather than a hardcoded whitelist of supported platforms
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7538
diff changeset
   276
        mode = 'c'
fd2a26e455b3 Determine whether static can be enabled based on link flags tests rather than a hardcoded whitelist of supported platforms
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7538
diff changeset
   277
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
   278
    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
   279
        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
   280
    else:
7539
fd2a26e455b3 Determine whether static can be enabled based on link flags tests rather than a hardcoded whitelist of supported platforms
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7538
diff changeset
   281
        env.append_value('CFLAGS', flag)
fd2a26e455b3 Determine whether static can be enabled based on link flags tests rather than a hardcoded whitelist of supported platforms
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7538
diff changeset
   282
fd2a26e455b3 Determine whether static can be enabled based on link flags tests rather than a hardcoded whitelist of supported platforms
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7538
diff changeset
   283
    if linkflags is not None:
fd2a26e455b3 Determine whether static can be enabled based on link flags tests rather than a hardcoded whitelist of supported platforms
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7538
diff changeset
   284
        env.append_value("LINKFLAGS", linkflags)
fd2a26e455b3 Determine whether static can be enabled based on link flags tests rather than a hardcoded whitelist of supported platforms
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7538
diff changeset
   285
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
   286
    try:
11476
77692ede4417 Use proper environment when checking for supported compiler flags
Vedran Miletić <rivanvx@gmail.com>
parents: 11475
diff changeset
   287
        retval = conf.check(compiler=mode, fragment='int main() { return 0; }', features='c', env=env)
9277
0f87d1cb030c Upgrade waf to 1.7.10 and fix included wscripts
Vedran Miletić <rivanvx@gmail.com>
parents: 9261
diff changeset
   288
    except Errors.ConfigurationError:
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
   289
        ok = False
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
   290
    else:
11457
5f76cbf2850b Update Waf to 1.8.11
Matthieu Coudron <mattator@gmail.com>
parents: 11276
diff changeset
   291
        ok = (retval == True)
7487
82cd20da9650 Upgrade to waf-1.6.7, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7463
diff changeset
   292
    conf.end_msg(ok)
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
   293
    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
   294
11457
5f76cbf2850b Update Waf to 1.8.11
Matthieu Coudron <mattator@gmail.com>
parents: 11276
diff changeset
   295
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
   296
def report_optional_feature(conf, name, caption, was_enabled, reason_not_enabled):
7487
82cd20da9650 Upgrade to waf-1.6.7, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7463
diff changeset
   297
    conf.env.append_value('NS3_OPTIONAL_FEATURES', [(name, caption, was_enabled, reason_not_enabled)])
82cd20da9650 Upgrade to waf-1.6.7, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7463
diff changeset
   298
11457
5f76cbf2850b Update Waf to 1.8.11
Matthieu Coudron <mattator@gmail.com>
parents: 11276
diff changeset
   299
7712
e22640804bf7 Bug 1355 - visualizer dependencies not detected at buildtime
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7707
diff changeset
   300
def check_optional_feature(conf, name):
e22640804bf7 Bug 1355 - visualizer dependencies not detected at buildtime
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7707
diff changeset
   301
    for (name1, caption, was_enabled, reason_not_enabled) in conf.env.NS3_OPTIONAL_FEATURES:
e22640804bf7 Bug 1355 - visualizer dependencies not detected at buildtime
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7707
diff changeset
   302
        if name1 == name:
e22640804bf7 Bug 1355 - visualizer dependencies not detected at buildtime
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7707
diff changeset
   303
            return was_enabled
e22640804bf7 Bug 1355 - visualizer dependencies not detected at buildtime
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7707
diff changeset
   304
    raise KeyError("Feature %r not declared yet" % (name,))
7487
82cd20da9650 Upgrade to waf-1.6.7, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7463
diff changeset
   305
11457
5f76cbf2850b Update Waf to 1.8.11
Matthieu Coudron <mattator@gmail.com>
parents: 11276
diff changeset
   306
7487
82cd20da9650 Upgrade to waf-1.6.7, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7463
diff changeset
   307
# starting with waf 1.6, conf.check() becomes fatal by default if the
82cd20da9650 Upgrade to waf-1.6.7, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7463
diff changeset
   308
# test fails, this alternative method makes the test non-fatal, as it
82cd20da9650 Upgrade to waf-1.6.7, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7463
diff changeset
   309
# was in waf <= 1.5
82cd20da9650 Upgrade to waf-1.6.7, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7463
diff changeset
   310
def _check_nonfatal(conf, *args, **kwargs):
82cd20da9650 Upgrade to waf-1.6.7, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7463
diff changeset
   311
    try:
82cd20da9650 Upgrade to waf-1.6.7, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7463
diff changeset
   312
        return conf.check(*args, **kwargs)
82cd20da9650 Upgrade to waf-1.6.7, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7463
diff changeset
   313
    except conf.errors.ConfigurationError:
82cd20da9650 Upgrade to waf-1.6.7, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7463
diff changeset
   314
        return None
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
   315
12329
e0d961707c93 build: (fixes #2459) Add ./waf --check-config option to reprint the summary
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12321
diff changeset
   316
# Write a summary of optional features status
e0d961707c93 build: (fixes #2459) Add ./waf --check-config option to reprint the summary
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12321
diff changeset
   317
def print_config(env, phase='configure'):
e0d961707c93 build: (fixes #2459) Add ./waf --check-config option to reprint the summary
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12321
diff changeset
   318
    if phase == 'configure':
e0d961707c93 build: (fixes #2459) Add ./waf --check-config option to reprint the summary
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12321
diff changeset
   319
        profile = get_build_profile(env)
e0d961707c93 build: (fixes #2459) Add ./waf --check-config option to reprint the summary
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12321
diff changeset
   320
    else:
e0d961707c93 build: (fixes #2459) Add ./waf --check-config option to reprint the summary
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12321
diff changeset
   321
        profile = get_build_profile()
e0d961707c93 build: (fixes #2459) Add ./waf --check-config option to reprint the summary
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12321
diff changeset
   322
        
e0d961707c93 build: (fixes #2459) Add ./waf --check-config option to reprint the summary
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12321
diff changeset
   323
    print("---- Summary of optional NS-3 features:")
e0d961707c93 build: (fixes #2459) Add ./waf --check-config option to reprint the summary
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12321
diff changeset
   324
    print("%-30s: %s%s%s" % ("Build profile", Logs.colors('GREEN'),
e0d961707c93 build: (fixes #2459) Add ./waf --check-config option to reprint the summary
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12321
diff changeset
   325
                             profile, Logs.colors('NORMAL')))
e0d961707c93 build: (fixes #2459) Add ./waf --check-config option to reprint the summary
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12321
diff changeset
   326
    bld = wutils.bld
e0d961707c93 build: (fixes #2459) Add ./waf --check-config option to reprint the summary
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12321
diff changeset
   327
    print("%-30s: %s%s%s" % ("Build directory", Logs.colors('GREEN'),
e0d961707c93 build: (fixes #2459) Add ./waf --check-config option to reprint the summary
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12321
diff changeset
   328
                             Options.options.out, Logs.colors('NORMAL')))
e0d961707c93 build: (fixes #2459) Add ./waf --check-config option to reprint the summary
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12321
diff changeset
   329
    
e0d961707c93 build: (fixes #2459) Add ./waf --check-config option to reprint the summary
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12321
diff changeset
   330
    
e0d961707c93 build: (fixes #2459) Add ./waf --check-config option to reprint the summary
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12321
diff changeset
   331
    for (name, caption, was_enabled, reason_not_enabled) in sorted(env['NS3_OPTIONAL_FEATURES'], key=lambda s : s[1]):
e0d961707c93 build: (fixes #2459) Add ./waf --check-config option to reprint the summary
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12321
diff changeset
   332
        if was_enabled:
e0d961707c93 build: (fixes #2459) Add ./waf --check-config option to reprint the summary
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12321
diff changeset
   333
            status = 'enabled'
e0d961707c93 build: (fixes #2459) Add ./waf --check-config option to reprint the summary
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12321
diff changeset
   334
            color = 'GREEN'
e0d961707c93 build: (fixes #2459) Add ./waf --check-config option to reprint the summary
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12321
diff changeset
   335
        else:
e0d961707c93 build: (fixes #2459) Add ./waf --check-config option to reprint the summary
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12321
diff changeset
   336
            status = 'not enabled (%s)' % reason_not_enabled
e0d961707c93 build: (fixes #2459) Add ./waf --check-config option to reprint the summary
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12321
diff changeset
   337
            color = 'RED'
e0d961707c93 build: (fixes #2459) Add ./waf --check-config option to reprint the summary
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12321
diff changeset
   338
        print("%-30s: %s%s%s" % (caption, Logs.colors(color), status, Logs.colors('NORMAL')))
11457
5f76cbf2850b Update Waf to 1.8.11
Matthieu Coudron <mattator@gmail.com>
parents: 11276
diff changeset
   339
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   340
def configure(conf):
9277
0f87d1cb030c Upgrade waf to 1.7.10 and fix included wscripts
Vedran Miletić <rivanvx@gmail.com>
parents: 9261
diff changeset
   341
    conf.load('relocation', tooldir=['waf-tools'])
7544
51f8237d285a Bug 1265 - Make ns-3 directory "movable"
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7539
diff changeset
   342
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
   343
    # attach some extra methods
7487
82cd20da9650 Upgrade to waf-1.6.7, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7463
diff changeset
   344
    conf.check_nonfatal = types.MethodType(_check_nonfatal, conf)
4326
179f86838e62 Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4202
diff changeset
   345
    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
   346
    conf.report_optional_feature = types.MethodType(report_optional_feature, conf)
7712
e22640804bf7 Bug 1355 - visualizer dependencies not detected at buildtime
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7707
diff changeset
   347
    conf.check_optional_feature = types.MethodType(check_optional_feature, 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
   348
    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
   349
9277
0f87d1cb030c Upgrade waf to 1.7.10 and fix included wscripts
Vedran Miletić <rivanvx@gmail.com>
parents: 9261
diff changeset
   350
    conf.load('compiler_c')
11457
5f76cbf2850b Update Waf to 1.8.11
Matthieu Coudron <mattator@gmail.com>
parents: 11276
diff changeset
   351
    cc_string = '.'.join(conf.env['CC_VERSION'])
9974
ea69d1cc3e46 display gcc version in waf configure
Tom Henderson <tomh@tomh.org>
parents: 9909
diff changeset
   352
    conf.msg('Checking for cc version',cc_string,'GREEN')
9277
0f87d1cb030c Upgrade waf to 1.7.10 and fix included wscripts
Vedran Miletić <rivanvx@gmail.com>
parents: 9261
diff changeset
   353
    conf.load('compiler_cxx')
0f87d1cb030c Upgrade waf to 1.7.10 and fix included wscripts
Vedran Miletić <rivanvx@gmail.com>
parents: 9261
diff changeset
   354
    conf.load('cflags', tooldir=['waf-tools'])
0f87d1cb030c Upgrade waf to 1.7.10 and fix included wscripts
Vedran Miletić <rivanvx@gmail.com>
parents: 9261
diff changeset
   355
    conf.load('command', tooldir=['waf-tools'])
0f87d1cb030c Upgrade waf to 1.7.10 and fix included wscripts
Vedran Miletić <rivanvx@gmail.com>
parents: 9261
diff changeset
   356
    conf.load('gnu_dirs')
11457
5f76cbf2850b Update Waf to 1.8.11
Matthieu Coudron <mattator@gmail.com>
parents: 11276
diff changeset
   357
    conf.load('clang_compilation_database', tooldir=['waf-tools'])
7345
850237ab2111 Bug 1199 - waf install doesn't work on x86_64
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7337
diff changeset
   358
7487
82cd20da9650 Upgrade to waf-1.6.7, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7463
diff changeset
   359
    env = conf.env
4594
14ce84fd7ae3 make dist generation work again
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4550
diff changeset
   360
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
   361
    if Options.options.enable_gcov:
7493
3bbefa91e694 Fix the --lcov-report option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7492
diff changeset
   362
        env['GCOV_ENABLED'] = True
7487
82cd20da9650 Upgrade to waf-1.6.7, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7463
diff changeset
   363
        env.append_value('CCFLAGS', '-fprofile-arcs')
82cd20da9650 Upgrade to waf-1.6.7, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7463
diff changeset
   364
        env.append_value('CCFLAGS', '-ftest-coverage')
82cd20da9650 Upgrade to waf-1.6.7, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7463
diff changeset
   365
        env.append_value('CXXFLAGS', '-fprofile-arcs')
82cd20da9650 Upgrade to waf-1.6.7, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7463
diff changeset
   366
        env.append_value('CXXFLAGS', '-ftest-coverage')
7551
5d13d02dae0f Update lcov to version 1.9
Tom Henderson <tomh@tomh.org>
parents: 7544
diff changeset
   367
        env.append_value('LINKFLAGS', '-lgcov')
11067
9a2e40812460 bug 1583: fix ./waf configure --enable-gcov
Tom Henderson <tomh@tomh.org>
parents: 10800
diff changeset
   368
        env.append_value('LINKFLAGS', '-coverage')
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   369
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
   370
    if Options.options.build_profile == 'debug':
11544
cfaf2d65b33c Build profile macros
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11476
diff changeset
   371
        env.append_value('DEFINES', 'NS3_BUILD_PROFILE_DEBUG')
7494
d93f5e8e0a59 waf-1.6: Mac OSX and other fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7493
diff changeset
   372
        env.append_value('DEFINES', 'NS3_ASSERT_ENABLE')
d93f5e8e0a59 waf-1.6: Mac OSX and other fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7493
diff changeset
   373
        env.append_value('DEFINES', '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
   374
11544
cfaf2d65b33c Build profile macros
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11476
diff changeset
   375
    if Options.options.build_profile == 'release':
cfaf2d65b33c Build profile macros
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11476
diff changeset
   376
        env.append_value('DEFINES', 'NS3_BUILD_PROFILE_RELEASE')
cfaf2d65b33c Build profile macros
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11476
diff changeset
   377
cfaf2d65b33c Build profile macros
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11476
diff changeset
   378
    if Options.options.build_profile == 'optimized':
cfaf2d65b33c Build profile macros
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11476
diff changeset
   379
        env.append_value('DEFINES', 'NS3_BUILD_PROFILE_OPTIMIZED')
cfaf2d65b33c Build profile macros
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11476
diff changeset
   380
4190
b6734a5d920c work around to allow FreeBSD to run tap-bridge
Craig Dowell <craigdo@ee.washington.edu>
parents: 4179
diff changeset
   381
    env['PLATFORM'] = sys.platform
7681
0873edb445e8 Bug 1327 - Version installed ns-3 files
Gustavo Carneiro / Vedran Miletić
parents: 7645
diff changeset
   382
    env['BUILD_PROFILE'] = Options.options.build_profile
8894
90d67c5e8255 Bug 1445 - When build with "-d release", don't suffix "-release"
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 8848
diff changeset
   383
    if Options.options.build_profile == "release":
90d67c5e8255 Bug 1445 - When build with "-d release", don't suffix "-release"
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 8848
diff changeset
   384
        env['BUILD_SUFFIX'] = ''
90d67c5e8255 Bug 1445 - When build with "-d release", don't suffix "-release"
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 8848
diff changeset
   385
    else:
90d67c5e8255 Bug 1445 - When build with "-d release", don't suffix "-release"
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 8848
diff changeset
   386
        env['BUILD_SUFFIX'] = '-'+Options.options.build_profile
90d67c5e8255 Bug 1445 - When build with "-d release", don't suffix "-release"
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 8848
diff changeset
   387
    
7682
8813ef4cec0f Bug 1339 - test.py uses the old name for the test runner
Mitch Watrous <watrous@u.washington.edu>
parents: 7681
diff changeset
   388
    env['APPNAME'] = wutils.APPNAME
8813ef4cec0f Bug 1339 - test.py uses the old name for the test runner
Mitch Watrous <watrous@u.washington.edu>
parents: 7681
diff changeset
   389
    env['VERSION'] = wutils.VERSION
4190
b6734a5d920c work around to allow FreeBSD to run tap-bridge
Craig Dowell <craigdo@ee.washington.edu>
parents: 4179
diff changeset
   390
13556
c00634af395e build: (fixes #2915) Enforce gcc minimum version
Tom Henderson <tomh@tomh.org>
parents: 13439
diff changeset
   391
    if conf.env['CXX_NAME'] in ['gcc']:
c00634af395e build: (fixes #2915) Enforce gcc minimum version
Tom Henderson <tomh@tomh.org>
parents: 13439
diff changeset
   392
        if tuple(map(int, conf.env['CC_VERSION'])) < gcc_min_version:
c00634af395e build: (fixes #2915) Enforce gcc minimum version
Tom Henderson <tomh@tomh.org>
parents: 13439
diff changeset
   393
            conf.fatal('gcc version %s older than minimum supported version %s' %
c00634af395e build: (fixes #2915) Enforce gcc minimum version
Tom Henderson <tomh@tomh.org>
parents: 13439
diff changeset
   394
                       ('.'.join(conf.env['CC_VERSION']), '.'.join(map(str, gcc_min_version))))
c00634af395e build: (fixes #2915) Enforce gcc minimum version
Tom Henderson <tomh@tomh.org>
parents: 13439
diff changeset
   395
5252
481053e0cd10 Bug 681: wrong compilation options for icpc (Intel C/C++ Compiler)
Andrey Mazo <mazo@iitp.ru>
parents: 5201
diff changeset
   396
    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
   397
        if Options.options.build_profile == 'release': 
f2f95faff5bb omit -march=native for <gcc-4.2;
Andrey Mazo <mazo@iitp.ru>
parents: 5454
diff changeset
   398
            env.append_value('CXXFLAGS', '-fomit-frame-pointer') 
8894
90d67c5e8255 Bug 1445 - When build with "-d release", don't suffix "-release"
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 8848
diff changeset
   399
        if Options.options.build_profile == 'optimized': 
5463
f2f95faff5bb omit -march=native for <gcc-4.2;
Andrey Mazo <mazo@iitp.ru>
parents: 5454
diff changeset
   400
            if conf.check_compilation_flag('-march=native'):
f2f95faff5bb omit -march=native for <gcc-4.2;
Andrey Mazo <mazo@iitp.ru>
parents: 5454
diff changeset
   401
                env.append_value('CXXFLAGS', '-march=native') 
10769
2a65963e27ac [Bug 1868] Optimized builds are sensitive to -fstrict-overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10604
diff changeset
   402
            env.append_value('CXXFLAGS', '-fstrict-overflow')
13556
c00634af395e build: (fixes #2915) Enforce gcc minimum version
Tom Henderson <tomh@tomh.org>
parents: 13439
diff changeset
   403
            if conf.env['CXX_NAME'] in ['gcc']:
12321
10ae5ec6a903 build: (partial fix #2499) relax -Wstrict-overflow to level 2
Tom Henderson <tomh@tomh.org>
parents: 12303
diff changeset
   404
                env.append_value('CXXFLAGS', '-Wstrict-overflow=2')
5463
f2f95faff5bb omit -march=native for <gcc-4.2;
Andrey Mazo <mazo@iitp.ru>
parents: 5454
diff changeset
   405
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
   406
        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
   407
            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
   408
        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
   409
            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
   410
9137
822abb428976 Allow using CXX='distcc g++' with ./waf configure.
Vedran Miletić <rivanvx@gmail.com>
parents: 9076
diff changeset
   411
        cxx = env['CXX']
9143
1573a6ddf0fe Fix bug introduced by changeset 9137:822abb428976 Allow using CXX='distcc g++' with ./waf configure.
Vedran Miletić <rivanvx@gmail.com>
parents: 9137
diff changeset
   412
        cxx_check_libstdcxx = cxx + ['-print-file-name=libstdc++.so']
9137
822abb428976 Allow using CXX='distcc g++' with ./waf configure.
Vedran Miletić <rivanvx@gmail.com>
parents: 9076
diff changeset
   413
        p = subprocess.Popen(cxx_check_libstdcxx, stdout=subprocess.PIPE)
11661
68c0e7f87bdf additional Python 2/3 compatibility
Tom Henderson <tomh@tomh.org>
parents: 11650
diff changeset
   414
        libstdcxx_output = maybe_decode(p.stdout.read().strip())
68c0e7f87bdf additional Python 2/3 compatibility
Tom Henderson <tomh@tomh.org>
parents: 11650
diff changeset
   415
        libstdcxx_location = os.path.dirname(libstdcxx_output)
4386
2e79cbd62d28 bug 553: Running code built with a special gcc
Gustavo Carneiro <gjcarneiro@gmail.com>
parents: 4369
diff changeset
   416
        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
   417
        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
   418
            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
   419
13751
434baa130664 build: Updating Waf 1.8.19 to 2.0.9
Steve Smith <smith84@llnl.gov>
parents: 13556
diff changeset
   420
        if Utils.unversioned_sys_platform() in ['linux']:
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
   421
            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
   422
                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
   423
11682
daa3bfadabef bug 2181: Xcode 7.0 (clang-602.0.53) errors
Tom Henderson <tomh@tomh.org>
parents: 11661
diff changeset
   424
    # bug 2181 on clang warning suppressions
daa3bfadabef bug 2181: Xcode 7.0 (clang-602.0.53) errors
Tom Henderson <tomh@tomh.org>
parents: 11661
diff changeset
   425
    if conf.env['CXX_NAME'] in ['clang']:
13762
7fe70ef74b90 build: Replace lingering instances of Options.platform
Tom Henderson <tomh@tomh.org>
parents: 13751
diff changeset
   426
        if Utils.unversioned_sys_platform() == 'darwin':
11682
daa3bfadabef bug 2181: Xcode 7.0 (clang-602.0.53) errors
Tom Henderson <tomh@tomh.org>
parents: 11661
diff changeset
   427
            if conf.env['CC_VERSION'] >= darwin_clang_version_warn_unused_local_typedefs:
daa3bfadabef bug 2181: Xcode 7.0 (clang-602.0.53) errors
Tom Henderson <tomh@tomh.org>
parents: 11661
diff changeset
   428
                env.append_value('CXXFLAGS', '-Wno-unused-local-typedefs')
daa3bfadabef bug 2181: Xcode 7.0 (clang-602.0.53) errors
Tom Henderson <tomh@tomh.org>
parents: 11661
diff changeset
   429
            if conf.env['CC_VERSION'] >= darwin_clang_version_warn_potentially_evaluated: 
daa3bfadabef bug 2181: Xcode 7.0 (clang-602.0.53) errors
Tom Henderson <tomh@tomh.org>
parents: 11661
diff changeset
   430
                env.append_value('CXXFLAGS', '-Wno-potentially-evaluated-expression')
daa3bfadabef bug 2181: Xcode 7.0 (clang-602.0.53) errors
Tom Henderson <tomh@tomh.org>
parents: 11661
diff changeset
   431
        else:
daa3bfadabef bug 2181: Xcode 7.0 (clang-602.0.53) errors
Tom Henderson <tomh@tomh.org>
parents: 11661
diff changeset
   432
            if conf.env['CC_VERSION'] >= clang_version_warn_unused_local_typedefs:
daa3bfadabef bug 2181: Xcode 7.0 (clang-602.0.53) errors
Tom Henderson <tomh@tomh.org>
parents: 11661
diff changeset
   433
                env.append_value('CXXFLAGS', '-Wno-unused-local-typedefs')
daa3bfadabef bug 2181: Xcode 7.0 (clang-602.0.53) errors
Tom Henderson <tomh@tomh.org>
parents: 11661
diff changeset
   434
            if conf.env['CC_VERSION'] >= clang_version_warn_potentially_evaluated: 
daa3bfadabef bug 2181: Xcode 7.0 (clang-602.0.53) errors
Tom Henderson <tomh@tomh.org>
parents: 11661
diff changeset
   435
                env.append_value('CXXFLAGS', '-Wno-potentially-evaluated-expression')
7291
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   436
    env['ENABLE_STATIC_NS3'] = False
7491
dea6f61d3247 Remove the --enable-shared-and-static option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7489
diff changeset
   437
    if Options.options.enable_static:
13762
7fe70ef74b90 build: Replace lingering instances of Options.platform
Tom Henderson <tomh@tomh.org>
parents: 13751
diff changeset
   438
        if Utils.unversioned_sys_platform() == 'darwin':
7539
fd2a26e455b3 Determine whether static can be enabled based on link flags tests rather than a hardcoded whitelist of supported platforms
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7538
diff changeset
   439
            if conf.check_compilation_flag(flag=[], linkflags=['-Wl,-all_load']):
7291
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   440
                conf.report_optional_feature("static", "Static build", True, '')
7539
fd2a26e455b3 Determine whether static can be enabled based on link flags tests rather than a hardcoded whitelist of supported platforms
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7538
diff changeset
   441
                env['ENABLE_STATIC_NS3'] = True
fd2a26e455b3 Determine whether static can be enabled based on link flags tests rather than a hardcoded whitelist of supported platforms
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7538
diff changeset
   442
            else:
fd2a26e455b3 Determine whether static can be enabled based on link flags tests rather than a hardcoded whitelist of supported platforms
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7538
diff changeset
   443
                conf.report_optional_feature("static", "Static build", False,
fd2a26e455b3 Determine whether static can be enabled based on link flags tests rather than a hardcoded whitelist of supported platforms
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7538
diff changeset
   444
                                             "Link flag -Wl,-all_load does not work")
fd2a26e455b3 Determine whether static can be enabled based on link flags tests rather than a hardcoded whitelist of supported platforms
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7538
diff changeset
   445
        else:
fd2a26e455b3 Determine whether static can be enabled based on link flags tests rather than a hardcoded whitelist of supported platforms
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7538
diff changeset
   446
            if conf.check_compilation_flag(flag=[], linkflags=['-Wl,--whole-archive,-Bstatic', '-Wl,-Bdynamic,--no-whole-archive']):
7291
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   447
                conf.report_optional_feature("static", "Static build", True, '')
7539
fd2a26e455b3 Determine whether static can be enabled based on link flags tests rather than a hardcoded whitelist of supported platforms
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7538
diff changeset
   448
                env['ENABLE_STATIC_NS3'] = True
fd2a26e455b3 Determine whether static can be enabled based on link flags tests rather than a hardcoded whitelist of supported platforms
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7538
diff changeset
   449
            else:
fd2a26e455b3 Determine whether static can be enabled based on link flags tests rather than a hardcoded whitelist of supported platforms
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7538
diff changeset
   450
                conf.report_optional_feature("static", "Static build", False,
fd2a26e455b3 Determine whether static can be enabled based on link flags tests rather than a hardcoded whitelist of supported platforms
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7538
diff changeset
   451
                                             "Link flag -Wl,--whole-archive,-Bstatic does not work")
7291
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   452
13192
6bb0ee10c0d6 build: (fixes 2800) Add CXX standard to use; default to c++11
Ryan Mast <mast9@llnl.gov>
parents: 13089
diff changeset
   453
    # Enables C++-11 support by default, unless user specified another option
6bb0ee10c0d6 build: (fixes 2800) Add CXX standard to use; default to c++11
Ryan Mast <mast9@llnl.gov>
parents: 13089
diff changeset
   454
    # Warn the user if the CXX Standard flag provided was not recognized  
6bb0ee10c0d6 build: (fixes 2800) Add CXX standard to use; default to c++11
Ryan Mast <mast9@llnl.gov>
parents: 13089
diff changeset
   455
    if conf.check_compilation_flag(Options.options.cxx_standard):
6bb0ee10c0d6 build: (fixes 2800) Add CXX standard to use; default to c++11
Ryan Mast <mast9@llnl.gov>
parents: 13089
diff changeset
   456
        env.append_value('CXXFLAGS', Options.options.cxx_standard)
6bb0ee10c0d6 build: (fixes 2800) Add CXX standard to use; default to c++11
Ryan Mast <mast9@llnl.gov>
parents: 13089
diff changeset
   457
    else:
6bb0ee10c0d6 build: (fixes 2800) Add CXX standard to use; default to c++11
Ryan Mast <mast9@llnl.gov>
parents: 13089
diff changeset
   458
        Logs.warn("CXX Standard flag " + Options.options.cxx_standard + " was not recognized, using compiler's default")
12144
9b1e40cd0a70 waf: (fixes #2270) Support -std=c++11 by default
Tom Henderson <tomh@tomh.org>
parents: 12098
diff changeset
   459
7636
58181e75d0f0 bug 1305 - do not list modules when exiting waf shell
Mitch Watrous <watrous@u.washington.edu>
parents: 7593
diff changeset
   460
    # Set this so that the lists won't be printed at the end of this
58181e75d0f0 bug 1305 - do not list modules when exiting waf shell
Mitch Watrous <watrous@u.washington.edu>
parents: 7593
diff changeset
   461
    # configure command.
58181e75d0f0 bug 1305 - do not list modules when exiting waf shell
Mitch Watrous <watrous@u.washington.edu>
parents: 7593
diff changeset
   462
    conf.env['PRINT_BUILT_MODULES_AT_END'] = False
58181e75d0f0 bug 1305 - do not list modules when exiting waf shell
Mitch Watrous <watrous@u.washington.edu>
parents: 7593
diff changeset
   463
7293
0f574c532cee Make test module not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7291
diff changeset
   464
    conf.env['MODULES_NOT_BUILT'] = []
0f574c532cee Make test module not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7291
diff changeset
   465
9277
0f87d1cb030c Upgrade waf to 1.7.10 and fix included wscripts
Vedran Miletić <rivanvx@gmail.com>
parents: 9261
diff changeset
   466
    conf.recurse('bindings/python')
7712
e22640804bf7 Bug 1355 - visualizer dependencies not detected at buildtime
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7707
diff changeset
   467
9277
0f87d1cb030c Upgrade waf to 1.7.10 and fix included wscripts
Vedran Miletić <rivanvx@gmail.com>
parents: 9261
diff changeset
   468
    conf.recurse('src')
12808
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   469
    conf.recurse('contrib')
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   470
6857
d7db3cee241f Add parsing of ns-3 configuration file
Mitch Watrous <watrous@u.washington.edu>
parents: 6834
diff changeset
   471
    # 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
   472
    if Options.options.enable_modules:
6857
d7db3cee241f Add parsing of ns-3 configuration file
Mitch Watrous <watrous@u.washington.edu>
parents: 6834
diff changeset
   473
        # Use the modules explicitly enabled. 
12808
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   474
        _enabled_mods = []
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   475
        _enabled_contrib_mods = []
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   476
        for mod in Options.options.enable_modules.split(','): 
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   477
            if mod in conf.env['NS3_MODULES'] and mod.startswith('ns3-'): 
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   478
                _enabled_mods.append(mod)
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   479
            elif 'ns3-' + mod in conf.env['NS3_MODULES']: 
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   480
                _enabled_mods.append('ns3-' + mod)
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   481
            elif mod in conf.env['NS3_CONTRIBUTED_MODULES'] and mod.startswith('ns3-'): 
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   482
                _enabled_contrib_mods.append(mod)
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   483
            elif 'ns3-' + mod in conf.env['NS3_CONTRIBUTED_MODULES']: 
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   484
                _enabled_contrib_mods.append('ns3-' + mod)
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   485
        conf.env['NS3_ENABLED_MODULES'] = _enabled_mods
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   486
        conf.env['NS3_ENABLED_CONTRIBUTED_MODULES'] = _enabled_contrib_mods
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   487
        
6857
d7db3cee241f Add parsing of ns-3 configuration file
Mitch Watrous <watrous@u.washington.edu>
parents: 6834
diff changeset
   488
    else:
d7db3cee241f Add parsing of ns-3 configuration file
Mitch Watrous <watrous@u.washington.edu>
parents: 6834
diff changeset
   489
        # 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
   490
        if modules_enabled[0] == 'all_modules':
d7db3cee241f Add parsing of ns-3 configuration file
Mitch Watrous <watrous@u.washington.edu>
parents: 6834
diff changeset
   491
            # Enable all modules if requested.
d7db3cee241f Add parsing of ns-3 configuration file
Mitch Watrous <watrous@u.washington.edu>
parents: 6834
diff changeset
   492
            conf.env['NS3_ENABLED_MODULES'] = conf.env['NS3_MODULES']
12808
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   493
            conf.env['NS3_ENABLED_CONTRIBUTED_MODULES'] = conf.env['NS3_CONTRIBUTED_MODULES']
6857
d7db3cee241f Add parsing of ns-3 configuration file
Mitch Watrous <watrous@u.washington.edu>
parents: 6834
diff changeset
   494
        else:
d7db3cee241f Add parsing of ns-3 configuration file
Mitch Watrous <watrous@u.washington.edu>
parents: 6834
diff changeset
   495
            # Enable the modules from the list.
12808
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   496
            _enabled_mods = []
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   497
            _enabled_contrib_mods = []
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   498
            for mod in modules_enabled: 
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   499
                if mod in conf.env['NS3_MODULES'] and mod.startswith('ns3-'): 
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   500
                    _enabled_mods.append(mod)
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   501
                elif 'ns3-' + mod in conf.env['NS3_MODULES']: 
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   502
                    _enabled_mods.append('ns3-' + mod)
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   503
                elif mod in conf.env['NS3_CONTRIBUTED_MODULES'] and mod.startswith('ns3-'): 
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   504
                    _enabled_contrib_mods.append(mod)
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   505
                elif 'ns3-' + mod in conf.env['NS3_CONTRIBUTED_MODULES']: 
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   506
                    _enabled_contrib_mods.append('ns3-' + mod)
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   507
            conf.env['NS3_ENABLED_MODULES'] = _enabled_mods
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   508
            conf.env['NS3_ENABLED_CONTRIBUTED_MODULES'] = _enabled_contrib_mods
7291
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   509
7293
0f574c532cee Make test module not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7291
diff changeset
   510
    # Add the template module to the list of enabled modules that
0f574c532cee Make test module not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7291
diff changeset
   511
    # should not be built if this is a static build on Darwin.  They
0f574c532cee Make test module not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7291
diff changeset
   512
    # don't work there for the template module, and this is probably
0f574c532cee Make test module not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7291
diff changeset
   513
    # because the template module has no source files.
0f574c532cee Make test module not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7291
diff changeset
   514
    if conf.env['ENABLE_STATIC_NS3'] and sys.platform == 'darwin':
0f574c532cee Make test module not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7291
diff changeset
   515
        conf.env['MODULES_NOT_BUILT'].append('template')
7291
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   516
7293
0f574c532cee Make test module not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7291
diff changeset
   517
    # Remove these modules from the list of enabled modules.
0f574c532cee Make test module not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7291
diff changeset
   518
    for not_built in conf.env['MODULES_NOT_BUILT']:
0f574c532cee Make test module not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7291
diff changeset
   519
        not_built_name = 'ns3-' + not_built
0f574c532cee Make test module not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7291
diff changeset
   520
        if not_built_name in conf.env['NS3_ENABLED_MODULES']:
0f574c532cee Make test module not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7291
diff changeset
   521
            conf.env['NS3_ENABLED_MODULES'].remove(not_built_name)
7291
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   522
            if not conf.env['NS3_ENABLED_MODULES']:
7496
ce1ec79d488c waf1.6: make the all_modules in src/wscript be automatically discovered
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7495
diff changeset
   523
                raise WafError('Exiting because the ' + not_built + ' module can not be built and it was the only one enabled.')
12808
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   524
        elif not_built_name in conf.env['NS3_ENABLED_CONTRIBUTED_MODULES']:
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   525
            conf.env['NS3_ENABLED_CONTRIBUTED_MODULES'].remove(not_built_name)
7291
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
   526
9277
0f87d1cb030c Upgrade waf to 1.7.10 and fix included wscripts
Vedran Miletić <rivanvx@gmail.com>
parents: 9261
diff changeset
   527
    conf.recurse('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
   528
3826
40c5841b616d merge in tap device
Craig Dowell <craigdo@ee.washington.edu>
parents: 3703
diff changeset
   529
    # for suid bits
7524
b5df4870db14 Don't fail on missing sudo or valgrind
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7518
diff changeset
   530
    try:
b5df4870db14 Don't fail on missing sudo or valgrind
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7518
diff changeset
   531
        conf.find_program('sudo', var='SUDO')
b5df4870db14 Don't fail on missing sudo or valgrind
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7518
diff changeset
   532
    except WafError:
b5df4870db14 Don't fail on missing sudo or valgrind
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7518
diff changeset
   533
        pass
3826
40c5841b616d merge in tap device
Craig Dowell <craigdo@ee.washington.edu>
parents: 3703
diff changeset
   534
4171
902589866374 teach enable-sudo to be a config time thing
Craig Dowell <craigdo@ee.washington.edu>
parents: 4164
diff changeset
   535
    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
   536
    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
   537
        env['ENABLE_SUDO'] = True
902589866374 teach enable-sudo to be a config time thing
Craig Dowell <craigdo@ee.washington.edu>
parents: 4164
diff changeset
   538
    else:
902589866374 teach enable-sudo to be a config time thing
Craig Dowell <craigdo@ee.washington.edu>
parents: 4164
diff changeset
   539
        env['ENABLE_SUDO'] = False
902589866374 teach enable-sudo to be a config time thing
Craig Dowell <craigdo@ee.washington.edu>
parents: 4164
diff changeset
   540
        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
   541
            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
   542
        else:
902589866374 teach enable-sudo to be a config time thing
Craig Dowell <craigdo@ee.washington.edu>
parents: 4164
diff changeset
   543
            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
   544
902589866374 teach enable-sudo to be a config time thing
Craig Dowell <craigdo@ee.washington.edu>
parents: 4164
diff changeset
   545
    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
   546
7023
af9c5ac72f2c Make examples and tests be enabled from the .ns3rc file
Mitch Watrous <watrous@u.washington.edu>
parents: 7019
diff changeset
   547
    # 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
   548
    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
   549
        # Tests were explicitly enabled. 
6998
1c2b8cfb71d2 Make tests not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents: 6981
diff changeset
   550
        env['ENABLE_TESTS'] = True
1c2b8cfb71d2 Make tests not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents: 6981
diff changeset
   551
        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
   552
    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
   553
        # Tests were explicitly disabled. 
6998
1c2b8cfb71d2 Make tests not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents: 6981
diff changeset
   554
        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
   555
        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
   556
    else:
af9c5ac72f2c Make examples and tests be enabled from the .ns3rc file
Mitch Watrous <watrous@u.washington.edu>
parents: 7019
diff changeset
   557
        # 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
   558
        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
   559
        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
   560
            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
   561
        elif tests_enabled:
af9c5ac72f2c Make examples and tests be enabled from the .ns3rc file
Mitch Watrous <watrous@u.washington.edu>
parents: 7019
diff changeset
   562
            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
   563
        else:
af9c5ac72f2c Make examples and tests be enabled from the .ns3rc file
Mitch Watrous <watrous@u.washington.edu>
parents: 7019
diff changeset
   564
            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
   565
12179
cd49c3198528 [core] Sort configuration report
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12144
diff changeset
   566
    conf.report_optional_feature("ENABLE_TESTS", "Tests", env['ENABLE_TESTS'], why_not_tests)
6998
1c2b8cfb71d2 Make tests not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents: 6981
diff changeset
   567
7023
af9c5ac72f2c Make examples and tests be enabled from the .ns3rc file
Mitch Watrous <watrous@u.washington.edu>
parents: 7019
diff changeset
   568
    # 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
   569
    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
   570
        # 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
   571
        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
   572
        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
   573
    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
   574
        # 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
   575
        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
   576
        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
   577
    else:
af9c5ac72f2c Make examples and tests be enabled from the .ns3rc file
Mitch Watrous <watrous@u.washington.edu>
parents: 7019
diff changeset
   578
        # 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
   579
        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
   580
        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
   581
            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
   582
        elif examples_enabled:
af9c5ac72f2c Make examples and tests be enabled from the .ns3rc file
Mitch Watrous <watrous@u.washington.edu>
parents: 7019
diff changeset
   583
            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
   584
        else:
af9c5ac72f2c Make examples and tests be enabled from the .ns3rc file
Mitch Watrous <watrous@u.washington.edu>
parents: 7019
diff changeset
   585
            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
   586
12179
cd49c3198528 [core] Sort configuration report
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12144
diff changeset
   587
    conf.report_optional_feature("ENABLE_EXAMPLES", "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
   588
                                 why_not_examples)
11650
7f374ac3b2f8 populate EXAMPLE_DIRECTORIES variable in the configuration cache for use by test.py
Tom Henderson <tomh@tomh.org>
parents: 11634
diff changeset
   589
    try:
7f374ac3b2f8 populate EXAMPLE_DIRECTORIES variable in the configuration cache for use by test.py
Tom Henderson <tomh@tomh.org>
parents: 11634
diff changeset
   590
        for dir in os.listdir('examples'):
7f374ac3b2f8 populate EXAMPLE_DIRECTORIES variable in the configuration cache for use by test.py
Tom Henderson <tomh@tomh.org>
parents: 11634
diff changeset
   591
            if dir.startswith('.') or dir == 'CVS':
7f374ac3b2f8 populate EXAMPLE_DIRECTORIES variable in the configuration cache for use by test.py
Tom Henderson <tomh@tomh.org>
parents: 11634
diff changeset
   592
                continue
7f374ac3b2f8 populate EXAMPLE_DIRECTORIES variable in the configuration cache for use by test.py
Tom Henderson <tomh@tomh.org>
parents: 11634
diff changeset
   593
            conf.env.append_value('EXAMPLE_DIRECTORIES', dir)
7f374ac3b2f8 populate EXAMPLE_DIRECTORIES variable in the configuration cache for use by test.py
Tom Henderson <tomh@tomh.org>
parents: 11634
diff changeset
   594
    except OSError:
7f374ac3b2f8 populate EXAMPLE_DIRECTORIES variable in the configuration cache for use by test.py
Tom Henderson <tomh@tomh.org>
parents: 11634
diff changeset
   595
        return
5369
86beb5869f67 split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents: 5368
diff changeset
   596
9832
02642e139f19 Bug 1695 - improve test.py output when -g selected without valgrind
Mitch Watrous <watrous@u.washington.edu>
parents: 9827
diff changeset
   597
    env['VALGRIND_FOUND'] = False
7524
b5df4870db14 Don't fail on missing sudo or valgrind
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7518
diff changeset
   598
    try:
b5df4870db14 Don't fail on missing sudo or valgrind
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7518
diff changeset
   599
        conf.find_program('valgrind', var='VALGRIND')
9832
02642e139f19 Bug 1695 - improve test.py output when -g selected without valgrind
Mitch Watrous <watrous@u.washington.edu>
parents: 9827
diff changeset
   600
        env['VALGRIND_FOUND'] = True
7524
b5df4870db14 Don't fail on missing sudo or valgrind
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7518
diff changeset
   601
    except WafError:
b5df4870db14 Don't fail on missing sudo or valgrind
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7518
diff changeset
   602
        pass
4119
9ffcf2400aa5 Bug #323: waf --valgrind doesn't check for valgrind first
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4118
diff changeset
   603
6913
54679ab32585 Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents: 6886
diff changeset
   604
    # 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
   605
    if env['ENABLE_STATIC_NS3']:
54679ab32585 Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents: 6886
diff changeset
   606
        if sys.platform == 'darwin':
9277
0f87d1cb030c Upgrade waf to 1.7.10 and fix included wscripts
Vedran Miletić <rivanvx@gmail.com>
parents: 9261
diff changeset
   607
            env.STLIB_MARKER = '-Wl,-all_load'
6913
54679ab32585 Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents: 6886
diff changeset
   608
        else:
9277
0f87d1cb030c Upgrade waf to 1.7.10 and fix included wscripts
Vedran Miletić <rivanvx@gmail.com>
parents: 9261
diff changeset
   609
            env.STLIB_MARKER = '-Wl,--whole-archive,-Bstatic'
6913
54679ab32585 Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents: 6886
diff changeset
   610
            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
   611
9277
0f87d1cb030c Upgrade waf to 1.7.10 and fix included wscripts
Vedran Miletić <rivanvx@gmail.com>
parents: 9261
diff changeset
   612
0f87d1cb030c Upgrade waf to 1.7.10 and fix included wscripts
Vedran Miletić <rivanvx@gmail.com>
parents: 9261
diff changeset
   613
    have_gsl = conf.check_cfg(package='gsl', args=['--cflags', '--libs'],
0f87d1cb030c Upgrade waf to 1.7.10 and fix included wscripts
Vedran Miletić <rivanvx@gmail.com>
parents: 9261
diff changeset
   614
                              uselib_store='GSL', mandatory=False)
4773
904c1803d5dc test framework should probably work on all supported machines
Craig Dowell <craigdo@ee.washington.edu>
parents: 4770
diff changeset
   615
    conf.env['ENABLE_GSL'] = have_gsl
904c1803d5dc test framework should probably work on all supported machines
Craig Dowell <craigdo@ee.washington.edu>
parents: 4770
diff changeset
   616
    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
   617
                                 conf.env['ENABLE_GSL'],
904c1803d5dc test framework should probably work on all supported machines
Craig Dowell <craigdo@ee.washington.edu>
parents: 4770
diff changeset
   618
                                 "GSL not found")
4392
25d38a0c9851 bug 537: no support to build static ns-3 binaries
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4388
diff changeset
   619
11809
8a71cfb6b773 [Waf] Improve libgcrypt detection
Matt <matthieu.coudron@lip6.fr>
parents: 11805
diff changeset
   620
    conf.find_program('libgcrypt-config', var='LIBGCRYPT_CONFIG', msg="python-config", mandatory=False)
8a71cfb6b773 [Waf] Improve libgcrypt detection
Matt <matthieu.coudron@lip6.fr>
parents: 11805
diff changeset
   621
    if env.LIBGCRYPT_CONFIG:
8a71cfb6b773 [Waf] Improve libgcrypt detection
Matt <matthieu.coudron@lip6.fr>
parents: 11805
diff changeset
   622
        conf.check_cfg(path=env.LIBGCRYPT_CONFIG, msg="Checking for libgcrypt", args='--cflags --libs', package='',
8a71cfb6b773 [Waf] Improve libgcrypt detection
Matt <matthieu.coudron@lip6.fr>
parents: 11805
diff changeset
   623
                                     define_name="HAVE_CRYPTO", global_define=True, uselib_store='GCRYPT', mandatory=False)
11788
232d7ad5a88d Added libgcrypt detection. It will be used to generate sha1 hashes for MPTCP
Matt <matthieu.coudron@lip6.fr>
parents: 11682
diff changeset
   624
    conf.report_optional_feature("libgcrypt", "Gcrypt library",
11809
8a71cfb6b773 [Waf] Improve libgcrypt detection
Matt <matthieu.coudron@lip6.fr>
parents: 11805
diff changeset
   625
                                 conf.env.HAVE_GCRYPT, "libgcrypt not found: you can use libgcrypt-config to find its location.")
11788
232d7ad5a88d Added libgcrypt detection. It will be used to generate sha1 hashes for MPTCP
Matt <matthieu.coudron@lip6.fr>
parents: 11682
diff changeset
   626
12297
45c08cbed1f9 DES Metrics implementation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12236
diff changeset
   627
    why_not_desmetrics = "defaults to disabled"
45c08cbed1f9 DES Metrics implementation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12236
diff changeset
   628
    if Options.options.enable_desmetrics:
45c08cbed1f9 DES Metrics implementation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12236
diff changeset
   629
        conf.env['ENABLE_DES_METRICS'] = True
45c08cbed1f9 DES Metrics implementation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12236
diff changeset
   630
        env.append_value('DEFINES', 'ENABLE_DES_METRICS')
45c08cbed1f9 DES Metrics implementation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12236
diff changeset
   631
        why_not_desmetrics = "option --enable-des-metrics selected"
45c08cbed1f9 DES Metrics implementation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12236
diff changeset
   632
    conf.report_optional_feature("DES Metrics", "DES Metrics event collection", conf.env['ENABLE_DES_METRICS'], why_not_desmetrics)
45c08cbed1f9 DES Metrics implementation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12236
diff changeset
   633
11788
232d7ad5a88d Added libgcrypt detection. It will be used to generate sha1 hashes for MPTCP
Matt <matthieu.coudron@lip6.fr>
parents: 11682
diff changeset
   634
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
   635
    # 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
   636
    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
   637
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
   638
    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
   639
        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
   640
            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
   641
                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
   642
        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
   643
            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
   644
                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
   645
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
   646
    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
   647
    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
   648
7494
d93f5e8e0a59 waf-1.6: Mac OSX and other fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7493
diff changeset
   649
    try:
d93f5e8e0a59 waf-1.6: Mac OSX and other fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7493
diff changeset
   650
        conf.find_program('doxygen', var='DOXYGEN')
d93f5e8e0a59 waf-1.6: Mac OSX and other fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7493
diff changeset
   651
    except WafError:
d93f5e8e0a59 waf-1.6: Mac OSX and other fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7493
diff changeset
   652
        pass
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
   653
5454
6db6a279dfff append {CC,CXX,LINK,LD}FLAGS_EXTRA to corresponding {CC,CXX,LINK}FLAGS.
Andrey Mazo <mazo@iitp.ru>
parents: 5453
diff changeset
   654
    # 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
   655
    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
   656
                              ['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
   657
                              ['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
   658
                              ['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
   659
        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
   660
            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
   661
            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
   662
12329
e0d961707c93 build: (fixes #2459) Add ./waf --check-config option to reprint the summary
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12321
diff changeset
   663
    print_config(env)
10604
eed0cb486e3f Repeat the build output directory and the build profile in the configure report.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10147
diff changeset
   664
    
7488
72d0c878f3c7 More waf 1.6.7 build fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7487
diff changeset
   665
9277
0f87d1cb030c Upgrade waf to 1.7.10 and fix included wscripts
Vedran Miletić <rivanvx@gmail.com>
parents: 9261
diff changeset
   666
class SuidBuild_task(Task.Task):
3826
40c5841b616d merge in tap device
Craig Dowell <craigdo@ee.washington.edu>
parents: 3703
diff changeset
   667
    """task that makes a binary Suid
40c5841b616d merge in tap device
Craig Dowell <craigdo@ee.washington.edu>
parents: 3703
diff changeset
   668
    """
7488
72d0c878f3c7 More waf 1.6.7 build fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7487
diff changeset
   669
    after = 'link'
72d0c878f3c7 More waf 1.6.7 build fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7487
diff changeset
   670
    def __init__(self, *args, **kwargs):
72d0c878f3c7 More waf 1.6.7 build fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7487
diff changeset
   671
        super(SuidBuild_task, self).__init__(*args, **kwargs)
3826
40c5841b616d merge in tap device
Craig Dowell <craigdo@ee.washington.edu>
parents: 3703
diff changeset
   672
        self.m_display = 'build-suid'
40c5841b616d merge in tap device
Craig Dowell <craigdo@ee.washington.edu>
parents: 3703
diff changeset
   673
        try:
7692
2a3b879f4b5f Fix issue with --enable-sudo, broken by the versioning of programs
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7688
diff changeset
   674
            program_obj = wutils.find_program(self.generator.name, self.generator.env)
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11544
diff changeset
   675
        except ValueError as ex:
7488
72d0c878f3c7 More waf 1.6.7 build fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7487
diff changeset
   676
            raise WafError(str(ex))
72d0c878f3c7 More waf 1.6.7 build fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7487
diff changeset
   677
        program_node = program_obj.path.find_or_declare(program_obj.target)
9277
0f87d1cb030c Upgrade waf to 1.7.10 and fix included wscripts
Vedran Miletić <rivanvx@gmail.com>
parents: 9261
diff changeset
   678
        self.filename = program_node.get_bld().abspath()
3826
40c5841b616d merge in tap device
Craig Dowell <craigdo@ee.washington.edu>
parents: 3703
diff changeset
   679
4179
2758871405b7 tweak wifi example, fix waf problems (thanks to Gustavo)
Craig Dowell <craigdo@ee.washington.edu>
parents: 4172
diff changeset
   680
2758871405b7 tweak wifi example, fix waf problems (thanks to Gustavo)
Craig Dowell <craigdo@ee.washington.edu>
parents: 4172
diff changeset
   681
    def run(self):
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11544
diff changeset
   682
        print('setting suid bit on executable ' + self.filename, file=sys.stderr)
4179
2758871405b7 tweak wifi example, fix waf problems (thanks to Gustavo)
Craig Dowell <craigdo@ee.washington.edu>
parents: 4172
diff changeset
   683
        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
   684
            return 1
2758871405b7 tweak wifi example, fix waf problems (thanks to Gustavo)
Craig Dowell <craigdo@ee.washington.edu>
parents: 4172
diff changeset
   685
        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
   686
            return 1
2758871405b7 tweak wifi example, fix waf problems (thanks to Gustavo)
Craig Dowell <craigdo@ee.washington.edu>
parents: 4172
diff changeset
   687
        return 0
2758871405b7 tweak wifi example, fix waf problems (thanks to Gustavo)
Craig Dowell <craigdo@ee.washington.edu>
parents: 4172
diff changeset
   688
2758871405b7 tweak wifi example, fix waf problems (thanks to Gustavo)
Craig Dowell <craigdo@ee.washington.edu>
parents: 4172
diff changeset
   689
    def runnable_status(self):
2758871405b7 tweak wifi example, fix waf problems (thanks to Gustavo)
Craig Dowell <craigdo@ee.washington.edu>
parents: 4172
diff changeset
   690
        "RUN_ME SKIP_ME or ASK_LATER"
7693
c452ea61d893 Fix small bug in SuidBuild_task
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7692
diff changeset
   691
        try:
c452ea61d893 Fix small bug in SuidBuild_task
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7692
diff changeset
   692
            st = os.stat(self.filename)
c452ea61d893 Fix small bug in SuidBuild_task
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7692
diff changeset
   693
        except OSError:
c452ea61d893 Fix small bug in SuidBuild_task
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7692
diff changeset
   694
            return Task.ASK_LATER
4179
2758871405b7 tweak wifi example, fix waf problems (thanks to Gustavo)
Craig Dowell <craigdo@ee.washington.edu>
parents: 4172
diff changeset
   695
        if st.st_uid == 0:
7487
82cd20da9650 Upgrade to waf-1.6.7, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7463
diff changeset
   696
            return Task.SKIP_ME
4179
2758871405b7 tweak wifi example, fix waf problems (thanks to Gustavo)
Craig Dowell <craigdo@ee.washington.edu>
parents: 4172
diff changeset
   697
        else:
7487
82cd20da9650 Upgrade to waf-1.6.7, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7463
diff changeset
   698
            return Task.RUN_ME
3826
40c5841b616d merge in tap device
Craig Dowell <craigdo@ee.washington.edu>
parents: 3703
diff changeset
   699
40c5841b616d merge in tap device
Craig Dowell <craigdo@ee.washington.edu>
parents: 3703
diff changeset
   700
def create_suid_program(bld, name):
7488
72d0c878f3c7 More waf 1.6.7 build fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7487
diff changeset
   701
    grp = bld.current_group
72d0c878f3c7 More waf 1.6.7 build fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7487
diff changeset
   702
    bld.add_group() # this to make sure no two sudo tasks run at the same time
9277
0f87d1cb030c Upgrade waf to 1.7.10 and fix included wscripts
Vedran Miletić <rivanvx@gmail.com>
parents: 9261
diff changeset
   703
    program = bld(features='cxx cxxprogram')
3826
40c5841b616d merge in tap device
Craig Dowell <craigdo@ee.washington.edu>
parents: 3703
diff changeset
   704
    program.is_ns3_program = True
40c5841b616d merge in tap device
Craig Dowell <craigdo@ee.washington.edu>
parents: 3703
diff changeset
   705
    program.module_deps = list()
40c5841b616d merge in tap device
Craig Dowell <craigdo@ee.washington.edu>
parents: 3703
diff changeset
   706
    program.name = name
8894
90d67c5e8255 Bug 1445 - When build with "-d release", don't suffix "-release"
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 8848
diff changeset
   707
    program.target = "%s%s-%s%s" % (wutils.APPNAME, wutils.VERSION, name, bld.env.BUILD_SUFFIX)
4164
1f6ae48061a9 checkpoint tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents: 4119
diff changeset
   708
4171
902589866374 teach enable-sudo to be a config time thing
Craig Dowell <craigdo@ee.washington.edu>
parents: 4164
diff changeset
   709
    if bld.env['ENABLE_SUDO']:
7488
72d0c878f3c7 More waf 1.6.7 build fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7487
diff changeset
   710
        program.create_task("SuidBuild")
72d0c878f3c7 More waf 1.6.7 build fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7487
diff changeset
   711
72d0c878f3c7 More waf 1.6.7 build fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7487
diff changeset
   712
    bld.set_group(grp)
4171
902589866374 teach enable-sudo to be a config time thing
Craig Dowell <craigdo@ee.washington.edu>
parents: 4164
diff changeset
   713
3826
40c5841b616d merge in tap device
Craig Dowell <craigdo@ee.washington.edu>
parents: 3703
diff changeset
   714
    return program
40c5841b616d merge in tap device
Craig Dowell <craigdo@ee.washington.edu>
parents: 3703
diff changeset
   715
6821
203367ae7433 merge src/simulator into src/core; move src/core to new module layout
Tom Henderson <tomh@tomh.org>
parents: 6676
diff changeset
   716
def create_ns3_program(bld, name, dependencies=('core',)):
9277
0f87d1cb030c Upgrade waf to 1.7.10 and fix included wscripts
Vedran Miletić <rivanvx@gmail.com>
parents: 9261
diff changeset
   717
    program = bld(features='cxx cxxprogram')
7593
fe607d42ec05 Correcting compilation behavior in Ubuntu 11.10. I guess, default behavior of ldd has been changed... As a result, many dynamic features of NS were not working
Alexander Afanasyev <alexander.afanasyev@ucla.edu>
parents: 7551
diff changeset
   718
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
   719
    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
   720
    program.name = name
8894
90d67c5e8255 Bug 1445 - When build with "-d release", don't suffix "-release"
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 8848
diff changeset
   721
    program.target = "%s%s-%s%s" % (wutils.APPNAME, wutils.VERSION, name, bld.env.BUILD_SUFFIX)
6913
54679ab32585 Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents: 6886
diff changeset
   722
    # Each of the modules this program depends on has its own library.
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
   723
    program.ns3_module_dependencies = ['ns3-'+dep for dep in dependencies]
9261
13b3ddbaac67 bug 1602: do not include directory above in gcc include path
Tom Henderson <tomh@tomh.org>
parents: 9239
diff changeset
   724
    program.includes = "#"
7495
d87f20fd2421 waf1.6: remove code not needed, fix static build, cleanup
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7494
diff changeset
   725
    program.use = program.ns3_module_dependencies
d87f20fd2421 waf1.6: remove code not needed, fix static build, cleanup
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7494
diff changeset
   726
    if program.env['ENABLE_STATIC_NS3']:
d87f20fd2421 waf1.6: remove code not needed, fix static build, cleanup
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7494
diff changeset
   727
        if sys.platform == 'darwin':
d87f20fd2421 waf1.6: remove code not needed, fix static build, cleanup
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7494
diff changeset
   728
            program.env.STLIB_MARKER = '-Wl,-all_load'
d87f20fd2421 waf1.6: remove code not needed, fix static build, cleanup
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7494
diff changeset
   729
        else:
9277
0f87d1cb030c Upgrade waf to 1.7.10 and fix included wscripts
Vedran Miletić <rivanvx@gmail.com>
parents: 9261
diff changeset
   730
            program.env.STLIB_MARKER = '-Wl,-Bstatic,--whole-archive'
7495
d87f20fd2421 waf1.6: remove code not needed, fix static build, cleanup
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7494
diff changeset
   731
            program.env.SHLIB_MARKER = '-Wl,-Bdynamic,--no-whole-archive'
7593
fe607d42ec05 Correcting compilation behavior in Ubuntu 11.10. I guess, default behavior of ldd has been changed... As a result, many dynamic features of NS were not working
Alexander Afanasyev <alexander.afanasyev@ucla.edu>
parents: 7551
diff changeset
   732
    else:
fe607d42ec05 Correcting compilation behavior in Ubuntu 11.10. I guess, default behavior of ldd has been changed... As a result, many dynamic features of NS were not working
Alexander Afanasyev <alexander.afanasyev@ucla.edu>
parents: 7551
diff changeset
   733
        if program.env.DEST_BINFMT == 'elf':
fe607d42ec05 Correcting compilation behavior in Ubuntu 11.10. I guess, default behavior of ldd has been changed... As a result, many dynamic features of NS were not working
Alexander Afanasyev <alexander.afanasyev@ucla.edu>
parents: 7551
diff changeset
   734
            # All ELF platforms are impacted but only the gcc compiler has a flag to fix it.
fe607d42ec05 Correcting compilation behavior in Ubuntu 11.10. I guess, default behavior of ldd has been changed... As a result, many dynamic features of NS were not working
Alexander Afanasyev <alexander.afanasyev@ucla.edu>
parents: 7551
diff changeset
   735
            if 'gcc' in (program.env.CXX_NAME, program.env.CC_NAME): 
fe607d42ec05 Correcting compilation behavior in Ubuntu 11.10. I guess, default behavior of ldd has been changed... As a result, many dynamic features of NS were not working
Alexander Afanasyev <alexander.afanasyev@ucla.edu>
parents: 7551
diff changeset
   736
                program.env.append_value ('SHLIB_MARKER', '-Wl,--no-as-needed')
fe607d42ec05 Correcting compilation behavior in Ubuntu 11.10. I guess, default behavior of ldd has been changed... As a result, many dynamic features of NS were not working
Alexander Afanasyev <alexander.afanasyev@ucla.edu>
parents: 7551
diff changeset
   737
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
   738
    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
   739
7094
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   740
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
   741
    ns3_module_dependencies = ['ns3-'+dep for dep in dependencies]
7487
82cd20da9650 Upgrade to waf-1.6.7, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7463
diff changeset
   742
    bld.env.append_value('NS3_SCRIPT_DEPENDENCIES', [(name, ns3_module_dependencies)])
7094
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   743
5848
ee2c83ed68cf get rid of examples waf script
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5468
diff changeset
   744
def add_examples_programs(bld):
7487
82cd20da9650 Upgrade to waf-1.6.7, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7463
diff changeset
   745
    env = bld.env
5848
ee2c83ed68cf get rid of examples waf script
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5468
diff changeset
   746
    if env['ENABLE_EXAMPLES']:
11475
f1837a4f71c0 Handle the case where scratch or examples directory is missing
Vedran Miletić <rivanvx@gmail.com>
parents: 11474
diff changeset
   747
        try:
f1837a4f71c0 Handle the case where scratch or examples directory is missing
Vedran Miletić <rivanvx@gmail.com>
parents: 11474
diff changeset
   748
            for dir in os.listdir('examples'):
f1837a4f71c0 Handle the case where scratch or examples directory is missing
Vedran Miletić <rivanvx@gmail.com>
parents: 11474
diff changeset
   749
                if dir.startswith('.') or dir == 'CVS':
f1837a4f71c0 Handle the case where scratch or examples directory is missing
Vedran Miletić <rivanvx@gmail.com>
parents: 11474
diff changeset
   750
                    continue
f1837a4f71c0 Handle the case where scratch or examples directory is missing
Vedran Miletić <rivanvx@gmail.com>
parents: 11474
diff changeset
   751
                if os.path.isdir(os.path.join('examples', dir)):
f1837a4f71c0 Handle the case where scratch or examples directory is missing
Vedran Miletić <rivanvx@gmail.com>
parents: 11474
diff changeset
   752
                    bld.recurse(os.path.join('examples', dir))
f1837a4f71c0 Handle the case where scratch or examples directory is missing
Vedran Miletić <rivanvx@gmail.com>
parents: 11474
diff changeset
   753
        except OSError:
f1837a4f71c0 Handle the case where scratch or examples directory is missing
Vedran Miletić <rivanvx@gmail.com>
parents: 11474
diff changeset
   754
            return
5848
ee2c83ed68cf get rid of examples waf script
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5468
diff changeset
   755
3275
b0d91237f2ec [Bug 221] need a scratch directory
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3189
diff changeset
   756
def add_scratch_programs(bld):
12808
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   757
    all_modules = [mod[len("ns3-"):] for mod in bld.env['NS3_ENABLED_MODULES'] + bld.env['NS3_ENABLED_CONTRIBUTED_MODULES']]
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   758
11475
f1837a4f71c0 Handle the case where scratch or examples directory is missing
Vedran Miletić <rivanvx@gmail.com>
parents: 11474
diff changeset
   759
    try:
f1837a4f71c0 Handle the case where scratch or examples directory is missing
Vedran Miletić <rivanvx@gmail.com>
parents: 11474
diff changeset
   760
        for filename in os.listdir("scratch"):
f1837a4f71c0 Handle the case where scratch or examples directory is missing
Vedran Miletić <rivanvx@gmail.com>
parents: 11474
diff changeset
   761
            if filename.startswith('.') or filename == 'CVS':
f1837a4f71c0 Handle the case where scratch or examples directory is missing
Vedran Miletić <rivanvx@gmail.com>
parents: 11474
diff changeset
   762
                continue
f1837a4f71c0 Handle the case where scratch or examples directory is missing
Vedran Miletić <rivanvx@gmail.com>
parents: 11474
diff changeset
   763
            if os.path.isdir(os.path.join("scratch", filename)):
f1837a4f71c0 Handle the case where scratch or examples directory is missing
Vedran Miletić <rivanvx@gmail.com>
parents: 11474
diff changeset
   764
                obj = bld.create_ns3_program(filename, all_modules)
f1837a4f71c0 Handle the case where scratch or examples directory is missing
Vedran Miletić <rivanvx@gmail.com>
parents: 11474
diff changeset
   765
                obj.path = obj.path.find_dir('scratch').find_dir(filename)
f1837a4f71c0 Handle the case where scratch or examples directory is missing
Vedran Miletić <rivanvx@gmail.com>
parents: 11474
diff changeset
   766
                obj.source = obj.path.ant_glob('*.cc')
f1837a4f71c0 Handle the case where scratch or examples directory is missing
Vedran Miletić <rivanvx@gmail.com>
parents: 11474
diff changeset
   767
                obj.target = filename
f1837a4f71c0 Handle the case where scratch or examples directory is missing
Vedran Miletić <rivanvx@gmail.com>
parents: 11474
diff changeset
   768
                obj.name = obj.target
f1837a4f71c0 Handle the case where scratch or examples directory is missing
Vedran Miletić <rivanvx@gmail.com>
parents: 11474
diff changeset
   769
                obj.install_path = None
f1837a4f71c0 Handle the case where scratch or examples directory is missing
Vedran Miletić <rivanvx@gmail.com>
parents: 11474
diff changeset
   770
            elif filename.endswith(".cc"):
f1837a4f71c0 Handle the case where scratch or examples directory is missing
Vedran Miletić <rivanvx@gmail.com>
parents: 11474
diff changeset
   771
                name = filename[:-len(".cc")]
f1837a4f71c0 Handle the case where scratch or examples directory is missing
Vedran Miletić <rivanvx@gmail.com>
parents: 11474
diff changeset
   772
                obj = bld.create_ns3_program(name, all_modules)
f1837a4f71c0 Handle the case where scratch or examples directory is missing
Vedran Miletić <rivanvx@gmail.com>
parents: 11474
diff changeset
   773
                obj.path = obj.path.find_dir('scratch')
f1837a4f71c0 Handle the case where scratch or examples directory is missing
Vedran Miletić <rivanvx@gmail.com>
parents: 11474
diff changeset
   774
                obj.source = filename
f1837a4f71c0 Handle the case where scratch or examples directory is missing
Vedran Miletić <rivanvx@gmail.com>
parents: 11474
diff changeset
   775
                obj.target = name
f1837a4f71c0 Handle the case where scratch or examples directory is missing
Vedran Miletić <rivanvx@gmail.com>
parents: 11474
diff changeset
   776
                obj.name = obj.target
f1837a4f71c0 Handle the case where scratch or examples directory is missing
Vedran Miletić <rivanvx@gmail.com>
parents: 11474
diff changeset
   777
                obj.install_path = None
f1837a4f71c0 Handle the case where scratch or examples directory is missing
Vedran Miletić <rivanvx@gmail.com>
parents: 11474
diff changeset
   778
    except OSError:
f1837a4f71c0 Handle the case where scratch or examples directory is missing
Vedran Miletić <rivanvx@gmail.com>
parents: 11474
diff changeset
   779
        return
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
   780
7488
72d0c878f3c7 More waf 1.6.7 build fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7487
diff changeset
   781
def _get_all_task_gen(self):
72d0c878f3c7 More waf 1.6.7 build fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7487
diff changeset
   782
    for group in self.groups:
72d0c878f3c7 More waf 1.6.7 build fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7487
diff changeset
   783
        for taskgen in group:
72d0c878f3c7 More waf 1.6.7 build fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7487
diff changeset
   784
            yield taskgen
7487
82cd20da9650 Upgrade to waf-1.6.7, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7463
diff changeset
   785
82cd20da9650 Upgrade to waf-1.6.7, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7463
diff changeset
   786
7488
72d0c878f3c7 More waf 1.6.7 build fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7487
diff changeset
   787
# ok, so WAF does not provide an API to prevent an
72d0c878f3c7 More waf 1.6.7 build fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7487
diff changeset
   788
# arbitrary taskgen from running; we have to muck around with
72d0c878f3c7 More waf 1.6.7 build fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7487
diff changeset
   789
# WAF internal state, something that might stop working if
72d0c878f3c7 More waf 1.6.7 build fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7487
diff changeset
   790
# WAF is upgraded...
72d0c878f3c7 More waf 1.6.7 build fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7487
diff changeset
   791
def _exclude_taskgen(self, taskgen):
72d0c878f3c7 More waf 1.6.7 build fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7487
diff changeset
   792
    for group in self.groups:
72d0c878f3c7 More waf 1.6.7 build fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7487
diff changeset
   793
        for tg1 in group:
72d0c878f3c7 More waf 1.6.7 build fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7487
diff changeset
   794
            if tg1 is taskgen:
72d0c878f3c7 More waf 1.6.7 build fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7487
diff changeset
   795
                group.remove(tg1)
72d0c878f3c7 More waf 1.6.7 build fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7487
diff changeset
   796
                break
72d0c878f3c7 More waf 1.6.7 build fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7487
diff changeset
   797
        else:
72d0c878f3c7 More waf 1.6.7 build fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7487
diff changeset
   798
            continue
72d0c878f3c7 More waf 1.6.7 build fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7487
diff changeset
   799
        break
7487
82cd20da9650 Upgrade to waf-1.6.7, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7463
diff changeset
   800
7331
827246e3bc4c Bug 1174 - Ns-3 does not generate static libraries
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7326
diff changeset
   801
7821
270a2b7f82ad Bug 1406 - waf exits with maximum recursion depth exceeded while calling a Python object if wscript has wrong filename
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7712
diff changeset
   802
def _find_ns3_module(self, name):
270a2b7f82ad Bug 1406 - waf exits with maximum recursion depth exceeded while calling a Python object if wscript has wrong filename
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7712
diff changeset
   803
    for obj in _get_all_task_gen(self):
270a2b7f82ad Bug 1406 - waf exits with maximum recursion depth exceeded while calling a Python object if wscript has wrong filename
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7712
diff changeset
   804
        # disable the modules themselves
270a2b7f82ad Bug 1406 - waf exits with maximum recursion depth exceeded while calling a Python object if wscript has wrong filename
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7712
diff changeset
   805
        if hasattr(obj, "is_ns3_module") and obj.name == name:
270a2b7f82ad Bug 1406 - waf exits with maximum recursion depth exceeded while calling a Python object if wscript has wrong filename
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7712
diff changeset
   806
            return obj
270a2b7f82ad Bug 1406 - waf exits with maximum recursion depth exceeded while calling a Python object if wscript has wrong filename
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7712
diff changeset
   807
    raise KeyError(name)
270a2b7f82ad Bug 1406 - waf exits with maximum recursion depth exceeded while calling a Python object if wscript has wrong filename
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7712
diff changeset
   808
12329
e0d961707c93 build: (fixes #2459) Add ./waf --check-config option to reprint the summary
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12321
diff changeset
   809
# Parse the waf lockfile generated by latest 'configure' operation
e0d961707c93 build: (fixes #2459) Add ./waf --check-config option to reprint the summary
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12321
diff changeset
   810
def get_build_profile(env=None):
13390
78abcf179b64 build: (fixes #2852) Fix --check-profile regression
Mathias Ettinger <mettinger@toulouse.viveris.com>
parents: 13192
diff changeset
   811
    if env:
78abcf179b64 build: (fixes #2852) Fix --check-profile regression
Mathias Ettinger <mettinger@toulouse.viveris.com>
parents: 13192
diff changeset
   812
        return Options.options.build_profile
78abcf179b64 build: (fixes #2852) Fix --check-profile regression
Mathias Ettinger <mettinger@toulouse.viveris.com>
parents: 13192
diff changeset
   813
78abcf179b64 build: (fixes #2852) Fix --check-profile regression
Mathias Ettinger <mettinger@toulouse.viveris.com>
parents: 13192
diff changeset
   814
    lockfile = os.environ.get('WAFLOCK', '.lock-waf_%s_build' % sys.platform)
78abcf179b64 build: (fixes #2852) Fix --check-profile regression
Mathias Ettinger <mettinger@toulouse.viveris.com>
parents: 13192
diff changeset
   815
    with open(lockfile, "r") as f:
78abcf179b64 build: (fixes #2852) Fix --check-profile regression
Mathias Ettinger <mettinger@toulouse.viveris.com>
parents: 13192
diff changeset
   816
        for line in f:
78abcf179b64 build: (fixes #2852) Fix --check-profile regression
Mathias Ettinger <mettinger@toulouse.viveris.com>
parents: 13192
diff changeset
   817
            if line.startswith("options ="):
78abcf179b64 build: (fixes #2852) Fix --check-profile regression
Mathias Ettinger <mettinger@toulouse.viveris.com>
parents: 13192
diff changeset
   818
                _, val = line.split('=', 1)
78abcf179b64 build: (fixes #2852) Fix --check-profile regression
Mathias Ettinger <mettinger@toulouse.viveris.com>
parents: 13192
diff changeset
   819
                for x in val.split(','):
78abcf179b64 build: (fixes #2852) Fix --check-profile regression
Mathias Ettinger <mettinger@toulouse.viveris.com>
parents: 13192
diff changeset
   820
                    optkey, optval = x.split(':')
78abcf179b64 build: (fixes #2852) Fix --check-profile regression
Mathias Ettinger <mettinger@toulouse.viveris.com>
parents: 13192
diff changeset
   821
                    if (optkey.lstrip() == '\'build_profile\''):
78abcf179b64 build: (fixes #2852) Fix --check-profile regression
Mathias Ettinger <mettinger@toulouse.viveris.com>
parents: 13192
diff changeset
   822
                        return str(optval.lstrip()).replace("'","")
78abcf179b64 build: (fixes #2852) Fix --check-profile regression
Mathias Ettinger <mettinger@toulouse.viveris.com>
parents: 13192
diff changeset
   823
78abcf179b64 build: (fixes #2852) Fix --check-profile regression
Mathias Ettinger <mettinger@toulouse.viveris.com>
parents: 13192
diff changeset
   824
    return "not found"
12329
e0d961707c93 build: (fixes #2459) Add ./waf --check-config option to reprint the summary
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12321
diff changeset
   825
e0d961707c93 build: (fixes #2459) Add ./waf --check-config option to reprint the summary
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12321
diff changeset
   826
def build(bld):
e0d961707c93 build: (fixes #2459) Add ./waf --check-config option to reprint the summary
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12321
diff changeset
   827
    env = bld.env
e0d961707c93 build: (fixes #2459) Add ./waf --check-config option to reprint the summary
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12321
diff changeset
   828
e0d961707c93 build: (fixes #2459) Add ./waf --check-config option to reprint the summary
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12321
diff changeset
   829
    if Options.options.check_config:
e0d961707c93 build: (fixes #2459) Add ./waf --check-config option to reprint the summary
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12321
diff changeset
   830
        print_config(env, 'build')
e0d961707c93 build: (fixes #2459) Add ./waf --check-config option to reprint the summary
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12321
diff changeset
   831
    else:
e0d961707c93 build: (fixes #2459) Add ./waf --check-config option to reprint the summary
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12321
diff changeset
   832
        if Options.options.check_profile:
e0d961707c93 build: (fixes #2459) Add ./waf --check-config option to reprint the summary
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12321
diff changeset
   833
            profile = get_build_profile()
e0d961707c93 build: (fixes #2459) Add ./waf --check-config option to reprint the summary
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12321
diff changeset
   834
            print("Build profile: %s" % profile)
e0d961707c93 build: (fixes #2459) Add ./waf --check-config option to reprint the summary
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12321
diff changeset
   835
        
e0d961707c93 build: (fixes #2459) Add ./waf --check-config option to reprint the summary
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12321
diff changeset
   836
    if Options.options.check_profile or Options.options.check_config:
11805
391bf90839ed add waf --check-profile option
Tom Henderson <tomh@tomh.org>
parents: 11788
diff changeset
   837
        raise SystemExit(0)
391bf90839ed add waf --check-profile option
Tom Henderson <tomh@tomh.org>
parents: 11788
diff changeset
   838
        return
391bf90839ed add waf --check-profile option
Tom Henderson <tomh@tomh.org>
parents: 11788
diff changeset
   839
7131
77b75cd826d0 Make modules no longer be enabled from waf build
Mitch Watrous <watrous@u.washington.edu>
parents: 7100
diff changeset
   840
    # 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
   841
    # 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
   842
    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
   843
        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
   844
        return
77b75cd826d0 Make modules no longer be enabled from waf build
Mitch Watrous <watrous@u.washington.edu>
parents: 7100
diff changeset
   845
6925
43d9c7eedf7b Test implicitly dependent modules
Mitch Watrous <watrous@u.washington.edu>
parents: 6919
diff changeset
   846
    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
   847
    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
   848
    bld.env['NS3_SCRIPT_DEPENDENCIES'] = []
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   849
    bld.env['NS3_RUNNABLE_PROGRAMS'] = []
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   850
    bld.env['NS3_RUNNABLE_SCRIPTS'] = []
6913
54679ab32585 Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents: 6886
diff changeset
   851
4326
179f86838e62 Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4202
diff changeset
   852
    wutils.bld = bld
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
   853
    if Options.options.no_task_lines:
9277
0f87d1cb030c Upgrade waf to 1.7.10 and fix included wscripts
Vedran Miletić <rivanvx@gmail.com>
parents: 9261
diff changeset
   854
        from waflib import Runner
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
   855
        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
   856
            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
   857
        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
   858
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
   859
    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
   860
    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
   861
    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
   862
    bld.create_suid_program = types.MethodType(create_suid_program, bld)
7488
72d0c878f3c7 More waf 1.6.7 build fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7487
diff changeset
   863
    bld.__class__.all_task_gen = property(_get_all_task_gen)
72d0c878f3c7 More waf 1.6.7 build fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7487
diff changeset
   864
    bld.exclude_taskgen = types.MethodType(_exclude_taskgen, bld)
7821
270a2b7f82ad Bug 1406 - waf exits with maximum recursion depth exceeded while calling a Python object if wscript has wrong filename
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7712
diff changeset
   865
    bld.find_ns3_module = types.MethodType(_find_ns3_module, bld)
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
   866
9239
02de8e19ce08 bug 1517: waf clean/distclean doesn't remove the doc/html directory
Tom Henderson <tomh@tomh.org>
parents: 9169
diff changeset
   867
    # Clean documentation build directories; other cleaning happens later
02de8e19ce08 bug 1517: waf clean/distclean doesn't remove the doc/html directory
Tom Henderson <tomh@tomh.org>
parents: 9169
diff changeset
   868
    if bld.cmd == 'clean':
02de8e19ce08 bug 1517: waf clean/distclean doesn't remove the doc/html directory
Tom Henderson <tomh@tomh.org>
parents: 9169
diff changeset
   869
        _cleandocs()
02de8e19ce08 bug 1517: waf clean/distclean doesn't remove the doc/html directory
Tom Henderson <tomh@tomh.org>
parents: 9169
diff changeset
   870
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   871
    # process subfolders from here
9277
0f87d1cb030c Upgrade waf to 1.7.10 and fix included wscripts
Vedran Miletić <rivanvx@gmail.com>
parents: 9261
diff changeset
   872
    bld.recurse('src')
12808
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   873
    bld.recurse('contrib')
537
e8a4183dfe00 Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff changeset
   874
6925
43d9c7eedf7b Test implicitly dependent modules
Mitch Watrous <watrous@u.washington.edu>
parents: 6919
diff changeset
   875
    # 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
   876
    # and enabled module test libraries.
12808
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   877
    if env['NS3_ENABLED_MODULES'] or env['NS3_ENABLED_CONTRIBUTED_MODULES']:
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   878
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
   879
        modules = env['NS3_ENABLED_MODULES']
12808
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   880
        contribModules = env['NS3_ENABLED_CONTRIBUTED_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
   881
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
   882
        # 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
   883
        # 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
   884
        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
   885
        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
   886
            changed = False
12808
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   887
            for module in modules + contribModules:
7488
72d0c878f3c7 More waf 1.6.7 build fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7487
diff changeset
   888
                module_obj = bld.get_tgen_by_name(module)
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
   889
                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
   890
                    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
   891
                # Each enabled module has its own library.
7487
82cd20da9650 Upgrade to waf-1.6.7, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7463
diff changeset
   892
                for dep in module_obj.use:
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
   893
                    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
   894
                        continue
12808
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   895
                    if dep not in modules and dep not in contribModules:
13439
cfe716146de6 build: (fixes #2902) missing modules cause Waf to run indefinitely
Jörg Christian Kirchhof <christian.kirchhof@rwth-aachen.de>
parents: 13390
diff changeset
   896
                        if dep in env['NS3_MODULES']: 
cfe716146de6 build: (fixes #2902) missing modules cause Waf to run indefinitely
Jörg Christian Kirchhof <christian.kirchhof@rwth-aachen.de>
parents: 13390
diff changeset
   897
                            modules.append(dep)
cfe716146de6 build: (fixes #2902) missing modules cause Waf to run indefinitely
Jörg Christian Kirchhof <christian.kirchhof@rwth-aachen.de>
parents: 13390
diff changeset
   898
                            changed = True
cfe716146de6 build: (fixes #2902) missing modules cause Waf to run indefinitely
Jörg Christian Kirchhof <christian.kirchhof@rwth-aachen.de>
parents: 13390
diff changeset
   899
                        elif dep in env['NS3_CONTRIBUTED_MODULES']: 
cfe716146de6 build: (fixes #2902) missing modules cause Waf to run indefinitely
Jörg Christian Kirchhof <christian.kirchhof@rwth-aachen.de>
parents: 13390
diff changeset
   900
                            contribModules.append(dep)
cfe716146de6 build: (fixes #2902) missing modules cause Waf to run indefinitely
Jörg Christian Kirchhof <christian.kirchhof@rwth-aachen.de>
parents: 13390
diff changeset
   901
                            changed = True
cfe716146de6 build: (fixes #2902) missing modules cause Waf to run indefinitely
Jörg Christian Kirchhof <christian.kirchhof@rwth-aachen.de>
parents: 13390
diff changeset
   902
                        else:
cfe716146de6 build: (fixes #2902) missing modules cause Waf to run indefinitely
Jörg Christian Kirchhof <christian.kirchhof@rwth-aachen.de>
parents: 13390
diff changeset
   903
                            Logs.error("Error:  Cannot find dependency \'" + dep[4:] + "\' of module \'"
cfe716146de6 build: (fixes #2902) missing modules cause Waf to run indefinitely
Jörg Christian Kirchhof <christian.kirchhof@rwth-aachen.de>
parents: 13390
diff changeset
   904
                                       + module[4:] + "\'; check the module wscript for errors.")
cfe716146de6 build: (fixes #2902) missing modules cause Waf to run indefinitely
Jörg Christian Kirchhof <christian.kirchhof@rwth-aachen.de>
parents: 13390
diff changeset
   905
                            raise SystemExit(1)
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
   906
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
   907
        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
   908
12808
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   909
        env['NS3_ENABLED_CONTRIBUTED_MODULES'] = contribModules
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   910
6998
1c2b8cfb71d2 Make tests not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents: 6981
diff changeset
   911
        # 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
   912
        # module test libraries.
1c2b8cfb71d2 Make tests not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents: 6981
diff changeset
   913
        if env['ENABLE_TESTS']:
1c2b8cfb71d2 Make tests not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents: 6981
diff changeset
   914
            for (mod, testlib) in bld.env['NS3_MODULES_WITH_TEST_LIBRARIES']:
12808
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   915
                if mod in bld.env['NS3_ENABLED_MODULES'] or mod in bld.env['NS3_ENABLED_CONTRIBUTED_MODULES']:
6998
1c2b8cfb71d2 Make tests not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents: 6981
diff changeset
   916
                    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
   917
43d9c7eedf7b Test implicitly dependent modules
Mitch Watrous <watrous@u.washington.edu>
parents: 6919
diff changeset
   918
    add_examples_programs(bld)
43d9c7eedf7b Test implicitly dependent modules
Mitch Watrous <watrous@u.washington.edu>
parents: 6919
diff changeset
   919
    add_scratch_programs(bld)
43d9c7eedf7b Test implicitly dependent modules
Mitch Watrous <watrous@u.washington.edu>
parents: 6919
diff changeset
   920
12808
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   921
    if env['NS3_ENABLED_MODULES'] or env['NS3_ENABLED_CONTRIBUTED_MODULES']:
6925
43d9c7eedf7b Test implicitly dependent modules
Mitch Watrous <watrous@u.washington.edu>
parents: 6919
diff changeset
   922
        modules = env['NS3_ENABLED_MODULES']
12808
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   923
        contribModules = env['NS3_ENABLED_CONTRIBUTED_MODULES']
6913
54679ab32585 Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents: 6886
diff changeset
   924
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
   925
        # 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
   926
        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
   927
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
   928
            # check for ns3moduleheader_taskgen
7488
72d0c878f3c7 More waf 1.6.7 build fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7487
diff changeset
   929
            if 'ns3moduleheader' in getattr(obj, "features", []):
12808
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   930
                if ("ns3-%s" % obj.module) not in modules and ("ns3-%s" % obj.module) not in contribModules:
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
   931
                    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
   932
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
   933
            # 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
   934
            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
   935
                # 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
   936
                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
   937
                for dep in obj.ns3_module_dependencies:
12808
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   938
                    if dep not in modules and dep not in contribModules: # prog. depends on a module that isn't enabled?
7487
82cd20da9650 Upgrade to waf-1.6.7, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7463
diff changeset
   939
                        bld.exclude_taskgen(obj)
7094
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   940
                        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
   941
                        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
   942
7094
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   943
                # 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
   944
                # dependencies will be built.
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   945
                if program_built:
8894
90d67c5e8255 Bug 1445 - When build with "-d release", don't suffix "-release"
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 8848
diff changeset
   946
                    object_name = "%s%s-%s%s" % (wutils.APPNAME, wutils.VERSION, 
90d67c5e8255 Bug 1445 - When build with "-d release", don't suffix "-release"
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 8848
diff changeset
   947
                                                  obj.name, bld.env.BUILD_SUFFIX)
9076
7c9f34fa2dd6 Bug 1463 - ./test.py --example should automatically detect the path
Mitch Watrous <watrous@u.washington.edu>
parents: 8967
diff changeset
   948
7c9f34fa2dd6 Bug 1463 - ./test.py --example should automatically detect the path
Mitch Watrous <watrous@u.washington.edu>
parents: 8967
diff changeset
   949
                    # Get the relative path to the program from the
7c9f34fa2dd6 Bug 1463 - ./test.py --example should automatically detect the path
Mitch Watrous <watrous@u.washington.edu>
parents: 8967
diff changeset
   950
                    # launch directory.
7c9f34fa2dd6 Bug 1463 - ./test.py --example should automatically detect the path
Mitch Watrous <watrous@u.washington.edu>
parents: 8967
diff changeset
   951
                    launch_dir = os.path.abspath(Context.launch_dir)
7c9f34fa2dd6 Bug 1463 - ./test.py --example should automatically detect the path
Mitch Watrous <watrous@u.washington.edu>
parents: 8967
diff changeset
   952
                    object_relative_path = os.path.join(
9277
0f87d1cb030c Upgrade waf to 1.7.10 and fix included wscripts
Vedran Miletić <rivanvx@gmail.com>
parents: 9261
diff changeset
   953
                        wutils.relpath(obj.path.get_bld().abspath(), launch_dir),
9076
7c9f34fa2dd6 Bug 1463 - ./test.py --example should automatically detect the path
Mitch Watrous <watrous@u.washington.edu>
parents: 8967
diff changeset
   954
                        object_name)
7c9f34fa2dd6 Bug 1463 - ./test.py --example should automatically detect the path
Mitch Watrous <watrous@u.washington.edu>
parents: 8967
diff changeset
   955
7c9f34fa2dd6 Bug 1463 - ./test.py --example should automatically detect the path
Mitch Watrous <watrous@u.washington.edu>
parents: 8967
diff changeset
   956
                    bld.env.append_value('NS3_RUNNABLE_PROGRAMS', object_relative_path)
7094
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   957
6641
cfd3533cc1ef One more stop to fixing --enable-modules
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6638
diff changeset
   958
            # disable the modules themselves
12808
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   959
            if hasattr(obj, "is_ns3_module") and obj.name not in modules and obj.name not in contribModules:
7487
82cd20da9650 Upgrade to waf-1.6.7, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7463
diff changeset
   960
                bld.exclude_taskgen(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
   961
6913
54679ab32585 Create separate module and test-module libraries
Mitch Watrous <watrous@u.washington.edu>
parents: 6886
diff changeset
   962
            # disable the module test libraries
6998
1c2b8cfb71d2 Make tests not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents: 6981
diff changeset
   963
            if hasattr(obj, "is_ns3_module_test_library"):
12808
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   964
                if not env['ENABLE_TESTS'] or ((obj.module_name not in modules) and (obj.module_name not in contribModules)) :
7487
82cd20da9650 Upgrade to waf-1.6.7, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7463
diff changeset
   965
                    bld.exclude_taskgen(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
   966
6641
cfd3533cc1ef One more stop to fixing --enable-modules
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6638
diff changeset
   967
            # disable the ns3header_taskgen
7488
72d0c878f3c7 More waf 1.6.7 build fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7487
diff changeset
   968
            if 'ns3header' in getattr(obj, "features", []):
12808
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   969
                if ("ns3-%s" % obj.module) not in modules and ("ns3-%s" % obj.module) not in contribModules:
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
   970
                    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
   971
11183
52ff59697ec9 bug 2002: Hardcoded include paths cause breakage
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11067
diff changeset
   972
            # disable the ns3privateheader_taskgen
52ff59697ec9 bug 2002: Hardcoded include paths cause breakage
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11067
diff changeset
   973
            if 'ns3privateheader' in getattr(obj, "features", []):
12808
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   974
                if ("ns3-%s" % obj.module) not in modules and ("ns3-%s" % obj.module) not in contribModules:
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   975
11183
52ff59697ec9 bug 2002: Hardcoded include paths cause breakage
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11067
diff changeset
   976
                    obj.mode = 'remove' # tell it to remove headers instead of installing 
52ff59697ec9 bug 2002: Hardcoded include paths cause breakage
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11067
diff changeset
   977
7707
42c37d556d61 Bug 1331 - waf generates and installs pkgconfig .pc files even for disabled modules and tests
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7706
diff changeset
   978
            # disable pcfile taskgens for disabled modules
42c37d556d61 Bug 1331 - waf generates and installs pkgconfig .pc files even for disabled modules and tests
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7706
diff changeset
   979
            if 'ns3pcfile' in getattr(obj, "features", []):
12808
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   980
                if obj.module not in bld.env.NS3_ENABLED_MODULES and obj.module not in bld.env.NS3_ENABLED_CONTRIBUTED_MODULES:
7707
42c37d556d61 Bug 1331 - waf generates and installs pkgconfig .pc files even for disabled modules and tests
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7706
diff changeset
   981
                    bld.exclude_taskgen(obj)
42c37d556d61 Bug 1331 - waf generates and installs pkgconfig .pc files even for disabled modules and tests
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7706
diff changeset
   982
42c37d556d61 Bug 1331 - waf generates and installs pkgconfig .pc files even for disabled modules and tests
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7706
diff changeset
   983
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
   984
    if env['NS3_ENABLED_MODULES']:
3408
2cc40b3e4fa5 python bindings
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3331
diff changeset
   985
        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
   986
12808
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   987
    if env['NS3_ENABLED_CONTRIBUTED_MODULES']:
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   988
        env['NS3_ENABLED_CONTRIBUTED_MODULES'] = list(contribModules)
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   989
7094
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   990
    # 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
   991
    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
   992
        script_runnable = True
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   993
        for dep in dependencies:
12808
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
   994
            if dep not in modules and dep not in contribModules:
7094
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   995
                script_runnable = False
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   996
                break
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   997
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
   998
        # 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
   999
        # be built.
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
  1000
        if script_runnable:
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
  1001
            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
  1002
9277
0f87d1cb030c Upgrade waf to 1.7.10 and fix included wscripts
Vedran Miletić <rivanvx@gmail.com>
parents: 9261
diff changeset
  1003
    bld.recurse('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
  1004
7337
ac13a12e9dd4 Bug 1206 - Test libraries are built but test suites are not being run in test.py
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7331
diff changeset
  1005
    # Process this subfolder here after the lists of enabled modules
ac13a12e9dd4 Bug 1206 - Test libraries are built but test suites are not being run in test.py
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7331
diff changeset
  1006
    # and module test libraries have been set.
9277
0f87d1cb030c Upgrade waf to 1.7.10 and fix included wscripts
Vedran Miletić <rivanvx@gmail.com>
parents: 9261
diff changeset
  1007
    bld.recurse('utils')
7337
ac13a12e9dd4 Bug 1206 - Test libraries are built but test suites are not being run in test.py
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7331
diff changeset
  1008
7636
58181e75d0f0 bug 1305 - do not list modules when exiting waf shell
Mitch Watrous <watrous@u.washington.edu>
parents: 7593
diff changeset
  1009
    # Set this so that the lists will be printed at the end of this
58181e75d0f0 bug 1305 - do not list modules when exiting waf shell
Mitch Watrous <watrous@u.washington.edu>
parents: 7593
diff changeset
  1010
    # build command.
58181e75d0f0 bug 1305 - do not list modules when exiting waf shell
Mitch Watrous <watrous@u.washington.edu>
parents: 7593
diff changeset
  1011
    bld.env['PRINT_BUILT_MODULES_AT_END'] = True
58181e75d0f0 bug 1305 - do not list modules when exiting waf shell
Mitch Watrous <watrous@u.washington.edu>
parents: 7593
diff changeset
  1012
9823
a22cd11590bd bug 1305: remove list of modules at end of waf clean
Alexander D'souza <moijes12@gmail.com>
parents: 9277
diff changeset
  1013
    # Do not print the modules built if build command was "clean"
a22cd11590bd bug 1305: remove list of modules at end of waf clean
Alexander D'souza <moijes12@gmail.com>
parents: 9277
diff changeset
  1014
    if bld.cmd == 'clean':
a22cd11590bd bug 1305: remove list of modules at end of waf clean
Alexander D'souza <moijes12@gmail.com>
parents: 9277
diff changeset
  1015
        bld.env['PRINT_BUILT_MODULES_AT_END'] = False
a22cd11590bd bug 1305: remove list of modules at end of waf clean
Alexander D'souza <moijes12@gmail.com>
parents: 9277
diff changeset
  1016
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
  1017
    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
  1018
        # 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
  1019
        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
  1020
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
  1021
        # 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
  1022
        # 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
  1023
        # want to do is run a test program.
7487
82cd20da9650 Upgrade to waf-1.6.7, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7463
diff changeset
  1024
        Options.options.targets += ',' + os.path.basename(program_name)
8848
9a34e12fab31 Automatically add the visualizer module to programs running with waf --run --vis
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7863
diff changeset
  1025
        if getattr(Options.options, "visualize", False):
9a34e12fab31 Automatically add the visualizer module to programs running with waf --run --vis
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7863
diff changeset
  1026
            program_obj = wutils.find_program(program_name, bld.env)
9a34e12fab31 Automatically add the visualizer module to programs running with waf --run --vis
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7863
diff changeset
  1027
            program_obj.use.append('ns3-visualizer')
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
  1028
        for gen in bld.all_task_gen:
11183
52ff59697ec9 bug 2002: Hardcoded include paths cause breakage
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11067
diff changeset
  1029
            if type(gen).__name__ in ['ns3header_taskgen', 'ns3privateheader_taskgen', 'ns3moduleheader_taskgen']:
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
  1030
                gen.post()
12564
f0e46b2c62df build: (fixes #2518) Suppress module list for Python programs
Ankit Deepak <adadeepak8@gmail.com>
parents: 12329
diff changeset
  1031
f0e46b2c62df build: (fixes #2518) Suppress module list for Python programs
Ankit Deepak <adadeepak8@gmail.com>
parents: 12329
diff changeset
  1032
    if Options.options.run or Options.options.pyrun:
7645
0baf0aea844a suppress list of modules built when running program from waf
Tom Henderson <tomh@tomh.org>
parents: 7636
diff changeset
  1033
        bld.env['PRINT_BUILT_MODULES_AT_END'] = False 
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
  1034
5468
6eebad1fb54d Bring back the --doxygen-no-build option from the dead.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5463
diff changeset
  1035
    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
  1036
        _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
  1037
        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
  1038
9239
02de8e19ce08 bug 1517: waf clean/distclean doesn't remove the doc/html directory
Tom Henderson <tomh@tomh.org>
parents: 9169
diff changeset
  1039
def _cleandir(name):
02de8e19ce08 bug 1517: waf clean/distclean doesn't remove the doc/html directory
Tom Henderson <tomh@tomh.org>
parents: 9169
diff changeset
  1040
    try:
02de8e19ce08 bug 1517: waf clean/distclean doesn't remove the doc/html directory
Tom Henderson <tomh@tomh.org>
parents: 9169
diff changeset
  1041
        shutil.rmtree(name)
02de8e19ce08 bug 1517: waf clean/distclean doesn't remove the doc/html directory
Tom Henderson <tomh@tomh.org>
parents: 9169
diff changeset
  1042
    except:
02de8e19ce08 bug 1517: waf clean/distclean doesn't remove the doc/html directory
Tom Henderson <tomh@tomh.org>
parents: 9169
diff changeset
  1043
        pass
7495
d87f20fd2421 waf1.6: remove code not needed, fix static build, cleanup
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7494
diff changeset
  1044
9239
02de8e19ce08 bug 1517: waf clean/distclean doesn't remove the doc/html directory
Tom Henderson <tomh@tomh.org>
parents: 9169
diff changeset
  1045
def _cleandocs():
02de8e19ce08 bug 1517: waf clean/distclean doesn't remove the doc/html directory
Tom Henderson <tomh@tomh.org>
parents: 9169
diff changeset
  1046
    _cleandir('doc/html')
13089
47e3db7a6275 [doxy] Add html-warn directory to waf clean
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 12808
diff changeset
  1047
    _cleandir('doc/html-warn')
9239
02de8e19ce08 bug 1517: waf clean/distclean doesn't remove the doc/html directory
Tom Henderson <tomh@tomh.org>
parents: 9169
diff changeset
  1048
    _cleandir('doc/manual/build')
9909
e8571e4f5394 include tutorial-pt-br in documentation build
Tom Henderson <tomh@tomh.org>
parents: 9874
diff changeset
  1049
    _cleandir('doc/manual/source-temp')
9239
02de8e19ce08 bug 1517: waf clean/distclean doesn't remove the doc/html directory
Tom Henderson <tomh@tomh.org>
parents: 9169
diff changeset
  1050
    _cleandir('doc/tutorial/build')
9909
e8571e4f5394 include tutorial-pt-br in documentation build
Tom Henderson <tomh@tomh.org>
parents: 9874
diff changeset
  1051
    _cleandir('doc/tutorial-pt-br/build')
9239
02de8e19ce08 bug 1517: waf clean/distclean doesn't remove the doc/html directory
Tom Henderson <tomh@tomh.org>
parents: 9169
diff changeset
  1052
    _cleandir('doc/models/build')
02de8e19ce08 bug 1517: waf clean/distclean doesn't remove the doc/html directory
Tom Henderson <tomh@tomh.org>
parents: 9169
diff changeset
  1053
    _cleandir('doc/models/source-temp')
02de8e19ce08 bug 1517: waf clean/distclean doesn't remove the doc/html directory
Tom Henderson <tomh@tomh.org>
parents: 9169
diff changeset
  1054
02de8e19ce08 bug 1517: waf clean/distclean doesn't remove the doc/html directory
Tom Henderson <tomh@tomh.org>
parents: 9169
diff changeset
  1055
# 'distclean' typically only cleans out build/ directory
02de8e19ce08 bug 1517: waf clean/distclean doesn't remove the doc/html directory
Tom Henderson <tomh@tomh.org>
parents: 9169
diff changeset
  1056
# Here we clean out any build or documentation artifacts not in build/
02de8e19ce08 bug 1517: waf clean/distclean doesn't remove the doc/html directory
Tom Henderson <tomh@tomh.org>
parents: 9169
diff changeset
  1057
def distclean(ctx):
02de8e19ce08 bug 1517: waf clean/distclean doesn't remove the doc/html directory
Tom Henderson <tomh@tomh.org>
parents: 9169
diff changeset
  1058
    _cleandocs()
02de8e19ce08 bug 1517: waf clean/distclean doesn't remove the doc/html directory
Tom Henderson <tomh@tomh.org>
parents: 9169
diff changeset
  1059
    # Now call waf's normal distclean
02de8e19ce08 bug 1517: waf clean/distclean doesn't remove the doc/html directory
Tom Henderson <tomh@tomh.org>
parents: 9169
diff changeset
  1060
    Scripting.distclean(ctx)
7495
d87f20fd2421 waf1.6: remove code not needed, fix static build, cleanup
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7494
diff changeset
  1061
4326
179f86838e62 Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4202
diff changeset
  1062
def shutdown(ctx):
179f86838e62 Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4202
diff changeset
  1063
    bld = wutils.bld
4328
20a0a6244177 waf fix
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4326
diff changeset
  1064
    if wutils.bld is None:
20a0a6244177 waf fix
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4326
diff changeset
  1065
        return
4326
179f86838e62 Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4202
diff changeset
  1066
    env = bld.env
179f86838e62 Upgrade to WAF 1.5.4
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4202
diff changeset
  1067
7636
58181e75d0f0 bug 1305 - do not list modules when exiting waf shell
Mitch Watrous <watrous@u.washington.edu>
parents: 7593
diff changeset
  1068
    # Only print the lists if a build was done.
58181e75d0f0 bug 1305 - do not list modules when exiting waf shell
Mitch Watrous <watrous@u.washington.edu>
parents: 7593
diff changeset
  1069
    if (env['PRINT_BUILT_MODULES_AT_END']):
7100
c3796788794a Make built modules list not be printed for clean and distclean
Mitch Watrous <watrous@u.washington.edu>
parents: 7097
diff changeset
  1070
7291
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
  1071
        # Print the list of built modules.
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11544
diff changeset
  1072
        print()
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11544
diff changeset
  1073
        print('Modules built:')
7863
5a610391f3f1 Bug 1392 - Modules built report does not clarify C++ or Python
Mitch Watrous <watrous@u.washington.edu>
parents: 7821
diff changeset
  1074
        names_without_prefix = []
12808
f2dba79bb5d1 build: (fixes #2630) Add contrib directory in parallel to src
Lauri Sormunen <lauri.sormunen@magister.fi>
parents: 12564
diff changeset
  1075
        for name in env['NS3_ENABLED_MODULES'] + env['NS3_ENABLED_CONTRIBUTED_MODULES']:
7863
5a610391f3f1 Bug 1392 - Modules built report does not clarify C++ or Python
Mitch Watrous <watrous@u.washington.edu>
parents: 7821
diff changeset
  1076
            name1 = name[len('ns3-'):]
5a610391f3f1 Bug 1392 - Modules built report does not clarify C++ or Python
Mitch Watrous <watrous@u.washington.edu>
parents: 7821
diff changeset
  1077
            if name not in env.MODULAR_BINDINGS_MODULES:
5a610391f3f1 Bug 1392 - Modules built report does not clarify C++ or Python
Mitch Watrous <watrous@u.washington.edu>
parents: 7821
diff changeset
  1078
                name1 += " (no Python)"
5a610391f3f1 Bug 1392 - Modules built report does not clarify C++ or Python
Mitch Watrous <watrous@u.washington.edu>
parents: 7821
diff changeset
  1079
            names_without_prefix.append(name1)
7293
0f574c532cee Make test module not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7291
diff changeset
  1080
        print_module_names(names_without_prefix)
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11544
diff changeset
  1081
        print()
7291
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
  1082
d39c09dbc3d9 Make emu and template modules not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7131
diff changeset
  1083
        # Print the list of enabled modules that were not built.
7293
0f574c532cee Make test module not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7291
diff changeset
  1084
        if env['MODULES_NOT_BUILT']:
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11544
diff changeset
  1085
            print('Modules not built (see ns-3 tutorial for explanation):')
7293
0f574c532cee Make test module not be built if not appropriate
Mitch Watrous <watrous@u.washington.edu>
parents: 7291
diff changeset
  1086
            print_module_names(env['MODULES_NOT_BUILT'])
11634
99173c0ad09b port wscripts, test.py, and waf-tools to Python3
Siddharth Santurkar <siddharth.santurkar@ieee.org>
parents: 11544
diff changeset
  1087
            print()
7066
948694386867 Print modules built list at end of waf build
Mitch Watrous <watrous@u.washington.edu>
parents: 7062
diff changeset
  1088
7636
58181e75d0f0 bug 1305 - do not list modules when exiting waf shell
Mitch Watrous <watrous@u.washington.edu>
parents: 7593
diff changeset
  1089
        # Set this so that the lists won't be printed until the next
58181e75d0f0 bug 1305 - do not list modules when exiting waf shell
Mitch Watrous <watrous@u.washington.edu>
parents: 7593
diff changeset
  1090
        # build is done.
58181e75d0f0 bug 1305 - do not list modules when exiting waf shell
Mitch Watrous <watrous@u.washington.edu>
parents: 7593
diff changeset
  1091
        bld.env['PRINT_BUILT_MODULES_AT_END'] = False
58181e75d0f0 bug 1305 - do not list modules when exiting waf shell
Mitch Watrous <watrous@u.washington.edu>
parents: 7593
diff changeset
  1092
7094
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
  1093
    # Write the build status file.
7495
d87f20fd2421 waf1.6: remove code not needed, fix static build, cleanup
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7494
diff changeset
  1094
    build_status_file = os.path.join(bld.out_dir, 'build-status.py')
7094
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
  1095
    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
  1096
    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
  1097
    out.write('\n')
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
  1098
    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
  1099
    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
  1100
    out.write('\n')
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
  1101
    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
  1102
    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
  1103
    out.write('\n')
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
  1104
    out.close()
f0748224dd68 Write a status file during waf build step
Mitch Watrous <watrous@u.washington.edu>
parents: 7088
diff changeset
  1105
4064
10222f483860 Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4029
diff changeset
  1106
    if Options.options.lcov_report:
7493
3bbefa91e694 Fix the --lcov-report option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7492
diff changeset