1## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- 2from waflib import Options 3 4required_python_modules = [ 5 'gi', 6 'gi.repository.GObject', 7 'cairo', 8 'pygraphviz', 9 'gi.repository.Gtk', 10 'gi.repository.Gdk', 11 'gi.repository.Pango', 12 'gi.repository.GooCanvas', 13] 14 15 16def configure(conf): 17 # If Python was explicitly disabled, then add this module to the 18 # list of modules that won't be built if they are enabled. 19 conf.env['ENABLE_PYVIZ'] = True 20 if not conf.check_optional_feature("python"): 21 conf.env['ENABLE_PYVIZ'] = False 22 conf.report_optional_feature("PyViz", "PyViz visualizer", 23 False, 24 "Python Bindings are needed but not enabled") 25 conf.env['MODULES_NOT_BUILT'].append('visualizer') 26 return 27 28 modules_missing = [] 29 for pymod in required_python_modules: 30 try: 31 conf.check_python_module(pymod) 32 except conf.errors.ConfigurationError: 33 modules_missing.append(pymod) 34 if modules_missing: 35 conf.report_optional_feature("PyViz", "PyViz visualizer", 36 False, "Missing python modules: %s" % (', '.join(modules_missing),)) 37 conf.env['ENABLE_PYVIZ'] = False 38 conf.env['MODULES_NOT_BUILT'].append('visualizer') 39 return 40 41 conf.report_optional_feature("PyViz", "PyViz visualizer", True, None) 42 43 44def build(bld): 45 46 module = bld.create_ns3_module('visualizer', ['internet', 'wifi', 'point-to-point', 'csma', 'bridge', 'wimax', 'lte', 'mesh']) 47 headers = bld(features='ns3header') 48 headers.module = 'visualizer' 49 50 # Don't do anything more for this module if Python was explicitly 51 # disabled. 52 if not bld.env['ENABLE_PYVIZ']: 53 return 54 55 headers.source = [] 56 57 # XXX This file was added so that static builds would work on 58 # Darwin, which doesn't like modules with no source files. It 59 # would have been better to add this module to the list 60 # conf.env['MODULES_NOT_BUILT'] if Python bindings were not 61 # enabled, but it's not possible for this module to determine in 62 # its configure() function if Python bindings will be enabled 63 # because that is done by the wscript file in bindings/python that 64 # is parsed after this module's wscript file is parsed. 65 module.source = [ 66 'model/dummy-file-for-static-builds.cc', 67 ] 68 69 module.features += ' pyembed' 70 #module.env.append_value('CXXFLAGS', module.env['shlib_CXXFLAGS']) 71 #module.includes = '.' 72 73 module.source.extend([ 74 'model/pyviz.cc', 75 'model/visual-simulator-impl.cc', 76 ]) 77 headers.source.append('model/pyviz.h') 78 79 vissrc = [ 80 'visualizer/base.py', 81 'visualizer/core.py', 82 'visualizer/hud.py', 83 'visualizer/__init__.py', 84 'visualizer/svgitem.py', 85 ] 86 pyviz = bld(features='py') 87 pyviz.source = vissrc 88 pyviz.install_path = '${PYTHONARCHDIR}/visualizer' 89 90 visplugin_src = [ 91 'visualizer/plugins/interface_statistics.py', 92 'visualizer/plugins/ipv4_routing_table.py', 93 'visualizer/plugins/olsr.py', 94 'visualizer/plugins/show_last_packets.py', 95 'visualizer/plugins/wifi_intrastructure_link.py' 96 ] 97 pyvizplug = bld(features='py') 98 pyvizplug.source = visplugin_src 99 pyvizplug.install_path = '${PYTHONARCHDIR}/visualizer/plugins' 100 101 bld.ns3_python_bindings() 102