author | Gustavo J. A. M. Carneiro <gjc@inescporto.pt> |
Thu, 05 Jul 2007 14:48:21 +0100 | |
changeset 917 | aed7f1b9e783 |
parent 916 | 1eca7915ca9e |
child 918 | 1ecec08ba4ba |
permissions | -rw-r--r-- |
537
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
1 |
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- |
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
2 |
import os |
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
|
3 |
import sys |
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
|
4 |
import shlex |
695
90a68c1c4328
WAF: add a dist_hook function to exclude the generated documentation from waf dist
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
694
diff
changeset
|
5 |
import shutil |
537
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
6 |
|
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
7 |
import Params |
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
8 |
import Object |
649
1d12fb509a0d
WAF: import the WAF subprocess replacement module 'pproc', to make it work on Python 2.3.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
647
diff
changeset
|
9 |
import pproc as subprocess |
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
|
10 |
import optparse |
537
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
11 |
|
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
12 |
Params.g_autoconfig = 1 |
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
13 |
|
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
14 |
# the following two variables are used by the target "waf dist" |
694
bfad4514a789
WAF: correct values of VERSION and APPNAME, for waf dist
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
693
diff
changeset
|
15 |
VERSION = file("VERSION").read().strip() |
bfad4514a789
WAF: correct values of VERSION and APPNAME, for waf dist
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
693
diff
changeset
|
16 |
APPNAME = 'ns' |
537
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
17 |
|
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
18 |
# these variables are mandatory ('/' are converted automatically) |
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
19 |
srcdir = '.' |
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
20 |
blddir = 'build' |
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
21 |
|
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
|
22 |
def dist_hook(srcdir, blddir): |
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
|
23 |
shutil.rmtree("doc/html") |
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
|
24 |
shutil.rmtree("doc/latex") |
537
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
25 |
|
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
26 |
def set_options(opt): |
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
|
27 |
|
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
|
28 |
def debug_option_callback(option, opt, value, parser): |
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
|
29 |
if value == 'debug': |
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
|
30 |
setattr(parser.values, option.dest, 'ultradebug') |
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
|
31 |
elif value == 'optimized': |
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
|
32 |
setattr(parser.values, option.dest, 'optimized') |
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
|
33 |
else: |
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
|
34 |
raise optparse.OptionValueError("allowed --debug-level values" |
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
|
35 |
" are debug, optimized.") |
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
|
36 |
|
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
|
37 |
opt.add_option('-d', '--debug-level', |
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
|
38 |
action='callback', |
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
|
39 |
type=str, dest='debug_level', default='debug', |
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
|
40 |
help=('Specify the debug level, does nothing if CFLAGS is set' |
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
|
41 |
' in the environment. [Allowed Values: debug, optimized].' |
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
|
42 |
' 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
|
43 |
'with the configure command.'), |
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
|
44 |
callback=debug_option_callback) |
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
|
45 |
|
537
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
46 |
# options provided by the modules |
642
033f1f4891ab
Make WAF check for the abstract tool 'compiler_cxx', instead of manually checking for multiple compilers.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
600
diff
changeset
|
47 |
opt.tool_options('compiler_cxx') |
537
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
48 |
|
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
49 |
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
|
50 |
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
|
51 |
' 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
|
52 |
'with the configure command.'), |
537
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
53 |
action="store_true", default=False, |
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
54 |
dest='enable_gcov') |
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
55 |
|
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
56 |
opt.add_option('--lcov-report', |
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
57 |
help=('Generate a code coverage report ' |
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
58 |
'(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
|
59 |
action="store_true", default=False, |
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
60 |
dest='lcov_report') |
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
61 |
|
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
62 |
opt.add_option('--doxygen', |
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
63 |
help=('Run doxygen to generate html documentation from source comments'), |
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
64 |
action="store_true", default=False, |
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
65 |
dest='doxygen') |
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
66 |
|
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
|
67 |
opt.add_option('--run', |
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
|
68 |
help=('Run a locally built program'), |
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
|
69 |
type="string", default='', dest='run') |
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
|
70 |
|
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
|
71 |
opt.add_option('--shell', |
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
|
72 |
help=('Run a shell with an environment suitably modified to run locally built programs'), |
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
|
73 |
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
|
74 |
dest='shell') |
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
|
75 |
|
537
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
76 |
# options provided in a script in a subdirectory named "src" |
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
77 |
opt.sub_options('src') |
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
78 |
|
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
79 |
|
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
80 |
def configure(conf): |
642
033f1f4891ab
Make WAF check for the abstract tool 'compiler_cxx', instead of manually checking for multiple compilers.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
600
diff
changeset
|
81 |
if not conf.check_tool('compiler_cxx'): |
033f1f4891ab
Make WAF check for the abstract tool 'compiler_cxx', instead of manually checking for multiple compilers.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
600
diff
changeset
|
82 |
Params.fatal("No suitable compiler found") |
537
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
83 |
|
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
84 |
# create the second environment, set the variant and set its name |
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
85 |
variant_env = conf.env.copy() |
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
|
86 |
debug_level = Params.g_options.debug_level.lower() |
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
|
87 |
if debug_level == 'ultradebug': |
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
|
88 |
variant_name = 'debug' |
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
|
89 |
else: |
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
|
90 |
variant_name = debug_level |
537
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
91 |
|
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
92 |
if Params.g_options.enable_gcov: |
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
93 |
variant_name += '-gcov' |
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
94 |
variant_env.append_value('CCFLAGS', '-fprofile-arcs') |
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
95 |
variant_env.append_value('CCFLAGS', '-ftest-coverage') |
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
96 |
variant_env.append_value('CXXFLAGS', '-fprofile-arcs') |
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
97 |
variant_env.append_value('CXXFLAGS', '-ftest-coverage') |
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
98 |
variant_env.append_value('LINKFLAGS', '-fprofile-arcs') |
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
99 |
|
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
100 |
conf.env['NS3_ACTIVE_VARIANT'] = variant_name |
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
101 |
variant_env['NS3_ACTIVE_VARIANT'] = variant_name |
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
102 |
variant_env.set_variant(variant_name) |
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
103 |
conf.set_env_name(variant_name, variant_env) |
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
104 |
conf.setenv(variant_name) |
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
105 |
|
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
106 |
variant_env.append_value('CXXDEFINES', 'RUN_SELF_TESTS') |
786
78982ea24359
WAF: be careful not to set gcc-specific flags (like -Werror) when using a non-gcc compiler.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
785
diff
changeset
|
107 |
|
78982ea24359
WAF: be careful not to set gcc-specific flags (like -Werror) when using a non-gcc compiler.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
785
diff
changeset
|
108 |
if os.path.basename(conf.env['CXX']).startswith("g++"): |
78982ea24359
WAF: be careful not to set gcc-specific flags (like -Werror) when using a non-gcc compiler.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
785
diff
changeset
|
109 |
variant_env.append_value('CXXFLAGS', ['-Wall', '-Werror']) |
78982ea24359
WAF: be careful not to set gcc-specific flags (like -Werror) when using a non-gcc compiler.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
785
diff
changeset
|
110 |
|
537
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
111 |
if 'debug' in Params.g_options.debug_level.lower(): |
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
112 |
variant_env.append_value('CXXDEFINES', 'NS3_DEBUG_ENABLE') |
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
113 |
variant_env.append_value('CXXDEFINES', 'NS3_ASSERT_ENABLE') |
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
114 |
|
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
|
115 |
if sys.platform == 'win32': |
786
78982ea24359
WAF: be careful not to set gcc-specific flags (like -Werror) when using a non-gcc compiler.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
785
diff
changeset
|
116 |
if os.path.basename(conf.env['CXX']).startswith("g++"): |
78982ea24359
WAF: be careful not to set gcc-specific flags (like -Werror) when using a non-gcc compiler.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
785
diff
changeset
|
117 |
variant_env.append_value("LINKFLAGS", "-Wl,--enable-runtime-pseudo-reloc") |
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
|
118 |
|
537
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
119 |
conf.sub_config('src') |
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
120 |
|
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
121 |
|
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
122 |
def build(bld): |
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
123 |
variant_name = bld.env_of_name('default')['NS3_ACTIVE_VARIANT'] |
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
124 |
variant_env = bld.env_of_name(variant_name) |
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
125 |
bld.m_allenvs['default'] = variant_env # switch to the active variant |
762
b64b1d4eadc0
WAF: process --run and --shell command-line options sooner, before running the build, since we may need a shell before the build finishes, in case the program to debug is part of the build itself.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
695
diff
changeset
|
126 |
|
915
9006896544b3
WAF: make the --run option work again
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
787
diff
changeset
|
127 |
if Params.g_options.shell: |
762
b64b1d4eadc0
WAF: process --run and --shell command-line options sooner, before running the build, since we may need a shell before the build finishes, in case the program to debug is part of the build itself.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
695
diff
changeset
|
128 |
run_shell() |
b64b1d4eadc0
WAF: process --run and --shell command-line options sooner, before running the build, since we may need a shell before the build finishes, in case the program to debug is part of the build itself.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
695
diff
changeset
|
129 |
return |
b64b1d4eadc0
WAF: process --run and --shell command-line options sooner, before running the build, since we may need a shell before the build finishes, in case the program to debug is part of the build itself.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
695
diff
changeset
|
130 |
|
537
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
131 |
# process subfolders from here |
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
132 |
bld.add_subdirs('src') |
600
fd944dbf33c6
WAF: simplify wscripts using the new chained uselib_local dependencies feature of WAF SVN; now build all samples and examples; add --disable-rpath configure option; add WAF build instructions.
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
537
diff
changeset
|
133 |
bld.add_subdirs('samples utils examples') |
537
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
134 |
|
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
135 |
|
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
136 |
def shutdown(): |
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
|
137 |
#import UnitTest |
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
|
138 |
#ut = UnitTest.unit_test() |
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
|
139 |
#ut.change_to_testfile_dir = True |
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
|
140 |
#ut.want_to_see_test_output = True |
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
|
141 |
#ut.want_to_see_test_error = True |
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
|
142 |
#ut.run() |
537
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
143 |
#ut.print_results() |
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
144 |
|
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
|
145 |
if Params.g_commands['check']: |
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
|
146 |
run_program('run-tests') |
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
|
147 |
|
537
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
148 |
if Params.g_options.lcov_report: |
671
4bec4600950c
WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
649
diff
changeset
|
149 |
lcov_report() |
537
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
150 |
|
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
151 |
if Params.g_options.doxygen: |
671
4bec4600950c
WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
649
diff
changeset
|
152 |
doxygen() |
4bec4600950c
WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
649
diff
changeset
|
153 |
|
915
9006896544b3
WAF: make the --run option work again
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
787
diff
changeset
|
154 |
if Params.g_options.run: |
9006896544b3
WAF: make the --run option work again
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
787
diff
changeset
|
155 |
run_program(Params.g_options.run) |
9006896544b3
WAF: make the --run option work again
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
787
diff
changeset
|
156 |
|
672
184d5a505279
WAF: remove the rpath options, and add --run and --shell as replacements; additionally, the new options "should" work on Mac OS X, as well as linux2 and win32.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
671
diff
changeset
|
157 |
def _find_program(program_name): |
916
1eca7915ca9e
WAF: when the program specified by --run is not found, print a list of all available program names in the error message.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
915
diff
changeset
|
158 |
found_programs = [] |
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
|
159 |
for obj in Object.g_allobjs: |
916
1eca7915ca9e
WAF: when the program specified by --run is not found, print a list of all available program names in the error message.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
915
diff
changeset
|
160 |
if obj.m_type != 'program' or not obj.target: |
1eca7915ca9e
WAF: when the program specified by --run is not found, print a list of all available program names in the error message.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
915
diff
changeset
|
161 |
continue |
1eca7915ca9e
WAF: when the program specified by --run is not found, print a list of all available program names in the error message.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
915
diff
changeset
|
162 |
found_programs.append(obj.target) |
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
|
163 |
if obj.target == program_name: |
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
|
164 |
return obj |
917
aed7f1b9e783
WAF: fix simple typo in error message.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
916
diff
changeset
|
165 |
raise ValueError("program '%s' not found; available programs are: %r" |
916
1eca7915ca9e
WAF: when the program specified by --run is not found, print a list of all available program names in the error message.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
915
diff
changeset
|
166 |
% (program_name, found_programs)) |
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
|
167 |
|
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
|
168 |
def _run_argv(argv): |
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
|
169 |
env = Params.g_build.env_of_name('default') |
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
|
170 |
if sys.platform == 'linux2': |
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
|
171 |
pathvar = 'LD_LIBRARY_PATH' |
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
|
172 |
pathsep = ':' |
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
|
173 |
elif sys.platform == 'darwin': |
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
|
174 |
pathvar = 'DYLD_LIBRARY_PATH' |
184d5a505279
WAF: remove the rpath options, and add --run and --shell as replacements; additionally, the new options "should" work on Mac OS X, as well as linux2 and win32.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
671
diff
changeset
|
175 |
pathsep = ':' |
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 |
elif sys.platform == 'win32': |
184d5a505279
WAF: remove the rpath options, and add --run and --shell as replacements; additionally, the new options "should" work on Mac OS X, as well as linux2 and win32.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
671
diff
changeset
|
177 |
pathvar = 'PATH' |
184d5a505279
WAF: remove the rpath options, and add --run and --shell as replacements; additionally, the new options "should" work on Mac OS X, as well as linux2 and win32.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
671
diff
changeset
|
178 |
pathsep = ';' |
785
bf8e7773836a
WAF: configure dynamic path for the cygwin platform.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
764
diff
changeset
|
179 |
elif sys.platform == 'cygwin': |
bf8e7773836a
WAF: configure dynamic path for the cygwin platform.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
764
diff
changeset
|
180 |
pathvar = 'PATH' |
bf8e7773836a
WAF: configure dynamic path for the cygwin platform.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
764
diff
changeset
|
181 |
pathsep = ':' |
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
|
182 |
else: |
184d5a505279
WAF: remove the rpath options, and add --run and --shell as replacements; additionally, the new options "should" work on Mac OS X, as well as linux2 and win32.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
671
diff
changeset
|
183 |
Params.warning(("Don't know how to configure " |
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
|
184 |
"dynamic library path for the platform '%s'") % (sys.platform,)) |
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
|
185 |
pathvar = None |
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
|
186 |
pathsep = None |
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
|
187 |
|
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
|
188 |
os_env = dict(os.environ) |
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
|
189 |
if pathvar is not None: |
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
|
190 |
if pathvar in os_env: |
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
|
191 |
os_env[pathvar] = pathsep.join([os_env[pathvar]] + list(env['NS3_MODULE_PATH'])) |
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
|
192 |
else: |
184d5a505279
WAF: remove the rpath options, and add --run and --shell as replacements; additionally, the new options "should" work on Mac OS X, as well as linux2 and win32.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
671
diff
changeset
|
193 |
os_env[pathvar] = pathsep.join(list(env['NS3_MODULE_PATH'])) |
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
|
194 |
|
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
|
195 |
retval = subprocess.Popen(argv, env=os_env).wait() |
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
|
196 |
if retval: |
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 |
raise SystemExit(retval) |
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
|
198 |
|
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 |
|
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 |
def run_program(program_string): |
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
|
201 |
env = Params.g_build.env_of_name('default') |
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
|
202 |
argv = shlex.split(program_string) |
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
|
203 |
program_name = argv[0] |
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
|
204 |
|
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
|
205 |
try: |
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
|
206 |
program_obj = _find_program(program_name) |
916
1eca7915ca9e
WAF: when the program specified by --run is not found, print a list of all available program names in the error message.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
915
diff
changeset
|
207 |
except ValueError, ex: |
1eca7915ca9e
WAF: when the program specified by --run is not found, print a list of all available program names in the error message.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
915
diff
changeset
|
208 |
Params.fatal(str(ex)) |
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
|
209 |
|
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
|
210 |
try: |
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
|
211 |
program_node, = program_obj.m_linktask.m_outputs |
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
|
212 |
except AttributeError: |
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
|
213 |
Params.fatal("%s does not appear to be a program" % (program_name,)) |
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
|
214 |
|
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
|
215 |
execvec = [program_node.abspath(env)] + argv[1:] |
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
|
216 |
return _run_argv(execvec) |
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
|
217 |
|
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
|
218 |
|
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
|
219 |
def run_shell(): |
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
|
220 |
if sys.platform == 'win32': |
184d5a505279
WAF: remove the rpath options, and add --run and --shell as replacements; additionally, the new options "should" work on Mac OS X, as well as linux2 and win32.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
671
diff
changeset
|
221 |
shell = os.environ.get("COMSPEC", "cmd.exe") |
184d5a505279
WAF: remove the rpath options, and add --run and --shell as replacements; additionally, the new options "should" work on Mac OS X, as well as linux2 and win32.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
671
diff
changeset
|
222 |
else: |
184d5a505279
WAF: remove the rpath options, and add --run and --shell as replacements; additionally, the new options "should" work on Mac OS X, as well as linux2 and win32.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
671
diff
changeset
|
223 |
shell = os.environ.get("SHELL", "/bin/sh") |
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
|
224 |
_run_argv([shell]) |
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
|
225 |
|
671
4bec4600950c
WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
649
diff
changeset
|
226 |
|
4bec4600950c
WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
649
diff
changeset
|
227 |
def doxygen(): |
4bec4600950c
WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
649
diff
changeset
|
228 |
doxygen_config = os.path.join('doc', 'doxygen.conf') |
4bec4600950c
WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
649
diff
changeset
|
229 |
if subprocess.Popen(['doxygen', doxygen_config]).wait(): |
4bec4600950c
WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
649
diff
changeset
|
230 |
raise SystemExit(1) |
4bec4600950c
WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
649
diff
changeset
|
231 |
|
4bec4600950c
WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
649
diff
changeset
|
232 |
|
4bec4600950c
WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
649
diff
changeset
|
233 |
def lcov_report(): |
4bec4600950c
WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
649
diff
changeset
|
234 |
env = Params.g_build.env_of_name('default') |
4bec4600950c
WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
649
diff
changeset
|
235 |
variant_name = env['NS3_ACTIVE_VARIANT'] |
4bec4600950c
WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
649
diff
changeset
|
236 |
|
4bec4600950c
WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
649
diff
changeset
|
237 |
if 'gcov' not in variant_name: |
4bec4600950c
WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
649
diff
changeset
|
238 |
Params.fatal("project not configured for code coverage;" |
4bec4600950c
WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
649
diff
changeset
|
239 |
" reconfigure with --enable-gcov") |
4bec4600950c
WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
649
diff
changeset
|
240 |
|
4bec4600950c
WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
649
diff
changeset
|
241 |
os.chdir(blddir) |
4bec4600950c
WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
649
diff
changeset
|
242 |
try: |
4bec4600950c
WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
649
diff
changeset
|
243 |
lcov_report_dir = os.path.join(variant_name, 'lcov-report') |
4bec4600950c
WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
649
diff
changeset
|
244 |
create_dir_command = "rm -rf " + lcov_report_dir |
4bec4600950c
WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
649
diff
changeset
|
245 |
create_dir_command += " && mkdir " + lcov_report_dir + ";" |
4bec4600950c
WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
649
diff
changeset
|
246 |
|
4bec4600950c
WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
649
diff
changeset
|
247 |
if subprocess.Popen(create_dir_command, shell=True).wait(): |
537
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
248 |
raise SystemExit(1) |
e8a4183dfe00
Add support for building with WAF
Gustavo J. A. M. Carneiro <gjcarneiro@gmail.com>
parents:
diff
changeset
|
249 |
|
671
4bec4600950c
WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
649
diff
changeset
|
250 |
info_file = os.path.join(lcov_report_dir, variant_name + '.info') |
4bec4600950c
WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
649
diff
changeset
|
251 |
lcov_command = "../utils/lcov/lcov -c -d . -o " + info_file |
4bec4600950c
WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
649
diff
changeset
|
252 |
lcov_command += " --source-dirs=" + os.getcwd() |
4bec4600950c
WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
649
diff
changeset
|
253 |
lcov_command += ":" + os.path.join( |
4bec4600950c
WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
649
diff
changeset
|
254 |
os.getcwd(), variant_name, 'include') |
4bec4600950c
WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
649
diff
changeset
|
255 |
if subprocess.Popen(lcov_command, shell=True).wait(): |
4bec4600950c
WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
649
diff
changeset
|
256 |
raise SystemExit(1) |
4bec4600950c
WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
649
diff
changeset
|
257 |
|
4bec4600950c
WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
649
diff
changeset
|
258 |
genhtml_command = "../utils/lcov/genhtml -o " + lcov_report_dir |
4bec4600950c
WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
649
diff
changeset
|
259 |
genhtml_command += " " + info_file |
4bec4600950c
WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
649
diff
changeset
|
260 |
if subprocess.Popen(genhtml_command, shell=True).wait(): |
4bec4600950c
WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
649
diff
changeset
|
261 |
raise SystemExit(1) |
4bec4600950c
WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
649
diff
changeset
|
262 |
finally: |
4bec4600950c
WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
649
diff
changeset
|
263 |
os.chdir("..") |
4bec4600950c
WAF: cleanup code by putting lcov and doxygen handling into their own separate functions
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
649
diff
changeset
|
264 |