2 # generator.swig: Base class for SWIG-related generators
5 import shutil
, ConfigParser
, re
, os
6 import generator
.util
.executable
as _exec
7 from generator
.gen_base
import _collect_paths
10 """Base class for SWIG-related generators"""
11 langs
= ["python", "perl", "ruby"]
12 short
= { "perl": "pl", "python": "py", "ruby": "rb" }
14 def __init__(self
, conf
, swig_path
):
17 # Now read and parse build.conf
18 parser
= ConfigParser
.ConfigParser()
21 # Read configuration options
22 self
.proxy_dir
= parser
.get('options', 'swig-proxy-dir')
23 self
.includes
= _collect_paths(parser
.get('options', 'includes'))
24 self
.swig_checkout_files
= \
25 _collect_paths(parser
.get('options', 'swig-checkout-files'))
27 # Calculate build options
29 for lang
in self
.langs
:
30 self
.opts
[lang
] = parser
.get('options', 'swig-%s-opts' % lang
)
32 # Calculate SWIG paths
33 self
.swig_path
= swig_path
35 self
.swig_libdir
= _exec
.output("%s -swiglib" % self
.swig_path
, strip
=1)
36 except AssertionError:
40 """Get the version number of SWIG"""
42 swig_version
= _exec
.output("%s -version" % self
.swig_path
)
43 m
= re
.search("Version (\d+).(\d+).(\d+)", swig_version
)
46 "%s0%s0%s" % (m
.group(1), m
.group(2), m
.group(3)))
47 except AssertionError: