Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(537)

Side by Side Diff: contrib/wscript

Issue 343030043: More flexible create-module.py and contrib/wscript
Patch Set: Revised patch Created 5 years, 10 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | doc/manual/source/documentation.rst » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 ## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- 1 ## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
2 from __future__ import print_function 2 from __future__ import print_function
3 import os, os.path 3 import os, os.path
4 import sys 4 import sys
5 import shutil 5 import shutil
6 import types 6 import types
7 import warnings 7 import warnings
8 8
9 from waflib import TaskGen, Task, Options, Build, Utils 9 from waflib import TaskGen, Task, Options, Build, Utils
10 from waflib.Errors import WafError 10 from waflib.Errors import WafError
11 import wutils 11 import wutils
12 12
13 try: 13 try:
14 set 14 set
15 except NameError: 15 except NameError:
16 from sets import Set as set # Python 2.3 fallback 16 from sets import Set as set # Python 2.3 fallback
17 17
18
19 # Allow mulitple modules to live in a single directory in contrib.
20 # For example, a directory structure like:
21 # contrib/package/module1
22 # /module2
23 # Useful for external projects that are building interdependent modules that
24 # are logically packaged together.
18 all_contrib_modules = [] 25 all_contrib_modules = []
19 for dirname in os.listdir('contrib'): 26 for dirpath in os.listdir('contrib'):
20 if dirname.startswith('.') or dirname == 'CVS': 27 if dirpath.startswith('.') or dirpath.endswith('CVS'):
21 continue 28 continue
22 path = os.path.join('contrib', dirname) 29 dirpath = os.path.join("contrib", dirpath)
23 if not os.path.isdir(path): 30 if not os.path.isdir(dirpath):
24 continue 31 continue
25 if os.path.exists(os.path.join(path, 'wscript')): 32 # Assume that all directories with a wscript file
26 all_contrib_modules.append(dirname) 33 # are the top level of a module
34 if os.path.exists(os.path.join(dirpath, 'wscript')):
35 fullDirPath = os.path.realpath(dirpath)
36 moduleDir=fullDirPath.replace(os.path.commonprefix([os.getcwd(), fullDir Path]), "", 1)
37 moduleDir=moduleDir.replace(os.path.sep + 'contrib' + os.path.sep, "", 1 )
38 all_contrib_modules.append(moduleDir)
39
27 all_contrib_modules.sort() 40 all_contrib_modules.sort()
28 41
29 def options(opt): 42 def options(opt):
30 for module in all_contrib_modules: 43 for module in all_contrib_modules:
31 opt.recurse(module, mandatory=False) 44 opt.recurse(module, mandatory=False)
32 45
33 def configure(conf): 46 def configure(conf):
47 # Append blddir to the module path before recursing into modules
48 # This is required for contrib modules with test suites
49 blddir = os.path.abspath(os.path.join(conf.bldnode.abspath(), conf.variant))
50 conf.env.append_value('NS3_MODULE_PATH', blddir)
51
52 # Remove duplicate path items
53 conf.env['NS3_MODULE_PATH'] = wutils.uniquify_list(conf.env['NS3_MODULE_PATH '])
54
34 for module in all_contrib_modules: 55 for module in all_contrib_modules:
35 conf.recurse(module, mandatory=False) 56 conf.recurse(module, mandatory=False)
36 57
37 ## Used to link the 'test-runner' program with all of ns-3 code 58 ## Used to link the 'test-runner' program with all of ns-3 code
38 conf.env['NS3_CONTRIBUTED_MODULES'] = ['ns3-' + module.split('/')[-1] for mo dule in all_contrib_modules] 59 conf.env['NS3_CONTRIBUTED_MODULES'] = ['ns3-' + module.split('/')[-1] for mo dule in all_contrib_modules]
39 60
40 61
41 # we need the 'ns3module' waf "feature" to be created because code 62 # we need the 'ns3module' waf "feature" to be created because code
42 # elsewhere looks for it to find the ns3 module objects. 63 # elsewhere looks for it to find the ns3 module objects.
43 64
44 def create_ns3_module(bld, name, dependencies=(), test=False): 65 def create_ns3_module(bld, name, dependencies=(), test=False):
45 static = bool(bld.env.ENABLE_STATIC_NS3) 66 static = bool(bld.env.ENABLE_STATIC_NS3)
46 # Create a separate library for this module. 67 # Create a separate library for this module.
47 if static: 68 if static:
48 module = bld(features='cxx cxxstlib ns3module') 69 module = bld(features='cxx cxxstlib ns3module')
49 else: 70 else:
50 module = bld(features='cxx cxxshlib ns3module') 71 module = bld(features='cxx cxxshlib ns3module')
51 module.target = '%s/lib/ns%s-%s%s' % (bld.srcnode.path_from(module.path), wu tils.VERSION, 72 target = '%s/lib/ns%s-%s%s' % (bld.srcnode.path_from(module.path),
52 name, bld.env.BUILD_SUFFIX) 73 wutils.VERSION,
74 name, bld.env.BUILD_SUFFIX)
75 ····
76 module.target = target
53 linkflags = [] 77 linkflags = []
54 cxxflags = [] 78 cxxflags = []
55 ccflags = [] 79 ccflags = []
56 if not static: 80 if not static:
57 cxxflags = module.env['shlib_CXXFLAGS'] 81 cxxflags = module.env['shlib_CXXFLAGS']
58 ccflags = module.env['shlib_CXXFLAGS'] 82 ccflags = module.env['shlib_CXXFLAGS']
59 # Turn on the link flags for shared libraries if we have the 83 # Turn on the link flags for shared libraries if we have the
60 # proper compiler and platform. 84 # proper compiler and platform.
61 if module.env['CXX_NAME'] in ['gcc', 'icc'] and module.env['WL_SONAME_SU PPORTED']: 85 if module.env['CXX_NAME'] in ['gcc', 'icc'] and module.env['WL_SONAME_SU PPORTED']:
62 # Get the module library name without any relative paths 86 # Get the module library name without any relative paths
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 return 166 return
143 167
144 bindings_dir = bld.path.find_dir("bindings") 168 bindings_dir = bld.path.find_dir("bindings")
145 if bindings_dir is None or not os.path.exists(bindings_dir.abspath()): 169 if bindings_dir is None or not os.path.exists(bindings_dir.abspath()):
146 warnings.warn("(in %s) Requested to build modular python bindings, but a pidefs dir not found " 170 warnings.warn("(in %s) Requested to build modular python bindings, but a pidefs dir not found "
147 "=> skipped the bindings." % str(bld.path), 171 "=> skipped the bindings." % str(bld.path),
148 Warning, stacklevel=2) 172 Warning, stacklevel=2)
149 return 173 return
150 174
151 if ("ns3-%s" % (module,)) not in env.NS3_ENABLED_MODULES: 175 if ("ns3-%s" % (module,)) not in env.NS3_ENABLED_MODULES:
152 #print "bindings for module %s which is not enabled, skip" % module 176 #print "bindings for module %s which is not enabled, skip" % module)
153 return 177 return
154 178
155 env.append_value('PYTHON_MODULES_BUILT', module) 179 env.append_value('PYTHON_MODULES_BUILT', module)
156 try: 180 try:
157 apidefs = env['PYTHON_BINDINGS_APIDEFS'].replace("-", "_") 181 apidefs = env['PYTHON_BINDINGS_APIDEFS'].replace("-", "_")
158 except AttributeError: 182 except AttributeError:
159 # we likely got an empty list for env['PYTHON_BINDINGS_APIDEFS'] 183 # we likely got an empty list for env['PYTHON_BINDINGS_APIDEFS']
160 return 184 return
161 185
162 #debug = ('PYBINDGEN_DEBUG' in os.environ) 186 #debug = ('PYBINDGEN_DEBUG' in os.environ)
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 285
262 if not_built in all_contrib_modules: 286 if not_built in all_contrib_modules:
263 all_contrib_modules.remove(not_built) 287 all_contrib_modules.remove(not_built)
264 288
265 bld.recurse(list(all_contrib_modules)) 289 bld.recurse(list(all_contrib_modules))
266 290
267 for module in all_contrib_modules: 291 for module in all_contrib_modules:
268 modheader = bld(features='ns3moduleheader') 292 modheader = bld(features='ns3moduleheader')
269 modheader.module = module.split('/')[-1] 293 modheader.module = module.split('/')[-1]
270 294
OLDNEW
« no previous file with comments | « no previous file | doc/manual/source/documentation.rst » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b