Make a status test pass against old servers.
[svn.git] / build / generator / swig / __init__.py
blobeca4bfecb195dfe5c850d32da57228aece51bced
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
9 class Generator:
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):
15 """Read build.conf"""
17 # Now read and parse build.conf
18 parser = ConfigParser.ConfigParser()
19 parser.read(conf)
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
28 self.opts = {}
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
34 try:
35 self.swig_libdir = _exec.output("%s -swiglib" % self.swig_path, strip=1)
36 except AssertionError:
37 pass
39 def version(self):
40 """Get the version number of SWIG"""
41 try:
42 swig_version = _exec.output("%s -version" % self.swig_path)
43 m = re.search("Version (\d+).(\d+).(\d+)", swig_version)
44 if m:
45 return int(
46 "%s0%s0%s" % (m.group(1), m.group(2), m.group(3)))
47 except AssertionError:
48 pass
49 return 0