author | Gustavo J. A. M. Carneiro <gjc@inescporto.pt> |
Wed, 14 Jan 2009 11:17:41 +0000 | |
changeset 4088 | e52c06d86145 |
parent 4082 | 048db3e90b9b |
child 4101 | ca51ffa0d02b |
permissions | -rw-r--r-- |
3408 | 1 |
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- |
2 |
||
3 |
import re |
|
4 |
import os |
|
5 |
import pproc as subprocess |
|
6 |
import shutil |
|
3619
a97d3ed04035
Disable Python support on the CygWin platform, at least until/if the problems are fixed.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3612
diff
changeset
|
7 |
import sys |
3408 | 8 |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
9 |
import Task |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
10 |
import Options |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
11 |
import Configure |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
12 |
import TaskGen |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
13 |
import Logs |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
14 |
import Build |
4066
d2309cf765d8
Fix --python-scan
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4064
diff
changeset
|
15 |
import Utils |
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
16 |
|
3408 | 17 |
## Adjust python path to look for our local copy of pybindgen |
18 |
LOCAL_PYBINDGEN_PATH = os.path.join(os.getcwd(), "bindings", "python", "pybindgen") |
|
19 |
#PYBINDGEN_BRANCH = 'lp:pybindgen' |
|
20 |
PYBINDGEN_BRANCH = 'https://launchpad.net/pybindgen' |
|
21 |
||
22 |
## https://launchpad.net/pybindgen/ |
|
3868
827884bf1356
Fix build of Python bindings with Python 2.6
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3855
diff
changeset
|
23 |
REQUIRED_PYBINDGEN_VERSION = (0, 9, 0, 605) |
3408 | 24 |
REQUIRED_PYGCCXML_VERSION = (0, 9, 5) |
25 |
||
26 |
||
3873
2ad80d9647f0
Add a --with-pybindgen option, to allow external pybindgen to be used instead of fetching it from the network
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3868
diff
changeset
|
27 |
def add_to_python_path(path): |
2ad80d9647f0
Add a --with-pybindgen option, to allow external pybindgen to be used instead of fetching it from the network
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3868
diff
changeset
|
28 |
if os.environ.get('PYTHONPATH', ''): |
2ad80d9647f0
Add a --with-pybindgen option, to allow external pybindgen to be used instead of fetching it from the network
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3868
diff
changeset
|
29 |
os.environ['PYTHONPATH'] = path + os.pathsep + os.environ.get('PYTHONPATH') |
2ad80d9647f0
Add a --with-pybindgen option, to allow external pybindgen to be used instead of fetching it from the network
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3868
diff
changeset
|
30 |
else: |
2ad80d9647f0
Add a --with-pybindgen option, to allow external pybindgen to be used instead of fetching it from the network
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3868
diff
changeset
|
31 |
os.environ['PYTHONPATH'] = path |
2ad80d9647f0
Add a --with-pybindgen option, to allow external pybindgen to be used instead of fetching it from the network
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3868
diff
changeset
|
32 |
|
2ad80d9647f0
Add a --with-pybindgen option, to allow external pybindgen to be used instead of fetching it from the network
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3868
diff
changeset
|
33 |
def set_pybindgen_pythonpath(env): |
2ad80d9647f0
Add a --with-pybindgen option, to allow external pybindgen to be used instead of fetching it from the network
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3868
diff
changeset
|
34 |
if env['WITH_PYBINDGEN']: |
2ad80d9647f0
Add a --with-pybindgen option, to allow external pybindgen to be used instead of fetching it from the network
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3868
diff
changeset
|
35 |
add_to_python_path(env['WITH_PYBINDGEN']) |
2ad80d9647f0
Add a --with-pybindgen option, to allow external pybindgen to be used instead of fetching it from the network
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3868
diff
changeset
|
36 |
else: |
2ad80d9647f0
Add a --with-pybindgen option, to allow external pybindgen to be used instead of fetching it from the network
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3868
diff
changeset
|
37 |
add_to_python_path(LOCAL_PYBINDGEN_PATH) |
2ad80d9647f0
Add a --with-pybindgen option, to allow external pybindgen to be used instead of fetching it from the network
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3868
diff
changeset
|
38 |
|
2ad80d9647f0
Add a --with-pybindgen option, to allow external pybindgen to be used instead of fetching it from the network
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3868
diff
changeset
|
39 |
|
3408 | 40 |
def set_options(opt): |
41 |
opt.tool_options('python') |
|
3637
a6d8bf62a61d
For better consistency, option --nsc becomes --enable-nsc, --python-disable becomes --disable-python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3625
diff
changeset
|
42 |
opt.add_option('--disable-python', |
3408 | 43 |
help=("Don't build Python bindings."), |
44 |
action="store_true", default=False, |
|
45 |
dest='python_disable') |
|
46 |
opt.add_option('--python-scan', |
|
47 |
help=("Rescan Python bindings. Needs working GCCXML / pygccxml environment."), |
|
48 |
action="store_true", default=False, |
|
49 |
dest='python_scan') |
|
50 |
opt.add_option('--pybindgen-checkout', |
|
51 |
help=("During configure, force checkout of pybingen inside ns-3, " |
|
52 |
"instead of using the system installed version."), |
|
53 |
action="store_true", default=False, |
|
54 |
dest='pybindgen_checkout') |
|
3873
2ad80d9647f0
Add a --with-pybindgen option, to allow external pybindgen to be used instead of fetching it from the network
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3868
diff
changeset
|
55 |
opt.add_option('--with-pybindgen', |
2ad80d9647f0
Add a --with-pybindgen option, to allow external pybindgen to be used instead of fetching it from the network
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3868
diff
changeset
|
56 |
help=('Path to an existing pybindgen source tree to use.'), |
2ad80d9647f0
Add a --with-pybindgen option, to allow external pybindgen to be used instead of fetching it from the network
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3868
diff
changeset
|
57 |
default=None, |
2ad80d9647f0
Add a --with-pybindgen option, to allow external pybindgen to be used instead of fetching it from the network
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3868
diff
changeset
|
58 |
dest='with_pybindgen', type="string") |
3408 | 59 |
|
60 |
def fetch_pybindgen(conf): |
|
61 |
""" |
|
62 |
Fetches pybindgen from launchpad as bindings/python/pybindgen. |
|
63 |
Returns True if successful, False it not. |
|
64 |
""" |
|
65 |
bzr = conf.find_program("bzr") |
|
66 |
if not bzr: |
|
4067
165b38956c24
Convert warning to Logs.warn (waf api change)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4066
diff
changeset
|
67 |
Logs.warn("the program 'bzr' is needed in order to fetch pybindgen") |
3408 | 68 |
return False |
69 |
if len(REQUIRED_PYBINDGEN_VERSION) == 4: |
|
70 |
rev = "-rrevno:%i" % REQUIRED_PYBINDGEN_VERSION[3] |
|
71 |
else: |
|
72 |
rev = "-rtag:%s" % '.'.join([str(x) for x in REQUIRED_PYBINDGEN_VERSION]) |
|
3719
3307abd75322
Allow interrupting PyBindGen fetching, via Ctrl-C, for the impatient developers.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3663
diff
changeset
|
73 |
|
3408 | 74 |
if os.path.exists(LOCAL_PYBINDGEN_PATH): |
3719
3307abd75322
Allow interrupting PyBindGen fetching, via Ctrl-C, for the impatient developers.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3663
diff
changeset
|
75 |
print "Trying to update pybindgen; this will fail if no network connection is available. Hit Ctrl-C to skip." |
3408 | 76 |
|
77 |
cmd = [bzr, "pull", rev, PYBINDGEN_BRANCH] |
|
78 |
print " => ", ' '.join(cmd) |
|
3719
3307abd75322
Allow interrupting PyBindGen fetching, via Ctrl-C, for the impatient developers.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3663
diff
changeset
|
79 |
try: |
3307abd75322
Allow interrupting PyBindGen fetching, via Ctrl-C, for the impatient developers.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3663
diff
changeset
|
80 |
if subprocess.Popen(cmd, cwd=LOCAL_PYBINDGEN_PATH).wait(): |
3307abd75322
Allow interrupting PyBindGen fetching, via Ctrl-C, for the impatient developers.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3663
diff
changeset
|
81 |
return False |
3307abd75322
Allow interrupting PyBindGen fetching, via Ctrl-C, for the impatient developers.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3663
diff
changeset
|
82 |
except KeyboardInterrupt: |
3307abd75322
Allow interrupting PyBindGen fetching, via Ctrl-C, for the impatient developers.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3663
diff
changeset
|
83 |
print "Interrupted; Python bindings will be disabled." |
3408 | 84 |
return False |
85 |
print "Update was successful." |
|
86 |
else: |
|
3719
3307abd75322
Allow interrupting PyBindGen fetching, via Ctrl-C, for the impatient developers.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3663
diff
changeset
|
87 |
print "Trying to fetch pybindgen; this will fail if no network connection is available. Hit Ctrl-C to skip." |
3408 | 88 |
cmd = [bzr, "checkout", rev, PYBINDGEN_BRANCH, LOCAL_PYBINDGEN_PATH] |
89 |
print " => ", ' '.join(cmd) |
|
3719
3307abd75322
Allow interrupting PyBindGen fetching, via Ctrl-C, for the impatient developers.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3663
diff
changeset
|
90 |
try: |
3307abd75322
Allow interrupting PyBindGen fetching, via Ctrl-C, for the impatient developers.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3663
diff
changeset
|
91 |
if subprocess.Popen(cmd).wait(): |
3307abd75322
Allow interrupting PyBindGen fetching, via Ctrl-C, for the impatient developers.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3663
diff
changeset
|
92 |
return False |
3307abd75322
Allow interrupting PyBindGen fetching, via Ctrl-C, for the impatient developers.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3663
diff
changeset
|
93 |
except KeyboardInterrupt: |
3307abd75322
Allow interrupting PyBindGen fetching, via Ctrl-C, for the impatient developers.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3663
diff
changeset
|
94 |
print "Interrupted; Python bindings will be disabled." |
3307abd75322
Allow interrupting PyBindGen fetching, via Ctrl-C, for the impatient developers.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3663
diff
changeset
|
95 |
shutil.rmtree(LOCAL_PYBINDGEN_PATH, True) |
3408 | 96 |
return False |
97 |
print "Fetch was successful." |
|
98 |
||
99 |
## generate a fake version.py file in pybindgen it's safer this |
|
100 |
## way, since the normal version generation process requires |
|
101 |
## bazaar python bindings, which may not be available. |
|
102 |
vfile = open(os.path.join(LOCAL_PYBINDGEN_PATH, "pybindgen", "version.py"), "wt") |
|
103 |
vfile.write(""" |
|
104 |
# (fake version generated by ns-3) |
|
105 |
__version__ = %r |
|
106 |
""" % list(REQUIRED_PYBINDGEN_VERSION)) |
|
107 |
vfile.close() |
|
108 |
||
109 |
return True |
|
110 |
||
111 |
||
112 |
def configure(conf): |
|
113 |
conf.env['ENABLE_PYTHON_BINDINGS'] = False |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
114 |
if Options.options.python_disable: |
3625
30afad8324d5
Add a summary of optional features at the end of the configuration stage.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3624
diff
changeset
|
115 |
conf.report_optional_feature("python", "Python Bindings", False, |
30afad8324d5
Add a summary of optional features at the end of the configuration stage.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3624
diff
changeset
|
116 |
"disabled by user request") |
3408 | 117 |
return |
118 |
||
119 |
conf.check_tool('misc') |
|
120 |
||
3619
a97d3ed04035
Disable Python support on the CygWin platform, at least until/if the problems are fixed.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3612
diff
changeset
|
121 |
if sys.platform == 'cygwin': |
3625
30afad8324d5
Add a summary of optional features at the end of the configuration stage.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3624
diff
changeset
|
122 |
conf.report_optional_feature("python", "Python Bindings", False, |
30afad8324d5
Add a summary of optional features at the end of the configuration stage.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3624
diff
changeset
|
123 |
"unsupported platform 'cygwin'") |
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
124 |
Logs.warn("Python is not supported in CygWin environment. Try MingW instead.") |
3619
a97d3ed04035
Disable Python support on the CygWin platform, at least until/if the problems are fixed.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3612
diff
changeset
|
125 |
return |
a97d3ed04035
Disable Python support on the CygWin platform, at least until/if the problems are fixed.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3612
diff
changeset
|
126 |
|
3408 | 127 |
## Check for Python |
128 |
try: |
|
129 |
conf.check_tool('python') |
|
3473
6bce86ea4778
Require new PyBindGen; make it work for Python 2.3.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3468
diff
changeset
|
130 |
conf.check_python_version((2,3)) |
3408 | 131 |
conf.check_python_headers() |
3625
30afad8324d5
Add a summary of optional features at the end of the configuration stage.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3624
diff
changeset
|
132 |
except Configure.ConfigurationError, ex: |
30afad8324d5
Add a summary of optional features at the end of the configuration stage.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3624
diff
changeset
|
133 |
conf.report_optional_feature("python", "Python Bindings", False, str(ex)) |
3408 | 134 |
return |
135 |
||
136 |
## Check for pybindgen |
|
3873
2ad80d9647f0
Add a --with-pybindgen option, to allow external pybindgen to be used instead of fetching it from the network
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3868
diff
changeset
|
137 |
|
2ad80d9647f0
Add a --with-pybindgen option, to allow external pybindgen to be used instead of fetching it from the network
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3868
diff
changeset
|
138 |
no_net = False |
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
139 |
if Options.options.with_pybindgen: |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
140 |
conf.env['WITH_PYBINDGEN'] = os.path.abspath(Options.options.with_pybindgen) |
3873
2ad80d9647f0
Add a --with-pybindgen option, to allow external pybindgen to be used instead of fetching it from the network
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3868
diff
changeset
|
141 |
no_net = True |
2ad80d9647f0
Add a --with-pybindgen option, to allow external pybindgen to be used instead of fetching it from the network
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3868
diff
changeset
|
142 |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
143 |
if Options.options.pybindgen_checkout: |
3408 | 144 |
fetch_pybindgen(conf) |
145 |
||
3873
2ad80d9647f0
Add a --with-pybindgen option, to allow external pybindgen to be used instead of fetching it from the network
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3868
diff
changeset
|
146 |
set_pybindgen_pythonpath(conf.env) |
2ad80d9647f0
Add a --with-pybindgen option, to allow external pybindgen to be used instead of fetching it from the network
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3868
diff
changeset
|
147 |
|
3408 | 148 |
try: |
149 |
conf.check_python_module('pybindgen') |
|
150 |
except Configure.ConfigurationError: |
|
4077
d2e461e575f4
Don't build or fetch NSC/pybindgen, those tasks are now moved to ns-3-allinone
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4076
diff
changeset
|
151 |
Logs.warn("pybindgen missing => no python bindings") |
d2e461e575f4
Don't build or fetch NSC/pybindgen, those tasks are now moved to ns-3-allinone
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4076
diff
changeset
|
152 |
conf.report_optional_feature("python", "Python Bindings", False, |
d2e461e575f4
Don't build or fetch NSC/pybindgen, those tasks are now moved to ns-3-allinone
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4076
diff
changeset
|
153 |
"PyBindGen missing") |
4082
048db3e90b9b
Bug 467: waf configure enables python after detecting pybindgen is missing
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4077
diff
changeset
|
154 |
return |
3408 | 155 |
else: |
156 |
out = subprocess.Popen([conf.env['PYTHON'], "-c", |
|
157 |
"import pybindgen.version; " |
|
158 |
"print '.'.join([str(x) for x in pybindgen.version.__version__])"], |
|
159 |
stdout=subprocess.PIPE).communicate()[0] |
|
160 |
pybindgen_version_str = out.strip() |
|
161 |
pybindgen_version = tuple([int(x) for x in pybindgen_version_str.split('.')]) |
|
162 |
conf.check_message('pybindgen', 'version', |
|
163 |
(pybindgen_version >= REQUIRED_PYBINDGEN_VERSION), |
|
164 |
pybindgen_version_str) |
|
165 |
if not (pybindgen_version >= REQUIRED_PYBINDGEN_VERSION): |
|
4067
165b38956c24
Convert warning to Logs.warn (waf api change)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4066
diff
changeset
|
166 |
Logs.warn("pybindgen (found %s) is too old (need %s)" % |
3408 | 167 |
(pybindgen_version_str, |
168 |
'.'.join([str(x) for x in REQUIRED_PYBINDGEN_VERSION]))) |
|
3873
2ad80d9647f0
Add a --with-pybindgen option, to allow external pybindgen to be used instead of fetching it from the network
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3868
diff
changeset
|
169 |
if no_net or not fetch_pybindgen(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:
3624
diff
changeset
|
170 |
conf.report_optional_feature("python", "Python Bindings", False, |
30afad8324d5
Add a summary of optional features at the end of the configuration stage.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3624
diff
changeset
|
171 |
"PyBindGen too old and newer version could not be retrieved") |
3408 | 172 |
return |
173 |
||
174 |
## If all has gone well, we finally enable the Python bindings |
|
175 |
conf.env['ENABLE_PYTHON_BINDINGS'] = True |
|
3625
30afad8324d5
Add a summary of optional features at the end of the configuration stage.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3624
diff
changeset
|
176 |
conf.report_optional_feature("python", "Python Bindings", True, None) |
3408 | 177 |
|
178 |
## Check for pygccxml |
|
179 |
try: |
|
180 |
conf.check_python_module('pygccxml') |
|
181 |
except Configure.ConfigurationError: |
|
3625
30afad8324d5
Add a summary of optional features at the end of the configuration stage.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3624
diff
changeset
|
182 |
conf.report_optional_feature("pygccxml", "Python API Scanning Support", False, |
30afad8324d5
Add a summary of optional features at the end of the configuration stage.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3624
diff
changeset
|
183 |
"Missing 'pygccxml' Python module") |
3408 | 184 |
return |
185 |
||
186 |
out = subprocess.Popen([conf.env['PYTHON'], "-c", |
|
187 |
"import pygccxml; print pygccxml.__version__"], |
|
188 |
stdout=subprocess.PIPE).communicate()[0] |
|
189 |
pygccxml_version_str = out.strip() |
|
190 |
pygccxml_version = tuple([int(x) for x in pygccxml_version_str.split('.')]) |
|
191 |
conf.check_message('pygccxml', 'version', |
|
192 |
(pygccxml_version >= REQUIRED_PYGCCXML_VERSION), |
|
193 |
pygccxml_version_str) |
|
194 |
if not (pygccxml_version >= REQUIRED_PYGCCXML_VERSION): |
|
4067
165b38956c24
Convert warning to Logs.warn (waf api change)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4066
diff
changeset
|
195 |
Logs.warn("pygccxml (found %s) is too old (need %s) => " |
3408 | 196 |
"automatic scanning of API definitions will not be possible" % |
197 |
(pygccxml_version_str, |
|
198 |
'.'.join([str(x) for x in REQUIRED_PYGCCXML_VERSION]))) |
|
3625
30afad8324d5
Add a summary of optional features at the end of the configuration stage.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3624
diff
changeset
|
199 |
conf.report_optional_feature("pygccxml", "Python API Scanning Support", False, |
30afad8324d5
Add a summary of optional features at the end of the configuration stage.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3624
diff
changeset
|
200 |
"pygccxml too old") |
3408 | 201 |
return |
202 |
||
203 |
||
204 |
## Check gccxml version |
|
205 |
gccxml = conf.find_program('gccxml', var='GCCXML') |
|
206 |
if not gccxml: |
|
4067
165b38956c24
Convert warning to Logs.warn (waf api change)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4066
diff
changeset
|
207 |
Logs.warn("gccxml missing; automatic scanning of API definitions will not be possible") |
3625
30afad8324d5
Add a summary of optional features at the end of the configuration stage.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3624
diff
changeset
|
208 |
conf.report_optional_feature("pygccxml", "Python API Scanning Support", False, |
30afad8324d5
Add a summary of optional features at the end of the configuration stage.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3624
diff
changeset
|
209 |
"gccxml missing") |
3408 | 210 |
return |
211 |
||
212 |
gccxml_version_line = os.popen(gccxml + " --version").readline().strip() |
|
213 |
m = re.match( "^GCC-XML version (\d\.\d(\.\d)?)$", gccxml_version_line) |
|
214 |
gccxml_version = m.group(1) |
|
215 |
gccxml_version_ok = ([int(s) for s in gccxml_version.split('.')] >= [0, 9]) |
|
216 |
conf.check_message('gccxml', 'version', True, gccxml_version) |
|
217 |
if not gccxml_version_ok: |
|
4067
165b38956c24
Convert warning to Logs.warn (waf api change)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4066
diff
changeset
|
218 |
Logs.warn("gccxml too old, need version >= 0.9; automatic scanning of API definitions will not be possible") |
3625
30afad8324d5
Add a summary of optional features at the end of the configuration stage.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3624
diff
changeset
|
219 |
conf.report_optional_feature("pygccxml", "Python API Scanning Support", False, |
30afad8324d5
Add a summary of optional features at the end of the configuration stage.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3624
diff
changeset
|
220 |
"gccxml too old") |
3408 | 221 |
return |
222 |
||
223 |
## If we reached |
|
224 |
conf.env['ENABLE_PYTHON_SCANNING'] = True |
|
3625
30afad8324d5
Add a summary of optional features at the end of the configuration stage.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3624
diff
changeset
|
225 |
conf.report_optional_feature("pygccxml", "Python API Scanning Support", True, None) |
3408 | 226 |
|
227 |
||
228 |
prio_headers = { |
|
229 |
-2: ( |
|
230 |
"string.h", # work around http://www.gccxml.org/Bug/view.php?id=6682 |
|
231 |
), |
|
232 |
-1: ( |
|
233 |
"propagation-delay-model.h", |
|
234 |
"propagation-loss-model.h", |
|
235 |
"net-device.h", |
|
236 |
) |
|
237 |
} |
|
238 |
||
239 |
def get_header_prio(header): |
|
240 |
for prio, headers in prio_headers.iteritems(): |
|
241 |
if header in headers: |
|
242 |
return prio |
|
243 |
return 1 |
|
244 |
||
3485
26de1421d000
When generating the everything.h header file for Python, handle ns3 headers inside subdirectories properly.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3474
diff
changeset
|
245 |
|
26de1421d000
When generating the everything.h header file for Python, handle ns3 headers inside subdirectories properly.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3474
diff
changeset
|
246 |
def calc_header_include(path): |
26de1421d000
When generating the everything.h header file for Python, handle ns3 headers inside subdirectories properly.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3474
diff
changeset
|
247 |
(head, tail) = os.path.split (path) |
26de1421d000
When generating the everything.h header file for Python, handle ns3 headers inside subdirectories properly.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3474
diff
changeset
|
248 |
if tail == 'ns3': |
26de1421d000
When generating the everything.h header file for Python, handle ns3 headers inside subdirectories properly.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3474
diff
changeset
|
249 |
return '' |
26de1421d000
When generating the everything.h header file for Python, handle ns3 headers inside subdirectories properly.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3474
diff
changeset
|
250 |
else: |
26de1421d000
When generating the everything.h header file for Python, handle ns3 headers inside subdirectories properly.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3474
diff
changeset
|
251 |
return os.path.join (calc_header_include (head), tail) |
26de1421d000
When generating the everything.h header file for Python, handle ns3 headers inside subdirectories properly.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3474
diff
changeset
|
252 |
|
26de1421d000
When generating the everything.h header file for Python, handle ns3 headers inside subdirectories properly.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3474
diff
changeset
|
253 |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
254 |
class gen_everything_h_task(Task.Task): |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
255 |
before = 'cc cxx' |
4068
e0eb69d55e40
correct dependency problem
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4067
diff
changeset
|
256 |
after = 'ns3header_task' |
e0eb69d55e40
correct dependency problem
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4067
diff
changeset
|
257 |
color = 'BLUE' |
3485
26de1421d000
When generating the everything.h header file for Python, handle ns3 headers inside subdirectories properly.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3474
diff
changeset
|
258 |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
259 |
def run(self): |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
260 |
assert len(self.outputs) == 1 |
3408 | 261 |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
262 |
header_files = [calc_header_include(node.abspath(self.env)) for node in self.inputs] |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
263 |
outfile = file(self.outputs[0].bldpath(self.env), "w") |
3408 | 264 |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
265 |
def sort_func(h1, h2): |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
266 |
return cmp((get_header_prio(h1), h1), (get_header_prio(h1), h2)) |
3408 | 267 |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
268 |
header_files.sort(sort_func) |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
269 |
|
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
270 |
print >> outfile, """ |
3917
fe95a4f9d423
Work around #define ECHO in a system header file included by Python.h on Mac OS X (bug #413)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3875
diff
changeset
|
271 |
|
fe95a4f9d423
Work around #define ECHO in a system header file included by Python.h on Mac OS X (bug #413)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3875
diff
changeset
|
272 |
/* http://www.nsnam.org/bugzilla/show_bug.cgi?id=413 */ |
fe95a4f9d423
Work around #define ECHO in a system header file included by Python.h on Mac OS X (bug #413)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3875
diff
changeset
|
273 |
#ifdef ECHO |
fe95a4f9d423
Work around #define ECHO in a system header file included by Python.h on Mac OS X (bug #413)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3875
diff
changeset
|
274 |
# undef ECHO |
fe95a4f9d423
Work around #define ECHO in a system header file included by Python.h on Mac OS X (bug #413)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3875
diff
changeset
|
275 |
#endif |
fe95a4f9d423
Work around #define ECHO in a system header file included by Python.h on Mac OS X (bug #413)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3875
diff
changeset
|
276 |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
277 |
""" |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
278 |
for header in header_files: |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
279 |
print >> outfile, "#include \"ns3/%s\"" % (header,) |
3408 | 280 |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
281 |
print >> outfile, """ |
3408 | 282 |
namespace ns3 { |
283 |
static inline Ptr<Object> |
|
284 |
__dummy_function_to_force_template_instantiation (Ptr<Object> obj, TypeId typeId) |
|
285 |
{ |
|
286 |
return obj->GetObject<Object> (typeId); |
|
287 |
} |
|
288 |
||
3731
317f9dbccc2b
New pybindgen and new API scanning, brings support for comparison operators and + - * / numeric operators.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3728
diff
changeset
|
289 |
|
317f9dbccc2b
New pybindgen and new API scanning, brings support for comparison operators and + - * / numeric operators.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3728
diff
changeset
|
290 |
static inline void |
317f9dbccc2b
New pybindgen and new API scanning, brings support for comparison operators and + - * / numeric operators.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3728
diff
changeset
|
291 |
__dummy_function_to_force_template_instantiation_v2 () |
317f9dbccc2b
New pybindgen and new API scanning, brings support for comparison operators and + - * / numeric operators.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3728
diff
changeset
|
292 |
{ |
317f9dbccc2b
New pybindgen and new API scanning, brings support for comparison operators and + - * / numeric operators.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3728
diff
changeset
|
293 |
Time t1, t2, t3; |
317f9dbccc2b
New pybindgen and new API scanning, brings support for comparison operators and + - * / numeric operators.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3728
diff
changeset
|
294 |
t1 = t2 + t3; |
317f9dbccc2b
New pybindgen and new API scanning, brings support for comparison operators and + - * / numeric operators.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3728
diff
changeset
|
295 |
t1 = t2 - t3; |
317f9dbccc2b
New pybindgen and new API scanning, brings support for comparison operators and + - * / numeric operators.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3728
diff
changeset
|
296 |
TimeSquare tsq = t2*t3; |
317f9dbccc2b
New pybindgen and new API scanning, brings support for comparison operators and + - * / numeric operators.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3728
diff
changeset
|
297 |
Time tsqdiv = tsq/Seconds(1); |
317f9dbccc2b
New pybindgen and new API scanning, brings support for comparison operators and + - * / numeric operators.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3728
diff
changeset
|
298 |
Scalar scal = t2/t3; |
317f9dbccc2b
New pybindgen and new API scanning, brings support for comparison operators and + - * / numeric operators.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3728
diff
changeset
|
299 |
TimeInvert inv = scal/t3; |
317f9dbccc2b
New pybindgen and new API scanning, brings support for comparison operators and + - * / numeric operators.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3728
diff
changeset
|
300 |
t1 = scal*t1; |
317f9dbccc2b
New pybindgen and new API scanning, brings support for comparison operators and + - * / numeric operators.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3728
diff
changeset
|
301 |
t1 = t1/scal; |
317f9dbccc2b
New pybindgen and new API scanning, brings support for comparison operators and + - * / numeric operators.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3728
diff
changeset
|
302 |
t1 < t2; |
317f9dbccc2b
New pybindgen and new API scanning, brings support for comparison operators and + - * / numeric operators.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3728
diff
changeset
|
303 |
t1 <= t2; |
317f9dbccc2b
New pybindgen and new API scanning, brings support for comparison operators and + - * / numeric operators.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3728
diff
changeset
|
304 |
t1 == t2; |
317f9dbccc2b
New pybindgen and new API scanning, brings support for comparison operators and + - * / numeric operators.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3728
diff
changeset
|
305 |
t1 != t2; |
317f9dbccc2b
New pybindgen and new API scanning, brings support for comparison operators and + - * / numeric operators.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3728
diff
changeset
|
306 |
t1 >= t2; |
317f9dbccc2b
New pybindgen and new API scanning, brings support for comparison operators and + - * / numeric operators.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3728
diff
changeset
|
307 |
t1 > t2; |
317f9dbccc2b
New pybindgen and new API scanning, brings support for comparison operators and + - * / numeric operators.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3728
diff
changeset
|
308 |
} |
317f9dbccc2b
New pybindgen and new API scanning, brings support for comparison operators and + - * / numeric operators.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3728
diff
changeset
|
309 |
|
3929
909b0a724ed3
Bug 289: CommandLine::AddValue is not wrapped
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3917
diff
changeset
|
310 |
|
3408 | 311 |
} |
312 |
""" |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
313 |
outfile.close() |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
314 |
return 0 |
3408 | 315 |
|
316 |
||
3541
15fe83e15ff5
Don't scan python bindings until the everything.h file to be scanned is generated. Closes #288.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3540
diff
changeset
|
317 |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
318 |
class all_ns3_headers_taskgen(TaskGen.task_gen): |
3408 | 319 |
"""Generates a 'everything.h' header file that includes some/all public ns3 headers. |
320 |
This single header file is to be parsed only once by gccxml, for greater efficiency. |
|
321 |
""" |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
322 |
def __init__(self, *args, **kwargs): |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
323 |
super(all_ns3_headers_taskgen, self).__init__(*args, **kwargs) |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
324 |
self.install_path = None |
3409
94ac3e381075
The 'everything.h' header file is only used for Python bindings and should be generated into bindings/python/, not ns3/.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3408
diff
changeset
|
325 |
#self.inst_dir = 'ns3' |
3408 | 326 |
|
327 |
def apply(self): |
|
328 |
## get all of the ns3 headers |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
329 |
ns3_dir_node = Build.bld.path.find_dir("ns3") |
3408 | 330 |
all_headers_inputs = [] |
331 |
||
332 |
for filename in self.to_list(self.source): |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
333 |
src_node = ns3_dir_node.find_or_declare(filename) |
3408 | 334 |
if src_node is None: |
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
335 |
raise Utils.WafError("source ns3 header file %s not found" % (filename,)) |
3408 | 336 |
all_headers_inputs.append(src_node) |
337 |
||
338 |
## if self.source was empty, include all ns3 headers in enabled modules |
|
339 |
if not all_headers_inputs: |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
340 |
for ns3headers in Build.bld.all_task_gen: |
3408 | 341 |
if type(ns3headers).__name__ == 'ns3header_taskgen': # XXX: find less hackish way to compare |
342 |
## skip headers not part of enabled modules |
|
343 |
if self.env['NS3_ENABLED_MODULES']: |
|
344 |
if ("ns3-%s" % ns3headers.module) not in self.env['NS3_ENABLED_MODULES']: |
|
345 |
continue |
|
346 |
||
347 |
for source in ns3headers.to_list(ns3headers.source): |
|
3485
26de1421d000
When generating the everything.h header file for Python, handle ns3 headers inside subdirectories properly.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3474
diff
changeset
|
348 |
#source = os.path.basename(source) |
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
349 |
node = ns3_dir_node.find_or_declare(source) |
3408 | 350 |
if node is None: |
4067
165b38956c24
Convert warning to Logs.warn (waf api change)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4066
diff
changeset
|
351 |
raise Utils.WafError("missing header file %s" % (source,)) |
3408 | 352 |
all_headers_inputs.append(node) |
353 |
assert all_headers_inputs |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
354 |
all_headers_outputs = [self.path.find_or_declare("everything.h")] |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
355 |
task = self.create_task('gen_everything_h', self.env) |
3408 | 356 |
task.set_inputs(all_headers_inputs) |
357 |
task.set_outputs(all_headers_outputs) |
|
358 |
||
359 |
def install(self): |
|
360 |
pass |
|
361 |
||
362 |
||
363 |
def get_modules_and_headers(): |
|
364 |
""" |
|
365 |
Gets a dict of |
|
366 |
module_name => ([module_dep1, module_dep2, ...], [module_header1, module_header2, ...]) |
|
367 |
tuples, one for each module. |
|
368 |
""" |
|
369 |
||
370 |
retval = {} |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
371 |
for module in Build.bld.all_task_gen: |
3408 | 372 |
if not module.name.startswith('ns3-'): |
373 |
continue |
|
374 |
module_name = module.name[4:] # strip the ns3- prefix |
|
375 |
## find the headers object for this module |
|
376 |
headers = [] |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
377 |
for ns3headers in Build.bld.all_task_gen: |
3408 | 378 |
if type(ns3headers).__name__ != 'ns3header_taskgen': # XXX: find less hackish way to compare |
379 |
continue |
|
380 |
if ns3headers.module != module_name: |
|
381 |
continue |
|
382 |
for source in ns3headers.to_list(ns3headers.source): |
|
383 |
headers.append(source) |
|
384 |
retval[module_name] = (list(module.module_deps), headers) |
|
385 |
return retval |
|
386 |
||
387 |
||
3541
15fe83e15ff5
Don't scan python bindings until the everything.h file to be scanned is generated. Closes #288.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3540
diff
changeset
|
388 |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
389 |
class python_scan_task(Task.TaskBase): |
3541
15fe83e15ff5
Don't scan python bindings until the everything.h file to be scanned is generated. Closes #288.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3540
diff
changeset
|
390 |
"""Uses gccxml to scan the file 'everything.h' and extract API definitions. |
15fe83e15ff5
Don't scan python bindings until the everything.h file to be scanned is generated. Closes #288.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3540
diff
changeset
|
391 |
""" |
4066
d2309cf765d8
Fix --python-scan
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4064
diff
changeset
|
392 |
after = 'gen_everything_h_task' |
d2309cf765d8
Fix --python-scan
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4064
diff
changeset
|
393 |
before = 'cc cxx' |
3541
15fe83e15ff5
Don't scan python bindings until the everything.h file to be scanned is generated. Closes #288.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3540
diff
changeset
|
394 |
def __init__(self, curdirnode, env): |
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
395 |
super(python_scan_task, self).__init__() |
3541
15fe83e15ff5
Don't scan python bindings until the everything.h file to be scanned is generated. Closes #288.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3540
diff
changeset
|
396 |
self.curdirnode = curdirnode |
15fe83e15ff5
Don't scan python bindings until the everything.h file to be scanned is generated. Closes #288.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3540
diff
changeset
|
397 |
self.env = env |
4066
d2309cf765d8
Fix --python-scan
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4064
diff
changeset
|
398 |
|
d2309cf765d8
Fix --python-scan
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4064
diff
changeset
|
399 |
def display(self): |
d2309cf765d8
Fix --python-scan
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4064
diff
changeset
|
400 |
return 'python-scan\n' |
3541
15fe83e15ff5
Don't scan python bindings until the everything.h file to be scanned is generated. Closes #288.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3540
diff
changeset
|
401 |
|
15fe83e15ff5
Don't scan python bindings until the everything.h file to be scanned is generated. Closes #288.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3540
diff
changeset
|
402 |
def run(self): |
15fe83e15ff5
Don't scan python bindings until the everything.h file to be scanned is generated. Closes #288.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3540
diff
changeset
|
403 |
#print "Rescanning the python bindings..." |
15fe83e15ff5
Don't scan python bindings until the everything.h file to be scanned is generated. Closes #288.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3540
diff
changeset
|
404 |
argv = [ |
15fe83e15ff5
Don't scan python bindings until the everything.h file to be scanned is generated. Closes #288.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3540
diff
changeset
|
405 |
self.env['PYTHON'], |
15fe83e15ff5
Don't scan python bindings until the everything.h file to be scanned is generated. Closes #288.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3540
diff
changeset
|
406 |
os.path.join(self.curdirnode.abspath(), 'ns3modulescan.py'), # scanning script |
15fe83e15ff5
Don't scan python bindings until the everything.h file to be scanned is generated. Closes #288.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3540
diff
changeset
|
407 |
self.curdirnode.find_dir('../..').abspath(self.env), # include path (where the ns3 include dir is) |
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
408 |
self.curdirnode.find_or_declare('everything.h').abspath(self.env), |
3541
15fe83e15ff5
Don't scan python bindings until the everything.h file to be scanned is generated. Closes #288.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3540
diff
changeset
|
409 |
os.path.join(self.curdirnode.abspath(), 'ns3modulegen_generated.py'), # output file |
15fe83e15ff5
Don't scan python bindings until the everything.h file to be scanned is generated. Closes #288.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3540
diff
changeset
|
410 |
] |
15fe83e15ff5
Don't scan python bindings until the everything.h file to be scanned is generated. Closes #288.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3540
diff
changeset
|
411 |
scan = subprocess.Popen(argv, stdin=subprocess.PIPE) |
15fe83e15ff5
Don't scan python bindings until the everything.h file to be scanned is generated. Closes #288.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3540
diff
changeset
|
412 |
scan.stdin.write(repr(get_modules_and_headers())) |
15fe83e15ff5
Don't scan python bindings until the everything.h file to be scanned is generated. Closes #288.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3540
diff
changeset
|
413 |
scan.stdin.close() |
4066
d2309cf765d8
Fix --python-scan
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4064
diff
changeset
|
414 |
retval = scan.wait() |
d2309cf765d8
Fix --python-scan
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4064
diff
changeset
|
415 |
print "Scan finished with exit code", retval |
d2309cf765d8
Fix --python-scan
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4064
diff
changeset
|
416 |
if retval: |
d2309cf765d8
Fix --python-scan
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4064
diff
changeset
|
417 |
return retval |
d2309cf765d8
Fix --python-scan
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4064
diff
changeset
|
418 |
# signal stop (we generated files into the source dir and WAF |
d2309cf765d8
Fix --python-scan
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4064
diff
changeset
|
419 |
# can't cope with it, so we have to force the user to restart |
d2309cf765d8
Fix --python-scan
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4064
diff
changeset
|
420 |
# WAF) |
d2309cf765d8
Fix --python-scan
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4064
diff
changeset
|
421 |
Build.bld.generator.stop = 1 |
d2309cf765d8
Fix --python-scan
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4064
diff
changeset
|
422 |
return 0 |
d2309cf765d8
Fix --python-scan
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4064
diff
changeset
|
423 |
|
3541
15fe83e15ff5
Don't scan python bindings until the everything.h file to be scanned is generated. Closes #288.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3540
diff
changeset
|
424 |
|
3408 | 425 |
def build(bld): |
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
426 |
if Options.options.python_disable: |
3408 | 427 |
return |
428 |
||
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
429 |
env = bld.env |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
430 |
curdir = bld.path.abspath() |
3591
f548d13ffd4e
Fix build when ns3_module_*__local.py files are used.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3575
diff
changeset
|
431 |
|
3873
2ad80d9647f0
Add a --with-pybindgen option, to allow external pybindgen to be used instead of fetching it from the network
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3868
diff
changeset
|
432 |
set_pybindgen_pythonpath(env) |
2ad80d9647f0
Add a --with-pybindgen option, to allow external pybindgen to be used instead of fetching it from the network
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3868
diff
changeset
|
433 |
|
3486
818a6bbef490
Only generate everything.h if python bindings are enabled. Based on patch by Mathieu Lacage. Closes #260.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3485
diff
changeset
|
434 |
if env['ENABLE_PYTHON_BINDINGS']: |
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
435 |
obj = bld.new_task_gen('all_ns3_headers') |
3408 | 436 |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
437 |
if Options.options.python_scan: |
3408 | 438 |
if not env['ENABLE_PYTHON_SCANNING']: |
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
439 |
raise Utils.WafError("Cannot re-scan python bindings: (py)gccxml not available") |
4066
d2309cf765d8
Fix --python-scan
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4064
diff
changeset
|
440 |
python_scan_task(bld.path, env) |
d2309cf765d8
Fix --python-scan
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4064
diff
changeset
|
441 |
return |
3408 | 442 |
|
3424
fd8ae9ea848b
Again, make Python depend only on scanned modules (last fix was incomplete).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3423
diff
changeset
|
443 |
## Get a list of scanned modules; the set of scanned modules |
fd8ae9ea848b
Again, make Python depend only on scanned modules (last fix was incomplete).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3423
diff
changeset
|
444 |
## may be smaller than the set of all modules, in case a new |
fd8ae9ea848b
Again, make Python depend only on scanned modules (last fix was incomplete).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3423
diff
changeset
|
445 |
## ns3 module is being developed which wasn't scanned yet. |
fd8ae9ea848b
Again, make Python depend only on scanned modules (last fix was incomplete).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3423
diff
changeset
|
446 |
scanned_modules = [] |
3591
f548d13ffd4e
Fix build when ns3_module_*__local.py files are used.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3575
diff
changeset
|
447 |
for filename in os.listdir(curdir): |
3424
fd8ae9ea848b
Again, make Python depend only on scanned modules (last fix was incomplete).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3423
diff
changeset
|
448 |
m = re.match(r"^ns3_module_(.+)\.py$", filename) |
fd8ae9ea848b
Again, make Python depend only on scanned modules (last fix was incomplete).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3423
diff
changeset
|
449 |
if m is None: |
fd8ae9ea848b
Again, make Python depend only on scanned modules (last fix was incomplete).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3423
diff
changeset
|
450 |
continue |
3591
f548d13ffd4e
Fix build when ns3_module_*__local.py files are used.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3575
diff
changeset
|
451 |
name = m.group(1) |
f548d13ffd4e
Fix build when ns3_module_*__local.py files are used.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3575
diff
changeset
|
452 |
if name.endswith("__local"): |
f548d13ffd4e
Fix build when ns3_module_*__local.py files are used.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3575
diff
changeset
|
453 |
continue |
f548d13ffd4e
Fix build when ns3_module_*__local.py files are used.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3575
diff
changeset
|
454 |
scanned_modules.append(name) |
3424
fd8ae9ea848b
Again, make Python depend only on scanned modules (last fix was incomplete).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3423
diff
changeset
|
455 |
|
3408 | 456 |
if env['ENABLE_PYTHON_BINDINGS']: |
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
457 |
source = [ |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
458 |
'ns3modulegen.py', |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
459 |
'ns3modulegen_generated.py', |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
460 |
'ns3modulegen_core_customizations.py', |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
461 |
] |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
462 |
target = [ |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
463 |
'ns3module.cc', |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
464 |
'ns3module.h', |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
465 |
'ns3modulegen.log', |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
466 |
] |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
467 |
argv = ['NS3_ENABLED_FEATURES=${FEATURES}', '${PYTHON}', '${SRC[0]}', '${TGT[0]}'] |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
468 |
argv.extend(get_modules_and_headers().iterkeys()) |
3423
f84261098ab0
Make Python bindings depend only on NS-3 modules that have been API-scanned, not all modules.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3421
diff
changeset
|
469 |
for module in scanned_modules: |
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
470 |
source.append("ns3_module_%s.py" % module) |
3591
f548d13ffd4e
Fix build when ns3_module_*__local.py files are used.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3575
diff
changeset
|
471 |
local = "ns3_module_%s__local.py" % module |
f548d13ffd4e
Fix build when ns3_module_*__local.py files are used.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3575
diff
changeset
|
472 |
if os.path.exists(os.path.join(curdir, local)): |
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
473 |
source.append(local) |
3423
f84261098ab0
Make Python bindings depend only on NS-3 modules that have been API-scanned, not all modules.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3421
diff
changeset
|
474 |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
475 |
argv.extend(['2>', '${TGT[2]}']) # 2> ns3modulegen.log |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
476 |
|
3423
f84261098ab0
Make Python bindings depend only on NS-3 modules that have been API-scanned, not all modules.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3421
diff
changeset
|
477 |
for module in scanned_modules: |
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
478 |
target.append("ns3_module_%s.cc" % module) |
3423
f84261098ab0
Make Python bindings depend only on NS-3 modules that have been API-scanned, not all modules.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3421
diff
changeset
|
479 |
|
3639
8e69ebf086f1
Use the information provided by conf.report_optional_feature() to enable/disable python bindings for optional APIs
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3637
diff
changeset
|
480 |
features = [] |
8e69ebf086f1
Use the information provided by conf.report_optional_feature() to enable/disable python bindings for optional APIs
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3637
diff
changeset
|
481 |
for (name, caption, was_enabled, reason_not_enabled) in env['NS3_OPTIONAL_FEATURES']: |
8e69ebf086f1
Use the information provided by conf.report_optional_feature() to enable/disable python bindings for optional APIs
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3637
diff
changeset
|
482 |
if was_enabled: |
8e69ebf086f1
Use the information provided by conf.report_optional_feature() to enable/disable python bindings for optional APIs
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3637
diff
changeset
|
483 |
features.append(name) |
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
484 |
|
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
485 |
bindgen = bld.new_task_gen('command', source=source, target=target, |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
486 |
command=argv, variables=dict(FEATURES=(','.join(features)))) |
4088
e52c06d86145
Add dependency annotations for the task that generates Python bindings
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4082
diff
changeset
|
487 |
bindgen.before = 'cxx' |
e52c06d86145
Add dependency annotations for the task that generates Python bindings
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4082
diff
changeset
|
488 |
bindgen.after = 'gen_everything_h_task' |
3408 | 489 |
|
490 |
## we build python bindings if either we have the tools to |
|
491 |
## generate them or if the pregenerated source file is already |
|
492 |
## present in the source dir. |
|
493 |
if env['ENABLE_PYTHON_BINDINGS'] \ |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
494 |
or os.path.exists(os.path.join(bld.path.abspath(), 'ns3module.cc')): |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
495 |
pymod = bld.new_task_gen('cxx', 'shlib', 'pyext') |
3408 | 496 |
pymod.source = ['ns3module.cc', 'ns3module_helpers.cc'] |
497 |
pymod.includes = '.' |
|
3424
fd8ae9ea848b
Again, make Python depend only on scanned modules (last fix was incomplete).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3423
diff
changeset
|
498 |
for module in scanned_modules: |
fd8ae9ea848b
Again, make Python depend only on scanned modules (last fix was incomplete).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3423
diff
changeset
|
499 |
pymod.source.append("ns3_module_%s.cc" % module) |
3408 | 500 |
pymod.target = 'ns3/_ns3' |
501 |
pymod.name = 'ns3module' |
|
502 |
pymod.uselib_local = "ns3" |
|
4076
1c67ab5f959a
Upgrade WAF; fix Darwin (OSX) build problems.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4068
diff
changeset
|
503 |
pymod.env.append_value('CXXDEFINES', ['NS_DEPRECATED=', 'NS3_DEPRECATED_H']) |
3408 | 504 |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
505 |
# copy the __init__.py file to the build dir. waf can't handle |
3408 | 506 |
# this, it's against waf's principles to have build dir files |
507 |
# with the same name as source dir files, apparently. |
|
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3977
diff
changeset
|
508 |
dirnode = bld.path.find_dir('ns3') |
3408 | 509 |
src = os.path.join(dirnode.abspath(), '__init__.py') |
510 |
dst = os.path.join(dirnode.abspath(env), '__init__.py') |
|
511 |
try: |
|
512 |
need_copy = os.stat(src).st_mtime > os.stat(dst).st_mtime |
|
513 |
except OSError: |
|
514 |
need_copy = True |
|
515 |
if need_copy: |
|
516 |
try: |
|
517 |
os.mkdir(os.path.dirname(dst)) |
|
518 |
except OSError: |
|
519 |
pass |
|
520 |
print "%r -> %r" % (src, dst) |
|
521 |
shutil.copy2(src, dst) |